Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
8fd80ad
feat(terragrunt): add typed flags, executable mode, exact values, log…
osterman Oct 31, 2026
bfa6850
refactor(terraform): split component execution preparation and export…
osterman Oct 31, 2026
16fc492
fix(terragrunt): make the integration layer's tests and fixtures plat…
osterman Nov 1, 2026
64f8e5f
test(terragrunt): match rejection reasons in the Pro scenario regardl…
osterman Nov 1, 2026
d7b62ff
fix(terragrunt): validate provider option declarations and resolve fl…
osterman Nov 8, 2026
100532a
fix(plugins): keep provider flags when an unrelated package cannot be…
osterman Nov 8, 2026
1674c25
fix(planfile): fail uploads on an unreadable plan record and keep rec…
osterman Nov 8, 2026
8460579
fix(terragrunt): honor prereleases, absolute unit paths, and environm…
osterman Nov 8, 2026
7d53ff7
fix(terragrunt): run prepared before-hooks and persist auth in execut…
osterman Nov 8, 2026
82f7cd2
test(terragrunt): fail on real regressions and stop depending on the …
osterman Nov 8, 2026
41b855e
fix(terragrunt): keep sensitivity for list elements, indexed locals, …
osterman Nov 8, 2026
63102db
fix(plugins): mask sensitive inputs in plugin logs and keep distinct …
osterman Nov 8, 2026
b1d954c
fix(terraform): resolve provider options before pre-run discovery
osterman Nov 8, 2026
6667dfa
fix(plugins): bound free-text release annotations
osterman Nov 8, 2026
2895d62
fix(terraform): let a restored plan retry in its verified rebuild
osterman Nov 8, 2026
55b8958
fix(terraform): rebuild a restored plan as the reviewed operation wit…
osterman Nov 8, 2026
d2890a9
test(terragrunt): build the plugin with the toolchain its go.mod requ…
osterman Nov 9, 2026
a1ebeab
refactor(terraform): extract the reviewed workdir restore from plan r…
osterman Nov 9, 2026
542d94c
fix(plugins): give each typed OCI media type constant its own group
osterman Nov 9, 2026
64d75d6
fix(plugins): validate provider option metadata types
osterman Nov 11, 2026
8c021af
fix(planfile): preserve downloaded plan permissions
osterman Nov 11, 2026
ae911ac
test(terragrunt): verify command preserves input environment
osterman Nov 11, 2026
b3be024
fix(terragrunt): validate provider option values
osterman Nov 11, 2026
fc956ad
test(terragrunt): synchronize web identity request capture
osterman Nov 11, 2026
71c33a1
fix(terragrunt): truncate logs at UTF-8 boundaries
osterman Nov 11, 2026
0260790
fix(plugins): handle set keys in unknown input paths
osterman Nov 11, 2026
9471e09
test: verify provider flags and sensitive option metadata
osterman Nov 11, 2026
9550c96
test(plugins): verify derived package source annotation
osterman Nov 11, 2026
b04ba72
test(provideroptions): assert explicit empty list
osterman Nov 11, 2026
77b2609
fix(provideroptions): normalize empty list aliases
osterman Nov 11, 2026
8a49b09
fix(terraform): invalidate caches after failed terragrunt runs
osterman Nov 11, 2026
46338ec
test(plugins): assert emitted diagnostic warnings
osterman Nov 11, 2026
895ee9d
fix(terraform): resolve terragrunt on invocation path
osterman Nov 11, 2026
a137342
fix(provideroptions): validate sensitive integers without echoing values
osterman Nov 11, 2026
5d54b2b
fix(plugins): validate inputs before rendering preparation logs
osterman Nov 11, 2026
a5bf3c6
fix(terragrunt): preserve sensitivity when scans cannot resolve paths
osterman Nov 11, 2026
a6fb269
fix(terragrunt): honor executable plan policies
osterman Nov 11, 2026
176e54b
Merge L7 Terragrunt semantics into L8 integration
osterman Nov 13, 2026
729f6c7
fix(terragrunt): protect logs and preserve review semantics
osterman Nov 13, 2026
26e74b7
fix(terragrunt): complete host integration review fixes
osterman Nov 13, 2026
aa3cdaa
ci(plugins): resolve the release comparison base for manual runs
osterman Nov 13, 2026
a58bfcd
test(plugin): count visible warning text, not styled output
osterman Nov 13, 2026
d9a5fee
fix(terragrunt): close three log redaction gaps
osterman Nov 13, 2026
3f377f7
fix(terragrunt): isolate and harden AWS credential resolution
osterman Nov 13, 2026
9d52044
fix(terragrunt): keep component env ahead of process-level options
osterman Nov 13, 2026
749353a
fix(terraform): accept restored plans in workdir subdirectories
osterman Nov 13, 2026
e1063b5
fix(terraform): download reviewed child modules before verifying a re…
osterman Nov 13, 2026
1343c60
Merge published L7 semantics into Terragrunt integration
osterman Nov 13, 2026
c8ef8a0
Refine merged preparation validation and workdir digest
osterman Nov 13, 2026
2f1139f
Merge latest published L7 base into Terragrunt integration
osterman Nov 13, 2026
5e194d9
Merge latest published L7 base into Terragrunt integration
osterman Nov 13, 2026
b34787e
fix(terraform): protect saved plan binding on Windows
osterman Nov 13, 2026
7c2d4ba
ci(windows): run plan-binding ACL regression
osterman Nov 13, 2026
3271089
fix(configuration): classify generated-file filesystem failures
osterman Nov 13, 2026
aaf83d2
Merge published L7 source and backend fixes into L8
osterman Nov 13, 2026
aafa2b7
Merge L7 schema fix for native Terragrunt subdirectories
osterman Nov 13, 2026
b8c8e13
fix(ci): disable CGO for Windows plan-binding ACL check
osterman Nov 13, 2026
795005d
fix(plugin): validate IAM probe responses by phase
osterman Nov 14, 2026
6fbae91
refactor(terragrunt): consolidate model problem declarations
osterman Nov 14, 2026
685f2c0
fix(terragrunt): document model performance tracking exemption
osterman Nov 14, 2026
a7cdc18
fix(schema): reduce GetComponentConfig complexity and drop unused gos…
osterman Nov 14, 2026
5c80f1c
fix(terragrunt): replace sensitive files atomically and classify temp…
osterman Nov 14, 2026
85fea8d
fix(terraform): pass the sanitized environment to reviewed-module dow…
osterman Nov 14, 2026
cb638f1
test(terragrunt): isolate AWS credential cache keys per invocation
osterman Nov 14, 2026
956095a
fix(terragrunt): register apply-time sensitive values in the reparse …
osterman Nov 14, 2026
60a039e
fix(terraform): capture executable-mode output for exec-metadata repo…
osterman Nov 14, 2026
23ce31a
fix(terraform): merge staged artifacts and apply the reviewed role wh…
osterman Nov 14, 2026
5915ad9
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 14, 2026
d639e62
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 14, 2026
100b535
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 14, 2026
9fd3be5
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 14, 2026
141be6d
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 14, 2026
873632d
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 14, 2026
2abbdb4
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 14, 2026
540cd04
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 14, 2026
e4e9599
test: match the Windows sensitive-file tests to atomic replacement
osterman Nov 14, 2026
3705ace
fix(terraform): invalidate alias-keyed caches after executable-mode runs
osterman Nov 15, 2026
c9be0d6
fix(terraform): reject a symlinked workdir before the transport check…
osterman Nov 15, 2026
cec8074
fix(terragrunt): include apply-time files in the sensitive-output scan
osterman Nov 15, 2026
333e078
fix(terragrunt): withhold collected logs when the apply-time reparse …
osterman Nov 15, 2026
3c50070
fix(plugin): register response inputs before printing warning diagnos…
osterman Nov 15, 2026
c72cf78
refactor(terraform): split the workdir root check out of holdsOnlyTra…
osterman Nov 15, 2026
72a3d31
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 15, 2026
441a154
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 15, 2026
cbc68aa
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 15, 2026
e29ffe8
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 16, 2026
856bbbc
Merge branch 'feat/terragrunt-native-semantics' into feat/terragrunt-…
osterman Nov 16, 2026
8fe22d8
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
3602cce
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
d8d2929
refactor(terraform): keep the plan environment helpers in a file this…
osterman Nov 16, 2026
8ae7bb0
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
ccdbedf
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
6ab14ed
fix(plugin): print preparation warnings once through the session deduper
osterman Nov 16, 2026
27bde2c
fix(terraform): keep configuration named like state in the saved-plan…
osterman Nov 16, 2026
dba9e79
fix(terragrunt): withhold logs when a sensitive local transforms call…
osterman Nov 16, 2026
833ad94
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
b0576bd
fix(plugin): reject dependencies on another provider's components
osterman Nov 16, 2026
e2210cd
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
e535c40
Merge remote-tracking branch 'origin/feat/terragrunt-native-semantics…
osterman Nov 16, 2026
c810c27
refactor(terragrunt): simplify sensitivity scanning and unit resolution
osterman Nov 17, 2026
e02bcf8
Merge exact validated L7 checkpoint into Terragrunt integration
osterman Nov 17, 2026
f681ab4
fix(terragrunt): protect preparation diagnostics and input logs
osterman Nov 17, 2026
85772ed
Merge published L7 consolidation and keep L8 within quality limits
osterman Nov 17, 2026
f049378
Merge final Terragrunt predecessor and repair preparation CI fixtures
osterman Nov 17, 2026
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
11 changes: 8 additions & 3 deletions .github/workflows/plugin-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ jobs:
# version bump in every layer that touches a package input. Compare such pull requests with the merge
# base of the default branch instead, the same range the whole stack is released against. Pushes and
# pull requests that target the default branch keep the provider's default base.
# The inventory --check also compares packed bytes with any published version in the registry,
# so a child cannot reuse its parent's published version for different package bytes.
#
# A manual run has no event base: the provider would fall back to refs/remotes/origin/HEAD, which
# actions/checkout never creates. Use the same default-branch merge base, so a manual run of a stack
# layer checks the same range as its pull request, and a manual run of the default branch compares
# its tip with itself.
- name: Resolve the release comparison base
id: base
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref != github.event.repository.default_branch
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.base.ref != github.event.repository.default_branch)
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
# Fail rather than fall back to the PR target when the branches share no history.
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ jobs:
run: |
atmos build version --target=${{ matrix.target }}

