(ctx context.Context, args CreateArgs)
| 16 | } |
| 17 | |
| 18 | func Create(ctx context.Context, args CreateArgs) error { |
| 19 | c, err := config.ScalingoAuthClient(ctx) |
| 20 | if err != nil { |
| 21 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 22 | } |
| 23 | |
| 24 | integrationExist := checkIfIntegrationAlreadyExist(ctx, c, args.SCMType.Str()) |
| 25 | if integrationExist { |
| 26 | io.Statusf("SCM Integration '%s' is already linked with your Scalingo account.\n", scalingo.SCMTypeDisplay[args.SCMType]) |
| 27 | return nil |
| 28 | } |
| 29 | |
| 30 | if args.SCMType == scalingo.SCMGithubType || args.SCMType == scalingo.SCMGitlabType { |
| 31 | io.Statusf("Please follow this URL to create the %s SCM integration:\n", scalingo.SCMTypeDisplay[args.SCMType]) |
| 32 | io.Statusf("%s/users/%s/link\n", config.C.ScalingoAuthURL, args.SCMType) |
| 33 | return nil |
| 34 | } |
| 35 | |
| 36 | _, err = c.SCMIntegrationsCreate(ctx, args.SCMType, args.URL, args.Token) |
| 37 | if err != nil { |
| 38 | return errors.Wrapf(ctx, err, "fail to create the SCM integration") |
| 39 | } |
| 40 | |
| 41 | io.Statusf("Your Scalingo account has been linked to your %s account.\n", scalingo.SCMTypeDisplay[args.SCMType]) |
| 42 | return nil |
| 43 | } |
no test coverage detected