-
-
Notifications
You must be signed in to change notification settings - Fork 126
atmos list vendor #1192
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
Merged
Merged
atmos list vendor #1192
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fe7e19c
Adds `list vendor` command
Cerebrovinny 4ef76e2
general refactor em clean code
Cerebrovinny a8abb9b
general clean up refactor
Cerebrovinny 395d9ac
Merge branch 'main' into feat/list-vendor
Cerebrovinny 5b576e4
[autofix.ci] apply automated fixes
autofix-ci[bot] 1779567
update margin const
Cerebrovinny 2451886
Merge remote-tracking branch 'origin/feat/list-vendor' into feat/list…
Cerebrovinny 91935e1
[autofix.ci] apply automated fixes
autofix-ci[bot] ea0c070
refactor expected error
Cerebrovinny 6d21137
clean code
Cerebrovinny e38e565
clean up refactor
Cerebrovinny d8fd768
[autofix.ci] apply automated fixes
autofix-ci[bot] 6329ba8
Refactors vendor output formatting
Cerebrovinny 5490941
Merge remote-tracking branch 'origin/feat/list-vendor' into feat/list…
Cerebrovinny f7191cf
clean up
Cerebrovinny 30119a1
Add vendor list config options for format and columns
Cerebrovinny a23a11f
Merge branch 'main' into feat/list-vendor
Cerebrovinny dff71bc
Update file parsing to use filetype.DetectFormatAndParseFile
Cerebrovinny 6627fb9
clean up
Cerebrovinny 31b5fda
refactor list vendor
Cerebrovinny c6e12db
csv tsv format
Cerebrovinny 2df9517
clean up
Cerebrovinny 414bbfc
clean up
Cerebrovinny 9bc44e6
clean up
Cerebrovinny 9604532
Merge branch 'main' into feat/list-vendor
Cerebrovinny a2f4b11
unit tests for vendor data process
Cerebrovinny 858828a
Merge branch 'main' into feat/list-vendor
Cerebrovinny ab3f1fb
Merge branch 'main' into feat/list-vendor
Cerebrovinny 6dd4ec6
Merge branch 'main' into feat/list-vendor
Cerebrovinny 3218829
Merge branch 'main' into feat/list-vendor
Cerebrovinny 345526d
Merge branch 'main' into feat/list-vendor
Cerebrovinny 2afbdc3
Merge branch 'main' into feat/list-vendor
Benbentwo 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 hidden or 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,87 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
log "github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/cloudposse/atmos/pkg/config" | ||
l "github.com/cloudposse/atmos/pkg/list" | ||
"github.com/cloudposse/atmos/pkg/schema" | ||
) | ||
|
||
// listVendorCmd lists vendor configurations. | ||
var listVendorCmd = &cobra.Command{ | ||
Use: "vendor", | ||
Short: "List all vendor configurations", | ||
Long: "List all vendor configurations in a tabular way, including component and vendor manifests.", | ||
Args: cobra.NoArgs, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// Check Atmos configuration | ||
checkAtmosConfig() | ||
|
||
// Get flags | ||
flags := cmd.Flags() | ||
|
||
formatFlag, err := flags.GetString("format") | ||
if err != nil { | ||
log.Error("Error getting the 'format' flag", "error", err) | ||
cmd.PrintErrln(fmt.Errorf("error getting the 'format' flag: %w", err)) | ||
cmd.PrintErrln("Run 'atmos list vendor --help' for usage") | ||
return | ||
} | ||
|
||
stackFlag, err := flags.GetString("stack") | ||
if err != nil { | ||
log.Error("Error getting the 'stack' flag", "error", err) | ||
cmd.PrintErrln(fmt.Errorf("error getting the 'stack' flag: %w", err)) | ||
cmd.PrintErrln("Run 'atmos list vendor --help' for usage") | ||
return | ||
} | ||
|
||
delimiterFlag, err := flags.GetString("delimiter") | ||
if err != nil { | ||
log.Error("Error getting the 'delimiter' flag", "error", err) | ||
cmd.PrintErrln(fmt.Errorf("error getting the 'delimiter' flag: %w", err)) | ||
cmd.PrintErrln("Run 'atmos list vendor --help' for usage") | ||
return | ||
} | ||
|
||
// Initialize CLI config | ||
configAndStacksInfo := schema.ConfigAndStacksInfo{} | ||
atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true) | ||
if err != nil { | ||
log.Error("Error initializing CLI config", "error", err) | ||
cmd.PrintErrln(fmt.Errorf("error initializing CLI config: %w", err)) | ||
return | ||
} | ||
|
||
// Set options | ||
options := &l.FilterOptions{ | ||
FormatStr: formatFlag, | ||
StackPattern: stackFlag, | ||
Delimiter: delimiterFlag, | ||
} | ||
|
||
// Call list vendor function | ||
output, err := l.FilterAndListVendor(&atmosConfig, options) | ||
if err != nil { | ||
log.Error("Error listing vendor configurations", "error", err) | ||
cmd.PrintErrln(fmt.Errorf("error listing vendor configurations: %w", err)) | ||
return | ||
} | ||
|
||
// Print output | ||
fmt.Println(output) | ||
}, | ||
} | ||
|
||
func init() { | ||
AddStackCompletion(listVendorCmd) | ||
listCmd.AddCommand(listVendorCmd) | ||
|
||
// Add flags | ||
listVendorCmd.Flags().StringP("format", "f", "", "Output format: table, json, yaml, csv, tsv") | ||
listVendorCmd.Flags().StringP("delimiter", "d", "", "Delimiter for CSV/TSV output") | ||
} |
This file contains hidden or 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,29 @@ | ||
– List all vendor configurations | ||
``` | ||
$ atmos list vendor | ||
``` | ||
|
||
– List vendor configurations with a specific output format | ||
``` | ||
$ atmos list vendor --format json | ||
``` | ||
|
||
– List vendor configurations filtered by component name pattern | ||
``` | ||
$ atmos list vendor --stack "vpc*" | ||
``` | ||
|
||
– List vendor configurations with comma-separated CSV format | ||
``` | ||
$ atmos list vendor --format csv | ||
``` | ||
|
||
– List vendor configurations with tab-separated TSV format | ||
``` | ||
$ atmos list vendor --format tsv | ||
``` | ||
|
||
– List vendor configurations with a custom delimiter | ||
``` | ||
$ atmos list vendor --format csv --delimiter "|" | ||
``` |
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.