chore: Cleanup a lot of code

This commit is contained in:
TheiLLeniumStudios
2026-01-15 00:21:56 +01:00
parent 6ac8f5d5d8
commit 082b7cc4c4
38 changed files with 413 additions and 848 deletions

View File

@@ -43,7 +43,6 @@ var _ = BeforeSuite(func() {
registry = utils.NewAdapterRegistry(kubeClient)
// Register optional adapters if CRDs are installed
if utils.IsArgoRolloutsInstalled(ctx, testEnv.RolloutsClient) {
GinkgoWriter.Println("Argo Rollouts detected, registering ArgoRolloutAdapter")
registry.RegisterAdapter(utils.NewArgoRolloutAdapter(testEnv.RolloutsClient))
@@ -60,7 +59,7 @@ var _ = BeforeSuite(func() {
deployValues := map[string]string{
"reloader.reloadStrategy": "annotations",
"reloader.watchGlobally": "false", // Only watch own namespace to prevent cross-talk between test suites
"reloader.watchGlobally": "false",
}
if utils.IsCSIDriverInstalled(ctx, csiClient) {

View File

@@ -130,36 +130,7 @@ var _ = Describe("Auto Reload Annotation Tests", func() {
})
})
Context("with reloader.stakater.com/auto=false annotation", func() {
It("should NOT reload Deployment when ConfigMap changes", func() {
By("Creating a ConfigMap")
_, err := utils.CreateConfigMap(ctx, kubeClient, testNamespace, configMapName,
map[string]string{"key": "initial"}, nil)
Expect(err).NotTo(HaveOccurred())
By("Creating a Deployment with auto=false annotation")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithConfigMapEnvFrom(configMapName),
utils.WithAnnotations(utils.BuildAutoFalseAnnotation()),
)
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
err = adapter.WaitReady(ctx, testNamespace, deploymentName, utils.WorkloadReadyTimeout)
Expect(err).NotTo(HaveOccurred())
By("Updating the ConfigMap data")
err = utils.UpdateConfigMap(ctx, kubeClient, testNamespace, configMapName, map[string]string{"key": "updated"})
Expect(err).NotTo(HaveOccurred())
By("Verifying Deployment is NOT reloaded (negative test)")
time.Sleep(utils.NegativeTestWait)
reloaded, err := adapter.WaitReloaded(ctx, testNamespace, deploymentName,
utils.AnnotationLastReloadedFrom, utils.ShortTimeout)
Expect(err).NotTo(HaveOccurred())
Expect(reloaded).To(BeFalse(), "Deployment with auto=false should NOT have been reloaded")
})
})
// Note: auto=false test is now in core/workloads_test.go as a DescribeTable for all workload types
Context("with configmap.reloader.stakater.com/auto=true annotation", func() {
It("should reload Deployment only when ConfigMap changes, not Secret", func() {

View File

@@ -48,10 +48,10 @@ var _ = Describe("Combination Annotation Tests", func() {
By("Creating a Deployment with auto=true AND explicit reload annotation for extra ConfigMap")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithConfigMapEnvFrom(configMapName), // auto-detected
utils.WithConfigMapEnvFrom(configMapName),
utils.WithAnnotations(utils.MergeAnnotations(
utils.BuildAutoTrueAnnotation(),
utils.BuildConfigMapReloadAnnotation(configMapName2), // explicitly listed
utils.BuildConfigMapReloadAnnotation(configMapName2),
)),
)
Expect(err).NotTo(HaveOccurred())
@@ -82,10 +82,10 @@ var _ = Describe("Combination Annotation Tests", func() {
By("Creating a Deployment with auto=true AND explicit reload annotation for extra ConfigMap")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithConfigMapEnvFrom(configMapName), // auto-detected
utils.WithConfigMapEnvFrom(configMapName),
utils.WithAnnotations(utils.MergeAnnotations(
utils.BuildAutoTrueAnnotation(),
utils.BuildConfigMapReloadAnnotation(configMapName2), // explicitly listed
utils.BuildConfigMapReloadAnnotation(configMapName2),
)),
)
Expect(err).NotTo(HaveOccurred())
@@ -116,10 +116,10 @@ var _ = Describe("Combination Annotation Tests", func() {
By("Creating a Deployment with auto=true AND explicit reload annotation for extra Secret")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithSecretEnvFrom(secretName), // auto-detected
utils.WithSecretEnvFrom(secretName),
utils.WithAnnotations(utils.MergeAnnotations(
utils.BuildAutoTrueAnnotation(),
utils.BuildSecretReloadAnnotation(secretName2), // explicitly listed
utils.BuildSecretReloadAnnotation(secretName2),
)),
)
Expect(err).NotTo(HaveOccurred())
@@ -153,10 +153,10 @@ var _ = Describe("Combination Annotation Tests", func() {
By("Creating a Deployment with auto=true AND exclude for second ConfigMap")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithConfigMapEnvFrom(configMapName),
utils.WithConfigMapEnvFrom(configMapName2), // also mounted, but excluded
utils.WithConfigMapEnvFrom(configMapName2),
utils.WithAnnotations(utils.MergeAnnotations(
utils.BuildAutoTrueAnnotation(),
utils.BuildConfigMapExcludeAnnotation(configMapName2), // exclude this one
utils.BuildConfigMapExcludeAnnotation(configMapName2),
)),
)
Expect(err).NotTo(HaveOccurred())

View File

@@ -357,7 +357,7 @@ var _ = Describe("Exclude Annotation Tests", func() {
Expect(err).NotTo(HaveOccurred())
By("Finding the SPCPS for non-excluded SPC")
// We need to find SPCPS for the non-excluded SPC (spcName2)
spcpsName2, err := utils.FindSPCPSForSPC(ctx, csiClient, testNamespace, spcName2, 30*time.Second)
Expect(err).NotTo(HaveOccurred())

View File

@@ -98,9 +98,7 @@ var _ = Describe("Search and Match Annotation Tests", func() {
By("Creating a Deployment WITHOUT search annotation (only standard annotation)")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName,
utils.WithConfigMapEnvFrom(configMapName),
// Note: No search or reload annotation - deployment won't be affected by match
)
utils.WithConfigMapEnvFrom(configMapName))
Expect(err).NotTo(HaveOccurred())
By("Waiting for Deployment to be ready")
@@ -141,7 +139,6 @@ var _ = Describe("Search and Match Annotation Tests", func() {
By("Creating second Deployment WITHOUT search annotation")
_, err = utils.CreateDeployment(ctx, kubeClient, testNamespace, deploymentName2,
utils.WithConfigMapEnvFrom(configMapName),
// No search annotation
)
Expect(err).NotTo(HaveOccurred())