From e9f64cfd81dbedb4118f78e56206752376f32109 Mon Sep 17 00:00:00 2001 From: jose luis <2064537+sosan@users.noreply.github.com> Date: Wed, 10 Apr 2024 00:19:06 +0200 Subject: [PATCH] added more e2e, more tests fallback to skip volume mount and log warning when path cannot be resolved, as /sys, /root, /var/lib/docker in e2e TestMultipleContainersInPod directory /data replaced with /data-dir Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com> --- pkg/transformer/kubernetes/k8sutils.go | 30 +++- pkg/transformer/kubernetes/k8sutils_test.go | 59 ++++++- pkg/transformer/kubernetes/kubernetes.go | 11 +- pkg/transformer/kubernetes/kubernetes_test.go | 2 +- script/test/cmd/tests_new.sh | 25 ++- .../certs-level2/certs-level3/cert2.pem | 1 + .../{compose.yaml => compose-1.yaml} | 0 .../configmap-file-configs/compose-2.yaml | 17 ++ .../configmap-file-configs/compose-3.yaml | 10 ++ .../{output-k8s.yaml => output-k8s-1.yaml} | 0 .../configmap-file-configs/output-k8s-2.yaml | 137 +++++++++++++++ .../configmap-file-configs/output-k8s-3.yaml | 49 ++++++ .../configmap-file-configs/output-os-1.yaml | 144 +++++++++++++++ .../configmap-file-configs/output-os-2.yaml | 165 ++++++++++++++++++ .../configmap-file-configs/output-os-3.yaml | 77 ++++++++ 15 files changed, 711 insertions(+), 16 deletions(-) create mode 100644 script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem rename script/test/fixtures/configmap-file-configs/{compose.yaml => compose-1.yaml} (100%) create mode 100644 script/test/fixtures/configmap-file-configs/compose-2.yaml create mode 100644 script/test/fixtures/configmap-file-configs/compose-3.yaml rename script/test/fixtures/configmap-file-configs/{output-k8s.yaml => output-k8s-1.yaml} (100%) create mode 100644 script/test/fixtures/configmap-file-configs/output-k8s-2.yaml create mode 100644 script/test/fixtures/configmap-file-configs/output-k8s-3.yaml create mode 100644 script/test/fixtures/configmap-file-configs/output-os-1.yaml create mode 100644 script/test/fixtures/configmap-file-configs/output-os-2.yaml create mode 100644 script/test/fixtures/configmap-file-configs/output-os-3.yaml diff --git a/pkg/transformer/kubernetes/k8sutils.go b/pkg/transformer/kubernetes/k8sutils.go index 00ced438..d0cd6968 100644 --- a/pkg/transformer/kubernetes/k8sutils.go +++ b/pkg/transformer/kubernetes/k8sutils.go @@ -989,14 +989,18 @@ func reformatSecretConfigUnderscoreWithDash(secretConfig types.ServiceSecretConf // isConfigFile checks if the given filePath should be used as a configMap // if dir is not empty, withindir are treated as cofigmaps // if it's configMap, mount readonly as default -func isConfigFile(filePath string) (useConfigMap bool, readonly bool) { - if strings.HasSuffix(filePath, ".sock") { +func isConfigFile(filePath string) (useConfigMap bool, readonly bool, skip bool) { + if filePath == "" || strings.HasSuffix(filePath, ".sock") { + skip = true return } fi, err := os.Stat(filePath) if err != nil { - log.Warnf("Failed to check if the directory is empty: %v", err) + log.Warnf("File don't exist or failed to check if the directory is empty: %v", err) + // dir/file not exist + // here not assigned skip to true, + // maybe dont want to skip return } @@ -1004,26 +1008,36 @@ func isConfigFile(filePath string) (useConfigMap bool, readonly bool) { isDirEmpty, err := checkIsEmptyDir(filePath) if err != nil { log.Warnf("Failed to check if the directory is empty: %v", err) + skip = true return } if isDirEmpty { - return false, false + return } } - return true, true + return true, true, skip } // checkIsEmptyDir checks if filepath is empty func checkIsEmptyDir(filePath string) (bool, error) { - entries, err := os.ReadDir(filePath) + files, err := os.ReadDir(filePath) if err != nil { return false, err } - if len(entries) == 0 { + if len(files) == 0 { return true, err } - return false, err + for _, file := range files { + if !file.IsDir() { + return false, nil + } + _, err := checkIsEmptyDir(file.Name()) + if err != nil { + return false, err + } + } + return true, nil } // setVolumeAccessMode sets the access mode for a volume based on the mode string diff --git a/pkg/transformer/kubernetes/k8sutils_test.go b/pkg/transformer/kubernetes/k8sutils_test.go index 68e2aa92..c971df92 100644 --- a/pkg/transformer/kubernetes/k8sutils_test.go +++ b/pkg/transformer/kubernetes/k8sutils_test.go @@ -817,7 +817,17 @@ func Test_isConfigFile(t *testing.T) { args args wantUseConfigMap bool wantReadonly bool + wantSkip bool }{ + { + name: "dir not empty", + args: args{ + filePath: "../../../script/test/fixtures/configmap-file-configs/certs", + }, + wantUseConfigMap: true, + wantReadonly: true, + wantSkip: false, + }, { name: "sock", args: args{ @@ -825,6 +835,7 @@ func Test_isConfigFile(t *testing.T) { }, wantUseConfigMap: false, wantReadonly: false, + wantSkip: true, }, { name: "cannot resolve filepath", @@ -833,6 +844,7 @@ func Test_isConfigFile(t *testing.T) { }, wantUseConfigMap: false, wantReadonly: false, + wantSkip: false, }, { name: "file cert", @@ -841,25 +853,66 @@ func Test_isConfigFile(t *testing.T) { }, wantUseConfigMap: true, wantReadonly: true, + wantSkip: false, }, { - name: "dir not empty", + name: "docker sock", args: args{ - filePath: "../../../script/test/fixtures/configmap-file-configs/certs", + filePath: "/var/run/docker.sock", + }, + wantUseConfigMap: false, + wantReadonly: false, + wantSkip: true, + }, + { + name: "dir sys", + args: args{ + filePath: "/sys", + }, + wantUseConfigMap: false, + wantReadonly: false, + wantSkip: true, + }, + { + name: "dir root", + args: args{ + filePath: "/root", + }, + wantUseConfigMap: false, + wantReadonly: false, + wantSkip: true, + }, + { + name: "docker var lib", + args: args{ + filePath: "/var/lib/docker", + }, + wantUseConfigMap: false, + wantReadonly: false, + wantSkip: true, + }, + { + name: "file from 3 levels", + args: args{ + filePath: "../../../script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem", }, wantUseConfigMap: true, wantReadonly: true, + wantSkip: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotUseConfigMap, gotReadonly := isConfigFile(tt.args.filePath) + gotUseConfigMap, gotReadonly, gotSkip := isConfigFile(tt.args.filePath) if gotUseConfigMap != tt.wantUseConfigMap { t.Errorf("isConfigFile() gotUseConfigMap = %v, want %v", gotUseConfigMap, tt.wantUseConfigMap) } if gotReadonly != tt.wantReadonly { t.Errorf("isConfigFile() gotReadonly = %v, want %v", gotReadonly, tt.wantReadonly) } + if gotSkip != tt.wantSkip { + t.Errorf("isConfigFile() gotSkip = %v, want %v", gotSkip, tt.wantSkip) + } }) } } diff --git a/pkg/transformer/kubernetes/kubernetes.go b/pkg/transformer/kubernetes/kubernetes.go index 188925ee..a48e6e64 100644 --- a/pkg/transformer/kubernetes/kubernetes.go +++ b/pkg/transformer/kubernetes/kubernetes.go @@ -951,13 +951,22 @@ func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) ( volumes = append(volumes, secretsVolumes...) var count int + skip := false //iterating over array of `Vols` struct as it contains all necessary information about volumes for _, volume := range service.Volumes { // check if ro/rw mode is defined, default rw readonly := len(volume.Mode) > 0 && (volume.Mode == "ro" || volume.Mode == "rox") + mountHost := volume.Host + if mountHost == "" { + mountHost = volume.MountPath + } // return useconfigmap and readonly, // not used asigned readonly because dont break e2e - useConfigMap, _ = isConfigFile(volume.Host) + useConfigMap, _, skip = isConfigFile(mountHost) + if skip { + log.Warnf("Skip file in path %s ", volume.Host) + continue + } if volume.VolumeName == "" { if useEmptyVolumes { volumeName = strings.Replace(volume.PVCName, "claim", "empty", 1) diff --git a/pkg/transformer/kubernetes/kubernetes_test.go b/pkg/transformer/kubernetes/kubernetes_test.go index eb9991d1..cef3ebc4 100644 --- a/pkg/transformer/kubernetes/kubernetes_test.go +++ b/pkg/transformer/kubernetes/kubernetes_test.go @@ -757,7 +757,7 @@ func TestMultipleContainersInPod(t *testing.T) { config.Volumes = []kobject.Volumes{ { VolumeName: "mountVolume", - MountPath: "/data", + MountPath: "/data-dir", }, } return config diff --git a/script/test/cmd/tests_new.sh b/script/test/cmd/tests_new.sh index f918780a..07a058d0 100755 --- a/script/test/cmd/tests_new.sh +++ b/script/test/cmd/tests_new.sh @@ -340,7 +340,26 @@ os_output="$KOMPOSE_ROOT/script/test/fixtures/resources-lowercase/output-os.yaml convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 convert::expect_success "$os_cmd" "$os_output" || exit 1 -#Test configmaps -k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose.yaml convert --stdout --with-kompose-annotation=false" -k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s.yaml" +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-1.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-1.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-1.yaml" convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-2.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-2.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 + +#Test auto configmaps from files/dir +k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --stdout --with-kompose-annotation=false" +k8s_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml" +os_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/compose-3.yaml convert --provider openshift --stdout --with-kompose-annotation=false" +os_output="$KOMPOSE_ROOT/script/test/fixtures/configmap-file-configs/output-os-3.yaml" +convert::expect_success "$k8s_cmd" "$k8s_output" || exit 1 +convert::expect_success "$os_cmd" "$os_output" || exit 1 \ No newline at end of file diff --git a/script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem b/script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem new file mode 100644 index 00000000..d0e872f7 --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/certs-level1/certs-level2/certs-level3/cert2.pem @@ -0,0 +1 @@ +content from file cert2.pem \ No newline at end of file diff --git a/script/test/fixtures/configmap-file-configs/compose.yaml b/script/test/fixtures/configmap-file-configs/compose-1.yaml similarity index 100% rename from script/test/fixtures/configmap-file-configs/compose.yaml rename to script/test/fixtures/configmap-file-configs/compose-1.yaml diff --git a/script/test/fixtures/configmap-file-configs/compose-2.yaml b/script/test/fixtures/configmap-file-configs/compose-2.yaml new file mode 100644 index 00000000..b85af40a --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/compose-2.yaml @@ -0,0 +1,17 @@ +services: + busy: + image: busybox + ports: + - "8081:8080" + - "8026:8025" + volumes: + - ./certs:/certs + - ./certs-level1/certs-level2/certs-level3/cert2.pem:/certs/cert2.pem + - ./auth.txt:/auth.txt + - ./users.php:/users.php:ro + command: + [ + "/bin/sh", + "-c", + "cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem" + ] diff --git a/script/test/fixtures/configmap-file-configs/compose-3.yaml b/script/test/fixtures/configmap-file-configs/compose-3.yaml new file mode 100644 index 00000000..9fbc4e97 --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/compose-3.yaml @@ -0,0 +1,10 @@ +services: + busy: + image: busybox + ports: + - "8081:8080" + - "8026:8025" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - /sys:/sys:ro + - /var/lib/docker/:/var/lib/docker:ro diff --git a/script/test/fixtures/configmap-file-configs/output-k8s.yaml b/script/test/fixtures/configmap-file-configs/output-k8s-1.yaml similarity index 100% rename from script/test/fixtures/configmap-file-configs/output-k8s.yaml rename to script/test/fixtures/configmap-file-configs/output-k8s-1.yaml diff --git a/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml b/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml new file mode 100644 index 00000000..955f996c --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/output-k8s-2.yaml @@ -0,0 +1,137 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "8026" + port: 8026 + targetPort: 8025 + selector: + io.kompose.service: busy + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: busy + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/configmap-file-configs-default: "true" + io.kompose.service: busy + spec: + containers: + - args: + - /bin/sh + - -c + - cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem + image: busybox + name: busy + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + - containerPort: 8025 + hostPort: 8026 + protocol: TCP + volumeMounts: + - mountPath: /certs + name: busy-cm0 + - mountPath: /certs/cert2.pem + name: busy-cm1 + subPath: cert2.pem + - mountPath: /auth.txt + name: busy-cm2 + subPath: auth.txt + - mountPath: /users.php + name: busy-cm3 + readOnly: true + subPath: users.php + restartPolicy: Always + volumes: + - configMap: + name: busy-cm0 + name: busy-cm0 + - configMap: + items: + - key: cert2.pem + path: cert2.pem + name: busy-cm1 + name: busy-cm1 + - configMap: + items: + - key: auth.txt + path: auth.txt + name: busy-cm2 + name: busy-cm2 + - configMap: + items: + - key: users.php + path: users.php + name: busy-cm3 + name: busy-cm3 + +--- +apiVersion: v1 +data: + cert1.pem: | + content of file cert1.pem +kind: ConfigMap +metadata: + labels: + io.kompose.service: busy + name: busy-cm0 + +--- +apiVersion: v1 +data: + cert2.pem: content from file cert2.pem +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm1 + +--- +apiVersion: v1 +data: + auth.txt: | + content from file auth.txt +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm2 + +--- +apiVersion: v1 +data: + users.php: | + content from file users.php +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm3 diff --git a/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml b/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml new file mode 100644 index 00000000..1093dc4e --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/output-k8s-3.yaml @@ -0,0 +1,49 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "8026" + port: 8026 + targetPort: 8025 + selector: + io.kompose.service: busy + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: busy + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/configmap-file-configs-default: "true" + io.kompose.service: busy + spec: + containers: + - image: busybox + name: busy + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + - containerPort: 8025 + hostPort: 8026 + protocol: TCP + restartPolicy: Always diff --git a/script/test/fixtures/configmap-file-configs/output-os-1.yaml b/script/test/fixtures/configmap-file-configs/output-os-1.yaml new file mode 100644 index 00000000..67eed8a5 --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/output-os-1.yaml @@ -0,0 +1,144 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "8026" + port: 8026 + targetPort: 8025 + selector: + io.kompose.service: busy + +--- +apiVersion: apps.openshift.io/v1 +kind: DeploymentConfig +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + replicas: 1 + selector: + io.kompose.service: busy + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/configmap-file-configs-default: "true" + io.kompose.service: busy + spec: + containers: + - args: + - /bin/sh + - -c + - cat /auth.txt /users.php /certs/cert1.pem + image: ' ' + name: busy + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + - containerPort: 8025 + hostPort: 8026 + protocol: TCP + volumeMounts: + - mountPath: /certs + name: busy-cm0 + - mountPath: /auth.txt + name: busy-cm1 + subPath: auth.txt + - mountPath: /users.php + name: busy-cm2 + readOnly: true + subPath: users.php + restartPolicy: Always + volumes: + - configMap: + name: busy-cm0 + name: busy-cm0 + - configMap: + items: + - key: auth.txt + path: auth.txt + name: busy-cm1 + name: busy-cm1 + - configMap: + items: + - key: users.php + path: users.php + name: busy-cm2 + name: busy-cm2 + test: false + triggers: + - type: ConfigChange + - imageChangeParams: + automatic: true + containerNames: + - busy + from: + kind: ImageStreamTag + name: busy:latest + type: ImageChange + +--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + lookupPolicy: + local: false + tags: + - from: + kind: DockerImage + name: busybox + name: latest + referencePolicy: + type: "" + +--- +apiVersion: v1 +data: + cert1.pem: | + content of file cert1.pem +kind: ConfigMap +metadata: + labels: + io.kompose.service: busy + name: busy-cm0 + +--- +apiVersion: v1 +data: + auth.txt: | + content from file auth.txt +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm1 + +--- +apiVersion: v1 +data: + users.php: | + content from file users.php +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm2 diff --git a/script/test/fixtures/configmap-file-configs/output-os-2.yaml b/script/test/fixtures/configmap-file-configs/output-os-2.yaml new file mode 100644 index 00000000..d856cbd7 --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/output-os-2.yaml @@ -0,0 +1,165 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "8026" + port: 8026 + targetPort: 8025 + selector: + io.kompose.service: busy + +--- +apiVersion: apps.openshift.io/v1 +kind: DeploymentConfig +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + replicas: 1 + selector: + io.kompose.service: busy + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/configmap-file-configs-default: "true" + io.kompose.service: busy + spec: + containers: + - args: + - /bin/sh + - -c + - cat /auth.txt /users.php /certs/cert1.pem /certs/cert2.pem + image: ' ' + name: busy + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + - containerPort: 8025 + hostPort: 8026 + protocol: TCP + volumeMounts: + - mountPath: /certs + name: busy-cm0 + - mountPath: /certs/cert2.pem + name: busy-cm1 + subPath: cert2.pem + - mountPath: /auth.txt + name: busy-cm2 + subPath: auth.txt + - mountPath: /users.php + name: busy-cm3 + readOnly: true + subPath: users.php + restartPolicy: Always + volumes: + - configMap: + name: busy-cm0 + name: busy-cm0 + - configMap: + items: + - key: cert2.pem + path: cert2.pem + name: busy-cm1 + name: busy-cm1 + - configMap: + items: + - key: auth.txt + path: auth.txt + name: busy-cm2 + name: busy-cm2 + - configMap: + items: + - key: users.php + path: users.php + name: busy-cm3 + name: busy-cm3 + test: false + triggers: + - type: ConfigChange + - imageChangeParams: + automatic: true + containerNames: + - busy + from: + kind: ImageStreamTag + name: busy:latest + type: ImageChange + +--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + lookupPolicy: + local: false + tags: + - from: + kind: DockerImage + name: busybox + name: latest + referencePolicy: + type: "" + +--- +apiVersion: v1 +data: + cert1.pem: | + content of file cert1.pem +kind: ConfigMap +metadata: + labels: + io.kompose.service: busy + name: busy-cm0 + +--- +apiVersion: v1 +data: + cert2.pem: content from file cert2.pem +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm1 + +--- +apiVersion: v1 +data: + auth.txt: | + content from file auth.txt +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm2 + +--- +apiVersion: v1 +data: + users.php: | + content from file users.php +kind: ConfigMap +metadata: + annotations: + use-subpath: "true" + labels: + io.kompose.service: busy + name: busy-cm3 diff --git a/script/test/fixtures/configmap-file-configs/output-os-3.yaml b/script/test/fixtures/configmap-file-configs/output-os-3.yaml new file mode 100644 index 00000000..77cb3d68 --- /dev/null +++ b/script/test/fixtures/configmap-file-configs/output-os-3.yaml @@ -0,0 +1,77 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + ports: + - name: "8081" + port: 8081 + targetPort: 8080 + - name: "8026" + port: 8026 + targetPort: 8025 + selector: + io.kompose.service: busy + +--- +apiVersion: apps.openshift.io/v1 +kind: DeploymentConfig +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + replicas: 1 + selector: + io.kompose.service: busy + strategy: + type: Recreate + template: + metadata: + labels: + io.kompose.network/configmap-file-configs-default: "true" + io.kompose.service: busy + spec: + containers: + - image: ' ' + name: busy + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + - containerPort: 8025 + hostPort: 8026 + protocol: TCP + restartPolicy: Always + test: false + triggers: + - type: ConfigChange + - imageChangeParams: + automatic: true + containerNames: + - busy + from: + kind: ImageStreamTag + name: busy:latest + type: ImageChange + +--- +apiVersion: image.openshift.io/v1 +kind: ImageStream +metadata: + labels: + io.kompose.service: busy + name: busy +spec: + lookupPolicy: + local: false + tags: + - from: + kind: DockerImage + name: busybox + name: latest + referencePolicy: + type: ""