Skip to content

[CASCL-1292] chore(kubectl-datadog): split autoscaling install.go into smaller files#2967

Closed
L3n41c wants to merge 1 commit into
mainfrom
lenaic/split-install-go
Closed

[CASCL-1292] chore(kubectl-datadog): split autoscaling install.go into smaller files#2967
L3n41c wants to merge 1 commit into
mainfrom
lenaic/split-install-go

Conversation

@L3n41c

@L3n41c L3n41c commented May 4, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Splits the 705-line cmd/kubectl-datadog/autoscaling/cluster/install/install.go (and its 444-line test) into smaller, more cohesive files within the same Go package. No behavior change — the logical content (excluding comments, blank lines, and import blocks) is byte-identical to before.

Layout after the split:

File Content
install_mode.go InstallMode pflag enum + String/Set/Type
create_karpenter_resources.go CreateKarpenterResources pflag enum + methods
inference_method.go InferenceMethod pflag enum + methods
install.go (slim) Cobra command wiring — flag-bound globals, options, complete, validate
steps.go Orchestration — run() + individual steps (CFN stacks, aws-auth, Helm, NodePool, cluster-info snapshot) + display messages + embedded CFN templates

Tests are split symmetrically.

Motivation

The parent PR #2961 introducing kubectl datadog autoscaling cluster install has become too large to review comfortably. Splitting install.go into smaller files makes incoming reviews and follow-ups (notably a future update subcommand that will reuse steps.go) easier to land.

The split also reflects the intended division of labour for the future update:

  • The cobra layer (install.go) will be duplicated by update.
  • The orchestration (steps.go) will be reused by update once run() is parameterized to drop its dependency on the install-package globals (deferred to that follow-up PR).

Additional Notes

  • The pflag boilerplate (three enum types × String/Set/Type) lives in dedicated files now; it was crowding the install logic in the original file.
  • steps.go still contains (*options).run and (*options).installHelmChart coupled to the install globals — parameterization is intentionally out of scope here and will be done as part of the PR that introduces update.

Minimum Agent Versions

Not applicable — refactor only, no runtime change.

  • Agent: n/a
  • Cluster Agent: n/a

Describe your test plan

Pure file-level reorganization, mechanically verified:

  • go build ./... passes
  • go test ./cmd/kubectl-datadog/autoscaling/cluster/install/... — all tests pass
  • make lint — 0 issues
  • Sorted-line diff between original install.go (resp. install_test.go) and the union of the new files is empty modulo comments / blank lines / package+import lines
  • CI green

Checklist

  • PR has at least one valid label: refactoring
  • qa/skip-qa label set (no runtime behavior changes)
  • All commits are signed

Pure file-level reorganization within the install package — no behavior
changes. Prepares for a future `update` subcommand that will reuse the
orchestration in steps.go (the install command is already idempotent and
most of its logic carries over).

Layout:

- install_mode.go, create_karpenter_resources.go, inference_method.go:
  pflag enum types and their String/Set/Type receiver methods (verbose
  boilerplate that obscured the install logic in the original file).
- install.go (now slim): cobra command wiring — flag-bound globals,
  options struct, complete/validate. To be duplicated by `update`.
- steps.go: orchestration — run() plus the individual steps
  (CloudFormation stacks, aws-auth ConfigMap, Helm release, NodePool
  resources, cluster-info snapshot) and the display messages. To be
  reused by `update` once run() is parameterized.

Tests are split symmetrically. Logical content (excluding comments,
blank lines, and import blocks) is byte-identical to the original.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@L3n41c L3n41c closed this May 4, 2026
@L3n41c
L3n41c deleted the lenaic/split-install-go branch May 4, 2026 13:25
@L3n41c L3n41c changed the title chore(kubectl-datadog): split autoscaling install.go into smaller files [CASCL-1292] chore(kubectl-datadog): split autoscaling install.go into smaller files May 4, 2026
@L3n41c

L3n41c commented May 4, 2026

Copy link
Copy Markdown
Member Author

Closed and superseded by #2968 — the GitHub branch-rename API closed this PR when the Jira ref CASCL-1292 was added retroactively to the branch name. Same content, same commit (rebased to amend the message), force-pushed to the renamed branch.

@codecov-commenter

codecov-commenter commented May 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.31250% with 223 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.41%. Comparing base (1ed0fbc) to head (fcc6c64).

Files with missing lines Patch % Lines
...bectl-datadog/autoscaling/cluster/install/steps.go 20.07% 223 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2967   +/-   ##
=======================================
  Coverage   41.41%   41.41%           
=======================================
  Files         327      331    +4     
  Lines       28891    28891           
=======================================
  Hits        11964    11964           
  Misses      16072    16072           
  Partials      855      855           
Flag Coverage Δ
unittests 41.41% <30.31%> (ø)

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

Files with missing lines Coverage Δ
...ling/cluster/install/create_karpenter_resources.go 100.00% <100.00%> (ø)
...og/autoscaling/cluster/install/inference_method.go 100.00% <100.00%> (ø)
...ctl-datadog/autoscaling/cluster/install/install.go 27.90% <ø> (-2.13%) ⬇️
...atadog/autoscaling/cluster/install/install_mode.go 100.00% <100.00%> (ø)
...bectl-datadog/autoscaling/cluster/install/steps.go 20.07% <20.07%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ed0fbc...fcc6c64. Read the comment docs.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants