Skip to content

Commit d0ec5f9

Browse files
authored
Merge branch 'main' into error-handling-infra
2 parents dd0c527 + c7fa891 commit d0ec5f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4153
-230
lines changed

.github/workflows/changelog-check.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ jobs:
4444
GH_TOKEN: ${{ github.token }}
4545
run: |
4646
PR_NUMBER="${{ github.event.pull_request.number }}"
47+
BASE_REF="${{ github.event.pull_request.base.sha }}"
48+
HEAD_REF="${{ github.event.pull_request.head.sha }}"
4749
48-
# Get all files added in this PR (not just the latest commit)
49-
NEW_BLOG_FILES=$(gh pr diff $PR_NUMBER --name-only | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true)
50+
# Use git diff directly instead of gh pr diff to avoid API limitations
51+
# GitHub's diff API has a limit of ~300 files or ~3000 lines, which fails on large PRs
52+
# git diff works locally without these limitations
53+
echo "Checking for blog post files between $BASE_REF and $HEAD_REF"
54+
NEW_BLOG_FILES=$(git diff --name-only "$BASE_REF" "$HEAD_REF" | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true)
5055
5156
if [ -z "$NEW_BLOG_FILES" ]; then
5257
echo "has_changelog=false" >> $GITHUB_OUTPUT
@@ -93,9 +98,11 @@ jobs:
9398
GH_TOKEN: ${{ github.token }}
9499
run: |
95100
PR_NUMBER="${{ github.event.pull_request.number }}"
101+
BASE_REF="${{ github.event.pull_request.base.sha }}"
102+
HEAD_REF="${{ github.event.pull_request.head.sha }}"
96103
97-
# Get list of blog files added
98-
BLOG_FILES=$(gh pr diff $PR_NUMBER --name-only | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true)
104+
# Get list of blog files added (using git diff to avoid API limitations)
105+
BLOG_FILES=$(git diff --name-only "$BASE_REF" "$HEAD_REF" | grep -E '^website/blog/.*\.(md|mdx)$' | grep -v 'tags.yml' || true)
99106
100107
# Find existing comment (warning or success)
101108
EXISTING_COMMENT=$(gh pr view $PR_NUMBER --json comments --jq '.comments[] | select(.body | contains("<!-- changelog-check -->")) | .id' | head -1)

NOTICE

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ APACHE 2.0 LICENSED DEPENDENCIES
107107

108108
- github.com/aws/aws-sdk-go-v2/config
109109
License: Apache-2.0
110-
URL: https://github.com/aws/aws-sdk-go-v2/blob/config/v1.31.17/config/LICENSE.txt
110+
URL: https://github.com/aws/aws-sdk-go-v2/blob/config/v1.31.18/config/LICENSE.txt
111111

112112
- github.com/aws/aws-sdk-go-v2/credentials
113113
License: Apache-2.0
114-
URL: https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.18.21/credentials/LICENSE.txt
114+
URL: https://github.com/aws/aws-sdk-go-v2/blob/credentials/v1.18.22/credentials/LICENSE.txt
115115

116116
- github.com/aws/aws-sdk-go-v2/feature/ec2/imds
117117
License: Apache-2.0
118118
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/ec2/imds/v1.18.13/feature/ec2/imds/LICENSE.txt
119119

120120
- github.com/aws/aws-sdk-go-v2/feature/s3/manager
121121
License: Apache-2.0
122-
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/s3/manager/v1.20.4/feature/s3/manager/LICENSE.txt
122+
URL: https://github.com/aws/aws-sdk-go-v2/blob/feature/s3/manager/v1.20.5/feature/s3/manager/LICENSE.txt
123123

124124
- github.com/aws/aws-sdk-go-v2/internal/configsources
125125
License: Apache-2.0
@@ -163,7 +163,7 @@ APACHE 2.0 LICENSED DEPENDENCIES
163163

164164
- github.com/aws/aws-sdk-go-v2/service/ssm
165165
License: Apache-2.0
166-
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssm/v1.66.4/service/ssm/LICENSE.txt
166+
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ssm/v1.67.0/service/ssm/LICENSE.txt
167167

168168
- github.com/aws/aws-sdk-go-v2/service/sso
169169
License: Apache-2.0
@@ -175,7 +175,7 @@ APACHE 2.0 LICENSED DEPENDENCIES
175175

176176
- github.com/aws/aws-sdk-go-v2/service/sts
177177
License: Apache-2.0
178-
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.39.1/service/sts/LICENSE.txt
178+
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/sts/v1.40.0/service/sts/LICENSE.txt
179179

180180
- github.com/aws/smithy-go
181181
License: Apache-2.0
@@ -748,7 +748,7 @@ BSD LICENSED DEPENDENCIES
748748

749749
- golang.org/x/oauth2
750750
License: BSD-3-Clause
751-
URL: https://cs.opensource.google/go/x/oauth2/+/v0.32.0:LICENSE
751+
URL: https://cs.opensource.google/go/x/oauth2/+/v0.33.0:LICENSE
752752

753753
- golang.org/x/sync
754754
License: BSD-3-Clause
@@ -954,7 +954,7 @@ MIT LICENSED DEPENDENCIES
954954

955955
- github.com/Azure/azure-sdk-for-go/sdk/azidentity
956956
License: MIT
957-
URL: https://github.com/Azure/azure-sdk-for-go/blob/sdk/azidentity/v1.13.0/sdk/azidentity/LICENSE.txt
957+
URL: https://github.com/Azure/azure-sdk-for-go/blob/sdk/azidentity/v1.13.1/sdk/azidentity/LICENSE.txt
958958

959959
- github.com/Azure/azure-sdk-for-go/sdk/internal
960960
License: MIT
@@ -978,7 +978,7 @@ MIT LICENSED DEPENDENCIES
978978

979979
- github.com/AzureAD/microsoft-authentication-library-for-go/apps
980980
License: MIT
981-
URL: https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v1.5.0/LICENSE
981+
URL: https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v1.6.0/LICENSE
982982

983983
- github.com/BurntSushi/toml
984984
License: MIT

cmd/describe.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ func init() {
2020
// when processing YAML template functions (!terraform.state, !terraform.output).
2121
// By default, all describe commands execute YAML functions and Go templates unless
2222
// disabled with --process-functions=false or --process-templates=false flags.
23-
describeCmd.PersistentFlags().StringP("identity", "i", "", "Specify the identity to authenticate to before describing. Use without value to interactively select.")
24-
25-
// Set NoOptDefVal to enable optional flag value for interactive identity selection.
26-
// When --identity is used without a value, it will receive IdentityFlagSelectValue.
27-
if identityFlag := describeCmd.PersistentFlags().Lookup("identity"); identityFlag != nil {
28-
identityFlag.NoOptDefVal = IdentityFlagSelectValue
29-
}
23+
//
24+
// NOTE: NoOptDefVal is NOT used here to avoid Cobra parsing issues with commands
25+
// that have positional arguments. When NoOptDefVal is set and a space-separated value
26+
// is used (--identity value), Cobra misinterprets the value as a subcommand/positional arg.
27+
// Users should use --identity=select or similar for interactive selection.
28+
describeCmd.PersistentFlags().StringP("identity", "i", "", "Specify the identity to authenticate with before describing")
3029

3130
// Register shell completion for identity flag.
3231
AddIdentityCompletion(describeCmd)

cmd/identity_flag.go

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
package cmd
22

33
import (
4-
"context"
5-
"errors"
6-
"fmt"
74
"strings"
85

96
"github.com/spf13/cobra"
107
"github.com/spf13/viper"
118

12-
errUtils "github.com/cloudposse/atmos/errors"
139
"github.com/cloudposse/atmos/pkg/auth"
14-
"github.com/cloudposse/atmos/pkg/auth/credentials"
15-
"github.com/cloudposse/atmos/pkg/auth/validation"
1610
cfg "github.com/cloudposse/atmos/pkg/config"
1711
"github.com/cloudposse/atmos/pkg/schema"
1812
)
@@ -133,45 +127,12 @@ func extractIdentityFromArgs(args []string) string {
133127
// Returns nil if identityName is empty (no authentication requested).
134128
// Returns error if identityName is provided but auth is not configured in atmos.yaml.
135129
// This helper reduces nested complexity in describe commands.
130+
//
131+
// This function delegates to auth.CreateAndAuthenticateManager to ensure consistent
132+
// authentication behavior across CLI commands and internal execution logic.
136133
func CreateAuthManagerFromIdentity(
137134
identityName string,
138135
authConfig *schema.AuthConfig,
139136
) (auth.AuthManager, error) {
140-
if identityName == "" {
141-
return nil, nil
142-
}
143-
144-
// Check if auth is configured when --identity flag is provided.
145-
if authConfig == nil || len(authConfig.Identities) == 0 {
146-
return nil, fmt.Errorf("%w: the --identity flag requires authentication to be configured in atmos.yaml with at least one identity", errUtils.ErrAuthNotConfigured)
147-
}
148-
149-
// Create a ConfigAndStacksInfo for the auth manager to populate with AuthContext.
150-
authStackInfo := &schema.ConfigAndStacksInfo{
151-
AuthContext: &schema.AuthContext{},
152-
}
153-
154-
credStore := credentials.NewCredentialStore()
155-
validator := validation.NewValidator()
156-
authManager, err := auth.NewAuthManager(authConfig, credStore, validator, authStackInfo)
157-
if err != nil {
158-
return nil, errors.Join(errUtils.ErrFailedToInitializeAuthManager, err)
159-
}
160-
161-
// Handle interactive selection.
162-
forceSelect := identityName == IdentityFlagSelectValue
163-
if forceSelect {
164-
identityName, err = authManager.GetDefaultIdentity(forceSelect)
165-
if err != nil {
166-
return nil, err
167-
}
168-
}
169-
170-
// Authenticate.
171-
_, err = authManager.Authenticate(context.Background(), identityName)
172-
if err != nil {
173-
return nil, err
174-
}
175-
176-
return authManager, nil
137+
return auth.CreateAndAuthenticateManager(identityName, authConfig, IdentityFlagSelectValue)
177138
}

cmd/root.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ var RootCmd = &cobra.Command{
302302
},
303303
}
304304

305-
// setupLogger configures the global logger based on the provided Atmos configuration.
306-
func setupLogger(atmosConfig *schema.AtmosConfiguration) {
305+
// SetupLogger configures the global logger based on the provided Atmos configuration.
306+
//
307+
//nolint:revive,cyclop // Function complexity is acceptable for logger configuration.
308+
func SetupLogger(atmosConfig *schema.AtmosConfiguration) {
307309
switch atmosConfig.Logs.Level {
308310
case "Trace":
309311
log.SetLevel(log.TraceLevel)
@@ -593,7 +595,7 @@ func Execute() error {
593595
}
594596

595597
// Set the log level for the charmbracelet/log package based on the atmosConfig.
596-
setupLogger(&atmosConfig)
598+
SetupLogger(&atmosConfig)
597599

598600
var err error
599601
// If CLI configuration was found, process its custom commands and command aliases.

cmd/root_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestSetupLogger_TraceLevel(t *testing.T) {
162162
},
163163
}
164164

165-
setupLogger(cfg)
165+
SetupLogger(cfg)
166166
assert.Equal(t, tt.expectedLevel, log.GetLevel(),
167167
"Expected level %v for config %q", tt.expectedLevel, tt.configLevel)
168168
})
@@ -228,7 +228,7 @@ func TestSetupLogger_TraceVisibility(t *testing.T) {
228228
Terminal: schema.Terminal{},
229229
},
230230
}
231-
setupLogger(cfg)
231+
SetupLogger(cfg)
232232

233233
// Test trace visibility.
234234
buf.Reset()
@@ -281,7 +281,7 @@ func TestSetupLogger_TraceLevelFromEnvironment(t *testing.T) {
281281
Terminal: schema.Terminal{},
282282
},
283283
}
284-
setupLogger(cfg)
284+
SetupLogger(cfg)
285285

286286
assert.Equal(t, log.TraceLevel, log.GetLevel(),
287287
"Should set trace level from environment variable")
@@ -309,10 +309,10 @@ func TestSetupLogger_NoColorWithTraceLevel(t *testing.T) {
309309
}
310310

311311
// Mock the IsColorEnabled to return false.
312-
// Since we can't easily mock it, we'll just test that setupLogger doesn't panic.
312+
// Since we can't easily mock it, we'll just test that SetupLogger doesn't panic.
313313
assert.NotPanics(t, func() {
314-
setupLogger(cfg)
315-
}, "setupLogger should not panic with trace level and no color")
314+
SetupLogger(cfg)
315+
}, "SetupLogger should not panic with trace level and no color")
316316

317317
assert.Equal(t, log.TraceLevel, log.GetLevel(),
318318
"Trace level should be set even with no color")

0 commit comments

Comments
 (0)