diff --git a/docs/Reloader-vs-ConfigmapController.md b/docs/Reloader-vs-ConfigmapController.md index 8fee3dd4..872040ee 100644 --- a/docs/Reloader-vs-ConfigmapController.md +++ b/docs/Reloader-vs-ConfigmapController.md @@ -8,5 +8,5 @@ Reloader is inspired from [Configmapcontroller](https://github.com/fabric8io/con | Reloader can watch both `secrets` and `configmaps`. | ConfigmapController can only watch changes in `configmaps`. It cannot detect changes in other resources like `secrets`. | | Reloader can perform rolling upgrades on `deployments` as well as on `statefulsets` and `daemonsets` | ConfigmapController can only perform rolling upgrades on `deployments`. It currently does not support rolling upgrades on `statefulsets` and `daemonsets` | | Reloader provides both unit test cases and end to end integration test cases for future updates. So one can make sure that new changes do not break any old functionality. | Currently there are not any unit test cases or end to end integration test cases in configmap controller. It add difficulties for any additional updates in configmap controller and one can not know for sure whether new changes breaks any old functionality or not. | -| Reloader uses SHA1 to encode the change in configmap or secret. It then saves the SHA1 value in `STAKATER_FOO_CONFIGMAP` or `STAKATER_FOO_SECRET` environment variable depending upon where the change has happened. The use of SHA1 provides a concise 40 characters encoded value that is very less pron to collision. | Configmap controller uses `FABRICB_FOO_REVISION` environment variable to store any change in configmap controller. It does not encode it or convert it in suitable hash value to avoid data pollution in deployment. | -| Reloader allows you to customize your own annotation (for both Secrets and Configmaps) using command line flags | Configmap controller restricts you to only their provided annotation | \ No newline at end of file +| Reloader uses SHA1 to encode the change in configmap or secret. It then saves the SHA1 value in `STAKATER_FOO_CONFIGMAP` or `STAKATER_FOO_SECRET` environment variable depending upon where the change has happened. The use of SHA1 provides a concise 40 characters encoded value that is very less prone to collision. | Configmap controller uses `FABRICB_FOO_REVISION` environment variable to store any change in configmap controller. It does not encode it or convert it in suitable hash value to avoid data pollution in deployment. | +| Reloader allows you to customize your own annotation (for both Secrets and Configmaps) using command line flags | Configmap controller restricts you to only their provided annotation | diff --git a/docs/features.md b/docs/features.md index 52f1dba9..18302854 100644 --- a/docs/features.md +++ b/docs/features.md @@ -2,6 +2,6 @@ These are the key features of Reloader: -1. Restart pod in a depoloyment on change in linked/related configmap's or secret's +1. Restart pod in a deployment on change in linked/related configmap's or secret's 2. Restart pod in a daemonset on change in linked/related configmap's or secret's 3. Restart pod in a statefulset on change in linked/related configmap's or secret's diff --git a/internal/pkg/controller/controller_test.go b/internal/pkg/controller/controller_test.go index 1727cdcf..e1971cfe 100644 --- a/internal/pkg/controller/controller_test.go +++ b/internal/pkg/controller/controller_test.go @@ -336,7 +336,7 @@ func TestControllerForUpdatingConfigmapShouldUpdateDeployment(t *testing.T) { } // Do not Perform rolling upgrade on deployment and create env var upon updating the labels configmap -func TestControllerUpdatingConfigmapLabelsShouldNotCreateorUpdateEnvInDeployment(t *testing.T) { +func TestControllerUpdatingConfigmapLabelsShouldNotCreateOrUpdateEnvInDeployment(t *testing.T) { // Creating configmap configmapName := configmapNamePrefix + "-update-" + testutil.RandSeq(5) configmapClient, err := testutil.CreateConfigMap(clients.KubernetesClient, namespace, configmapName, "www.google.com") @@ -552,7 +552,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDeployment(t *testing.T) { } // Do not Perform rolling upgrade on pod and create or update a env var upon updating the label in secret -func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDeployment(t *testing.T) { +func TestControllerUpdatingSecretLabelsShouldNotCreateOrUpdateEnvInDeployment(t *testing.T) { // Creating secret secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5) secretClient, err := testutil.CreateSecret(clients.KubernetesClient, namespace, secretName, data) @@ -820,7 +820,7 @@ func TestControllerUpdatingSecretShouldUpdateEnvInDaemonSet(t *testing.T) { } // Do not Perform rolling upgrade on pod and create or update a env var upon updating the label in secret -func TestControllerUpdatingSecretLabelsShouldNotCreateorUpdateEnvInDaemonSet(t *testing.T) { +func TestControllerUpdatingSecretLabelsShouldNotCreateOrUpdateEnvInDaemonSet(t *testing.T) { // Creating secret secretName := secretNamePrefix + "-update-" + testutil.RandSeq(5) secretClient, err := testutil.CreateSecret(clients.KubernetesClient, namespace, secretName, data) diff --git a/internal/pkg/handler/upgrade.go b/internal/pkg/handler/upgrade.go index 508481b9..51e702d8 100644 --- a/internal/pkg/handler/upgrade.go +++ b/internal/pkg/handler/upgrade.go @@ -260,7 +260,7 @@ func getContainerToUpdate(upgradeFuncs callbacks.RollingUpgradeFuncs, item inter func updateContainers(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface{}, config util.Config, autoReload bool) constants.Result { var result constants.Result - envar := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + config.Type + envVar := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + config.Type container := getContainerToUpdate(upgradeFuncs, item, config, autoReload) if container == nil { @@ -268,12 +268,12 @@ func updateContainers(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface } //update if env var exists - result = updateEnvVar(upgradeFuncs.ContainersFunc(item), envar, config.SHAValue) + result = updateEnvVar(upgradeFuncs.ContainersFunc(item), envVar, config.SHAValue) // if no existing env var exists lets create one if result == constants.NoEnvVarFound { e := v1.EnvVar{ - Name: envar, + Name: envVar, Value: config.SHAValue, } container.Env = append(container.Env, e) @@ -282,11 +282,11 @@ func updateContainers(upgradeFuncs callbacks.RollingUpgradeFuncs, item interface return result } -func updateEnvVar(containers []v1.Container, envar string, shaData string) constants.Result { +func updateEnvVar(containers []v1.Container, envVar string, shaData string) constants.Result { for i := range containers { envs := containers[i].Env for j := range envs { - if envs[j].Name == envar { + if envs[j].Name == envVar { if envs[j].Value != shaData { envs[j].Value = shaData return constants.Updated diff --git a/internal/pkg/testutil/kube.go b/internal/pkg/testutil/kube.go index 465acd52..32100a64 100644 --- a/internal/pkg/testutil/kube.go +++ b/internal/pkg/testutil/kube.go @@ -563,11 +563,11 @@ func GetSecretWithUpdatedLabel(namespace string, secretName string, label string } // GetResourceSHA returns the SHA value of given environment variable -func GetResourceSHA(containers []v1.Container, envar string) string { +func GetResourceSHA(containers []v1.Container, envVar string) string { for i := range containers { envs := containers[i].Env for j := range envs { - if envs[j].Name == envar { + if envs[j].Name == envVar { return envs[j].Value } }