Skip to content

Commit

Permalink
test/provisioner: avoid adding duplicate file in secretGenerator
Browse files Browse the repository at this point in the history
Adds a check to avoid adding a file to secretGenerator in
kustomization.yaml if it already is listed there.

Originally, in the libvirtd tests, if libvirtd_ssh_key_file was set and
TEST_PROVISION_FILE environment variable was used, it would fail if one
did not remember to reset the kustomization.yaml between tests.

Fixes: #1192

Signed-off-by: Derek Lee <derlee@redhat.com>
  • Loading branch information
Derek Lee authored and wainersm committed Jul 26, 2023
1 parent bc2deeb commit 8cc3d2e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/provisioner/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ func (kh *KustomizeOverlay) SetKustomizeSecretGeneratorFile(sgName string, file
gs := &m.SecretGenerator[i]

newFiles := gs.GeneratorArgs.DataSources.FileSources
newFiles = append(newFiles, file)

if !slices.Contains(newFiles, file) {
newFiles = append(newFiles, file)
}

gs.GeneratorArgs.DataSources.FileSources = newFiles

if err = kf.Write(m); err != nil {
Expand Down

0 comments on commit 8cc3d2e

Please sign in to comment.