Skip to content

Commit e9c123c

Browse files
committed
Add some debugging output
1 parent f77f3a3 commit e9c123c

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

main.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func main() {
2929
if err := run(context.Background(), stackName, flag.Args()); err != nil {
3030
var ae smithy.APIError
3131
if errors.As(err, &ae) && ae.ErrorCode() == "ValidationError" && ae.ErrorMessage() == "No updates are to be performed." {
32+
debugf("error: %v", err)
3233
log.Print(githubWarnPrefix, "nothing to update")
3334
return
3435
}
@@ -50,6 +51,7 @@ func run(ctx context.Context, stackName string, args []string) error {
5051
if len(toReplace) == 0 {
5152
return errors.New("empty parameters list")
5253
}
54+
debugf("loaded parameters: %v", toReplace)
5355
cfg, err := config.LoadDefaultConfig(ctx)
5456
if err != nil {
5557
return err
@@ -78,6 +80,16 @@ func run(ctx context.Context, stackName string, args []string) error {
7880
return fmt.Errorf("stack has no parameters with these names: %s", strings.Join(slices.Sorted(maps.Keys(toReplace)), ", "))
7981
}
8082

83+
debugf("parameters to call UpdateStack with:")
84+
for _, p := range params {
85+
switch {
86+
case aws.ToBool(p.UsePreviousValue):
87+
debugf("%s (use the previous value)", aws.ToString(p.ParameterKey))
88+
default:
89+
debugf("%s: %s", aws.ToString(p.ParameterKey), aws.ToString(p.ParameterValue))
90+
}
91+
}
92+
8193
token := newToken()
8294
_, err = svc.UpdateStack(ctx, &cloudformation.UpdateStackInput{
8395
StackName: &stackName,
@@ -91,12 +103,6 @@ func run(ctx context.Context, stackName string, args []string) error {
91103
return err
92104
}
93105
log.Print("polling for stack updates until it's ready, this may take a while")
94-
debugf := func(format string, args ...any) {
95-
if !underGithub {
96-
return
97-
}
98-
log.Printf("::debug::"+format, args...)
99-
}
100106
oldEventsCutoff := time.Now().Add(-time.Hour)
101107
ticker := time.NewTicker(20 * time.Second)
102108
defer ticker.Stop()
@@ -143,6 +149,13 @@ func newToken() string {
143149
return "ucs-" + hex.EncodeToString(b)
144150
}
145151

152+
func debugf(format string, args ...any) {
153+
if !underGithub {
154+
return
155+
}
156+
log.Printf("::debug::"+format, args...)
157+
}
158+
146159
func init() {
147160
const usage = `Updates CloudFormation stack by updating some of its parameters while preserving all other settings.
148161

0 commit comments

Comments
 (0)