Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions cmd/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,28 @@ func (l *ListCommandProvider) GetCompatibilityFlags() map[string]compat.Compatib
return nil
}

// GetAliases returns command aliases (none for list command).
// GetAliases returns command aliases for list subcommands.
// Creates "atmos vendor list" as an alias for "atmos list vendor".
// Creates "atmos workflow list" as an alias for "atmos list workflows".
func (l *ListCommandProvider) GetAliases() []internal.CommandAlias {
return nil
return []internal.CommandAlias{
{
Subcommand: "vendor",
ParentCommand: "vendor",
Name: "list",
Short: "List all vendor configurations (alias for 'atmos list vendor')",
Long: `List Atmos vendor configurations including component and vendor manifests with support for filtering, custom column selection, sorting, and multiple output formats. This is an alias for "atmos list vendor".`,
Example: "atmos vendor list\natmos vendor list --format json",
},
{
Subcommand: "workflows",
ParentCommand: "workflow",
Name: "list",
Short: "List all Atmos workflows (alias for 'atmos list workflows')",
Long: `List Atmos workflows with support for filtering by file, custom column selection, sorting, and multiple output formats. This is an alias for "atmos list workflows".`,
Example: "atmos workflow list\natmos workflow list --format json",
},
}
}

// IsExperimental returns whether this command is experimental.
Expand Down
21 changes: 19 additions & 2 deletions cmd/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,24 @@ func TestListCommandProvider(t *testing.T) {
assert.Nil(t, provider.GetCompatibilityFlags())
})

