-
Notifications
You must be signed in to change notification settings - Fork 1.4k
⚒️ fix CAPBK file conversion, add validating webhook #3100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,23 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error { | |
| dst.Spec.Verbosity = restored.Spec.Verbosity | ||
| dst.Spec.UseExperimentalRetryJoin = restored.Spec.UseExperimentalRetryJoin | ||
| dst.Spec.Files = restored.Spec.Files | ||
| for i := range restored.Spec.Files { | ||
| file := restored.Spec.Files[i] | ||
| if file.ContentFrom != nil { | ||
| dst.Spec.Files = append(dst.Spec.Files, file) | ||
|
|
||
| // Track files successfully up-converted. We need this to dedupe | ||
| // restored files from user-updated files on up-conversion. We store | ||
| // them as pointers for later modification without paying for second | ||
| // lookup. | ||
| dstPaths := make(map[string]*kubeadmbootstrapv1alpha3.File, len(dst.Spec.Files)) | ||
| for i := range dst.Spec.Files { | ||
| file := dst.Spec.Files[i] | ||
| dstPaths[file.Path] = &file | ||
| } | ||
|
|
||
| // If we find a restored file matching the file path of a v1alpha2 | ||
| // file with no content, we should restore contentFrom to that file. | ||
| for _, restoredFile := range restored.Spec.Files { | ||
| dstFile, exists := dstPaths[restoredFile.Path] | ||
| if exists && dstFile.Content == "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read the other thread but I'm still not sure I follow why we're checking for empty Content here instead of checking for set ContentFrom... isn't empty string content a valid File use case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if you set a file content to empty in either v1a2 or v1a3, that still works. This will only try to match files where a v1a3 file was downconverted into empty content and then re-unconverted. It requires a match on the path. Realistically, I don’t think this makes any difference. When does downconversion even happen in this scenario? V1a3 is the storage version, this is mostly for the sake of maintaining roundtrip-ability?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said I know string pointer is more correct and this feels weird, but I think it works okay in practice |
||
| dstFile.ContentFrom = restoredFile.ContentFrom | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first time you left this in review I agreed but for this one I don’t think I do because we need the pointer to the indexed value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense