Added Case for Config Map in kompose down.

To implement this, added label in
configmap object at the time of init

Fixed ConfigMap test because we are
adding one more field labels in metadata
This commit is contained in:
Piyush Garg 2017-12-20 00:27:00 +05:30
parent f66ba3cee6
commit 52f8f1f2b4
2 changed files with 28 additions and 3 deletions

View File

@ -178,6 +178,7 @@ func (k *Kubernetes) InitConfigMap(name string, service kobject.ServiceConfig, o
},
ObjectMeta: api.ObjectMeta{
Name: name + "-" + envName,
Labels: transformer.ConfigLabels(name + "-" + envName),
},
Data: envs,
}
@ -1066,6 +1067,24 @@ func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.C
log.Infof("Successfully deleted Pod: %s", t.Name)
}
}
case *api.ConfigMap:
// delete ConfigMap
configMap, err := client.ConfigMaps(namespace).List(options)
if err != nil {
errorList = append(errorList, err)
break
}
for _, l := range configMap.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = client.ConfigMaps(namespace).Delete(t.Name)
if err != nil {
errorList = append(errorList, err)
break
}
log.Infof("Successfully deleted ConfigMap: %s", t.Name)
}
}
}
}

View File

@ -113,7 +113,10 @@
"apiVersion": "v1",
"metadata": {
"name": "redis-foo-env",
"creationTimestamp": null
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis-foo-env"
}
},
"data": {
"ALLOW_EMPTY_PASSWORD": "yes"
@ -124,7 +127,10 @@
"apiVersion": "v1",
"metadata": {
"name": "redis-bar-env",
"creationTimestamp": null
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis-bar-env"
}
},
"data": {
"BAR": "FOO",