t.Run("GetAliases returns nil", func(t *testing.T) {
assert.Nil(t, provider.GetAliases())
t.Run("GetAliases returns vendor and workflow aliases", func(t *testing.T) {
aliases := provider.GetAliases()
require.Len(t, aliases, 2)

// Verify vendor list alias.
vendorAlias := aliases[0]
assert.Equal(t, "vendor", vendorAlias.Subcommand)
assert.Equal(t, "vendor", vendorAlias.ParentCommand)
assert.Equal(t, "list", vendorAlias.Name)
assert.Contains(t, vendorAlias.Long, `alias for "atmos list vendor"`)
assert.Contains(t, vendorAlias.Example, "atmos vendor list")

// Verify workflow list alias.
workflowAlias := aliases[1]
assert.Equal(t, "workflows", workflowAlias.Subcommand)
assert.Equal(t, "workflow", workflowAlias.ParentCommand)
assert.Equal(t, "list", workflowAlias.Name)
assert.Contains(t, workflowAlias.Long, `alias for "atmos list workflows"`)
assert.Contains(t, workflowAlias.Example, "atmos workflow list")
})
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
"github.com/cloudposse/atmos/cmd/terraform/workdir"
themeCmd "github.com/cloudposse/atmos/cmd/theme"
toolchainCmd "github.com/cloudposse/atmos/cmd/toolchain"
_ "github.com/cloudposse/atmos/cmd/vendor"
"github.com/cloudposse/atmos/cmd/version"
_ "github.com/cloudposse/atmos/cmd/workflow"
"github.com/cloudposse/atmos/toolchain"
Expand Down
18 changes: 0 additions & 18 deletions cmd/vendor.go

This file was deleted.

110 changes: 110 additions & 0 deletions cmd/vendor/vendor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package vendor

import (
"github.com/spf13/cobra"

"github.com/cloudposse/atmos/cmd/internal"
e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/flags"
"github.com/cloudposse/atmos/pkg/flags/compat"
)

// vendorCmd executes 'atmos vendor' CLI commands.
var vendorCmd = &cobra.Command{
Use: "vendor",
Short: "Manage external dependencies for components or stacks",
Long: `This command manages external dependencies for Atmos components or stacks by vendoring them. Vendoring involves copying and locking required dependencies locally, ensuring consistency, reliability, and alignment with the principles of immutable infrastructure.`,
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
}

// vendorPullCmd executes 'vendor pull' CLI commands.
var vendorPullCmd = &cobra.Command{
Use: "pull",
Short: "Pull the latest vendor configurations or dependencies",
Long: "Pull and update vendor-specific configurations or dependencies to ensure the project has the latest required resources.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := e.ExecuteVendorPullCmd(cmd, args)
return err
},
}

// vendorDiffCmd executes 'vendor diff' CLI commands.
var vendorDiffCmd = &cobra.Command{
Use: "diff",
Short: "Show differences in vendor configurations or dependencies",
Long: "This command compares and displays the differences in vendor-specific configurations or dependencies.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
RunE: func(cmd *cobra.Command, args []string) error {
err := e.ExecuteVendorDiffCmd(cmd, args)
return err
},
}

func init() {
// Set up vendor pull flags.
vendorPullCmd.PersistentFlags().StringP("component", "c", "", "Only vendor the specified component")
vendorPullCmd.PersistentFlags().StringP("stack", "s", "", "Only vendor the specified stack")
vendorPullCmd.PersistentFlags().StringP("type", "t", "terraform", "The type of the vendor (terraform or helmfile).")
vendorPullCmd.PersistentFlags().Bool("dry-run", false, "Simulate pulling the latest version of the specified component from the remote repository without making any changes.")
vendorPullCmd.PersistentFlags().String("tags", "", "Only vendor the components that have the specified tags")
vendorPullCmd.PersistentFlags().Bool("everything", false, "Vendor all components")

// Set up vendor diff flags.
vendorDiffCmd.PersistentFlags().StringP("component", "c", "", "Compare the differences between the local and vendored versions of the specified component.")
vendorDiffCmd.PersistentFlags().StringP("type", "t", "terraform", "Compare the differences between the local and vendored versions of the specified component, filtering by type (terraform or helmfile).")
vendorDiffCmd.PersistentFlags().Bool("dry-run", false, "Simulate the comparison of differences between the local and vendored versions of the specified component without making any changes.")

// Add subcommands.
vendorCmd.AddCommand(vendorPullCmd)
// vendorDiffCmd is not implemented yet, so exclude it from help.
// vendorCmd.AddCommand(vendorDiffCmd)

// Register with command registry.
internal.Register(&VendorCommandProvider{})
}

// VendorCommandProvider implements the CommandProvider interface.
type VendorCommandProvider struct{}

// GetCommand returns the vendor command.
func (v *VendorCommandProvider) GetCommand() *cobra.Command {
return vendorCmd
}

// GetName returns the command name.
func (v *VendorCommandProvider) GetName() string {
return "vendor"
}

// GetGroup returns the command group.
func (v *VendorCommandProvider) GetGroup() string {
return "Component Lifecycle"
}

// GetFlagsBuilder returns the flags builder for this command.
func (v *VendorCommandProvider) GetFlagsBuilder() flags.Builder {
return nil
}

// GetPositionalArgsBuilder returns the positional args builder for this command.
func (v *VendorCommandProvider) GetPositionalArgsBuilder() *flags.PositionalArgsBuilder {
return nil
}

// GetCompatibilityFlags returns compatibility flags for this command.
func (v *VendorCommandProvider) GetCompatibilityFlags() map[string]compat.CompatibilityFlag {
return nil
}

// GetAliases returns command aliases (none for vendor command).
func (v *VendorCommandProvider) GetAliases() []internal.CommandAlias {
return nil
}

// IsExperimental returns whether this command is experimental.
func (v *VendorCommandProvider) IsExperimental() bool {
return false
}
58 changes: 58 additions & 0 deletions cmd/vendor/vendor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package vendor

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// TestVendorPullCmd_ExecutorError tests that vendor pull executor handles unexpected args.
func TestVendorPullCmd_ExecutorError(t *testing.T) {
stacksPath := "../../tests/fixtures/scenarios/terraform-apply-affected"

t.Setenv("ATMOS_CLI_CONFIG_PATH", stacksPath)
t.Setenv("ATMOS_BASE_PATH", stacksPath)

err := vendorPullCmd.RunE(vendorPullCmd, []string{"unexpected-arg"})
assert.Error(t, err, "vendor pull command should return an error with unexpected arguments")
}

// TestVendorCommandProvider tests the VendorCommandProvider interface methods.
func TestVendorCommandProvider(t *testing.T) {
provider := &VendorCommandProvider{}

t.Run("GetCommand returns vendorCmd", func(t *testing.T) {
cmd := provider.GetCommand()
require.NotNil(t, cmd)
assert.Equal(t, "vendor", cmd.Use)
})

t.Run("GetName returns vendor", func(t *testing.T) {
assert.Equal(t, "vendor", provider.GetName())
})

t.Run("GetGroup returns Component Lifecycle", func(t *testing.T) {
assert.Equal(t, "Component Lifecycle", provider.GetGroup())
})

t.Run("GetFlagsBuilder returns nil", func(t *testing.T) {
assert.Nil(t, provider.GetFlagsBuilder())
})

t.Run("GetPositionalArgsBuilder returns nil", func(t *testing.T) {
assert.Nil(t, provider.GetPositionalArgsBuilder())
})

t.Run("GetCompatibilityFlags returns nil", func(t *testing.T) {
assert.Nil(t, provider.GetCompatibilityFlags())
})

t.Run("GetAliases returns nil", func(t *testing.T) {
assert.Nil(t, provider.GetAliases())
})

t.Run("IsExperimental returns false", func(t *testing.T) {
assert.False(t, provider.IsExperimental())
})
}
35 changes: 0 additions & 35 deletions cmd/vendor_diff.go

This file was deleted.

36 changes: 0 additions & 36 deletions cmd/vendor_pull.go

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/vendor_test.go

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading