Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9b57ef4
Add vendor update and diff commands
osterman Oct 21, 2025
058a3ec
Add version constraints support for vendor updates
osterman Oct 21, 2025
22b89d6
Update vendor diff documentation to reflect GitHub-only implementation
osterman Oct 21, 2025
c8b4f89
Add vendor source provider interface for multi-provider support
osterman Oct 21, 2025
54c8fa6
Fix code quality and documentation issues per review
osterman Oct 21, 2025
9bc2952
docs: Add comprehensive version constraints documentation
osterman Oct 21, 2025
79e8ab8
docs: Add blog post for vendor update and diff feature
osterman Oct 21, 2025
92ea64c
docs: Strengthen blog post messaging on update debt and shared respon…
osterman Oct 22, 2025
4064d98
Merge main into feat/vendor-diff-and-update
osterman Oct 30, 2025
af9f14a
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2025
bb1ff4b
fix: Add performance tracking and update deprecated imports
osterman Oct 30, 2025
84c89fa
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 30, 2025
9fcde50
Merge origin/main into feat/vendor-diff-and-update
osterman Dec 1, 2025
4d8ce52
refactor: Move vendor commands to cmd/vendor/ and logic to pkg/vendor…
osterman Dec 2, 2025
280d390
fix: Address CodeRabbit review comments for vendor commands
osterman Dec 2, 2025
76bdbf4
refactor: Split pkg/vendoring into source/ and version/ subpackages
osterman Dec 5, 2025
ccb5be3
Merge remote-tracking branch 'origin/main' into feat/vendor-diff-and-…
osterman Dec 5, 2025
a01f0d2
fix: Address CodeRabbit review comments for GitHub provider
osterman Dec 5, 2025
16adbc8
Merge remote-tracking branch 'origin/main' into feat/vendor-diff-and-…
osterman Dec 6, 2025
00eab04
Merge origin/main into feat/vendor-diff-and-update
osterman Dec 7, 2025
6002313
Merge origin/main into feat/vendor-diff-and-update
osterman Dec 10, 2025
22134ca
fix: Address CodeRabbit PR review comments
osterman Dec 10, 2025
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
5 changes: 3 additions & 2 deletions cmd/list/vendor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cloudposse/atmos/pkg/flags"
"github.com/cloudposse/atmos/pkg/flags/global"
l "github.com/cloudposse/atmos/pkg/list"
log "github.com/cloudposse/atmos/pkg/logger"
"github.com/cloudposse/atmos/pkg/schema"
)

Expand Down Expand Up @@ -80,9 +81,9 @@ func init() {
// Add stack completion
addStackCompletion(vendorCmd)

// Bind flags to Viper for environment variable support
// Bind flags to Viper for environment variable support.
if err := vendorParser.BindToViper(viper.GetViper()); err != nil {
panic(err)
log.Error("Failed to bind vendor list flags to viper", "error", err)
}
}

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
_ "github.com/cloudposse/atmos/cmd/list"
_ "github.com/cloudposse/atmos/cmd/profile"
themeCmd "github.com/cloudposse/atmos/cmd/theme"
_ "github.com/cloudposse/atmos/cmd/vendor"
"github.com/cloudposse/atmos/cmd/version"
)

Expand Down
18 changes: 0 additions & 18 deletions cmd/vendor.go

This file was deleted.

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

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

errUtils "github.com/cloudposse/atmos/errors"
"github.com/cloudposse/atmos/pkg/flags"
"github.com/cloudposse/atmos/pkg/flags/global"
"github.com/cloudposse/atmos/pkg/perf"
"github.com/cloudposse/atmos/pkg/schema"
vendor "github.com/cloudposse/atmos/pkg/vendoring"
)

// DiffOptions contains all options for vendor diff command.
type DiffOptions struct {
global.Flags // Embedded global flags (chdir, logs-level, etc.).
AtmosConfig *schema.AtmosConfiguration // Populated after config init.
Component string // --component, -c (required).
ComponentType string // --type, -t (default: "terraform").
From string // --from (source version/ref).
To string // --to (target version/ref).
File string // --file (specific file to diff).
Context int // --context (lines of context, default: 3).
Unified bool // --unified (unified diff format, default: true).
}

// SetAtmosConfig implements AtmosConfigSetter for DiffOptions.
func (o *DiffOptions) SetAtmosConfig(cfg *schema.AtmosConfiguration) {
o.AtmosConfig = cfg
}

// Validate checks that diff options are consistent.
func (o *DiffOptions) Validate() error {
defer perf.Track(nil, "vendor.DiffOptions.Validate")()

if o.Component == "" {
return errUtils.ErrComponentFlagRequired
}
return nil
}

var diffParser *flags.StandardParser

var diffCmd = &cobra.Command{
Use: "diff",
Short: "Show differences between vendor component versions",
Long: "Compare vendor component versions and display the differences between the current version and a target version or between two specified versions.",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
RunE: runDiff,
}

func init() {
// Create parser with all diff-specific flags.
diffParser = flags.NewStandardParser(
// String flags.
flags.WithStringFlag("component", "c", "", "Component to diff (required)"),
flags.WithStringFlag("type", "t", "terraform", "Component type (terraform or helmfile)"),
flags.WithStringFlag("from", "", "", "Source version/ref to compare from (default: current version)"),
flags.WithStringFlag("to", "", "", "Target version/ref to compare to (default: latest)"),
flags.WithStringFlag("file", "", "", "Specific file to diff within the component"),

// Int flags.
flags.WithIntFlag("context", "", 3, "Number of context lines to show in diff"),

// Bool flags.
flags.WithBoolFlag("unified", "", true, "Use unified diff format"),

// Environment variable bindings.
flags.WithEnvVars("component", "ATMOS_VENDOR_COMPONENT"),
flags.WithEnvVars("type", "ATMOS_VENDOR_TYPE"),
flags.WithEnvVars("from", "ATMOS_VENDOR_FROM"),
flags.WithEnvVars("to", "ATMOS_VENDOR_TO"),
flags.WithEnvVars("context", "ATMOS_VENDOR_CONTEXT"),
)

// Register flags with cobra command.
diffParser.RegisterFlags(diffCmd)

// Shell completions.
_ = diffCmd.RegisterFlagCompletionFunc("component", componentsArgCompletion)
}

func runDiff(cmd *cobra.Command, args []string) error {
defer perf.Track(nil, "vendor.runDiff")()

// Parse options with Viper precedence (CLI > ENV > config).
opts, err := parseDiffOptions(cmd)
if err != nil {
return err
}

// Validate options.
if err := opts.Validate(); err != nil {
return err
}

// Initialize Atmos config.
// Vendor diff doesn't use stack flag, so skip stack validation.
if err := initAtmosConfig(opts, true); err != nil {
return err
}

// Execute via pkg/vendoring.
return vendor.Diff(opts.AtmosConfig, &vendor.DiffParams{
Component: opts.Component,
ComponentType: opts.ComponentType,
From: opts.From,
To: opts.To,
File: opts.File,
Context: opts.Context,
Unified: opts.Unified,
NoColor: false, // This would come from global flags if needed.
})
}

func parseDiffOptions(cmd *cobra.Command) (*DiffOptions, error) {
defer perf.Track(nil, "vendor.parseDiffOptions")()

v := viper.GetViper()
if err := diffParser.BindFlagsToViper(cmd, v); err != nil {
return nil, fmt.Errorf("%w: %w", errUtils.ErrParseFlag, err)
}

return &DiffOptions{
// global.Flags embedded - would be populated from root persistent flags.
Component: v.GetString(flagComponent),
ComponentType: v.GetString(flagType),
From: v.GetString("from"),
To: v.GetString("to"),
File: v.GetString("file"),
Context: v.GetInt("context"),
Unified: v.GetBool("unified"),
}, nil
}
138 changes: 138 additions & 0 deletions cmd/vendor/pull.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package vendor

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

errUtils "github.com/cloudposse/atmos/errors"
"github.com/cloudposse/atmos/pkg/flags"
"github.com/cloudposse/atmos/pkg/flags/global"
"github.com/cloudposse/atmos/pkg/perf"
"github.com/cloudposse/atmos/pkg/schema"
vendor "github.com/cloudposse/atmos/pkg/vendoring"
)

// PullOptions contains all options for vendor pull command.
type PullOptions struct {
global.Flags // Embedded global flags (chdir, logs-level, etc.).
AtmosConfig *schema.AtmosConfiguration // Populated after config init.
Component string // --component, -c.
Stack string // --stack, -s.
ComponentType string // --type, -t (default: "terraform").
Tags string // --tags (comma-separated).
DryRun bool // --dry-run.
Everything bool // --everything.
}

// SetAtmosConfig implements AtmosConfigSetter for PullOptions.
func (o *PullOptions) SetAtmosConfig(cfg *schema.AtmosConfiguration) {
o.AtmosConfig = cfg
}

// Validate checks that pull options are consistent.
func (o *PullOptions) Validate() error {
defer perf.Track(nil, "vendor.PullOptions.Validate")()

if o.Component != "" && o.Stack != "" {
return fmt.Errorf("%w: --component and --stack cannot be used together", errUtils.ErrMutuallyExclusiveFlags)
}
if o.Component != "" && o.Tags != "" {
return fmt.Errorf("%w: --component and --tags cannot be used together", errUtils.ErrMutuallyExclusiveFlags)
}
if o.Everything && (o.Component != "" || o.Stack != "" || o.Tags != "") {
return fmt.Errorf("%w: --everything cannot be combined with --component, --stack, or --tags", errUtils.ErrMutuallyExclusiveFlags)
}
return nil
}

var pullParser *flags.StandardParser

var pullCmd = &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: runPull,
}

func init() {
// Create parser with all pull-specific flags.
pullParser = flags.NewStandardParser(
// String flags.
flags.WithStringFlag("component", "c", "", "Only vendor the specified component"),
flags.WithStringFlag("stack", "s", "", "Only vendor the specified stack"),
flags.WithStringFlag("type", "t", "terraform", "Component type (terraform or helmfile)"),
flags.WithStringFlag("tags", "", "", "Only vendor components with specified tags (comma-separated)"),

// Bool flags.
flags.WithBoolFlag("dry-run", "", false, "Simulate without making changes"),
flags.WithBoolFlag("everything", "", false, "Vendor all components"),

// Environment variable bindings.
flags.WithEnvVars("component", "ATMOS_VENDOR_COMPONENT"),
flags.WithEnvVars("stack", "ATMOS_VENDOR_STACK", "ATMOS_STACK"),
flags.WithEnvVars("type", "ATMOS_VENDOR_TYPE"),
flags.WithEnvVars("tags", "ATMOS_VENDOR_TAGS"),
flags.WithEnvVars("dry-run", "ATMOS_VENDOR_DRY_RUN"),
)

// Register flags with cobra command.
pullParser.RegisterFlags(pullCmd)

// Shell completions.
_ = pullCmd.RegisterFlagCompletionFunc("component", componentsArgCompletion)
addStackCompletion(pullCmd)
}

func runPull(cmd *cobra.Command, args []string) error {
defer perf.Track(nil, "vendor.runPull")()

// Parse options with Viper precedence (CLI > ENV > config).
opts, err := parsePullOptions(cmd)
if err != nil {
return err
}

// Validate options.
if err := opts.Validate(); err != nil {
return err
}

// Initialize Atmos config.
skipStackValidation := opts.Stack == ""
if err := initAtmosConfig(opts, skipStackValidation); err != nil {
return err
}

// Execute via pkg/vendoring.
return vendor.Pull(opts.AtmosConfig, &vendor.PullParams{
Component: opts.Component,
Stack: opts.Stack,
ComponentType: opts.ComponentType,
DryRun: opts.DryRun,
Tags: opts.Tags,
Everything: opts.Everything,
})
}

func parsePullOptions(cmd *cobra.Command) (*PullOptions, error) {
defer perf.Track(nil, "vendor.parsePullOptions")()

v := viper.GetViper()
if err := pullParser.BindFlagsToViper(cmd, v); err != nil {
return nil, fmt.Errorf("%w: %w", errUtils.ErrParseFlag, err)
}

return &PullOptions{
// global.Flags embedded - would be populated from root persistent flags.
Component: v.GetString(flagComponent),
Stack: v.GetString("stack"),
ComponentType: v.GetString(flagType),
Tags: v.GetString("tags"),
DryRun: v.GetBool("dry-run"),
Everything: v.GetBool("everything"),
}, nil
}
Loading
Loading