Skip to content

refactor(aws): split client.go into domain files (#322 #323 #324) - #336

Merged
scttfrdmn merged 1 commit into
mainfrom
audit/phase3-split-client
Jul 11, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
audit/phase3-split-client

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #322, #323, #324. Part of the audit tracker #328 (Phase 3). Pure internal reorganization — zero behavior change, public API unchanged.

What moved

pkg/aws/client.go was 2379 LOC / 60 funcs. Every method hangs off the single-field type Client struct { cfg aws.Config }, so moving methods between same-package files is 100% mechanical.

New/target file Contents
tags.go (new) buildTags, managedResourceTags, propagatableSnapshotTags, intToBase36, slugifyDNSLabel
securitygroup.go (new) CreateOrGet{MPI,Windows,DCV}SecurityGroup, EnsureLustrePorts, GetDefaultVPC, sgHasUDP8443
ebs.go (new) buildBlockDevices, AttachDeviceName, estimateVolumeSize, rootVolumeSizeFrom{AMI,Mappings}
iam.go (existing) moved SetupSporedIAMRole, waitForInstanceProfile, sporedDCVRolePolicy const
client.go remainder: construction + Launch + instance lifecycle (→ ~1340 LOC)

Bundled cleanups

Verification

  • Function inventory conserved: client.go had 60 funcs → 58 now live across client/tags/sg/ebs, and iam.go went 18 → 20 (the 2 moved). Nothing dropped.
  • go build ./..., go vet ./pkg/aws, gofmt -l clean.
  • Full go test ./pkg/aws green, including TestBuildInlinePolicy (the hardcoded spored-statement-count assertion — unchanged, this PR doesn't touch the policy).
  • Rebuilt bin/spawn and diffed the full recursive command+flag tree against main → byte-identical (a pkg-internal split must be invisible to the CLI).
  • Pre-existing unrelated TestCatalogValid (feat(plugin): permissions declaration block (#388) #392) still fails on main.

Pure same-package reorganization of the 2379-LOC pkg/aws/client.go, no
behavior change. All methods hang off the single-field *Client, so moves
are mechanical.

- tags.go (NEW): buildTags + managedResourceTags + propagatableSnapshotTags
  + intToBase36/slugifyDNSLabel helpers. #324: added section comments to
  buildTags (base/naming/lifecycle/notify/storage/jobarray/custom).
- securitygroup.go (NEW): CreateOrGet{MPI,Windows,DCV}SecurityGroup,
  EnsureLustrePorts, GetDefaultVPC, sgHasUDP8443.
- ebs.go (NEW): buildBlockDevices, AttachDeviceName, estimateVolumeSize,
  rootVolumeSizeFrom{AMI,Mappings}.
- iam.go (existing): moved SetupSporedIAMRole + waitForInstanceProfile +
  sporedDCVRolePolicy const here. #323: extracted the inline assume-role
  trust policy to a named sporedTrustPolicy const.
- client.go: now construction + Launch + instance lifecycle (2379→~1340).

Verified: func inventory conserved (60 → 58 in client-family + 2 into iam);
go build ./..., go vet, gofmt clean; full pkg/aws test suite green incl.
TestBuildInlinePolicy (the statement-count gotcha); rebuilt bin/spawn and
diffed the full command+flag tree against main — byte-identical.
Part of the 2026-07-11 audit (#328, Phase 3).
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.55738% with 501 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/securitygroup.go 2.92% 299 Missing ⚠️
pkg/aws/tags.go 56.14% 74 Missing and 26 partials ⚠️
pkg/aws/iam.go 0.00% 90 Missing ⚠️
pkg/aws/ebs.go 88.67% 12 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 664268d into main Jul 11, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the audit/phase3-split-client branch July 11, 2026 20:25
scttfrdmn added a commit that referenced this pull request Jul 15, 2026
Finish the pkg/aws god-package split begun in #336. GetEFSDNSName moves to
efs.go; LookupEC2OnDemandPrice and its regionToLocationName map move to
pricing.go (the map is only used by that function). Same-package move — all
callers and the exported API are unchanged. client.go drops from 1350 to 1251
LOC of cohesive client/launch/lifecycle code.

Closes #325.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[audit] Refactor: pkg/aws/client.go (2379 LOC / 60 funcs) is a grab-bag — move domains to sibling files

1 participant