Conversation
Address review comment from wikkyk on PR #698. https://claude.ai/code/session_015FdS7SaR8zLrDVCqqKXTTT
- Extract testFilename constant to deduplicate "test.yaml" literals - Merge duplicate DocumentNode/SequenceNode switch cases in defaults.go - Merge duplicate typeString/typeBool switch cases in sentinel.go Restore() - Extract runStdin, processFile, writeInPlace from run() to reduce cognitive complexity from 31 to under 15 - Extract generateUnique helper to reduce generateSentinel complexity from 16 to under 15 https://claude.ai/code/session_015FdS7SaR8zLrDVCqqKXTTT
Address review comment from wikkyk on PR #698. https://claude.ai/code/session_015FdS7SaR8zLrDVCqqKXTTT
- Extract testFilename constant to deduplicate "test.yaml" literals - Merge duplicate DocumentNode/SequenceNode switch cases in defaults.go - Merge duplicate typeString/typeBool switch cases in sentinel.go Restore() - Extract runStdin, processFile, writeInPlace from run() to reduce cognitive complexity from 31 to under 15 - Extract generateUnique helper to reduce generateSentinel complexity from 16 to under 15 https://claude.ai/code/session_015FdS7SaR8zLrDVCqqKXTTT
0e3b218 to
42a9181
Compare
b864da6 to
4e7c901
Compare
|
e2e not required because this PR doesn't touch anything that would be tested by e2e. |
|
The 11 accepted issues in SonarQube are all about string constant duplications in places where we actually want to keep the naked string, so it's just a case of the tool being too eager. |
4e7c901 to
0282e42
Compare
|
Minor tweaks: added copyright headers, component name to commit messages; renamed the binary to just |
0282e42 to
16b79c7
Compare
|
TODO: in k8s 34, add an option to output kyaml. |
Introduce the convert CLI tool and the pkg/convert library for migrating CAPMOX v1alpha1 resources to v1alpha2, and CAPI v1beta1 resources to v1beta2. The tool detects resource types, routes to typed converters using controller-runtime's conversion interface, and outputs re-indented YAML. Co-authored-by: Claude <noreply@anthropic.com>
…ment
Add sentinel scan/replace/restore so that ${VAR} expressions survive
the Go struct round-trip during conversion. Each expression is replaced
with a type-appropriate placeholder before unmarshalling, then restored
in the final YAML output.
Co-authored-by: Claude <noreply@anthropic.com>
Remove null scalars, empty mappings, and known-default values (like zoneConfigs, externalManagedControlPlane) that the typed conversion injects but were absent in the original v1alpha1 manifest. Co-authored-by: Claude <noreply@anthropic.com>
Remove the top-level status key when it contains only zero/null values. If a status block has real data, it is kept and a warning is emitted so the operator can review it manually. Co-authored-by: Claude <noreply@anthropic.com>
Copy head, line, and foot comments from the original YAML tree to the converted output by matching node structure. Warnings are emitted for comments on fields that no longer exist in the target schema. Co-authored-by: Claude <noreply@anthropic.com>
Document the convert CLI tool usage, supported resource types, and post-conversion review steps in the v0.8 to v1alpha2 migration guide. Co-authored-by: Claude <noreply@anthropic.com>
Fix missing newline before --- separator for passthrough documents. splitYAMLDocuments strips trailing newlines when flushing document chunks before a separator, causing them to concatenate directly. Co-authored-by: Claude <noreply@anthropic.com>
…calar quotes Text-based Restore stripped " around sentinels, treating them as YAML quoting. Inside block scalars (e.g. shell scripts) those chars are literal content. Introduce RestoreNode, which replaces sentinels in scalar node Values directly — surrounding " are left intact. typeInt nodes get their !!int tag cleared so go-yaml re-infers the type. Array sentinels still go through text-based Restore after serialisation. The top-level Restore call in convertDocument is removed. Co-Authored-By: Claude <noreply@anthropic.com>
…replacement Fix gofmt: double space before inline comment in sentinel.go. Co-authored-by: Claude <noreply@anthropic.com>
6f4dad0 to
2037e30
Compare
…tput Preserve block scalar style (literal |, folded >) from source nodes during GraftComments. k8syaml.Marshal always emits literal style, so folded (>) scalars were silently converted to literal (|). Rename copyComments → copyMetadata and add Style copying restricted to block scalar styles (LiteralStyle, FoldedStyle). Non-block styles like DoubleQuotedStyle are intentionally not copied. Co-authored-by: Claude <noreply@anthropic.com> https://claude.ai/code/session_015FdS7SaR8zLrDVCqqKXTTT
…ng documents bytes.TrimSpace treated " ---" (indented) the same as "---", splitting KubeadmControlPlane manifests mid-block-scalar when embedded YAML used "---" separators. Document separators in YAML are always at column 0, so a plain bytes.Equal check is sufficient and correct. Co-Authored-By: Claude <noreply@anthropic.com>
|
65278
left a comment
There was a problem hiding this comment.
Tool works for a complex test case. I've specifically not reviewed the code in depth because it's supposed to be used at your own risk. It doesn't run any infrastructure.



Issue #
fixes #534
Description of changes:
Migration tool that converts v1alpha1 templates etc to v1alpha2.
It uses the conversion routines in conversion.go, CAPI, etc to make sure that the conversions are consistent with in-cluster conversions.
It tries its best to maintain the original file structure, namely:
Default and null values get stripped. Status fields get stripped. Helpful warnings are emitted when the conversion is lossy.
It should be compatible with clusterctl.
Testing performed:
Comprehensive tests have been added, including an 'end-to-end' full-conversion test.
I have tested this converter on all examples and templates in the repo and it results in almost identical files, with the exception of the manual changes that were applied that cannot be done automatically.