- name: Verify Windows plan-binding ACL
if: matrix.target == 'windows' && ! github.event.pull_request.draft
shell: bash
# Match the CLI and acceptance harness; the hosted CGO runtime can
# crash during startup before this test reaches its ACL assertions.
env:
CGO_ENABLED: '0'
run: go test ./pkg/component/terraform -run '^TestPlanBindingPrivateACLUnderPermissiveParent$' -count=1 -v

# Mage keeps the cross-platform acceptance orchestration in typed,
# unit-tested Go code while the workflow remains a one-command dispatch.
# Reuse this job's warm Go cache to compile the large test binaries once.
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ linters:
# Only this cloud-specific leaf imports the SDK; the parent downloader stays generic.
- "!**/pkg/downloader/s3/**"
- "!**/pkg/github/**"
# The Terragrunt plugin bridge resolves the AWS identity of an invocation for Terragrunt's own
# AWS calls (get_aws_account_id, S3 dependency state). It is an AWS-specific leaf of a separate
# module that cannot import the Atmos auth packages.
- "!**/plugins/terragrunt/bridge/aws.go"
- "!**/plugins/terragrunt/bridge/aws_test.go"
# The S3 deployment Mage target is an AWS-specific build tool and
# intentionally uses the AWS SDK instead of shelling out to a CLI.
- "!**/magefiles/s3/**"
Expand Down
23 changes: 19 additions & 4 deletions cmd/help_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/wordwrap"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/cloudposse/atmos/cmd/internal"
tuiUtils "github.com/cloudposse/atmos/internal/tui/utils"
atmosansi "github.com/cloudposse/atmos/pkg/ansi"
"github.com/cloudposse/atmos/pkg/component/provideroptions"
cfg "github.com/cloudposse/atmos/pkg/config"
"github.com/cloudposse/atmos/pkg/flags/compat"
log "github.com/cloudposse/atmos/pkg/logger"
Expand Down Expand Up @@ -495,10 +497,7 @@ func printFlags(w io.Writer, cmd *cobra.Command, atmosConfig *schema.AtmosConfig
termWidth := getTerminalWidth()

if cmd.HasAvailableLocalFlags() {
fmt.Fprintln(w, styles.heading.Render("FLAGS"))
fmt.Fprintln(w)
renderFlags(w, cmd.LocalFlags(), styles.commandName, styles.flagName, styles.flagDesc, termWidth, atmosConfig)
fmt.Fprintln(w)
renderLocalFlagSections(w, cmd.LocalFlags(), styles, termWidth, atmosConfig)
}

if cmd.HasAvailableInheritedFlags() {
Expand Down Expand Up @@ -686,3 +685,19 @@ func printFooter(w io.Writer, cmd *cobra.Command, styles *helpStyles) {
usageMsg = renderMarkdownDescription(usageMsg)
fmt.Fprintf(w, "\n%s\n", styles.muted.Render(usageMsg))
}

// renderLocalFlagSections prints the FLAGS section, followed by one section for each configuration
// provider whose declared options the command accepts.
func renderLocalFlagSections(w io.Writer, local *pflag.FlagSet, styles *helpStyles, termWidth int, atmosConfig *schema.AtmosConfiguration) {
rest, providerSections := provideroptions.SplitFlags(local)
fmt.Fprintln(w, styles.heading.Render("FLAGS"))
fmt.Fprintln(w)
renderFlags(w, rest, styles.commandName, styles.flagName, styles.flagDesc, termWidth, atmosConfig)
fmt.Fprintln(w)
for _, section := range providerSections {
fmt.Fprintln(w, styles.heading.Render(section.Title))
fmt.Fprintln(w)
renderFlags(w, section.Flags, styles.commandName, styles.flagName, styles.flagDesc, termWidth, atmosConfig)
fmt.Fprintln(w)
}
}
60 changes: 60 additions & 0 deletions cmd/help_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package cmd
import (
"bytes"
"os"
"slices"
"strings"
"testing"

"github.com/charmbracelet/lipgloss"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

terraformcmd "github.com/cloudposse/atmos/cmd/terraform"
"github.com/cloudposse/atmos/pkg/ansi"
"github.com/cloudposse/atmos/pkg/component/provideroptions"
"github.com/cloudposse/atmos/pkg/flags/compat"
"github.com/cloudposse/atmos/pkg/schema"
"github.com/cloudposse/atmos/pkg/ui/markdown"
Expand Down Expand Up @@ -1422,3 +1426,59 @@ func TestGetExperimentalBadge(t *testing.T) {
})
}
}

