-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement: atmos list values #1036
Open
Cerebrovinny
wants to merge
74
commits into
main
Choose a base branch
from
DEV-2802
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,256
−97
Open
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
2e1e51d
feat: add `list values` command to compare component configurations a…
Cerebrovinny 547f984
feat: add TSV format support for workflow listing
Cerebrovinny 917cdd0
wip
Cerebrovinny 72a8e76
[autofix.ci] apply automated fixes
autofix-ci[bot] b6b19b2
Merge branch 'main' into DEV-2802
Cerebrovinny 30e14d0
update list values
Cerebrovinny f3db126
[autofix.ci] apply automated fixes
autofix-ci[bot] 54d8ad0
fixes and clean up
Cerebrovinny b03b3c2
[autofix.ci] apply automated fixes
autofix-ci[bot] cc9c8bf
update terminal
Cerebrovinny 9060a00
test list values
Cerebrovinny 79e94f8
Update website/docs/cli/commands/list/list-values.mdx
Cerebrovinny cfec6fb
Add markdown docs for listing values/vars; update examples
Cerebrovinny df4c494
Add logger, replace error prints with log calls
Cerebrovinny 872d881
Refactor imports and rename logger variable
Cerebrovinny 368d21d
Handle 'no values found' error; improve logging logic
Cerebrovinny 6a3e02b
Improve error messages with colored output
Cerebrovinny 538d6b7
Add expectedError field to test cases for error validation
Cerebrovinny 216e6cd
Merge branch 'main' into DEV-2802
Cerebrovinny 6d87e2c
Refactor error handling, add custom error type
Cerebrovinny befa005
Refactor error handling, update TTY check logic
Cerebrovinny f07cb4a
Refactor commands to list metadata and settings
Cerebrovinny 132dfce
general fixes
Cerebrovinny 52f11fb
Remove unused getMapKeys function
Cerebrovinny ab3bde4
[autofix.ci] apply automated fixes
autofix-ci[bot] 948a3c0
Merge branch 'main' into DEV-2802
Cerebrovinny 1ce3cf4
Merge branch 'main' into DEV-2802
Cerebrovinny 571d382
Merge branch 'main' into DEV-2802
Cerebrovinny 9b72518
Switch to charmbracelet/log, remove custom logger setup
Cerebrovinny f4779cc
[autofix.ci] apply automated fixes
autofix-ci[bot] 7d92050
Remove examples from command help, update markdown docs
Cerebrovinny 4e758fc
Merge remote-tracking branch 'origin/DEV-2802' into DEV-2802
Cerebrovinny a2f790c
Merge branch 'main' into DEV-2802
Cerebrovinny d0e24c3
[autofix.ci] apply automated fixes
autofix-ci[bot] 53f83ab
Refactor error logging, simplify path conversion
Cerebrovinny e0ec172
Merge branch 'main' into DEV-2802
Cerebrovinny a8af871
Merge branch 'main' into DEV-2802
osterman de1e0e2
Refactor imports, improve error logging
Cerebrovinny 5fbaeef
Refactor list commands, add common flags & error handling
Cerebrovinny cc864f6
clean up
Cerebrovinny 936bb93
Update website/docs/cli/commands/list/list-metadata.mdx
Cerebrovinny 74842b7
Improve list commands & table formatting
Cerebrovinny 9017862
[autofix.ci] apply automated fixes
autofix-ci[bot] e45f2ff
Update website/docs/cli/commands/list/list-settings.mdx
Cerebrovinny e3d0c38
Update query docs and linter configuration
Cerebrovinny 1de71b5
Improve table and delimited formatter
Cerebrovinny 9be83fa
refactor and clean up
Cerebrovinny cf17568
lint static fixes
Cerebrovinny 735f339
[autofix.ci] apply automated fixes
autofix-ci[bot] ae180a2
fixes lint static check
Cerebrovinny 67b8ce4
[autofix.ci] apply automated fixes
autofix-ci[bot] 47ecda6
fixes lint static check
Cerebrovinny 404f398
lint fixes
Cerebrovinny feeecdd
clean up the processcustomcommands is already on process command aliases
Cerebrovinny 153a751
chore: update tests
Cerebrovinny 4fa3270
disable vendor pull tests
Cerebrovinny 7773a61
fix: unix line break windows
Cerebrovinny 725825e
Update website/docs/cli/commands/list/list-metadata.mdx
Cerebrovinny 38c14d3
Update website/docs/cli/commands/list/list-settings.mdx
Cerebrovinny a4ab6ea
Update cmd/markdown/atmos_list_vars_usage.md
Cerebrovinny 4a69ea0
Update cmd/markdown/atmos_list_values_usage.md
Cerebrovinny 7d0c33d
Update cmd/list_metadata.go
Cerebrovinny 86aef46
Update website/docs/cli/commands/list/list-settings.mdx
Cerebrovinny 2814f90
Update website/docs/cli/commands/list/list-settings.mdx
Cerebrovinny a042ce4
Update website/docs/cli/commands/list/list-metadata.mdx
Cerebrovinny fbec33d
fix: tests improvements
Cerebrovinny 9eb34d2
fix: delimited
Cerebrovinny 487bfef
[autofix.ci] apply automated fixes
autofix-ci[bot] 0cf853b
disable vendor
Cerebrovinny d490867
Update pkg/utils/wildcard.go
Cerebrovinny 89accc3
fix: fixes build
Cerebrovinny e781fb5
disable vendor
Cerebrovinny 31e9b74
fix: disable more oci tests
Cerebrovinny 19b252b
fix: disable more oci tests
Cerebrovinny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,97 @@ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
|
||
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/list/errors" | ||
fl "github.com/cloudposse/atmos/pkg/list/flags" | ||
f "github.com/cloudposse/atmos/pkg/list/format" | ||
u "github.com/cloudposse/atmos/pkg/list/utils" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
utils "github.com/cloudposse/atmos/pkg/utils" | ||
) | ||
|
||
// listMetadataCmd lists metadata across stacks. | ||
var listMetadataCmd = &cobra.Command{ | ||
Use: "metadata", | ||
Short: "List metadata across stacks", | ||
Long: "List metadata information across all stacks", | ||
Example: "atmos list metadata\n" + | ||
"atmos list metadata --query .component\n" + | ||
"atmos list metadata --format json\n" + | ||
"atmos list metadata --stack '*-{dev,staging}-*'\n" + | ||
"atmos list metadata --stack 'prod-*'", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Check Atmos configuration | ||
checkAtmosConfig() | ||
output, err := listMetadata(cmd) | ||
if err != nil { | ||
log.Error("failed to list metadata", "error", err) | ||
return | ||
} | ||
|
||
utils.PrintMessage(output) | ||
}, | ||
} | ||
|
||
func init() { | ||
fl.AddCommonListFlags(listMetadataCmd) | ||
|
||
AddStackCompletion(listMetadataCmd) | ||
|
||
listCmd.AddCommand(listMetadataCmd) | ||
} | ||
|
||
func listMetadata(cmd *cobra.Command) (string, error) { | ||
commonFlags, err := fl.GetCommonListFlags(cmd) | ||
if err != nil { | ||
return "", &errors.QueryError{ | ||
Query: "common flags", | ||
Cause: err, | ||
} | ||
} | ||
|
||
if f.Format(commonFlags.Format) == f.FormatCSV && commonFlags.Delimiter == f.DefaultTSVDelimiter { | ||
commonFlags.Delimiter = f.DefaultCSVDelimiter | ||
} | ||
|
||
// Initialize CLI config | ||
configAndStacksInfo := schema.ConfigAndStacksInfo{} | ||
atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) | ||
if err != nil { | ||
return "", &errors.InitConfigError{Cause: err} | ||
} | ||
|
||
// Get all stacks | ||
stacksMap, err := e.ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, false, false, false, nil) | ||
if err != nil { | ||
return "", &errors.DescribeStacksError{Cause: err} | ||
} | ||
|
||
// Use .metadata as the default query if none provided | ||
if commonFlags.Query == "" { | ||
commonFlags.Query = ".metadata" | ||
} | ||
|
||
output, err := l.FilterAndListValues(stacksMap, &l.FilterOptions{ | ||
Component: "", | ||
Query: commonFlags.Query, | ||
IncludeAbstract: false, | ||
MaxColumns: commonFlags.MaxColumns, | ||
FormatStr: commonFlags.Format, | ||
Delimiter: commonFlags.Delimiter, | ||
StackPattern: commonFlags.Stack, | ||
}) | ||
if err != nil { | ||
if u.IsNoValuesFoundError(err) { | ||
return "", &errors.NoMetadataFoundError{Query: commonFlags.Query} | ||
} | ||
return "", &errors.MetadataFilteringError{Cause: err} | ||
} | ||
|
||
return output, nil | ||
} |
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,91 @@ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
|
||
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/list/errors" | ||
fl "github.com/cloudposse/atmos/pkg/list/flags" | ||
f "github.com/cloudposse/atmos/pkg/list/format" | ||
u "github.com/cloudposse/atmos/pkg/list/utils" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
utils "github.com/cloudposse/atmos/pkg/utils" | ||
) | ||
|
||
// listSettingsCmd lists settings across stacks. | ||
var listSettingsCmd = &cobra.Command{ | ||
Use: "settings", | ||
Short: "List settings across stacks", | ||
Long: "List settings configuration across all stacks", | ||
Example: "atmos list settings\n" + | ||
"atmos list settings --query .terraform\n" + | ||
"atmos list settings --format json\n" + | ||
"atmos list settings --stack '*-dev-*'\n" + | ||
"atmos list settings --stack 'prod-*'", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Check Atmos configuration | ||
checkAtmosConfig() | ||
output, err := listSettings(cmd) | ||
if err != nil { | ||
log.Error("failed to list settings", "error", err) | ||
return | ||
} | ||
|
||
utils.PrintMessage(output) | ||
}, | ||
} | ||
|
||
func init() { | ||
fl.AddCommonListFlags(listSettingsCmd) | ||
|
||
AddStackCompletion(listSettingsCmd) | ||
|
||
listCmd.AddCommand(listSettingsCmd) | ||
} | ||
|
||
func listSettings(cmd *cobra.Command) (string, error) { | ||
// Get common flags | ||
commonFlags, err := fl.GetCommonListFlags(cmd) | ||
if err != nil { | ||
return "", &errors.CommonFlagsError{Cause: err} | ||
} | ||
|
||
if f.Format(commonFlags.Format) == f.FormatCSV && commonFlags.Delimiter == f.DefaultTSVDelimiter { | ||
commonFlags.Delimiter = f.DefaultCSVDelimiter | ||
} | ||
|
||
// Initialize CLI config | ||
configAndStacksInfo := schema.ConfigAndStacksInfo{} | ||
atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) | ||
if err != nil { | ||
return "", &errors.InitConfigError{Cause: err} | ||
} | ||
|
||
// Get all stacks | ||
stacksMap, err := e.ExecuteDescribeStacks(atmosConfig, "", nil, nil, nil, false, false, false, false, nil) | ||
if err != nil { | ||
return "", &errors.DescribeStacksError{Cause: err} | ||
} | ||
|
||
// Use empty query to avoid further processing since handleComponentProperties will extract the settings | ||
output, err := l.FilterAndListValues(stacksMap, &l.FilterOptions{ | ||
Component: "settings", | ||
Query: commonFlags.Query, | ||
IncludeAbstract: false, | ||
MaxColumns: commonFlags.MaxColumns, | ||
FormatStr: commonFlags.Format, | ||
Delimiter: commonFlags.Delimiter, | ||
StackPattern: commonFlags.Stack, | ||
}) | ||
if err != nil { | ||
if u.IsNoValuesFoundError(err) { | ||
return "", &errors.NoSettingsFoundError{Query: commonFlags.Query} | ||
} | ||
return "", &errors.SettingsFilteringError{Cause: err} | ||
} | ||
|
||
return output, nil | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was 👍 from me. Since we're using
gofumpt
for auto-formatting (seeautofix
workflow), thegofmt
is at odds with it.