Skip to content

fix(secrets): SOPS cloud-KMS secrets authenticate via Atmos identity - #2643

Merged
Andriy Knysh (aknysh) merged 9 commits into
mainfrom
osterman/sops-aws-kms-identity
Jun 21, 2026
Merged

Andriy Knysh (aknysh) merged 9 commits into
mainfrom
osterman/sops-aws-kms-identity

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

what

  • atmos secret and !secret (during terraform plan) against a SOPS cloud-KMS backend now authenticate using the Atmos identity — --identity / ATMOS_IDENTITY, the per-provider secrets.providers.<name>.identity, or the stack/component effective identity — instead of requiring ambient cloud credentials.
  • The cloud is inferred from the SOPS file's master-key type at runtime (AWS KMS / GCP KMS / Azure Key Vault); there is no per-cloud kind. Credentials are injected into the in-process getsops encrypt/decrypt via ApplyToMasterKey (no process-environment mutation).
  • Refactors SOPS into its own package pkg/secrets/providers/sops/ with a registry of per-cloud key handlers (aws.go / gcp.go / azure.go); the cloud-SDK credential building lives in the depguard-exempt pkg/store/sopsauth/ bridge so the SOPS package imports no cloud SDK directly.
  • Threads the auth resolver + effective identity to the provider via a transient AtmosConfiguration.SecretsAuth seam, populated in both the atmos secret and terraform code paths.
  • Fixes the SOPS decrypt error to emit identity/permission hints for cloud-KMS files (derived from the file's actual key types) instead of the misleading age-key hint.

why

references

…2637)

