forked from LaconicNetwork/kompose
bug: fix annotation bug (#1887)
#### What type of PR is this? <!-- Add one of the following kinds: /kind bug /kind cleanup /kind documentation /kind feature --> #### What this PR does / why we need it: When supplying a label in the compose file, it should stay in the output too. #### Which issue(s) this PR fixes: <!-- *Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Fixes https://github.com/kubernetes/kompose/issues/1885 #### Special notes for your reviewer: Signed-off-by: Charlie Drage <charlie@charliedrage.com>
This commit is contained in:
@@ -249,10 +249,6 @@ func ConfigAllLabels(name string, service *kobject.ServiceConfig) map[string]str
|
||||
func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
|
||||
annotations := map[string]string{}
|
||||
|
||||
if !service.WithKomposeAnnotation {
|
||||
return annotations
|
||||
}
|
||||
|
||||
for key, value := range service.Annotations {
|
||||
annotations[key] = value
|
||||
}
|
||||
@@ -270,6 +266,15 @@ func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
|
||||
annotations["kompose.version"] = version.VERSION + " (" + version.GITCOMMIT + ")"
|
||||
}
|
||||
|
||||
// if service.WithKomposeAnnotation = false, we remove **all** kompose annotations (io.kompose.*)
|
||||
if !service.WithKomposeAnnotation {
|
||||
for key := range annotations {
|
||||
if strings.HasPrefix(key, "kompose.") {
|
||||
delete(annotations, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return annotations
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user