-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
789 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// listCmd commands list stacks and components | ||
var listCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "Execute 'list' commands", | ||
Long: `This command lists stacks and components`, | ||
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(listCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
e "github.com/cloudposse/atmos/internal/exec" | ||
"github.com/cloudposse/atmos/pkg/config" | ||
l "github.com/cloudposse/atmos/pkg/list" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
u "github.com/cloudposse/atmos/pkg/utils" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// listComponentsCmd lists atmos components | ||
var listComponentsCmd = &cobra.Command{ | ||
Use: "components", | ||
Short: "Execute 'list components' command", | ||
Long: `This command lists all Atmos components or filters components by stacks.`, | ||
Example: "atmos list components\n" + | ||
"atmos list components -s <stack>", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Check Atmos configuration | ||
checkAtmosConfig() | ||
|
||
stackFlag, _ := cmd.Flags().GetString("stack") | ||
|
||
configAndStacksInfo := schema.ConfigAndStacksInfo{} | ||
cliConfig, err := config.InitCliConfig(configAndStacksInfo, true) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error initializing CLI config: %v", err), color.New(color.FgRed)) | ||
return | ||
} | ||
|
||
stacksMap, err := e.ExecuteDescribeStacks(cliConfig, "", nil, nil, nil, false, false, false) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error describing stacks: %v", err), color.New(color.FgRed)) | ||
return | ||
} | ||
|
||
output, err := l.FilterAndListComponents(stackFlag, stacksMap) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error: %v"+"\n", err), color.New(color.FgYellow)) | ||
return | ||
} | ||
|
||
u.PrintMessageInColor(output, color.New(color.FgGreen)) | ||
}, | ||
} | ||
|
||
func init() { | ||
listComponentsCmd.PersistentFlags().StringP("stack", "s", "", "Filter components by stack (e.g., atmos list components -s stack1)") | ||
listCmd.AddCommand(listComponentsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
e "github.com/cloudposse/atmos/internal/exec" | ||
"github.com/cloudposse/atmos/pkg/config" | ||
l "github.com/cloudposse/atmos/pkg/list" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
u "github.com/cloudposse/atmos/pkg/utils" | ||
"github.com/fatih/color" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// listStacksCmd lists atmos stacks | ||
var listStacksCmd = &cobra.Command{ | ||
Use: "stacks", | ||
Short: "Execute 'list stacks' command", | ||
Long: `This command lists all Atmos stacks or all stacks for the specified component: atmos list stacks -c <component>`, | ||
Example: "atmos list stacks\n" + | ||
"atmos list stacks -c <component>", | ||
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Check Atmos configuration | ||
checkAtmosConfig() | ||
|
||
componentFlag, _ := cmd.Flags().GetString("component") | ||
|
||
configAndStacksInfo := schema.ConfigAndStacksInfo{} | ||
cliConfig, err := config.InitCliConfig(configAndStacksInfo, true) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error initializing CLI config: %v", err), color.New(color.FgRed)) | ||
return | ||
} | ||
|
||
stacksMap, err := e.ExecuteDescribeStacks(cliConfig, "", nil, nil, nil, false, false, false) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error describing stacks: %v", err), color.New(color.FgRed)) | ||
return | ||
} | ||
|
||
output, err := l.FilterAndListStacks(stacksMap, componentFlag) | ||
if err != nil { | ||
u.PrintMessageInColor(fmt.Sprintf("Error filtering stacks: %v", err), color.New(color.FgRed)) | ||
return | ||
} | ||
u.PrintMessageInColor(output, color.New(color.FgGreen)) | ||
}, | ||
} | ||
|
||
func init() { | ||
listStacksCmd.DisableFlagParsing = false | ||
listStacksCmd.PersistentFlags().StringP("component", "c", "", "atmos list stacks -c <component>") | ||
listCmd.AddCommand(listStacksCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.