Skip to content

Commit 4533660

Browse files
Merge pull request #34 from towardsthecloud/codex/rename-cfn-to-cloudformation-in-cli
feat: rename cfn CLI group to cloudformation
2 parents 0ae438a + 7f3daaf commit 4533660

9 files changed

Lines changed: 49 additions & 46 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
with:
1919
go-version-file: go.mod
2020

21-
- name: Install tooling
22-
run: make setup
21+
- name: Install lint tooling
22+
run: make setup-lint
2323

2424
- name: Run lint target
2525
run: make lint

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LDFLAGS := -X github.com/towardsthecloud/aws-toolbox/internal/version.Version=$(
1717
LDFLAGS += -X github.com/towardsthecloud/aws-toolbox/internal/version.Commit=$(COMMIT)
1818
LDFLAGS += -X github.com/towardsthecloud/aws-toolbox/internal/version.Date=$(DATE)
1919

20-
.PHONY: help setup fmt lint test test-integration coverage build docs changelog changelog-current release-check release-snapshot tag
20+
.PHONY: help setup setup-lint fmt lint test test-integration coverage build docs changelog changelog-current release-check release-snapshot tag
2121

2222
help: ## List available targets
2323
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-18s %s\n", $$1, $$2}'
@@ -51,6 +51,9 @@ setup: ## Install local development tooling
5151
rm -rf "$$tmpdir"; \
5252
fi
5353

54+
setup-lint: ## Install tooling required for linting only
55+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
56+
5457
fmt: ## Format Go code
5558
go fmt ./...
5659

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ awstbx cloudwatch count-log-groups --output json
102102
`awstbx` currently includes:
103103

104104
- `appstream`
105-
- `cfn`
105+
- `cloudformation`
106106
- `cloudwatch`
107107
- `ec2`
108108
- `ecs`

docs/migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Total: 58 legacy items.
1313
| Legacy item | `awstbx` replacement | Notes |
1414
| --- | --- | --- |
1515
| `archived/appstream/appstream_delete_image.py` | `awstbx appstream delete-image` | Direct port |
16-
| `archived/cloudformation/cfn_delete_stackset.py` | `awstbx cfn delete-stackset` | Direct port |
17-
| `archived/cloudformation/cfn_find_stack_by_resource.py` | `awstbx cfn find-stack-by-resource` | Direct port |
16+
| `archived/cloudformation/cfn_delete_stackset.py` | `awstbx cloudformation delete-stackset` | Direct port |
17+
| `archived/cloudformation/cfn_find_stack_by_resource.py` | `awstbx cloudformation find-stack-by-resource` | Direct port |
1818
| `archived/cloudwatch/cw_count_log_groups.py` | `awstbx cloudwatch count-log-groups` | Direct port |
1919
| `archived/cloudwatch/cw_delete_log_groups.py` | `awstbx cloudwatch delete-log-groups` | Merged command |
2020
| `archived/cloudwatch/cw_delete_log_groups_by_name.py` | `awstbx cloudwatch delete-log-groups --filter-name-contains <text>` | Merged command |

internal/cli/coverage_boost_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestCoverageBoostRootExecutionBranches(t *testing.T) {
9292
func TestCoverageBoostLegacyFlagsRejected(t *testing.T) {
9393
cases := [][]string{
9494
{"appstream", "delete-image", "--name", "img-a"},
95-
{"cfn", "delete-stackset", "--name", "stackset-a"},
95+
{"cloudformation", "delete-stackset", "--name", "stackset-a"},
9696
{"cloudwatch", "delete-log-groups", "--keep", "30d"},
9797
{"ec2", "delete-security-groups", "--tag", "env=dev"},
9898
{"kms", "delete-keys", "--tag", "env=dev"},

internal/cli/help_defaults.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ awstbx appstream delete-image --image-name image-name --no-confirm`),
2424
"awstbx appstream delete-image": strings.TrimSpace(`
2525
awstbx appstream delete-image --image-name image-name --dry-run
2626
awstbx appstream delete-image --image-name image-name --no-confirm`),
27-
"awstbx cfn": strings.TrimSpace(`
28-
awstbx cfn delete-stackset --stackset-name my-stackset --dry-run
29-
awstbx cfn find-stack-by-resource --resource i-0123456789abcdef0`),
30-
"awstbx cfn delete-stackset": strings.TrimSpace(`
31-
awstbx cfn delete-stackset --stackset-name my-stackset --dry-run
32-
awstbx cfn delete-stackset --stackset-name my-stackset --no-confirm`),
33-
"awstbx cfn find-stack-by-resource": strings.TrimSpace(`
34-
awstbx cfn find-stack-by-resource --resource i-0123456789abcdef0
35-
awstbx cfn find-stack-by-resource --resource AWS::S3::Bucket --include-nested`),
27+
"awstbx cloudformation": strings.TrimSpace(`
28+
awstbx cloudformation delete-stackset --stackset-name my-stackset --dry-run
29+
awstbx cloudformation find-stack-by-resource --resource i-0123456789abcdef0`),
30+
"awstbx cloudformation delete-stackset": strings.TrimSpace(`
31+
awstbx cloudformation delete-stackset --stackset-name my-stackset --dry-run
32+
awstbx cloudformation delete-stackset --stackset-name my-stackset --no-confirm`),
33+
"awstbx cloudformation find-stack-by-resource": strings.TrimSpace(`
34+
awstbx cloudformation find-stack-by-resource --resource i-0123456789abcdef0
35+
awstbx cloudformation find-stack-by-resource --resource AWS::S3::Bucket --include-nested`),
3636
"awstbx cloudwatch": strings.TrimSpace(`
3737
awstbx cloudwatch count-log-groups
3838
awstbx cloudwatch delete-log-groups --retention-days 30 --filter-name-contains /aws/lambda --dry-run`),

internal/cli/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77
"github.com/towardsthecloud/aws-toolbox/internal/cliutil"
88
"github.com/towardsthecloud/aws-toolbox/internal/service/appstream"
9-
"github.com/towardsthecloud/aws-toolbox/internal/service/cfn"
9+
"github.com/towardsthecloud/aws-toolbox/internal/service/cloudformation"
1010
"github.com/towardsthecloud/aws-toolbox/internal/service/cloudwatch"
1111
"github.com/towardsthecloud/aws-toolbox/internal/service/ec2"
1212
"github.com/towardsthecloud/aws-toolbox/internal/service/ecs"
@@ -61,7 +61,7 @@ func NewRootCommand() *cobra.Command {
6161
rootCmd.AddCommand(newVersionCommand())
6262

6363
rootCmd.AddCommand(appstream.NewCommand())
64-
rootCmd.AddCommand(cfn.NewCommand())
64+
rootCmd.AddCommand(cloudformation.NewCommand())
6565
rootCmd.AddCommand(cloudwatch.NewCommand())
6666
rootCmd.AddCommand(ec2.NewCommand())
6767
rootCmd.AddCommand(ecs.NewCommand())

internal/service/cfn/cfn.go renamed to internal/service/cloudformation/cloudformation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cfn
1+
package cloudformation
22

33
import (
44
"context"
@@ -36,7 +36,7 @@ var newClient = func(cfg awssdk.Config) API {
3636
var sleep = time.Sleep
3737

3838
func NewCommand() *cobra.Command {
39-
cmd := cliutil.NewServiceGroupCommand("cfn", "Manage CloudFormation resources")
39+
cmd := cliutil.NewServiceGroupCommand("cloudformation", "Manage CloudFormation resources")
4040

4141
cmd.AddCommand(newDeleteStackSetCommand())
4242
cmd.AddCommand(newFindStackByResourceCommand())

internal/service/cfn/cfn_test.go renamed to internal/service/cloudformation/cloudformation_test.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cfn
1+
package cloudformation
22

33
import (
44
"bytes"
@@ -97,7 +97,7 @@ func executeCommand(t *testing.T, args ...string) (string, error) {
9797
}
9898

9999
func TestDeleteStackSetRequiresName(t *testing.T) {
100-
_, err := executeCommand(t, "cfn", "delete-stackset")
100+
_, err := executeCommand(t, "cloudformation", "delete-stackset")
101101
if err == nil || !strings.Contains(err.Error(), "--stackset-name is required") {
102102
t.Fatalf("expected required name error, got %v", err)
103103
}
@@ -136,9 +136,9 @@ func TestDeleteStackSetDryRun(t *testing.T) {
136136
func(awssdk.Config) API { return client },
137137
)
138138

139-
output, err := executeCommand(t, "--output", "json", "--dry-run", "cfn", "delete-stackset", "--stackset-name", "stackset-a")
139+
output, err := executeCommand(t, "--output", "json", "--dry-run", "cloudformation", "delete-stackset", "--stackset-name", "stackset-a")
140140
if err != nil {
141-
t.Fatalf("execute cfn delete-stackset dry-run: %v", err)
141+
t.Fatalf("execute cloudformation delete-stackset dry-run: %v", err)
142142
}
143143
if deleteInstancesCalls != 0 || deleteStackSetCalls != 0 {
144144
t.Fatalf("expected no delete calls in dry-run, got instances=%d stackset=%d", deleteInstancesCalls, deleteStackSetCalls)
@@ -183,9 +183,9 @@ func TestDeleteStackSetNoConfirmExecutes(t *testing.T) {
183183
func(awssdk.Config) API { return client },
184184
)
185185

186-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "stackset-a")
186+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "stackset-a")
187187
if err != nil {
188-
t.Fatalf("execute cfn delete-stackset --no-confirm: %v", err)
188+
t.Fatalf("execute cloudformation delete-stackset --no-confirm: %v", err)
189189
}
190190
if deleteInstancesCalls != 1 || describeOperationCalls != 1 || deleteStackSetCalls != 1 {
191191
t.Fatalf("unexpected API call counts instances=%d describe=%d stackset=%d", deleteInstancesCalls, describeOperationCalls, deleteStackSetCalls)
@@ -231,9 +231,9 @@ func TestDeleteStackSetWaitsBeyondLegacyTimeout(t *testing.T) {
231231
func(awssdk.Config) API { return client },
232232
)
233233

234-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "stackset-a")
234+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "stackset-a")
235235
if err != nil {
236-
t.Fatalf("execute cfn delete-stackset with long-running operation: %v", err)
236+
t.Fatalf("execute cloudformation delete-stackset with long-running operation: %v", err)
237237
}
238238
if describeOperationCalls != 200 {
239239
t.Fatalf("expected operation polling to continue until success, got %d calls", describeOperationCalls)
@@ -244,7 +244,7 @@ func TestDeleteStackSetWaitsBeyondLegacyTimeout(t *testing.T) {
244244
}
245245

246246
func TestFindStackByResourceRequiresResource(t *testing.T) {
247-
_, err := executeCommand(t, "cfn", "find-stack-by-resource")
247+
_, err := executeCommand(t, "cloudformation", "find-stack-by-resource")
248248
if err == nil || !strings.Contains(err.Error(), "--resource is required") {
249249
t.Fatalf("expected required resource error, got %v", err)
250250
}
@@ -284,9 +284,9 @@ func TestFindStackByResourceMatchesNestedWhenRequested(t *testing.T) {
284284
func(awssdk.Config) API { return client },
285285
)
286286

287-
output, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "AWS::S3::Bucket", "--exact", "--include-nested")
287+
output, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "AWS::S3::Bucket", "--exact", "--include-nested")
288288
if err != nil {
289-
t.Fatalf("execute cfn find-stack-by-resource: %v", err)
289+
t.Fatalf("execute cloudformation find-stack-by-resource: %v", err)
290290
}
291291
if !strings.Contains(output, "parent-stack") || !strings.Contains(output, "nested-stack") {
292292
t.Fatalf("expected both parent and nested matches, output=%s", output)
@@ -319,7 +319,7 @@ func TestDeleteStackSetUserDeclines(t *testing.T) {
319319
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
320320

321321
// Without --no-confirm, stdin is empty so the prompter reads EOF and returns false (declined).
322-
output, err := executeCommand(t, "--output", "json", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
322+
output, err := executeCommand(t, "--output", "json", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
323323
if err != nil {
324324
t.Fatalf("expected no error when user declines, got %v", err)
325325
}
@@ -339,7 +339,7 @@ func TestDeleteStackSetListInstancesError(t *testing.T) {
339339

340340
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
341341

342-
_, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
342+
_, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
343343
if err == nil || !strings.Contains(err.Error(), "list stack set instances") {
344344
t.Fatalf("expected list instances error, got %v", err)
345345
}
@@ -363,7 +363,7 @@ func TestDeleteStackSetInstanceDeletionError(t *testing.T) {
363363

364364
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
365365

366-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
366+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
367367
if err != nil {
368368
t.Fatalf("command should not return error, got %v", err)
369369
}
@@ -401,7 +401,7 @@ func TestDeleteStackSetWaitOperationFailure(t *testing.T) {
401401

402402
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
403403

404-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
404+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
405405
if err != nil {
406406
t.Fatalf("command should not return error, got %v", err)
407407
}
@@ -441,7 +441,7 @@ func TestDeleteStackSetDeleteStackSetError(t *testing.T) {
441441

442442
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
443443

444-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
444+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
445445
if err != nil {
446446
t.Fatalf("command should not return error, got %v", err)
447447
}
@@ -469,7 +469,7 @@ func TestDeleteStackSetNoInstances(t *testing.T) {
469469

470470
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
471471

472-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "empty-stackset")
472+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "empty-stackset")
473473
if err != nil {
474474
t.Fatalf("unexpected error: %v", err)
475475
}
@@ -492,7 +492,7 @@ func TestDeleteStackSetDryRunNoInstances(t *testing.T) {
492492

493493
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
494494

495-
output, err := executeCommand(t, "--output", "json", "--dry-run", "cfn", "delete-stackset", "--stackset-name", "empty-stackset")
495+
output, err := executeCommand(t, "--output", "json", "--dry-run", "cloudformation", "delete-stackset", "--stackset-name", "empty-stackset")
496496
if err != nil {
497497
t.Fatalf("unexpected error: %v", err)
498498
}
@@ -530,7 +530,7 @@ func TestDeleteStackSetEmptyOperationID(t *testing.T) {
530530

531531
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
532532

533-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
533+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
534534
if err != nil {
535535
t.Fatalf("unexpected error: %v", err)
536536
}
@@ -1065,7 +1065,7 @@ func TestFindStackByResourceSubstringMatch(t *testing.T) {
10651065

10661066
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
10671067

1068-
output, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "bucket")
1068+
output, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "bucket")
10691069
if err != nil {
10701070
t.Fatalf("unexpected error: %v", err)
10711071
}
@@ -1103,7 +1103,7 @@ func TestFindStackByResourceNoMatches(t *testing.T) {
11031103

11041104
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
11051105

1106-
output, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "nonexistent-thing")
1106+
output, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "nonexistent-thing")
11071107
if err != nil {
11081108
t.Fatalf("unexpected error: %v", err)
11091109
}
@@ -1122,7 +1122,7 @@ func TestFindStackByResourceListStacksError(t *testing.T) {
11221122

11231123
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
11241124

1125-
_, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "something")
1125+
_, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "something")
11261126
if err == nil || !strings.Contains(err.Error(), "list stacks") {
11271127
t.Fatalf("expected list stacks error, got %v", err)
11281128
}
@@ -1144,7 +1144,7 @@ func TestFindStackByResourceListResourcesError(t *testing.T) {
11441144

11451145
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
11461146

1147-
_, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "something")
1147+
_, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "something")
11481148
if err == nil || !strings.Contains(err.Error(), "list resources for stack") {
11491149
t.Fatalf("expected list resources error, got %v", err)
11501150
}
@@ -1176,7 +1176,7 @@ func TestFindStackByResourceExcludesNestedByDefault(t *testing.T) {
11761176

11771177
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
11781178

1179-
output, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "Bucket")
1179+
output, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "Bucket")
11801180
if err != nil {
11811181
t.Fatalf("unexpected error: %v", err)
11821182
}
@@ -1213,7 +1213,7 @@ func TestFindStackByResourceMatchesPhysicalID(t *testing.T) {
12131213

12141214
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
12151215

1216-
output, err := executeCommand(t, "--output", "json", "cfn", "find-stack-by-resource", "--resource", "prod-users-table", "--exact")
1216+
output, err := executeCommand(t, "--output", "json", "cloudformation", "find-stack-by-resource", "--resource", "prod-users-table", "--exact")
12171217
if err != nil {
12181218
t.Fatalf("unexpected error: %v", err)
12191219
}
@@ -1252,7 +1252,7 @@ func TestDeleteStackSetMultipleInstancesPartialFailure(t *testing.T) {
12521252

12531253
withMockDeps(t, defaultMockLoader(), defaultMockClientFactory(client))
12541254

1255-
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cfn", "delete-stackset", "--stackset-name", "my-stackset")
1255+
output, err := executeCommand(t, "--output", "json", "--no-confirm", "cloudformation", "delete-stackset", "--stackset-name", "my-stackset")
12561256
if err != nil {
12571257
t.Fatalf("command should not return error, got %v", err)
12581258
}

0 commit comments

Comments
 (0)