(ctx context.Context)
| 13 | ) |
| 14 | |
| 15 | func List(ctx context.Context) error { |
| 16 | c, err := config.ScalingoAuthClient(ctx) |
| 17 | if err != nil { |
| 18 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 19 | } |
| 20 | |
| 21 | integrations, err := c.SCMIntegrationsList(ctx) |
| 22 | if err != nil { |
| 23 | return errors.Wrapf(ctx, err, "fail to list SCM integrations") |
| 24 | } |
| 25 | |
| 26 | nbrIntegrations := len(integrations) |
| 27 | if nbrIntegrations == 0 { |
| 28 | io.Status("Your Scalingo account is not linked to any SCM integrations.") |
| 29 | return nil |
| 30 | } |
| 31 | |
| 32 | pluralIntegration := "" |
| 33 | if nbrIntegrations > 1 { |
| 34 | pluralIntegration = "s" |
| 35 | } |
| 36 | |
| 37 | io.Statusf("You already have %d SCM integration%s linked with your Scalingo account:\n", nbrIntegrations, pluralIntegration) |
| 38 | |
| 39 | t := tablewriter.NewWriter(os.Stdout) |
| 40 | t.Header([]string{"ID", "Type", "URL", "Username", "Email"}) |
| 41 | for _, i := range integrations { |
| 42 | t.Append([]string{i.ID, scalingo.SCMTypeDisplay[i.SCMType], i.URL, i.Username, i.Email}) |
| 43 | } |
| 44 | t.Render() |
| 45 | return nil |
| 46 | } |
no test coverage detected