Skip to content

Commit

Permalink
chore: add assertions and use isEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvemo committed Nov 14, 2023
1 parent f048d22 commit 6b9f438
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/src/plugins/kubernetes/container/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { prepareSecrets } from "../../secrets.js"
import { Mutagen } from "../../../../mutagen.js"
import { randomString } from "../../../../util/string.js"
import type { V1Container, V1Service } from "@kubernetes/client-node"
import { cloneDeep, isEmpty } from "lodash-es"
import { cloneDeep, isEmpty, isEqual } from "lodash-es"
import { compareDeployedResources, waitForResources } from "../../status/status.js"
import type { KubernetesDeployment, KubernetesResource, KubernetesServiceAccount } from "../../types.js"
import type { BuildActionHandler, BuildActionResults } from "../../../../plugin/action-types.js"
Expand Down Expand Up @@ -313,7 +313,7 @@ export function isEqualAnnotations(r1: KubernetesResource, r2: KubernetesResourc
// normalize annotations before comparison
const a1 = r1.metadata.annotations !== undefined ? r1.metadata.annotations : {}
const a2 = r2.metadata.annotations !== undefined ? r2.metadata.annotations : {}
return JSON.stringify(a1) === JSON.stringify(a2)
return isEqual(a1, a2)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ describe("Ensure serviceAccount annotations for in-cluster building", () => {
log,
})
// Both annotations should be present
expect(isEqualAnnotations(originalServiceAccount, status.remoteResources[0]))
expect(isEqualAnnotations(originalServiceAccount, status.remoteResources[0])).to.be.true

const reducedAnnotations = {
"iam.gke.io/gcp-service-account": "[email protected]",
Expand All @@ -660,7 +660,7 @@ describe("Ensure serviceAccount annotations for in-cluster building", () => {
log,
})
// Only reduced annotations should be present
expect(isEqualAnnotations(updatedServiceAccount, updatedStatus.remoteResources[0]))
expect(isEqualAnnotations(updatedServiceAccount, updatedStatus.remoteResources[0])).to.be.true
})
it("should cycle the util deployment when the serviceAccount annotations changed", async () => {
const originalAnnotations = {
Expand All @@ -678,7 +678,7 @@ describe("Ensure serviceAccount annotations for in-cluster building", () => {
provider.config.kaniko = { serviceAccountAnnotations: updatedAnnotations }
const { updated } = await ensureUtilDeployment({ ctx, provider, log, api, namespace: projectNamespace })

expect(updated)
expect(updated).to.be.true
})
})

Expand Down Expand Up @@ -740,7 +740,7 @@ describe("Ensure serviceAccount annotations for in-cluster building", () => {
provider.config.clusterBuildkit = { serviceAccountAnnotations: updatedAnnotations, cache: defaultCacheConfig }
const { updated } = await ensureBuildkit({ ctx, provider, log: garden.log, api, namespace: projectNamespace })

expect(updated)
expect(updated).to.be.true
})
})
})

0 comments on commit 6b9f438

Please sign in to comment.