Skip to content

Commit 0fe4449

Browse files
authored
Merge pull request #5563 from fluxcd/fix-migrate-f
Fix `flux migrate -f` not considering kind comments
2 parents f4a811f + 7c5fb22 commit 0fe4449

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

cmd/flux/migrate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ func (f *FileSystemMigrator) detectFileUpgrades(file string) ([]APIUpgrade, erro
623623
if idx == -1 {
624624
continue
625625
}
626-
kind := strings.TrimSpace(kindLine[idx+len(kindPrefix):])
626+
kindValuePrefix := strings.TrimSpace(kindLine[idx+len(kindPrefix):])
627+
kind := strings.Split(kindValuePrefix, " ")[0]
627628

628629
// Build GroupKind.
629630
gk := schema.GroupKind{

cmd/flux/migrate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestFileSystemMigrator(t *testing.T) {
153153
for _, wf := range tt.writtenFiles {
154154
b, err := os.ReadFile(wf.goldenFile)
155155
g.Expect(err).ToNot(HaveOccurred())
156-
g.Expect(fileSystem.writtenFiles[wf.file]).To(Equal(b),
156+
g.Expect(string(fileSystem.writtenFiles[wf.file])).To(Equal(string(b)),
157157
"file %s does not match golden file %s", wf.file, wf.goldenFile)
158158
}
159159
})

cmd/flux/testdata/migrate/file-system/dir.golden/some-file.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec:
1212
wait: true
1313
dependsOn:
1414
- apiVersion: image.toolkit.fluxcd.io/v1 # update this from v1beta1
15-
kind: ImageRepository
15+
kind: ImageRepository # there can be comments here too
1616

1717

1818
---

cmd/flux/testdata/migrate/file-system/dir/some-file.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec:
1212
wait: true
1313
dependsOn:
1414
- apiVersion: image.toolkit.fluxcd.io/v1beta1 # update this from v1beta1
15-
kind: ImageRepository
15+
kind: ImageRepository # there can be comments here too
1616

1717

1818
---

0 commit comments

Comments
 (0)