(ctx context.Context, app string)
| 49 | } |
| 50 | |
| 51 | func Show(ctx context.Context, app string) error { |
| 52 | c, err := config.ScalingoClient(ctx) |
| 53 | if err != nil { |
| 54 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 55 | } |
| 56 | |
| 57 | repoLink, err := c.SCMRepoLinkShow(ctx, app) |
| 58 | var scerr *http.RequestFailedError |
| 59 | if errors.As(err, &scerr) && scerr.Code == 404 { |
| 60 | io.Statusf("Your app '%s' has no integration link.\n", app) |
| 61 | return nil |
| 62 | } |
| 63 | if err != nil { |
| 64 | return errors.Wrapf(ctx, err, "fail to get integration link for this app") |
| 65 | } |
| 66 | |
| 67 | templater, err := template.New("integrationSettings"). |
| 68 | Funcs(template.FuncMap{ |
| 69 | "enabledIcon": enabledIcon, |
| 70 | "title": title, |
| 71 | }). |
| 72 | Parse(integrationSettingsTemplateText) |
| 73 | |
| 74 | if err != nil { |
| 75 | return errors.Wrapf(ctx, err, "invalid integration settings template") |
| 76 | } |
| 77 | |
| 78 | settings := IntegrationSettings{ |
| 79 | AppName: app, |
| 80 | AppID: repoLink.AppID, |
| 81 | SCMType: scalingo.SCMTypeDisplay[repoLink.SCMType], |
| 82 | IntegrationID: repoLink.AuthIntegrationUUID, |
| 83 | LinkerUsername: repoLink.Linker.Username, |
| 84 | RepositoryOwner: repoLink.Owner, |
| 85 | RepositoryName: repoLink.Repo, |
| 86 | Branch: repoLink.Branch, |
| 87 | AutoDeploy: repoLink.AutoDeployEnabled, |
| 88 | AutoDeployReviewApps: repoLink.DeployReviewAppsEnabled, |
| 89 | ReviewAppsFromForks: repoLink.AutomaticCreationFromForksAllowed, |
| 90 | DestroyOnClose: repoLink.DeleteOnCloseEnabled, |
| 91 | HoursBeforeDestroyOnClose: repoLink.HoursBeforeDeleteOnClose, |
| 92 | DestroyOnStale: repoLink.DeleteStaleEnabled, |
| 93 | HoursBeforeDestroyOnStale: repoLink.HoursBeforeDeleteStale, |
| 94 | } |
| 95 | |
| 96 | err = templater.Execute(os.Stdout, settings) |
| 97 | |
| 98 | if err != nil { |
| 99 | return errors.Wrapf(ctx, err, "failed rendering integration settings") |
| 100 | } |
| 101 | |
| 102 | return nil |
| 103 | } |
no test coverage detected