Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable annotations when flag --with-kompose-annotation=false is specified #1754

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/transformer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,15 @@ func ConfigAllLabels(name string, service *kobject.ServiceConfig) map[string]str
// ConfigAnnotations configures annotations
func ConfigAnnotations(service kobject.ServiceConfig) map[string]string {
annotations := map[string]string{}
for key, value := range service.Annotations {
annotations[key] = value
}

if !service.WithKomposeAnnotation {
return annotations
}

for key, value := range service.Annotations {
annotations[key] = value
}

annotations["kompose.cmd"] = strings.Join(os.Args, " ")
versionCmd := exec.Command("kompose", "version")
out, err := versionCmd.Output()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -17,7 +15,6 @@ spec:
selector:
io.kompose.service: redis


---
apiVersion: v1
kind: Service
Expand All @@ -34,13 +31,10 @@ spec:
selector:
io.kompose.service: web


---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -53,8 +47,6 @@ spec:
strategy: {}
template:
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.network/change-in-volume-default: "true"
Expand All @@ -66,7 +58,6 @@ spec:
resources: {}
restartPolicy: Always


---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -108,4 +99,3 @@ spec:
- emptyDir: {}
name: code-volume


10 changes: 0 additions & 10 deletions script/test/fixtures/change-in-volume/output-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -17,7 +15,6 @@ spec:
selector:
io.kompose.service: redis


---
apiVersion: v1
kind: Service
Expand All @@ -34,13 +31,10 @@ spec:
selector:
io.kompose.service: web


---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -53,8 +47,6 @@ spec:
strategy: {}
template:
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.network/change-in-volume-default: "true"
Expand All @@ -66,7 +58,6 @@ spec:
resources: {}
restartPolicy: Always


---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -108,4 +99,3 @@ spec:
- emptyDir: {}
name: code-volume


Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -17,7 +15,6 @@ spec:
selector:
io.kompose.service: redis


---
apiVersion: v1
kind: Service
Expand All @@ -34,13 +31,10 @@ spec:
selector:
io.kompose.service: web


---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand Down Expand Up @@ -75,7 +69,6 @@ spec:
name: redis:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -98,7 +91,6 @@ spec:
referencePolicy:
type: ""


---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
Expand Down Expand Up @@ -151,7 +143,6 @@ spec:
name: web:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -174,4 +165,3 @@ spec:
referencePolicy:
type: ""


10 changes: 0 additions & 10 deletions script/test/fixtures/change-in-volume/output-os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand All @@ -17,7 +15,6 @@ spec:
selector:
io.kompose.service: redis


---
apiVersion: v1
kind: Service
Expand All @@ -34,13 +31,10 @@ spec:
selector:
io.kompose.service: web


---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
kompose.service.type: headless
creationTimestamp: null
labels:
io.kompose.service: redis
Expand Down Expand Up @@ -75,7 +69,6 @@ spec:
name: redis:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -98,7 +91,6 @@ spec:
referencePolicy:
type: ""


---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
Expand Down Expand Up @@ -151,7 +143,6 @@ spec:
name: web:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -174,4 +165,3 @@ spec:
referencePolicy:
type: ""


Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.image-pull-policy: IfNotPresent
creationTimestamp: null
labels:
io.kompose.service: foo
Expand All @@ -16,13 +14,10 @@ spec:
selector:
io.kompose.service: foo


---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.image-pull-policy: IfNotPresent
creationTimestamp: null
labels:
io.kompose.service: foo
Expand All @@ -35,8 +30,6 @@ spec:
strategy: {}
template:
metadata:
annotations:
kompose.image-pull-policy: IfNotPresent
creationTimestamp: null
labels:
io.kompose.network/compose-env-interpolation-default: "true"
Expand All @@ -53,4 +46,3 @@ spec:
resources: {}
restartPolicy: Always


10 changes: 0 additions & 10 deletions script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.service: db
Expand All @@ -17,8 +15,6 @@ spec:
type: Recreate
template:
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.network/configmap-volume-default: "true"
Expand All @@ -41,7 +37,6 @@ spec:
name: db-cm0
name: db-cm0


---
apiVersion: v1
binaryData:
Expand All @@ -59,8 +54,6 @@ metadata:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.service: web
Expand All @@ -74,8 +67,6 @@ spec:
type: Recreate
template:
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.network/configmap-volume-default: "true"
Expand Down Expand Up @@ -103,7 +94,6 @@ spec:
name: web-cm1
name: web-cm1


---
apiVersion: v1
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.service: db
Expand Down Expand Up @@ -50,7 +48,6 @@ spec:
name: db:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -73,7 +70,6 @@ spec:
referencePolicy:
type: ""


---
apiVersion: v1
binaryData:
Expand All @@ -91,8 +87,6 @@ metadata:
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
kompose.volume.type: configMap
creationTimestamp: null
labels:
io.kompose.service: web
Expand Down Expand Up @@ -144,7 +138,6 @@ spec:
name: web:latest
type: ImageChange


---
apiVersion: image.openshift.io/v1
kind: ImageStream
Expand All @@ -167,7 +160,6 @@ spec:
referencePolicy:
type: ""


---
apiVersion: v1
data:
Expand Down
Loading
Loading