Fix environment variables interpolation (#1524)

This commit is contained in:
AhmedGrati
2022-11-19 10:35:33 +08:00
committed by GitHub
parent 089e946489
commit acb8046f84
12 changed files with 288 additions and 18 deletions
+9 -1
View File
@@ -202,4 +202,12 @@ os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/mul
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-k8s.json"
os_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-type-volumes/output-os.json"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
convert::expect_success "$os_cmd" "$os_output"
convert::expect_success "$os_cmd" "$os_output"
# Test environment variables interpolation
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/docker-compose.yaml convert --stdout -j --with-kompose-annotation=false"
os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/docker-compose.yaml convert --stdout -j --with-kompose-annotation=false"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-k8s.json"
os_output="$KOMPOSE_ROOT/script/test/fixtures/envvars-interpolation/output-os.json"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
convert::expect_success "$os_cmd" "$os_output"
@@ -0,0 +1,13 @@
version: '3.5'
services:
myservice:
image: alpine
environment:
PROTOCOL: 'https'
DOMAIN: 'google.com'
command:
[
'curl',
'$PROTOCOL://$DOMAIN/',
]
@@ -0,0 +1,60 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Deployment",
"apiVersion": "apps/v1",
"metadata": {
"name": "myservice",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "myservice"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"io.kompose.service": "myservice"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "myservice"
}
},
"spec": {
"containers": [
{
"name": "myservice",
"image": "alpine",
"args": [
"curl",
"$(PROTOCOL)://$(DOMAIN)/"
],
"env": [
{
"name": "DOMAIN",
"value": "google.com"
},
{
"name": "PROTOCOL",
"value": "https"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
]
}
@@ -0,0 +1,120 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "myservice",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "myservice"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"myservice"
],
"from": {
"kind": "ImageStreamTag",
"name": "myservice:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "myservice"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "myservice"
}
},
"spec": {
"containers": [
{
"name": "myservice",
"image": " ",
"args": [
"curl",
"$(PROTOCOL)://$(DOMAIN)/"
],
"env": [
{
"name": "DOMAIN",
"value": "google.com"
},
{
"name": "PROTOCOL",
"value": "https"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {
"latestVersion": 0,
"observedGeneration": 0,
"replicas": 0,
"updatedReplicas": 0,
"availableReplicas": 0,
"unavailableReplicas": 0
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "myservice",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "myservice"
}
},
"spec": {
"lookupPolicy": {
"local": false
},
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "alpine"
},
"generation": null,
"importPolicy": {},
"referencePolicy": {
"type": ""
}
}
]
},
"status": {
"dockerImageRepository": ""
}
}
]
}