Add build_args support in buildconfig
now args provided under build in docker-compose file can be available in buildconfig. it solves #406 Added unit test and functional test solves #445 Separated key:"value" pairs by spaces
This commit is contained in:
@@ -27,8 +27,6 @@ fi
|
||||
|
||||
# Warning Template
|
||||
warning="Buildconfig using $uri::$branch as source."
|
||||
# Replacing variables with current branch and uri
|
||||
sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json
|
||||
|
||||
#######
|
||||
# Tests related to docker-compose file in /script/test/fixtures/etherpad
|
||||
@@ -58,11 +56,15 @@ unset $(cat $KOMPOSE_ROOT/script/test/fixtures/gitlab/envs | cut -d'=' -f1)
|
||||
# kubernetes test
|
||||
convert::expect_success_and_warning "kompose -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-k8s.json" "Kubernetes provider doesn't support build key - ignoring"
|
||||
# openshift test
|
||||
# Replacing variables with current branch and uri
|
||||
sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json
|
||||
convert::expect_success_and_warning "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/docker-compose.yml convert --stdout -j" "/tmp/output-os.json" "$warning"
|
||||
rm /tmp/output-os.json
|
||||
|
||||
######
|
||||
# Tests related to docker-compose file in /script/test/fixtures/entrypoint-command
|
||||
# kubernetes test
|
||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json"
|
||||
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-k8s.json"
|
||||
# openshift test
|
||||
convert::expect_success "kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/docker-compose.yml convert --stdout -j" "$KOMPOSE_ROOT/script/test/fixtures/entrypoint-command/output-os.json"
|
||||
|
||||
@@ -209,6 +211,8 @@ convert::check_artifacts_generated "kompose -f $KOMPOSE_ROOT/script/test/fixture
|
||||
|
||||
####
|
||||
# Test regarding build context (running kompose from various directories)
|
||||
# Replacing variables with current branch and uri
|
||||
sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/output-os-template.json > /tmp/output-os.json
|
||||
CURRENT_DIR=$(pwd)
|
||||
cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/"
|
||||
convert::expect_success_and_warning "kompose convert --provider openshift --stdout -j" "/tmp/output-os.json" "$warning"
|
||||
@@ -217,6 +221,15 @@ convert::expect_success_and_warning "kompose convert --provider openshift --stdo
|
||||
cd "$KOMPOSE_ROOT/script/test/fixtures/nginx-node-redis/node"
|
||||
convert::expect_success_and_warning "kompose convert --provider openshift --stdout -j -f ../docker-compose.yml" "/tmp/output-os.json" "$warning"
|
||||
cd $CURRENT_DIR
|
||||
rm /tmp/output-os.json
|
||||
|
||||
|
||||
# Test the presence of build args in buildconfig
|
||||
# Replacing variables with current branch and uri
|
||||
sed -e "s;%URI%;$uri;g" -e "s;%REF%;$branch;g" $KOMPOSE_ROOT/script/test/fixtures/buildargs/output-os-template.json > /tmp/output-buildarg-os.json
|
||||
export $(cat $KOMPOSE_ROOT/script/test/fixtures/buildargs/envs)
|
||||
convert::expect_success_and_warning "kompose --provider openshift -f $KOMPOSE_ROOT/script/test/fixtures/buildargs/docker-compose.yml convert --stdout -j" "/tmp/output-buildarg-os.json" "$warning"
|
||||
rm /tmp/output-buildarg-os.json
|
||||
|
||||
# Test related to support docker-compose.yaml beside docker-compose.yml
|
||||
# Store the original path
|
||||
@@ -234,7 +247,4 @@ convert::expect_success "kompose --provider=openshift convert --stdout -j" "$KOM
|
||||
# Return back to the original path
|
||||
cd $CURRENT_DIR
|
||||
|
||||
# Removes generated output
|
||||
rm -rf /tmp/output-os.json
|
||||
|
||||
exit $EXIT_STATUS
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
## Docker Compose Buildargs
|
||||
|
||||
### Usage
|
||||
|
||||
The simplest thing to do:
|
||||
|
||||
```bash
|
||||
export $(cat envs)
|
||||
```
|
||||
|
||||
To customize the values edit `envs` file.
|
||||
@@ -0,0 +1,2 @@
|
||||
FROM busybox
|
||||
RUN touch /test
|
||||
@@ -0,0 +1,16 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
foo:
|
||||
build:
|
||||
context: "./build"
|
||||
args:
|
||||
NAME: web
|
||||
command: "sleep 3600"
|
||||
foo1:
|
||||
build:
|
||||
context: "./build"
|
||||
args:
|
||||
- NAME=web
|
||||
- foo
|
||||
command: "sleep 3600"
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
foo=bar
|
||||
@@ -0,0 +1,319 @@
|
||||
{
|
||||
"kind": "List",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {},
|
||||
"items": [
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo1",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo1"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ports": [
|
||||
{
|
||||
"name": "headless",
|
||||
"port": 55555,
|
||||
"targetPort": 0
|
||||
}
|
||||
],
|
||||
"selector": {
|
||||
"io.kompose.service": "foo1"
|
||||
},
|
||||
"clusterIP": "None"
|
||||
},
|
||||
"status": {
|
||||
"loadBalancer": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ports": [
|
||||
{
|
||||
"name": "headless",
|
||||
"port": 55555,
|
||||
"targetPort": 0
|
||||
}
|
||||
],
|
||||
"selector": {
|
||||
"io.kompose.service": "foo"
|
||||
},
|
||||
"clusterIP": "None"
|
||||
},
|
||||
"status": {
|
||||
"loadBalancer": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DeploymentConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo1",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo1"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"strategy": {
|
||||
"resources": {}
|
||||
},
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
},
|
||||
{
|
||||
"type": "ImageChange",
|
||||
"imageChangeParams": {
|
||||
"automatic": true,
|
||||
"containerNames": [
|
||||
"foo1"
|
||||
],
|
||||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "foo1:latest"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"replicas": 1,
|
||||
"test": false,
|
||||
"selector": {
|
||||
"io.kompose.service": "foo1"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo1"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"name": "foo1",
|
||||
"image": " ",
|
||||
"args": [
|
||||
"sleep",
|
||||
"3600"
|
||||
],
|
||||
"resources": {}
|
||||
}
|
||||
],
|
||||
"restartPolicy": "Always"
|
||||
}
|
||||
}
|
||||
},
|
||||
"status": {}
|
||||
},
|
||||
{
|
||||
"kind": "ImageStream",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo1",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo1"
|
||||
}
|
||||
},
|
||||
"spec": {},
|
||||
"status": {
|
||||
"dockerImageRepository": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "BuildConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo1",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": {
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
},
|
||||
{
|
||||
"type": "ImageChange"
|
||||
}
|
||||
],
|
||||
"runPolicy": "Serial",
|
||||
"source": {
|
||||
"type": "Git",
|
||||
"git": {
|
||||
"uri": "%URI%",
|
||||
"ref": "%REF%"
|
||||
},
|
||||
"contextDir": "script/test/fixtures/buildargs/build/"
|
||||
},
|
||||
"strategy": {
|
||||
"type": "Docker",
|
||||
"dockerStrategy": {
|
||||
"env": [
|
||||
{
|
||||
"name": "NAME",
|
||||
"value": "web"
|
||||
},
|
||||
{
|
||||
"name": "foo",
|
||||
"value": "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"to": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "foo1:latest"
|
||||
}
|
||||
},
|
||||
"resources": {},
|
||||
"postCommit": {},
|
||||
"nodeSelector": null
|
||||
},
|
||||
"status": {
|
||||
"lastVersion": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DeploymentConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"strategy": {
|
||||
"resources": {}
|
||||
},
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
},
|
||||
{
|
||||
"type": "ImageChange",
|
||||
"imageChangeParams": {
|
||||
"automatic": true,
|
||||
"containerNames": [
|
||||
"foo"
|
||||
],
|
||||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "foo:latest"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"replicas": 1,
|
||||
"test": false,
|
||||
"selector": {
|
||||
"io.kompose.service": "foo"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"name": "foo",
|
||||
"image": " ",
|
||||
"args": [
|
||||
"sleep",
|
||||
"3600"
|
||||
],
|
||||
"resources": {}
|
||||
}
|
||||
],
|
||||
"restartPolicy": "Always"
|
||||
}
|
||||
}
|
||||
},
|
||||
"status": {}
|
||||
},
|
||||
{
|
||||
"kind": "ImageStream",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"io.kompose.service": "foo"
|
||||
}
|
||||
},
|
||||
"spec": {},
|
||||
"status": {
|
||||
"dockerImageRepository": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "BuildConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "foo",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": {
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
},
|
||||
{
|
||||
"type": "ImageChange"
|
||||
}
|
||||
],
|
||||
"runPolicy": "Serial",
|
||||
"source": {
|
||||
"type": "Git",
|
||||
"git": {
|
||||
"uri": "%URI%",
|
||||
"ref": "%REF%"
|
||||
},
|
||||
"contextDir": "script/test/fixtures/buildargs/build/"
|
||||
},
|
||||
"strategy": {
|
||||
"type": "Docker",
|
||||
"dockerStrategy": {
|
||||
"env": [
|
||||
{
|
||||
"name": "NAME",
|
||||
"value": "web"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"to": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "foo:latest"
|
||||
}
|
||||
},
|
||||
"resources": {},
|
||||
"postCommit": {},
|
||||
"nodeSelector": null
|
||||
},
|
||||
"status": {
|
||||
"lastVersion": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user