Skip to content

Commit 4de5ff5

Browse files
committed
OCPBUGS-23539: Keep Machine manifests out of OpenShift Manifests asset
IsMachineManifest() should match all of the manifests generated by either the Master or Worker machines asset. Several new types of files have been added, particularly for baremetal, without updating this function. This resulted in the files being matched by the generic OpenShift Manifests asset as well as the one that actually created them.
1 parent bb67d96 commit 4de5ff5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pkg/asset/machines/master.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,21 @@ func IsMachineManifest(file *asset.File) bool {
747747
} else if matched {
748748
return true
749749
}
750+
if matched, err := filepath.Match(secretFileNamePattern, filename); err != nil {
751+
panic("bad format for secret file name pattern")
752+
} else if matched {
753+
return true
754+
}
755+
if matched, err := filepath.Match(networkConfigSecretFileNamePattern, filename); err != nil {
756+
panic("bad format for network config secret file name pattern")
757+
} else if matched {
758+
return true
759+
}
760+
if matched, err := filepath.Match(hostFileNamePattern, filename); err != nil {
761+
panic("bad format for host file name pattern")
762+
} else if matched {
763+
return true
764+
}
750765
if matched, err := filepath.Match(masterMachineFileNamePattern, filename); err != nil {
751766
panic("bad format for master machine file name pattern")
752767
} else if matched {

pkg/asset/machines/master_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ func TestBaremetalGeneratedAssetFiles(t *testing.T) {
307307

308308
assert.Len(t, master.NetworkConfigSecretFiles, 1)
309309
verifySecret(t, master.NetworkConfigSecretFiles[0], "openshift/99_openshift-cluster-api_host-network-config-secrets-0.yaml", "master-0-network-config-secret", "map[nmstate:[105 110 116 101 114 102 97 99 101 115 58 32 110 117 108 108 10]]")
310+
verifyManifestOwnership(t, master)
310311
}
311312

312313
func verifyHost(t *testing.T, a *asset.File, eFilename, eName string) {
@@ -326,6 +327,13 @@ func verifySecret(t *testing.T, a *asset.File, eFilename, eName, eData string) {
326327
assert.Equal(t, eData, fmt.Sprintf("%v", secret.Data))
327328
}
328329

330+
func verifyManifestOwnership(t *testing.T, a asset.WritableAsset) {
331+
t.Helper()
332+
for _, file := range a.Files() {
333+
assert.True(t, IsMachineManifest(file), file.Filename)
334+
}
335+
}
336+
329337
func networkConfig(config string) *v1.JSON {
330338
var nc v1.JSON
331339
yaml.Unmarshal([]byte(config), &nc)

0 commit comments

Comments
 (0)