`atmos secret` and `!secret` against a SOPS cloud-KMS backend ignored the
Atmos identity (--identity / ATMOS_IDENTITY / secrets.providers.<name>.identity
/ the stack's effective identity) and required ambient cloud credentials,
forcing every call to be wrapped in `atmos auth exec`.

The SOPS provider now resolves credentials from the identity and injects them
into the in-process getsops encrypt/decrypt via ApplyToMasterKey (no env
mutation). The cloud is inferred from the file's master-key type at runtime —
there is no per-cloud "kind". SOPS moves to its own package
(pkg/secrets/providers/sops) with a registry of per-cloud key handlers
(aws/gcp/azure), and the cloud-SDK credential building lives in the
depguard-exempt pkg/store/sopsauth bridge. Backward compatible: with no
resolvable identity, the ambient-credential fallback is unchanged.

Reproduced with a Floci KMS E2E (ambient creds cleared, identity-only) and
covered by unit tests for key-service selection, registry dispatch, identity
precedence, and kind-aware error hints.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@atmos-pro

atmos-pro Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Jun 20, 2026
@github-actions github-actions Bot added the size/l Large size PR label Jun 20, 2026
@github-actions

github-actions Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

Document that the SOPS cloud-KMS kinds (sops/aws-kms, sops/gcp-kms,
sops/azure-kv) authenticate via an Atmos identity (no atmos auth exec
wrapper), the identity precedence (per-provider > --identity/ATMOS_IDENTITY
> stack/component effective), and the ambient-credential fallback.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5fe5bcdb-d946-48b8-b0da-0c8454c2e22e

📥 Commits

Reviewing files that changed from the base of the PR and between 253a977 and 248f818.

📒 Files selected for processing (1)
  • lychee.toml

📝 Walkthrough

Walkthrough

Adds identity-aware authentication to SOPS cloud-KMS operations. A new sopsauth package bridges Atmos identity resolution to getsops master-key appliers for AWS KMS, GCP KMS, and Azure Key Vault. A routing key service dispatches SOPS Decrypt/Encrypt to per-cloud handlers. SecretsAuthContext is added to AtmosConfiguration and injected in both atmos secret and Terraform execution paths. The sops provider package is migrated to its own package namespace with an exported New constructor and updated provider contracts.

Changes

SOPS Cloud-KMS Identity Authentication

Layer / File(s) Summary
Secrets auth and provider contracts
pkg/store/identity.go, pkg/store/sopsauth/builder.go, pkg/schema/schema.go, pkg/secrets/providers/keygen.go, pkg/secrets/providers/provider.go, pkg/secrets/providers/sops/errors.go
SecretsAuthContext struct added to pkg/store, three cloud applier interfaces and a Builder interface defined in sopsauth. AtmosConfiguration gains a transient SecretsAuth field. KeyGenerator, KeygenResult, and KeygenOutput moved to the shared providers package. SOPS sentinel errors extracted to their own file.
Per-cloud identity credential resolvers
pkg/store/sopsauth/aws.go, pkg/store/sopsauth/gcp.go, pkg/store/sopsauth/azure.go, pkg/store/sopsauth/sopsauth_test.go
AWSKMS, GCPKMS, and AzureKV methods on resolverBuilder resolve Atmos identity auth context into cloud-SDK credentials and return the matching getsops master-key applier. Tests validate resolver error wrapping, nil-context handling, and success paths for each cloud provider.
Cloud key handler registry and dispatch
pkg/secrets/providers/sops/keyservice.go, pkg/secrets/providers/sops/aws.go, pkg/secrets/providers/sops/gcp.go, pkg/secrets/providers/sops/azure.go, pkg/secrets/providers/sops/handlers_test.go
Global cloudKeyHandlers registry keyed by getsops key-type identifier. sopsKeyServiceClient dispatches Decrypt/Encrypt to the matching cloud handler or falls through to a fallback client. Each handler reconstructs the SOPS master key, applies identity credentials, and performs master-key decrypt or encrypt. Tests validate handler dispatch, key-type routing, and identity application.
SOPS provider migration and identity-aware key usage
pkg/secrets/providers/sops/sops.go, pkg/secrets/providers/sops/sops_age_key_store.go, pkg/secrets/providers/sops/sops_keygen.go
Package migrated to sops, New(...) exported. sopsProvider gains authResolver/effectiveIdentity with precedence logic. keyClient() wraps cloud-KMS via wrapCloudKeyService. writeNewFile uses GenerateDataKeyWithKeyServices. decryptErr inspects master-key types for kind-aware hints. All method signatures updated to providers.Coordinate/Scope.
CLI and Terraform secrets auth injection
cmd/secret/shared.go, cmd/secret/shared_identity_test.go, internal/exec/terraform_execute_helpers.go, pkg/secrets/factory.go, go.mod
injectSecretStoreAuthResolver extended with scope parameter and secretsDefaultIdentity helper; sets atmosConfig.SecretsAuth. Terraform path sets SecretsAuth with storeDefaultIdentity(info.Identity). Blank SOPS import added to factory for init registration. aws-sdk-go-v2/service/kms promoted to direct dependency. Tests validate identity precedence and nil-argument no-ops.
Provider registry and keygen contract migration
pkg/secrets/providers/registry_test.go, pkg/secrets/providers/sops/sops_keygen_test.go, pkg/secrets/providers/sops/sops_keygen_coverage_test.go
Registry test migrated to providers_test package with blank SOPS import. Keygen tests updated to providers.KeygenResult, providers.ErrKeygenNotSupported, and providers.Coordinate.
SOPS package unit coverage updates
pkg/secrets/providers/sops/construct_test.go, pkg/secrets/providers/sops/keyservice_test.go, pkg/secrets/providers/sops/sops_test.go, pkg/secrets/providers/sops/sops_coverage_test.go, pkg/secrets/providers/sops/sops_age_key_file_test.go, pkg/secrets/providers/sops/sops_age_key_store_test.go, pkg/secrets/providers/sops/sops_inline_key_test.go
All sops tests migrated to sops package, using providers.Coordinate, providers.FileResettable, New(...). Keyservice tests added for dispatch routing, identity precedence, key-type mapping, and error hint generation. Constructor and coverage tests validate scoping, resettable behavior, and integration.
E2E scenario fixture and documentation
tests/sops_kms_floci_test.go, tests/fixtures/scenarios/sops-kms-floci/*, docs/fixes/2026-06-20-sops-cloud-kms-identity.md, website/docs/cli/configuration/secrets.mdx, lychee.toml
TestSopsKmsFlociE2E creates a Floci-backed KMS key, writes a .sops.yaml creation rule, runs secret set and secret get with explicit --identity, and asserts round-trip success. Fixture defines dev stage with !secret integration. Fix doc and CLI guide clarify cloud-KMS identity model, precedence rules, and SOPS age-key inputs. Lychee config excludes no-color.org from link checking.

Sequence Diagram

sequenceDiagram
  participant CLI as atmos secret / terraform exec
  participant SharedWiring as injectSecretStoreAuthResolver / injectTerraformStoreAuthResolver
  participant AtmosConfig as AtmosConfiguration.SecretsAuth
  participant sopsProvider as sopsProvider.keyClient()
  participant sopsKeyServiceClient
  participant cloudKeyHandler as awsKeyHandler / gcpKeyHandler / azureKeyHandler
  participant sopsauthBuilder as sopsauth.Builder
  participant MasterKey as getsops MasterKey

  CLI->>SharedWiring: scope / info.Identity
  SharedWiring->>AtmosConfig: set SecretsAuthContext{Resolver, DefaultIdentity}
  CLI->>sopsProvider: Get / Set (Decrypt / Encrypt)
  sopsProvider->>sopsKeyServiceClient: wrapCloudKeyService(authResolver, identity, base)
  sopsKeyServiceClient->>sopsKeyServiceClient: keyTypeID(req.Key)
  sopsKeyServiceClient->>cloudKeyHandler: decrypt / encrypt(builder, identity, req)
  cloudKeyHandler->>sopsauthBuilder: AWSKMS / GCPKMS / AzureKV(ctx, identity)
  sopsauthBuilder-->>cloudKeyHandler: applier
  cloudKeyHandler->>MasterKey: ApplyToMasterKey + Decrypt / Encrypt
  MasterKey-->>cloudKeyHandler: plaintext / ciphertext
  cloudKeyHandler-->>sopsKeyServiceClient: result bytes
  sopsKeyServiceClient-->>sopsProvider: DecryptResponse / EncryptResponse
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related issues

Possibly related PRs

  • cloudposse/atmos#2099: Introduced the core AuthContextResolver and identity-aware store framework in pkg/store/identity.go that this PR extends with SecretsAuthContext and the sopsauth bridge.
  • cloudposse/atmos#1911: Targets the same declarative secrets system for SOPS cloud-KMS-backed !secret provider integration where this PR extends/implements identity-aware auth plumbing for cloud KMS SOPS de/encryption.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: enabling SOPS cloud-KMS secrets to authenticate via Atmos identity instead of ambient credentials.
Docstring Coverage ✅ Passed Docstring coverage is 82.98% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/sops-aws-kms-identity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/store/sopsauth/aws.go`:
- Around line 20-27: The ResolveAWSAuthContext method can return a nil
authContext without an error, and the code then passes this nil value to
awsAuthConfigOpts which dereferences it, causing a panic. After checking the
error returned by ResolveAWSAuthContext, add an explicit nil check for
authContext and return an error immediately if authContext is nil before it is
passed to awsAuthConfigOpts.

In `@pkg/store/sopsauth/azure.go`:
- Around line 19-27: The authContext variable obtained from
b.resolver.ResolveAzureAuthContext is used without a nil check, which can cause
a nil-pointer panic if the resolver returns a nil context. After the error check
for ResolveAzureAuthContext, add an explicit nil check for authContext and
return a controlled error if it is nil, before proceeding to use
authContext.TenantID.

In `@pkg/store/sopsauth/gcp.go`:
- Around line 24-31: After calling b.resolver.ResolveGCPAuthContext(ctx,
identity), add a nil check for the returned authContext before attempting to
dereference its fields like authContext.AccessToken. The current code only
checks for errors but not for a nil context, which would cause a panic if the
resolver returns (nil, nil). Insert a nil guard after the error check and before
accessing authContext.AccessToken to return an appropriate error if authContext
is nil.

In `@tests/fixtures/scenarios/sops-kms-floci/atmos.yaml`:
- Line 42: The fixture file contains a Unix-specific path `/dev/stderr` in the
logs configuration on line 42. Remove the `file: /dev/stderr` line entirely to
use the default logging sink, or if logging to a file is required, replace it
with a fixture-relative file path that works cross-platform (such as a relative
path like `logs/output.log`) to ensure the scenario works on Windows, macOS, and
Linux.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff157d98-64f0-4bbb-97a8-b4a97004d21b

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9754b and f39a261.

📒 Files selected for processing (37)
  • cmd/secret/shared.go
  • cmd/secret/shared_loaders_test.go
  • docs/fixes/2026-06-20-sops-cloud-kms-identity.md
  • go.mod
  • internal/exec/terraform_execute_helpers.go
  • pkg/schema/schema.go
  • pkg/secrets/factory.go
  • pkg/secrets/providers/keygen.go
  • pkg/secrets/providers/provider.go
  • pkg/secrets/providers/registry_test.go
  • pkg/secrets/providers/sops/aws.go
  • pkg/secrets/providers/sops/azure.go
  • pkg/secrets/providers/sops/construct_test.go
  • pkg/secrets/providers/sops/errors.go
  • pkg/secrets/providers/sops/gcp.go
  • pkg/secrets/providers/sops/keyservice.go
  • pkg/secrets/providers/sops/keyservice_test.go
  • pkg/secrets/providers/sops/sops.go
  • pkg/secrets/providers/sops/sops_age_key_file_test.go
  • pkg/secrets/providers/sops/sops_age_key_store.go
  • pkg/secrets/providers/sops/sops_age_key_store_test.go
  • pkg/secrets/providers/sops/sops_coverage_test.go
  • pkg/secrets/providers/sops/sops_inline_key_test.go
  • pkg/secrets/providers/sops/sops_keygen.go
  • pkg/secrets/providers/sops/sops_keygen_coverage_test.go
  • pkg/secrets/providers/sops/sops_keygen_test.go
  • pkg/secrets/providers/sops/sops_test.go
  • pkg/secrets/providers/store_test.go
  • pkg/store/identity.go
  • pkg/store/sopsauth/aws.go
  • pkg/store/sopsauth/azure.go
  • pkg/store/sopsauth/builder.go
  • pkg/store/sopsauth/gcp.go
  • tests/fixtures/scenarios/sops-kms-floci/atmos.yaml
  • tests/fixtures/scenarios/sops-kms-floci/components/terraform/app/main.tf
  • tests/fixtures/scenarios/sops-kms-floci/stacks/dev.yaml
  • tests/sops_kms_floci_test.go
💤 Files with no reviewable changes (2)
  • pkg/secrets/providers/provider.go
  • pkg/secrets/providers/store_test.go

Comment thread pkg/store/sopsauth/aws.go Resolved
Comment thread pkg/store/sopsauth/azure.go Resolved
Comment thread pkg/store/sopsauth/gcp.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@website/docs/cli/configuration/secrets.mdx`:
- Line 215: In the secrets.mdx file, locate the sentence that states "The cloud
is inferred from the file's recipients at runtime" and replace the term
"recipients" with "master keys" or "master-key type" for precision. The
documentation should clarify that the cloud provider inference is based on the
SOPS file's master-key type (the KMS key ARNs and resource IDs in the metadata)
rather than the more generic term "recipients". This will align the
documentation with the actual implementation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f68574c4-16f0-41e8-a5e2-51521be5f5f2

📥 Commits

Reviewing files that changed from the base of the PR and between f39a261 and 065f55e.

📒 Files selected for processing (1)
  • website/docs/cli/configuration/secrets.mdx

…log path

Address CodeRabbit review on #2643. The sopsauth cloud builders dereferenced
the resolver result without a nil guard; the AuthContextResolver interface
contract permits a (nil, nil) return, so add fail-fast guards with wrapped
static sentinel errors in aws.go, gcp.go, and azure.go. Also drop the
hardcoded /dev/stderr logs.file from the Floci KMS fixture (Atmos already
defaults to that sink) for cross-platform portability.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ients

Address CodeRabbit review on #2643. Cloud-KMS inference is based on the SOPS
file's master-key type (KMS key ARNs/resource IDs in metadata), not the more
generic SOPS "recipients" term.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 20, 2026
@codecov

codecov Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.52482% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.04%. Comparing base (2c2e565) to head (248f818).

Files with missing lines Patch % Lines
pkg/secrets/providers/sops/aws.go 70.00% 9 Missing ⚠️
pkg/secrets/providers/sops/azure.go 59.09% 9 Missing ⚠️
pkg/secrets/providers/sops/gcp.go 55.00% 9 Missing ⚠️
pkg/secrets/providers/sops/sops.go 94.50% 3 Missing and 2 partials ⚠️
pkg/secrets/providers/sops/keyservice.go 95.00% 2 Missing ⚠️
pkg/store/sopsauth/aws.go 90.90% 1 Missing and 1 partial ⚠️
pkg/store/sopsauth/azure.go 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2643      +/-   ##
==========================================
+ Coverage   80.02%   80.04%   +0.02%     
==========================================
  Files        1353     1361       +8     
  Lines      127034   127262     +228     
==========================================
+ Hits       101653   101873     +220     
- Misses      19731    19733       +2     
- Partials     5650     5656       +6     
Flag Coverage Δ
unittests 80.04% <86.52%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/secret/shared.go 79.04% <100.00%> (+2.45%) ⬆️
internal/exec/terraform_execute_helpers.go 75.68% <100.00%> (+0.18%) ⬆️
pkg/schema/schema.go 87.70% <ø> (ø)
pkg/secrets/factory.go 83.33% <ø> (ø)
pkg/secrets/providers/sops/sops_age_key_store.go 87.71% <100.00%> (ø)
pkg/secrets/providers/sops/sops_keygen.go 85.58% <100.00%> (ø)
pkg/store/sopsauth/builder.go 100.00% <100.00%> (ø)
pkg/store/sopsauth/gcp.go 100.00% <100.00%> (ø)
pkg/secrets/providers/sops/keyservice.go 95.00% <95.00%> (ø)
pkg/store/sopsauth/aws.go 90.90% <90.90%> (ø)
... and 5 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The #2643 patch landed at 50% coverage; the new cloud-credential code was
largely untested. Add deterministic unit tests for the testable surface:

- pkg/store/sopsauth: full coverage of AWSKMS/GCPKMS/AzureKV (resolver error,
  nil-context guard, and offline success paths) plus awsAuthConfigOpts, via the
  existing store.MockAuthContextResolver — package 0% -> 95.9%.
- pkg/secrets/providers/sops: handler credential-resolution error branches for
  all three clouds, the pure keyservice->master-key converters, cloudKeyTypeName,
  duplicate-registration panic, and the Encrypt dispatch path.
- cmd/secret: secretsDefaultIdentity precedence (explicit vs select/disabled/empty
  -> authenticated chain tail) and the injectSecretStoreAuthResolver nil guard.

The cloud KMS success paths (mk.Decrypt/Encrypt make real network calls) remain
covered by the Floci E2E rather than fragile network-dependent unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/store/sopsauth/sopsauth_test.go (1)

20-176: 🏗️ Heavy lift

Prefer table-driven tests for the repeated resolver scenarios.

The subtests are solid, but this many repeated branches are easier to maintain and extend as table-driven cases (especially for AWS/GCP/Azure parity and new edge cases).

Refactor sketch
+type kmsCase struct {
+  name string
+  setup func(*store.MockAuthContextResolver)
+  assertErr func(*testing.T, error)
+}
+
+cases := []kmsCase{
+  {
+    name: "resolver error is wrapped",
+    setup: func(r *store.MockAuthContextResolver) {
+      r.EXPECT().ResolveAWSAuthContext(gomock.Any(), "id").Return(nil, errResolve)
+    },
+    assertErr: func(t *testing.T, err error) { require.ErrorIs(t, err, errResolve) },
+  },
+  // ...
+}
+for _, tc := range cases {
+  t.Run(tc.name, func(t *testing.T) {
+    // shared setup + assertions
+  })
+}

As per coding guidelines, **/*_test.go: “Use table-driven tests for testing multiple scenarios in Go.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/sopsauth/sopsauth_test.go` around lines 20 - 176, The test
functions TestAWSKMS, TestGCPKMS, and TestAzureKV contain repeated resolver test
scenarios that would be better organized as table-driven tests. Refactor these
functions by defining test cases as a slice of structs containing the scenario
name, mock setup expectations, and assertions, then iterate through them with a
single loop. This will reduce code duplication, make it easier to add new edge
cases, and improve maintainability across the different KMS provider
implementations. Keep the TestAWSAuthConfigOpts function as-is since it follows
a different testing pattern.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/secrets/providers/sops/handlers_test.go`:
- Around line 103-106: The test for deep-copying the encryption context
currently only verifies that mutating the source key.Context does not affect the
result mk.EncryptionContext. To complete the bidirectional isolation test per
coding guidelines, add a second assertion that mutates mk.EncryptionContext (for
example, setting a different key-value pair) and then verify that the original
key.Context remains unchanged, ensuring true deep-copy isolation in both
directions.

---

Nitpick comments:
In `@pkg/store/sopsauth/sopsauth_test.go`:
- Around line 20-176: The test functions TestAWSKMS, TestGCPKMS, and TestAzureKV
contain repeated resolver test scenarios that would be better organized as
table-driven tests. Refactor these functions by defining test cases as a slice
of structs containing the scenario name, mock setup expectations, and
assertions, then iterate through them with a single loop. This will reduce code
duplication, make it easier to add new edge cases, and improve maintainability
across the different KMS provider implementations. Keep the
TestAWSAuthConfigOpts function as-is since it follows a different testing
pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f066965-635b-47b0-a833-962410c29594

📥 Commits

Reviewing files that changed from the base of the PR and between 065f55e and cae491d.

📒 Files selected for processing (8)
  • cmd/secret/shared_identity_test.go
  • pkg/secrets/providers/sops/handlers_test.go
  • pkg/store/sopsauth/aws.go
  • pkg/store/sopsauth/azure.go
  • pkg/store/sopsauth/gcp.go
  • pkg/store/sopsauth/sopsauth_test.go
  • tests/fixtures/scenarios/sops-kms-floci/atmos.yaml
  • website/docs/cli/configuration/secrets.mdx
💤 Files with no reviewable changes (1)
  • tests/fixtures/scenarios/sops-kms-floci/atmos.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/store/sopsauth/azure.go
  • pkg/store/sopsauth/gcp.go
  • pkg/store/sopsauth/aws.go
  • website/docs/cli/configuration/secrets.mdx

… test

Address CodeRabbit review on #2643. Per the aliasing test contract, verify both
directions: mutating the converted master key's encryption-context value must not
affect the original source map (result -> src), in addition to the existing
src -> result check.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 20, 2026
The Check Markdown Links job failed with exit code 2 due to two timeouts
for https://no-color.org/, the canonical NO_COLOR standard site referenced
in two PRD docs. lychee counts timeouts as failures. The site is valid but
intermittently slow in CI, matching the existing flaky-host exclusion pattern
(gnu.org, tldp.org, kubernetes.io, etc.).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@aknysh
Andriy Knysh (aknysh) merged commit c78ba98 into main Jun 21, 2026
62 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/sops-aws-kms-identity branch June 21, 2026 20:11
@atmos-pro

atmos-pro Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Andriy Knysh (aknysh) added a commit that referenced this pull request Jun 21, 2026
Resolves conflicts from the SOPS refactor in #2643 (main), which moved
pkg/secrets/providers/sops.go into the new pkg/secrets/providers/sops
subpackage and added cloud-KMS auth via Atmos identity.

- pkg/secrets/providers/store_test.go: kept this branch's localFakeStore +
  TestStoreProvider_LocalStatusCheck (testing storeProvider.LocalStatusCheck);
  dropped TestNewSops_FromSection/TestNewSops_NotFound, which main moved to the
  sops subpackage (newSopsProvider no longer lives in package providers).
- pkg/secrets/providers/sops/sops_test.go: qualified this branch's added tests'
  references to LocalStatus and Coordinate with the providers package now that
  the file lives in package sops.

The auto-merged sops/sops.go retains both main's cloud-KMS auth (sopsauth,
keyservice, authResolver) and this branch's credential-free existence check
(keyExists/branchHasKey/LocalStatusCheck). go build ./..., go vet ./..., and the
full secret suite (pkg/secrets/..., pkg/store/..., cmd/secret/...) pass.
@github-actions

Copy link
Copy Markdown

These changes were released in v1.222.0-rc.6.

This branch was successfully deployed

1 active deployment
preview — 248f818b Deployed Jun 21, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atmos secret with a SOPS aws-kms backend ignores atmos identity and requires ambient AWS credentials

2 participants