Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
fix: the handlers should be changing user provided input (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin authored Apr 9, 2024
1 parent cb8fadb commit 0e91d4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions pkg/handlers/nutanix/mutation/prismcentralendpoint/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ func (h *nutanixPrismCentralEndpoint) Mutate(
Kind: credentials.NutanixTrustBundleKindString,
Data: string(decoded),
}
}

// Always force insecure to false if additional trust bundle is provided.
// This ensures that the trust bundle is actually used to validate the connection.
if additionalTrustBundle != "" && prismCentral.Insecure {
log.Info("AdditionalTrustBundle is provided, setting insecure to false")
prismCentral.Insecure = false
// TODO: Consider always setting Insecure to false when AdditionalTrustBundle is set.
// But do it in a webhook and not hidden in this handler.
}

obj.Spec.Template.Spec.PrismCentral = prismCentral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ var _ = Describe("Generate Nutanix Prism Central Endpoint patches", func() {
gomega.BeEquivalentTo("prism-central.nutanix.com"),
),
gomega.HaveKeyWithValue("port", gomega.BeEquivalentTo(9441)),
// Assert the insecure field was set to false as the additional trust bundle is set
gomega.HaveKeyWithValue("insecure", false),
// Assert the insecure field was not modified when additional trust bundle is set.
gomega.HaveKeyWithValue("insecure", true),
gomega.HaveKey("credentialRef"),
gomega.HaveKey("additionalTrustBundle"),
),
Expand Down

0 comments on commit 0e91d4d

Please sign in to comment.