diff --git a/pkg/transformer/utils.go b/pkg/transformer/utils.go index 44340dbb8..501eaecbe 100644 --- a/pkg/transformer/utils.go +++ b/pkg/transformer/utils.go @@ -275,6 +275,9 @@ func ConfigAnnotations(service kobject.ServiceConfig) map[string]string { // Print either prints to stdout or to file/s func Print(name, path string, trailing string, data []byte, toStdout, generateJSON bool, f *os.File, provider string) (string, error) { file := "" + // simple hack to remove status from the output + re := regexp.MustCompile(`(?s)status:.*`) + data = re.ReplaceAll(data, nil) if generateJSON { file = fmt.Sprintf("%s-%s.json", name, trailing) } else { @@ -292,11 +295,6 @@ func Print(name, path string, trailing string, data []byte, toStdout, generateJS } else { // Write content separately to each file file = filepath.Join(path, file) - - // simple hack to remove status from the output - re := regexp.MustCompile(`(?s)status:.*`) - data = re.ReplaceAll(data, nil) - if err := os.WriteFile(file, data, 0644); err != nil { return "", errors.Wrap(err, "Failed to write %s: "+trailing) } diff --git a/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml b/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml index 831d5053e..a6f9d3dfb 100644 --- a/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml +++ b/script/test/fixtures/change-in-volume/output-k8s-empty-vols-template.yaml @@ -17,8 +17,6 @@ spec: targetPort: 0 selector: io.kompose.service: redis -status: - loadBalancer: {} --- apiVersion: v1 @@ -36,8 +34,6 @@ spec: targetPort: 5000 selector: io.kompose.service: web -status: - loadBalancer: {} --- apiVersion: apps/v1 @@ -70,7 +66,6 @@ spec: name: redis resources: {} restartPolicy: Always -status: {} --- apiVersion: apps/v1 @@ -112,6 +107,4 @@ spec: restartPolicy: Always volumes: - emptyDir: {} - name: code-volume -status: {} - + name: code-volume \ No newline at end of file diff --git a/script/test/fixtures/change-in-volume/output-k8s.yaml b/script/test/fixtures/change-in-volume/output-k8s.yaml index 831d5053e..08a793c51 100644 --- a/script/test/fixtures/change-in-volume/output-k8s.yaml +++ b/script/test/fixtures/change-in-volume/output-k8s.yaml @@ -17,9 +17,6 @@ spec: targetPort: 0 selector: io.kompose.service: redis -status: - loadBalancer: {} - --- apiVersion: v1 kind: Service @@ -36,9 +33,6 @@ spec: targetPort: 5000 selector: io.kompose.service: web -status: - loadBalancer: {} - --- apiVersion: apps/v1 kind: Deployment @@ -70,8 +64,6 @@ spec: name: redis resources: {} restartPolicy: Always -status: {} - --- apiVersion: apps/v1 kind: Deployment @@ -112,6 +104,4 @@ spec: restartPolicy: Always volumes: - emptyDir: {} - name: code-volume -status: {} - + name: code-volume \ No newline at end of file diff --git a/script/test/fixtures/compose-env-interpolation/output-k8s.yaml b/script/test/fixtures/compose-env-interpolation/output-k8s.yaml index 109ea022a..dafe71437 100644 --- a/script/test/fixtures/compose-env-interpolation/output-k8s.yaml +++ b/script/test/fixtures/compose-env-interpolation/output-k8s.yaml @@ -29,8 +29,6 @@ spec: name: foo resources: {} restartPolicy: Always -status: {} - --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy diff --git a/script/test/fixtures/compose-file-support/output-k8s.yaml b/script/test/fixtures/compose-file-support/output-k8s.yaml index ac7350236..e956c765b 100644 --- a/script/test/fixtures/compose-file-support/output-k8s.yaml +++ b/script/test/fixtures/compose-file-support/output-k8s.yaml @@ -14,9 +14,6 @@ spec: targetPort: 80 selector: io.kompose.service: web -status: - loadBalancer: {} - --- apiVersion: apps/v1 kind: Deployment @@ -47,6 +44,4 @@ spec: hostPort: 80 protocol: TCP resources: {} - restartPolicy: Always -status: {} - + restartPolicy: Always \ No newline at end of file diff --git a/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml b/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml index a72027acc..f7dff43c9 100644 --- a/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml +++ b/script/test/fixtures/configmap-volume/output-k8s-withlabel.yaml @@ -41,8 +41,6 @@ spec: path: configs.tar name: db-cm0 name: db-cm0 -status: {} - --- apiVersion: v1 binaryData: @@ -105,8 +103,6 @@ spec: path: test-a-key.key name: web-cm1 name: web-cm1 -status: {} - --- apiVersion: v1 data: diff --git a/script/test/fixtures/configmap-volume/output-k8s.yaml b/script/test/fixtures/configmap-volume/output-k8s.yaml index 895322f8c..d08fc91d2 100644 --- a/script/test/fixtures/configmap-volume/output-k8s.yaml +++ b/script/test/fixtures/configmap-volume/output-k8s.yaml @@ -37,7 +37,6 @@ spec: path: configs.tar name: db-cm0 name: db-cm0 -status: {} --- apiVersion: v1 @@ -97,8 +96,6 @@ spec: path: test-a-key.key name: web-cm1 name: web-cm1 -status: {} - --- apiVersion: v1 data: diff --git a/script/test/fixtures/custom-build-push/output-k8s.yaml b/script/test/fixtures/custom-build-push/output-k8s.yaml index 32d118b67..77893140b 100644 --- a/script/test/fixtures/custom-build-push/output-k8s.yaml +++ b/script/test/fixtures/custom-build-push/output-k8s.yaml @@ -24,8 +24,6 @@ spec: name: nginx resources: {} restartPolicy: Always -status: {} - --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy diff --git a/script/test/fixtures/deploy/placement/output-placement-k8s.yaml b/script/test/fixtures/deploy/placement/output-placement-k8s.yaml index 46e5db6c8..35445415a 100644 --- a/script/test/fixtures/deploy/placement/output-placement-k8s.yaml +++ b/script/test/fixtures/deploy/placement/output-placement-k8s.yaml @@ -14,9 +14,6 @@ spec: targetPort: 6379 selector: io.kompose.service: redis -status: - loadBalancer: {} - --- apiVersion: apps/v1 kind: Deployment @@ -77,5 +74,3 @@ spec: maxSkew: 1 topologyKey: ssd whenUnsatisfiable: ScheduleAnyway -status: {} - diff --git a/script/test/fixtures/env/output-k8s.yaml b/script/test/fixtures/env/output-k8s.yaml index a885df994..17acdace9 100644 --- a/script/test/fixtures/env/output-k8s.yaml +++ b/script/test/fixtures/env/output-k8s.yaml @@ -1,12 +1,29 @@ --- apiVersion: v1 kind: Service +metadata: + creationTimestamp: null + labels: + io.kompose.service: another-namenode + name: another-namenode +spec: + ports: + - name: "50070" + port: 50070 + targetPort: 50070 + - name: "8020" + port: 8020 + targetPort: 8020 + selector: + io.kompose.service: another-namenode +--- +apiVersion: v1 +kind: Service metadata: creationTimestamp: null labels: io.kompose.service: namenode name: namenode - namespace: default spec: ports: - name: "50070" @@ -17,9 +34,6 @@ spec: targetPort: 8020 selector: io.kompose.service: namenode -status: - loadBalancer: {} - --- apiVersion: apps/v1 kind: Deployment @@ -28,7 +42,6 @@ metadata: labels: io.kompose.service: another-namenode name: another-namenode - namespace: default spec: replicas: 1 selector: @@ -56,10 +69,15 @@ spec: name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env image: bde2020/hadoop-namenode:2.0.0-hadoop2.7.4-java8 name: another-namenode + ports: + - containerPort: 50070 + hostPort: 50070 + protocol: TCP + - containerPort: 8020 + hostPort: 8020 + protocol: TCP resources: {} restartPolicy: Always -status: {} - --- apiVersion: v1 data: @@ -71,8 +89,6 @@ metadata: labels: io.kompose.service: another-namenode-home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env name: home-runner-work-kompose-kompose-script-test-fixtures-env-hadoop-hive-namenode-env - namespace: default - --- apiVersion: apps/v1 kind: Deployment @@ -81,7 +97,6 @@ metadata: labels: io.kompose.service: namenode name: namenode - namespace: default spec: replicas: 1 selector: @@ -119,6 +134,4 @@ spec: hostPort: 8020 protocol: TCP resources: {} - restartPolicy: Always -status: {} - + restartPolicy: Always \ No newline at end of file diff --git a/script/test/fixtures/envvars-interpolation/output-k8s.yaml b/script/test/fixtures/envvars-interpolation/output-k8s.yaml index 9a58466dd..1a42cb21b 100644 --- a/script/test/fixtures/envvars-interpolation/output-k8s.yaml +++ b/script/test/fixtures/envvars-interpolation/output-k8s.yaml @@ -33,5 +33,5 @@ spec: name: myservice resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/expose/output-k8s.yaml b/script/test/fixtures/expose/output-k8s.yaml index 2f2311c1b..b92dc4b73 100644 --- a/script/test/fixtures/expose/output-k8s.yaml +++ b/script/test/fixtures/expose/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 6379 selector: io.kompose.service: redis -status: - loadBalancer: {} + --- apiVersion: v1 @@ -37,8 +36,7 @@ spec: targetPort: 5000 selector: io.kompose.service: web -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -70,7 +68,7 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + --- apiVersion: apps/v1 @@ -111,7 +109,7 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + --- apiVersion: networking.k8s.io/v1 @@ -154,6 +152,5 @@ spec: - batman.example.com - batwoman.example.com secretName: test-secret -status: - loadBalancer: {} + diff --git a/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml b/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml index b5f9a93fb..5944f3770 100644 --- a/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml +++ b/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml @@ -21,8 +21,7 @@ spec: selector: io.kompose.service: front-end type: LoadBalancer -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -68,5 +67,5 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml b/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml index 656c7c07b..79fffadec 100644 --- a/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml +++ b/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml @@ -21,8 +21,7 @@ spec: selector: io.kompose.service: front-end type: ClusterIP -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -68,7 +67,7 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + --- apiVersion: networking.k8s.io/v1 @@ -97,6 +96,5 @@ spec: number: 80 path: / pathType: Prefix -status: - loadBalancer: {} + diff --git a/script/test/fixtures/fsgroup/output-k8s.yaml b/script/test/fixtures/fsgroup/output-k8s.yaml index 95ad09ef2..dc66788cd 100644 --- a/script/test/fixtures/fsgroup/output-k8s.yaml +++ b/script/test/fixtures/fsgroup/output-k8s.yaml @@ -43,7 +43,7 @@ spec: - name: pgadmin-data persistentVolumeClaim: claimName: pgadmin-data -status: {} + --- apiVersion: v1 @@ -59,7 +59,7 @@ spec: resources: requests: storage: 100Mi -status: {} + --- apiVersion: networking.k8s.io/v1 diff --git a/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml b/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml index 55ba111bf..3380594bf 100644 --- a/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml +++ b/script/test/fixtures/healthcheck/output-healthcheck-k8s.yaml @@ -21,8 +21,7 @@ spec: targetPort: 27017 selector: io.kompose.service: my-group -status: - loadBalancer: {} + --- apiVersion: v1 @@ -47,8 +46,7 @@ spec: targetPort: 3306 selector: io.kompose.service: my-group -status: - loadBalancer: {} + --- apiVersion: v1 @@ -74,8 +72,7 @@ spec: targetPort: 5432 selector: io.kompose.service: postgresql -status: - loadBalancer: {} + --- apiVersion: v1 @@ -98,8 +95,7 @@ spec: targetPort: 6379 selector: io.kompose.service: redis -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -175,7 +171,7 @@ spec: timeoutSeconds: 2 resources: {} restartPolicy: Always -status: {} + --- apiVersion: apps/v1 @@ -237,7 +233,7 @@ spec: timeoutSeconds: 1 resources: {} restartPolicy: Always -status: {} + --- apiVersion: apps/v1 @@ -294,5 +290,5 @@ spec: timeoutSeconds: 1 resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/host-port-protocol/output-k8s.yaml b/script/test/fixtures/host-port-protocol/output-k8s.yaml index 32b1f5c7f..f1da086d2 100644 --- a/script/test/fixtures/host-port-protocol/output-k8s.yaml +++ b/script/test/fixtures/host-port-protocol/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 80 selector: io.kompose.service: nginx -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -48,5 +47,5 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/multiple-files/output-k8s.yaml b/script/test/fixtures/multiple-files/output-k8s.yaml index 2934ed6d4..a5667860e 100644 --- a/script/test/fixtures/multiple-files/output-k8s.yaml +++ b/script/test/fixtures/multiple-files/output-k8s.yaml @@ -25,7 +25,7 @@ spec: name: bar resources: {} restartPolicy: Always -status: {} + --- apiVersion: apps/v1 @@ -54,5 +54,5 @@ spec: name: foo resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/multiple-type-volumes/output-k8s.yaml b/script/test/fixtures/multiple-type-volumes/output-k8s.yaml index a67801bc4..d80e5f8f3 100644 --- a/script/test/fixtures/multiple-type-volumes/output-k8s.yaml +++ b/script/test/fixtures/multiple-type-volumes/output-k8s.yaml @@ -37,7 +37,7 @@ spec: - name: db-data persistentVolumeClaim: claimName: db-data -status: {} + --- apiVersion: v1 @@ -54,7 +54,7 @@ spec: resources: requests: storage: 100Mi -status: {} + --- apiVersion: apps/v1 @@ -104,7 +104,7 @@ spec: path: test-a-key.key name: web-cm1 name: web-cm1 -status: {} + --- apiVersion: v1 diff --git a/script/test/fixtures/namespace/output-k8s.yaml b/script/test/fixtures/namespace/output-k8s.yaml index 5d262bfcf..fcb0e2322 100644 --- a/script/test/fixtures/namespace/output-k8s.yaml +++ b/script/test/fixtures/namespace/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 80 selector: io.kompose.service: web -status: - loadBalancer: {} + --- apiVersion: v1 @@ -25,7 +24,7 @@ metadata: name: web namespace: web spec: {} -status: {} + --- apiVersion: apps/v1 @@ -58,5 +57,5 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/network-policies/output-k8s.yaml b/script/test/fixtures/network-policies/output-k8s.yaml index 049edeabb..6dc3a1571 100644 --- a/script/test/fixtures/network-policies/output-k8s.yaml +++ b/script/test/fixtures/network-policies/output-k8s.yaml @@ -24,7 +24,7 @@ spec: name: nginx resources: {} restartPolicy: Always -status: {} + --- apiVersion: networking.k8s.io/v1 diff --git a/script/test/fixtures/read-only/output-k8s.yaml b/script/test/fixtures/read-only/output-k8s.yaml index 7d7d3fbf5..4f97db89b 100644 --- a/script/test/fixtures/read-only/output-k8s.yaml +++ b/script/test/fixtures/read-only/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 80 selector: io.kompose.service: test -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -50,5 +49,5 @@ spec: securityContext: readOnlyRootFilesystem: true restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/service-group/output-k8s.yaml b/script/test/fixtures/service-group/output-k8s.yaml index a639d78e1..395558458 100644 --- a/script/test/fixtures/service-group/output-k8s.yaml +++ b/script/test/fixtures/service-group/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 8000 selector: io.kompose.service: dispatcher-librenms -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -67,7 +66,7 @@ spec: - name: dispatcher-librenms-claim0 persistentVolumeClaim: claimName: dispatcher-librenms-claim0 -status: {} + --- apiVersion: v1 @@ -84,5 +83,5 @@ spec: resources: requests: storage: 100Mi -status: {} + diff --git a/script/test/fixtures/single-file-output/output-k8s.yaml b/script/test/fixtures/single-file-output/output-k8s.yaml index d1e5dd28b..1435452f8 100644 --- a/script/test/fixtures/single-file-output/output-k8s.yaml +++ b/script/test/fixtures/single-file-output/output-k8s.yaml @@ -17,8 +17,7 @@ spec: targetPort: 80 selector: io.kompose.service: front-end -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -60,7 +59,7 @@ spec: protocol: TCP resources: {} restartPolicy: Always -status: {} + --- apiVersion: networking.k8s.io/v1 @@ -87,6 +86,5 @@ spec: number: 80 path: / pathType: Prefix -status: - loadBalancer: {} + diff --git a/script/test/fixtures/statefulset/output-k8s.yaml b/script/test/fixtures/statefulset/output-k8s.yaml index fcdae4d77..0de21470b 100644 --- a/script/test/fixtures/statefulset/output-k8s.yaml +++ b/script/test/fixtures/statefulset/output-k8s.yaml @@ -16,8 +16,7 @@ spec: selector: io.kompose.service: db type: ClusterIP -status: - loadBalancer: {} + --- apiVersion: v1 @@ -37,8 +36,7 @@ spec: selector: io.kompose.service: wordpress type: ClusterIP -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -96,10 +94,6 @@ spec: resources: requests: storage: 100Mi - status: {} -status: - availableReplicas: 0 - replicas: 0 --- apiVersion: apps/v1 @@ -157,8 +151,4 @@ spec: resources: requests: storage: 100Mi - status: {} -status: - availableReplicas: 0 - replicas: 0 diff --git a/script/test/fixtures/v2/output-k8s.yaml b/script/test/fixtures/v2/output-k8s.yaml index 3a9c0a3df..6cef2ca8d 100644 --- a/script/test/fixtures/v2/output-k8s.yaml +++ b/script/test/fixtures/v2/output-k8s.yaml @@ -86,8 +86,7 @@ spec: targetPort: 5010 selector: io.kompose.service: foo -status: - loadBalancer: {} + --- apiVersion: v1 @@ -107,8 +106,7 @@ spec: selector: io.kompose.service: redis type: LoadBalancer -status: - loadBalancer: {} + --- apiVersion: v1 @@ -129,8 +127,7 @@ spec: selector: io.kompose.service: redis type: LoadBalancer -status: - loadBalancer: {} + --- apiVersion: v1 @@ -232,7 +229,7 @@ spec: securityContext: supplementalGroups: - 1234 -status: {} + --- apiVersion: networking.k8s.io/v1 @@ -288,5 +285,5 @@ spec: limits: memory: "10485760e3" restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/v3.0/output-k8s.yaml b/script/test/fixtures/v3.0/output-k8s.yaml index f339d4c34..c61a9cef3 100644 --- a/script/test/fixtures/v3.0/output-k8s.yaml +++ b/script/test/fixtures/v3.0/output-k8s.yaml @@ -17,8 +17,7 @@ spec: targetPort: 0 selector: io.kompose.service: redis -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -53,7 +52,7 @@ spec: name: foo resources: {} restartPolicy: Always -status: {} + --- apiVersion: apps/v1 @@ -93,5 +92,5 @@ spec: name: redis resources: {} restartPolicy: Always -status: {} + diff --git a/script/test/fixtures/vols-subpath/output-k8s.yaml b/script/test/fixtures/vols-subpath/output-k8s.yaml index 13d7daf47..c8914cd88 100644 --- a/script/test/fixtures/vols-subpath/output-k8s.yaml +++ b/script/test/fixtures/vols-subpath/output-k8s.yaml @@ -44,7 +44,7 @@ spec: - name: postgres-data persistentVolumeClaim: claimName: postgres-data -status: {} + --- apiVersion: v1 @@ -60,7 +60,7 @@ spec: resources: requests: storage: 100Mi -status: {} + --- apiVersion: networking.k8s.io/v1 diff --git a/script/test/fixtures/volume-mounts/windows/output-k8s.yaml b/script/test/fixtures/volume-mounts/windows/output-k8s.yaml index c4fdc940b..64b0a2e80 100644 --- a/script/test/fixtures/volume-mounts/windows/output-k8s.yaml +++ b/script/test/fixtures/volume-mounts/windows/output-k8s.yaml @@ -14,8 +14,7 @@ spec: targetPort: 80 selector: io.kompose.service: db -status: - loadBalancer: {} + --- apiVersion: apps/v1 @@ -55,7 +54,7 @@ spec: - name: db-claim0 persistentVolumeClaim: claimName: db-claim0 -status: {} + --- apiVersion: v1 @@ -72,5 +71,5 @@ spec: resources: requests: storage: 100Mi -status: {} +