Repository navigation
style: use distro constants in dockerinstall - #979
Merged
Merged
Conversation
## Summary
Replaces repeated `"ubuntu"`, `"debian"`, and `"raspbian"` string literals in `pkg/dockerinstall` with the existing named constants `DistroUbuntu`, `DistroDebian`, and `DistroRaspbian`, resolving the `goconst` "but such constant already exists" findings.
## Linter + category
- **Linter:** `golangci-lint` → `goconst`
- **Category:** "but such constant already exists" findings (string literals duplicated where an exported constant with the same value is already defined)
## Findings fixed
Resolved 3 `goconst` "already exists" package-level findings, across 21 literal replacements (no behavioral change — each literal is replaced with the constant of identical value):
- `"ubuntu"` (8 occurrences) → `DistroUbuntu`
- `"debian"` (6 occurrences) → `DistroDebian`
- `"raspbian"` (3 occurrences) → `DistroRaspbian`
Files touched (single package, `pkg/dockerinstall`):
- `pkg/dockerinstall/install.go` — `switch` case list
- `pkg/dockerinstall/validator.go` — supported-distro map keys
- `pkg/dockerinstall/detector_test.go` — `s.Equal` assertions + `Distro` table literals
The remaining occurrences in `validator_test.go` were intentionally left as literals so the change stays minimal and does not surface adjacent pre-existing `goconst` ("make it a constant") findings for `22.04`/`stretch` as new. After this change each of the three strings appears fewer than 3 times as a literal, so the "already exists" findings no longer fire.
## Fix method
Mechanical — literal-for-named-constant substitution. The constants already exist in `pkg/dockerinstall/constants.go`; no new constants, no logic changes. Raw-string `/etc/os-release` test fixtures (which simulate file content, not Go literals) were deliberately left untouched.
## Verification
- `task cli:format` — clean
- `task cli:lint:ci` — **0 new issues** (`--new-from-patch` against `origin/main`)
- `go test ./pkg/dockerinstall/...` — `ok` (passes)
- `task cli:test` — all packages pass except the known pre-existing `pkg/git` `TestRepoClone*` failures (a stale assertion on `origin/main`, unrelated to this change — verified failing on a clean checkout of `main`)
This PR was created by an AI agent as part of an automated daily lint fix job.
✅ Deploy Preview for images-devsy-sh canceled.
|
✅ Deploy Preview for devsydev canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces repeated
"ubuntu","debian", and"raspbian"string literals inpkg/dockerinstallwith the existing named constantsDistroUbuntu,DistroDebian, andDistroRaspbian, resolving thegoconst"but such constant already exists" findings.Linter + category
golangci-lint→goconstFindings fixed
Resolved 3
goconst"already exists" package-level findings, across 21 literal replacements (no behavioral change — each literal is replaced with the constant of identical value):"ubuntu"(8 occurrences) →DistroUbuntu"debian"(6 occurrences) →DistroDebian"raspbian"(3 occurrences) →DistroRaspbianFiles touched (single package,
pkg/dockerinstall):pkg/dockerinstall/install.go—switchcase listpkg/dockerinstall/validator.go— supported-distro map keyspkg/dockerinstall/detector_test.go—s.Equalassertions +Distrotable literalsThe remaining occurrences in
validator_test.gowere intentionally left as literals so the change stays minimal and does not surface adjacent pre-existinggoconst("make it a constant") findings for22.04/stretchas new. After this change each of the three strings appears fewer than 3 times as a literal, so the "already exists" findings no longer fire.Fix method
Mechanical — literal-for-named-constant substitution. The constants already exist in
pkg/dockerinstall/constants.go; no new constants, no logic changes. Raw-string/etc/os-releasetest fixtures (which simulate file content, not Go literals) were deliberately left untouched.Verification
task cli:format— cleantask cli:lint:ci— 0 new issues (--new-from-patchagainstorigin/main)go test ./pkg/dockerinstall/...—ok(passes)task cli:test— all packages pass except the known pre-existingpkg/gitTestRepoClone*failures (a stale assertion onorigin/main, unrelated to this change — verified failing on a clean checkout ofmain)This PR was created by an AI agent as part of an automated daily lint fix job.