func TestPrintFlagsGroupsProviderFlagsUnderTheirProvider(t *testing.T) {
root := &cobra.Command{Use: "terraform"}
plan := &cobra.Command{Use: "plan", Run: func(*cobra.Command, []string) {}}
plan.Flags().Bool("affected", false, "Plan the affected components")
root.AddCommand(plan)
options, err := provideroptions.Parse("tool", []any{
map[string]any{"name": "level", "type": "string", "description": "Provider log level.", "commands": []any{"plan"}},
})
if err != nil {
t.Fatal(err)
}
if err := provideroptions.Register(root, []provideroptions.Provider{{Section: "tool", Name: "tool", Mode: provideroptions.ModeNative, Options: options}}); err != nil {
t.Fatal(err)
}

var buf bytes.Buffer
styles := createHelpStyles(lipgloss.NewRenderer(&buf))
printFlags(&buf, plan, &schema.AtmosConfiguration{}, &styles)
// Runners advertise color, and styling splits words with escape sequences; assert on the text.
output := ansi.Strip(buf.String())

flags, providerFlags, found := strings.Cut(output, "TOOL FLAGS")
if !found {
t.Fatalf("provider section missing: %q", output)
}
if !strings.Contains(flags, "--affected") || strings.Contains(flags, "--tool-level") {
t.Errorf("Atmos flags and provider flags are not separated: %q", flags)
}
if !strings.Contains(providerFlags, "--tool-level") || !strings.Contains(providerFlags, "Provider log level.") {
t.Errorf("provider section lacks its flag: %q", providerFlags)
}
}

func TestRegisterProviderFlagsWithoutEnabledProvidersChangesNothing(t *testing.T) {
flagNames := func() []string {
var names []string
plan().Flags().VisitAll(func(flag *pflag.Flag) { names = append(names, flag.Name) })
return names
}
before := flagNames()
for _, args := range [][]string{{"terraform", "plan"}, {"version"}, nil} {
if err := terraformcmd.RegisterProviderFlags(&schema.AtmosConfiguration{}, args); err != nil {
t.Errorf("args %v: %v", args, err)
}
}
if !slices.Equal(flagNames(), before) {
t.Error("registration without a provider changed the flags")
}
}

// plan finds the terraform plan command in the real command tree.
func plan() *cobra.Command {
command, _, _ := RootCmd.Find([]string{"terraform", "plan"})
return command
}
5 changes: 1 addition & 4 deletions cmd/help_topics_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func printLocalFlagsOnly(w io.Writer, cmd *cobra.Command, atmosConfig *schema.At
return
}

fmt.Fprintln(w, styles.heading.Render("FLAGS"))
fmt.Fprintln(w)
renderFlags(w, localFlags, styles.commandName, styles.flagName, styles.flagDesc, getTerminalWidth(), atmosConfig)
fmt.Fprintln(w)
renderLocalFlagSections(w, localFlags, styles, getTerminalWidth(), atmosConfig)
}

func commandSpecificFlagSet(cmd *cobra.Command) *pflag.FlagSet {
Expand Down
8 changes: 6 additions & 2 deletions cmd/plugin/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func validateCommand() *cobra.Command {
}

func packCommand() *cobra.Command {
parser := newOutputParser(flags.WithStringFlag(packOutputFlag, "o", "", "Destination OCI layout directory"))
parser := newOutputParser(append(sourceFlags(), flags.WithStringFlag(packOutputFlag, "o", "", "Destination OCI layout directory"))...)
command := &cobra.Command{Use: "pack [directory] --output <layout>", Short: "Pack precompiled plugins into a multi-platform OCI layout", Args: cobra.MaximumNArgs(1)}
registerOutputFlags(command, parser)
_ = command.MarkFlagRequired(packOutputFlag)
Expand All @@ -68,7 +68,11 @@ func packCommand() *cobra.Command {
return err
}
output := values.GetString(packOutputFlag)
if err := pluginoci.Pack(directory, output, registry, pluginoci.WithExecutableFormatCheck()); err != nil {
opts, err := packOptions(values)
if err != nil {
return err
}
if err := pluginoci.Pack(directory, output, registry, opts...); err != nil {
return err
}
files, err := pluginoci.LayoutFiles(output)
Expand Down
4 changes: 2 additions & 2 deletions cmd/plugin/publish_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestPublishPublicAccessAfterUpload(t *testing.T) {
require.NoError(t, err, "ordinary publication must support private registries")
}

func publicReleaseLayout(t *testing.T, descriptors *extension.Registry) string {
func publicReleaseLayout(t *testing.T, descriptors *extension.Registry, opts ...pluginoci.Option) string {
t.Helper()
directory := t.TempDir()
require.NoError(t, os.MkdirAll(filepath.Join(directory, "bin"), 0o755))
Expand All @@ -107,6 +107,6 @@ spec:
example/fixture: {}
`), 0o644))
layout := filepath.Join(t.TempDir(), "layout")
require.NoError(t, pluginoci.Pack(directory, layout, descriptors))
require.NoError(t, pluginoci.Pack(directory, layout, descriptors, opts...))
return layout
}
41 changes: 41 additions & 0 deletions cmd/plugin/publish_safety_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"go.uber.org/mock/gomock"

errUtils "github.com/cloudposse/atmos/errors"
atmosoci "github.com/cloudposse/atmos/pkg/oci"
"github.com/cloudposse/atmos/pkg/plugin/extension"
)

//go:generate go run go.uber.org/mock/mockgen -destination=mock_registry_test.go -package=plugin github.com/cloudposse/atmos/pkg/oci Registry
Expand Down Expand Up @@ -121,3 +123,42 @@ func TestDeleteReleaseConfirmation(t *testing.T) {
require.ErrorIs(t, deleteRelease(t.Context(), client, reference, true, deletePrompts{interactive: neverInteractive, confirm: noConfirm}), denied)
})
}

func TestPackOptionsSourceIsOptInAndNeverImplicit(t *testing.T) {
t.Setenv("GITHUB_REPOSITORY", "")
t.Setenv("GITHUB_SERVER_URL", "")
values := func(source string) *viper.Viper {
result := viper.New()
result.Set(sourceFlag, source)
return result
}

opts, err := packOptions(values(""))
require.NoError(t, err)
require.Len(t, opts, 1, "without --source only the executable format check applies")

opts, err = packOptions(values("https://github.com/example/repo"))
require.NoError(t, err)
require.Len(t, opts, 2)

_, err = packOptions(values(sourceGitHubActions))
require.ErrorIs(t, err, errUtils.ErrPluginInvalidConfig, "github-actions must fail loudly outside GitHub Actions")

t.Setenv("GITHUB_REPOSITORY", "example/repo")
opts, err = packOptions(values(sourceGitHubActions))
require.NoError(t, err)
require.Len(t, opts, 2)
descriptors := extension.New()
require.NoError(t, descriptors.Register(extension.Descriptor{Capability: "fixture", Path: []string{"fixtures"}, Version: 1, Validate: func(extension.Binding) error { return nil }}))
layout := publicReleaseLayout(t, descriptors, opts...)
index, err := atmosoci.LoadIndex(layout, "")
require.NoError(t, err)
manifest, err := index.IndexManifest()
require.NoError(t, err)
require.Equal(t, "https://github.com/example/repo", manifest.Annotations["org.opencontainers.image.source"])

t.Setenv("GITHUB_REPOSITORY", "example/repo")
opts, err = packOptions(values(""))
require.NoError(t, err)
require.Len(t, opts, 1, "the CI environment alone never links a package")
}
47 changes: 43 additions & 4 deletions cmd/plugin/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package plugin
import (
"context"
"fmt"
"os"
"slices"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -23,7 +25,7 @@ import (
)

func releaseCommand() *cobra.Command {
parser := newOutputParser(append(publicationFlags(), inventoryReleaseFlags()...)...)
parser := newOutputParser(slices.Concat(publicationFlags(), inventoryReleaseFlags(), sourceFlags())...)
command := &cobra.Command{
Use: "release [directory] [--to <repository> | --inventory <file>]",
Short: "Build all targets, test the host target, and publish a plugin release",
Expand Down Expand Up @@ -122,18 +124,55 @@ func (backend *releaseBackend) Test(ctx context.Context, directory string) error
}

func (backend *releaseBackend) Pack(ctx context.Context, directory, layout string) error {
if err := pluginoci.Pack(directory, layout, backend.manager.Installer.Descriptors, pluginoci.WithExecutableFormatCheck()); err != nil {
opts, err := packOptions(backend.values)
if err != nil {
return err
}
if err := pluginoci.Pack(directory, layout, backend.manager.Installer.Descriptors, opts...); err != nil {
return err
}
// Inventory entries always supply a destination. Directory-only checks can
// remain offline unless the caller supplies --to.
destination := backend.values.GetString(publishDestinationFlag)
if backend.values.GetBool(releaseCheckFlag) && destination != "" {
return pluginoci.CheckPublication(ctx, backend.manager.Installer.Registry, layout, destination)
}
return nil
}

const (
// The source flag selects the repository recorded as the package source.
sourceFlag = "source"
// The github-actions value asks packing to derive the repository link from the GitHub Actions environment.
sourceGitHubActions = "github-actions"
)

// sourceFlags declares the opt-in repository link recorded as org.opencontainers.image.source.
func sourceFlags() []flags.Option {
return []flags.Option{
flags.WithStringFlag(sourceFlag, "", "", "Repository URL recorded as the package source so registries such as GHCR link the package to it (https URL, or "+sourceGitHubActions+" to derive it from GITHUB_REPOSITORY); defaults to metadata.repository in plugin.yaml"),
flags.WithEnvVars(sourceFlag, "ATMOS_PLUGIN_SOURCE"),
}
}

// packOptions translates the shared pack flags into packing options. Nothing is
// derived from the environment unless --source asks for it.
func packOptions(values *viper.Viper) ([]pluginoci.Option, error) {
opts := []pluginoci.Option{pluginoci.WithExecutableFormatCheck()}
switch source := values.GetString(sourceFlag); source {
case "":
case sourceGitHubActions:
derived := pluginoci.GitHubActionsSource(os.Getenv) //nolint:forbidigo // GITHUB_* is the runner's own context, not Atmos configuration, and is read only when --source asks for it.
if derived == "" {
return nil, errUtils.Build(fmt.Errorf("%w: --%s=%s requires GITHUB_REPOSITORY (and optionally an https GITHUB_SERVER_URL)", errUtils.ErrPluginInvalidConfig, sourceFlag, sourceGitHubActions)).
WithHintf("Run inside GitHub Actions, or pass the repository explicitly with `--%s https://github.com/<owner>/<repo>`.", sourceFlag).
Err()
}
opts = append(opts, pluginoci.WithSource(derived))
default:
opts = append(opts, pluginoci.WithSource(source))
}
return opts, nil
}

func (backend *releaseBackend) Publish(ctx context.Context, layout string) (*pluginoci.Release, error) {
return publishLayout(ctx, backend.manager, layout, backend.values)
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import (
_ "github.com/cloudposse/atmos/cmd/secret"
stackcmd "github.com/cloudposse/atmos/cmd/stack"
_ "github.com/cloudposse/atmos/cmd/store"
_ "github.com/cloudposse/atmos/cmd/terraform"
terraformcmd "github.com/cloudposse/atmos/cmd/terraform"
"github.com/cloudposse/atmos/cmd/terraform/backend"
terraformcache "github.com/cloudposse/atmos/cmd/terraform/cache"
"github.com/cloudposse/atmos/cmd/terraform/workdir"
Expand Down Expand Up @@ -1915,6 +1915,11 @@ func Execute() error {
if err != nil {
return err
}

// Provider options come from static package metadata and must exist before Cobra parses flags.
if err = terraformcmd.RegisterProviderFlags(&atmosConfig, os.Args[1:]); err != nil {
return err
}
}

// Custom commands and configured aliases can now use inherited discovery metadata.
Expand Down
3 changes: 1 addition & 2 deletions cmd/terraform/planfile/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ func resolveDownloadPlanfilePath(cmd *cobra.Command, opts *DownloadOptions, atmo
return "", fmt.Errorf("%w: failed to resolve component path: %w", errUtils.ErrPlanfileDownloadFailed, err)
}

planfilePath := exec.ConstructTerraformComponentPlanfilePath(atmosConfig, &info)
return planfilePath, nil
return canonicalPlanfilePath(atmosConfig, &info)
}

// printDownloadSuccess prints the success message for a download.
Expand Down
Loading
Loading