Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: allow usage of different PatchManifestFunc + add test for equal WorkloadSecretID #1104

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmxnzo
Copy link
Contributor

@jmxnzo jmxnzo commented Dec 23, 2024

This PR introduces the patchManifest() method in contrasttest.go to allow executing variadic PatchManifestFunc on the current manifest, which obtain different modifications.

  • type PatchManifestFunc was introduced to allow using variadic modification functions on the current manifest.
  • existing patchReferenceValues (implements patchManifestFunc) was reduced to the modifcations of the reference values.
  • patchWorkloadSecretID (implements patchManifestFunc) was added to allow overwriting a certain workload secret.
  • a workload secret test case was added, to check that setting the same WorkloadSecretID in two different deployments will result in the identical contrast-secrets.

@jmxnzo jmxnzo added the no changelog PRs not listed in the release notes label Dec 23, 2024
@jmxnzo jmxnzo force-pushed the e2e/workload-secrets-jla branch from 9f01b81 to 379e448 Compare December 23, 2024 19:51
@jmxnzo jmxnzo changed the title e2e: allow usage of multiple PatchManifestFunc + test equal WorkloadSecretID e2e: allow usage of different PatchManifestFunc + test equal WorkloadSecretID Dec 23, 2024
@jmxnzo jmxnzo changed the title e2e: allow usage of different PatchManifestFunc + test equal WorkloadSecretID e2e: allow usage of different PatchManifestFunc + add test for equal WorkloadSecretID Dec 23, 2024
type PatchManifestFunc func(*manifest.Manifest, platforms.Platform, ...interface{})

// PatchManifest modifies the current manifest by executing a provided PatchManifestFunc on it.
func (ct *ContrastTest) PatchManifest(t *testing.T, platform platforms.Platform, patchFn PatchManifestFunc, args ...interface{}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a good design, as you loose type safety if your argument(s) have type interface{}/any.
Better use

type PatchManifestFunc func(manifest.Manifest) manifest.Manifest

As patch func. You can either declare patchReferenceValues inline in the test (if it is only used once) or write a func that takes the args and returns type PatchManifestFunc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog PRs not listed in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants