Skip to content

internal/config: replace TypeOf with TypeFor - #2360

Open
cadejacobson wants to merge 1 commit into
coreos:mainfrom
cadejacobson:typeFor
Open

cadejacobson wants to merge 1 commit into
coreos:mainfrom
cadejacobson:typeFor

Conversation

@cadejacobson

@cadejacobson cadejacobson commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the original TypeOf calls with the TypeFor call, which was introduced in Golang 1.22. This allows for compile time checking, rather than runtime checking with a dummy variable created in its place (for example, TypeOf("")). The new TypeFor calls TypeOf under the hood, but in a way that is easier to work with for interfaces.

There are 24 instances of these in the go fix output of the ci pipeline. A link to the first one is here:
https://github.com/coreos/ignition/actions/runs/42288477470/job/128135379929#step:7:14

References:

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes replace reflect.TypeOf calls on zero-value instances with reflect.TypeFor in translation code, config checks, offline fetch logic, and tests. The reflected types and described checks remain unchanged.

Changes: Reflection type lookups

Layer / File(s) Summary
Replace runtime type lookups
butane/translate/translate.go, config/util/interfaces.go, internal/exec/stages/fetch_offline/fetch-offline.go
Runtime type lookups use reflect.TypeFor. The described checks and conversion behavior remain unchanged.
Update config type checks and translation tests
config/config_test.go, config/v3_*/translate/translate_test.go, config/v3_7_experimental/translate/translate_test.go, docs/release-notes.d/reflect-typefor.change.md
Config structural checks and translation tests use reflect.TypeFor. The release note describes the replacements.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Refactor

Possibly related issues

  • coreos/ignition#2353 — The PR adds a release-note fragment, matching the workflow described by this issue.

Suggested reviewers: prestist

Merge Risk: Minimal · up to 0e70f

The type lookup changes introduce no identified merge-blocking risk.

Pre-merge checks: Passed 6

Check name Status Explanation
Title check Passed The title follows the required format. It uses the subsystem prefix "internal/config:", a lowercase imperative description, and has no trailing period. It accurately describes the TypeOf-to-TypeFor ch…
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Commit Message Convention Passed The PR has one non-merge commit: internal/config: replace TypeOf with TypeFor. Its subject follows the required format.
Description check Passed The description states the PR replaces TypeOf calls with reflect.TypeFor (Go 1.22). This matches the raw summary, which lists the changed files and the reflect.TypeFor substitutions. The description a…
Full details: Title check

Explanation

The title follows the required format. It uses the subsystem prefix "internal/config:", a lowercase imperative description, and has no trailing period. It accurately describes the TypeOf-to-TypeFor changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 11 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description states the PR replaces TypeOf calls with reflect.TypeFor (Go 1.22). This matches the raw summary, which lists the changed files and the reflect.TypeFor substitutions. The description also gives the motivation and the CI go fix count of 24 instances. It is on-topic and specific, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b3e3422 and 0e70f84.

Files selected for processing: 1

  • docs/release-notes.d/reflect-typefor.change.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Recent review details

Context from checks skipped due to timeout: 4

  • GitHub Check: CodeRabbit
  • GitHub Check: Test (1.26.x)
  • GitHub Check: Test (1.25.x)
  • GitHub Check: tmt-tests
Additional context used

Path-based instructions: 1

Documentation served via GitHub Pages/Jekyll.

CodeRabbit configuration file

Files:

  • docs/release-notes.d/reflect-typefor.change.md
Additional comments: 1

docs/release-notes.d/reflect-typefor.change.md: 1

1-1: LGTM!

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Binary size report (bin/amd64/ignition)

Size
Base (main) 33MiB
PR (#2360) 33MiB
Delta +256B (0.00%)

@Rolv-Apneseth

Copy link
Copy Markdown
Member

blackbox test is failing, I assume due to:

systemd[1]: kola-runext.service: The kernel OOM killer killed some processes in this unit.

I see this is failing across other PRs too so I assume @prestist is looking into it.

This branch has not been deployed

No deployments
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.

3 participants