Update configmap if already present

in e2e if the configmap is ready present,
we need to update it to make life simpler
for helm chart e2e.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-04-01 12:49:40 +05:30 committed by mergify[bot]
parent 22c432cece
commit b2dfcae802

View File

@ -368,7 +368,18 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
Expect(err).Should(BeNil())
cm.Data["config.json"] = string(data)
cm.Namespace = cephCSINamespace
_, err = c.CoreV1().ConfigMaps(cephCSINamespace).Create(&cm)
// if the configmap is present update it,during cephcsi helm charts
// deployment empty configmap gets created we need to override it
_, err = c.CoreV1().ConfigMaps(cephCSINamespace).Get(cm.Name, metav1.GetOptions{})
if err == nil {
_, updateErr := c.CoreV1().ConfigMaps(cephCSINamespace).Update(&cm)
Expect(updateErr).Should(BeNil())
}
if apierrs.IsNotFound(err) {
_, err = c.CoreV1().ConfigMaps(cephCSINamespace).Create(&cm)
}
Expect(err).Should(BeNil())
}