RunListProfiles runs the list profiles command logic
(f factory.Factory, cobraCmd *cobra.Command, args []string)
| 37 | |
| 38 | // RunListProfiles runs the list profiles command logic |
| 39 | func (cmd *profilesCmd) RunListProfiles(f factory.Factory, cobraCmd *cobra.Command, args []string) error { |
| 40 | logger := f.GetLog() |
| 41 | // Set config root |
| 42 | configLoader, err := f.NewConfigLoader("") |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | configExists, err := configLoader.SetDevSpaceRoot(logger) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | if !configExists { |
| 51 | return errors.New(message.ConfigNotFound) |
| 52 | } |
| 53 | |
| 54 | config, err := configLoader.LoadWithParser(context.Background(), nil, nil, loader.NewProfilesParser(), nil, logger) |
| 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | |
| 59 | profiles := config.Config().Profiles |
| 60 | |
| 61 | // Specify the table column names |
| 62 | headerColumnNames := []string{ |
| 63 | "Name", |
| 64 | "Description", |
| 65 | } |
| 66 | |
| 67 | configRows := make([][]string, 0, len(profiles)) |
| 68 | for _, profile := range profiles { |
| 69 | configRows = append(configRows, []string{ |
| 70 | profile.Name, |
| 71 | profile.Description, |
| 72 | }) |
| 73 | } |
| 74 | |
| 75 | log.PrintTable(logger, headerColumnNames, configRows) |
| 76 | return nil |
| 77 | } |
no test coverage detected