From f05d4ed0eb58a90ef443a928994234364b89d89d Mon Sep 17 00:00:00 2001 From: faizanahmad055 Date: Tue, 17 Jul 2018 16:55:54 +0500 Subject: [PATCH] Fix testcase with updated annotation --- internal/pkg/controller/controller_test.go | 2 +- internal/pkg/handler/updated-handler.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/pkg/controller/controller_test.go b/internal/pkg/controller/controller_test.go index 0035d0fb..82d65fb7 100644 --- a/internal/pkg/controller/controller_test.go +++ b/internal/pkg/controller/controller_test.go @@ -172,7 +172,7 @@ func initDeployment(namespace string, deploymentName string) *v1beta1.Deployment Name: deploymentName, Namespace: namespace, Labels: map[string]string{"firstLabel": "temp"}, - Annotations: map[string]string{"reloader.stakater.com/update-on-change": deploymentName}, + Annotations: map[string]string{"reloader.stakater.com/configmap.update-on-change": deploymentName}, }, Spec: v1beta1.DeploymentSpec{ Replicas: &replicaset, diff --git a/internal/pkg/handler/updated-handler.go b/internal/pkg/handler/updated-handler.go index f3f0a3f3..d589383e 100644 --- a/internal/pkg/handler/updated-handler.go +++ b/internal/pkg/handler/updated-handler.go @@ -1,17 +1,17 @@ package handler import ( + "bytes" + "crypto/sha1" "io" "sort" "strings" - "crypto/sha1" - "bytes" "github.com/sirupsen/logrus" "github.com/stakater/Reloader/pkg/kube" "k8s.io/api/core/v1" - "k8s.io/client-go/kubernetes" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" ) const ( @@ -50,7 +50,7 @@ func (r ResourceUpdatedHandler) Handle() error { return nil } -func rollingUpgrade(r ResourceUpdatedHandler, resourceType string, rollingUpgradeType string){ +func rollingUpgrade(r ResourceUpdatedHandler, resourceType string, rollingUpgradeType string) { client, err := kube.GetClient() if err != nil { logrus.Fatalf("Unable to create Kubernetes client error = %v", err) @@ -92,7 +92,7 @@ func rollingUpgradeForDeployment(client kubernetes.Interface, r ResourceUpdatedH containers := d.Spec.Template.Spec.Containers // match deployments with the correct annotation annotationValue := d.ObjectMeta.Annotations[updateOnChangeAnnotation] - + if annotationValue != "" { values := strings.Split(annotationValue, ",") matches := false @@ -121,7 +121,6 @@ func rollingUpgradeForDeployment(client kubernetes.Interface, r ResourceUpdatedH return nil } - func rollingUpgradeForDaemonSets(client kubernetes.Interface, r ResourceUpdatedHandler, namespace string, name string, sshData string, envName string) error { daemonSets, err := client.ExtensionsV1beta1().DaemonSets(namespace).List(meta_v1.ListOptions{}) if err != nil { @@ -181,7 +180,7 @@ func rollingUpgradeForStatefulSets(client kubernetes.Interface, r ResourceUpdate containers := d.Spec.Template.Spec.Containers // match statefulSets with the correct annotation annotationValue := d.ObjectMeta.Annotations[updateOnChangeAnnotation] - + if annotationValue != "" { values := strings.Split(annotationValue, ",") matches := false @@ -293,4 +292,4 @@ func generateSHA(data string) string { io.WriteString(hasher, data) sha := hasher.Sum(nil) return string(sha[:]) -} \ No newline at end of file +}