From 15b2c85437df3e594c2e14ebcf8648c7d227e1b3 Mon Sep 17 00:00:00 2001 From: shivdudhani Date: Wed, 22 May 2019 20:22:26 -0700 Subject: [PATCH] validate if copyFrom is specified --- client/client.go | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/client/client.go b/client/client.go index 3b5a39cb7f..e04b34fd6b 100644 --- a/client/client.go +++ b/client/client.go @@ -178,19 +178,19 @@ func (c *Client) GenerateSecret(generator types.Generation, namespace string) er c.logger.Printf("Preparing to create secret %s/%s", namespace, generator.Name) secret := v1.Secret{} - // if generator.CopyFrom != nil { - c.logger.Printf("Copying data from secret %s/%s", generator.CopyFrom.Namespace, generator.CopyFrom.Name) - // Get configMap resource - unstrSecret, err := c.GetResource(Secrets, generator.CopyFrom.Namespace, generator.CopyFrom.Name) - if err != nil { - return err + if generator.CopyFrom != nil { + c.logger.Printf("Copying data from secret %s/%s", generator.CopyFrom.Namespace, generator.CopyFrom.Name) + // Get configMap resource + unstrSecret, err := c.GetResource(Secrets, generator.CopyFrom.Namespace, generator.CopyFrom.Name) + if err != nil { + return err + } + // typed object + secret, err = convertToSecret(unstrSecret) + if err != nil { + return err + } } - // typed object - secret, err = convertToSecret(unstrSecret) - if err != nil { - return err - } - // } secret.ObjectMeta = meta.ObjectMeta{ Name: generator.Name, @@ -218,20 +218,20 @@ func (c *Client) GenerateConfigMap(generator types.Generation, namespace string) c.logger.Printf("Preparing to create configmap %s/%s", namespace, generator.Name) configMap := v1.ConfigMap{} - // if generator.CopyFrom != nil { - c.logger.Printf("Copying data from configmap %s/%s", generator.CopyFrom.Namespace, generator.CopyFrom.Name) - // Get configMap resource - unstrConfigMap, err := c.GetResource(ConfigMaps, generator.CopyFrom.Namespace, generator.CopyFrom.Name) - if err != nil { - return err - } - // typed object - configMap, err = convertToConfigMap(unstrConfigMap) - if err != nil { - return err + if generator.CopyFrom != nil { + c.logger.Printf("Copying data from configmap %s/%s", generator.CopyFrom.Namespace, generator.CopyFrom.Name) + // Get configMap resource + unstrConfigMap, err := c.GetResource(ConfigMaps, generator.CopyFrom.Namespace, generator.CopyFrom.Name) + if err != nil { + return err + } + // typed object + configMap, err = convertToConfigMap(unstrConfigMap) + if err != nil { + return err + } } - // } configMap.ObjectMeta = meta.ObjectMeta{ Name: generator.Name, Namespace: namespace,