MCPcopy Create free account
hub / github.com/devspace-sh/devspace / RunListProfiles

Method RunListProfiles

cmd/list/profiles.go:39–77  ·  view source on GitHub ↗

RunListProfiles runs the list profiles command logic

(f factory.Factory, cobraCmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

37
38// RunListProfiles runs the list profiles command logic
39func (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}

Callers 1

newProfilesCmdFunction · 0.95

Calls 7

SetDevSpaceRootMethod · 0.95
LoadWithParserMethod · 0.95
NewProfilesParserFunction · 0.92
PrintTableFunction · 0.92
GetLogMethod · 0.65
NewConfigLoaderMethod · 0.65
ConfigMethod · 0.65

Tested by

no test coverage detected