From 510dde198ce11ae6a794c0774d85a68dfa062250 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 20 Apr 2017 18:40:36 +0530 Subject: [PATCH] delete buildConfig based on label --- pkg/transformer/openshift/openshift.go | 3 +- .../fixtures/ngnix-node-redis/output-os.json | 280 +++++++++--------- 2 files changed, 148 insertions(+), 135 deletions(-) diff --git a/pkg/transformer/openshift/openshift.go b/pkg/transformer/openshift/openshift.go index 90a590e40..8e183c159 100644 --- a/pkg/transformer/openshift/openshift.go +++ b/pkg/transformer/openshift/openshift.go @@ -209,7 +209,8 @@ func initBuildConfig(name string, service kobject.ServiceConfig, composeFileDir APIVersion: "v1", }, ObjectMeta: api.ObjectMeta{ - Name: name, + Name: name, + Labels: transformer.ConfigLabels(name), }, Spec: buildapi.BuildConfigSpec{ Triggers: []buildapi.BuildTriggerPolicy{ diff --git a/script/test/fixtures/ngnix-node-redis/output-os.json b/script/test/fixtures/ngnix-node-redis/output-os.json index 23a6689fd..bff0a7f9c 100644 --- a/script/test/fixtures/ngnix-node-redis/output-os.json +++ b/script/test/fixtures/ngnix-node-redis/output-os.json @@ -3,6 +3,32 @@ "apiVersion": "v1", "metadata": {}, "items": [ + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": { + "ports": [ + { + "name": "80", + "port": 80, + "targetPort": 80 + } + ], + "selector": { + "io.kompose.service": "nginx" + } + }, + "status": { + "loadBalancer": {} + } + }, { "kind": "Service", "apiVersion": "v1", @@ -108,7 +134,7 @@ } }, { - "kind": "Service", + "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { "name": "nginx", @@ -118,19 +144,117 @@ } }, "spec": { - "ports": [ + "strategy": { + "resources": {} + }, + "triggers": [ { - "name": "80", - "port": 80, - "targetPort": 80 + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "nginx" + ], + "from": { + "kind": "ImageStreamTag", + "name": "nginx:latest" + } + } } ], + "replicas": 1, + "test": false, "selector": { "io.kompose.service": "nginx" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": { + "containers": [ + { + "name": "nginx", + "image": " ", + "ports": [ + { + "containerPort": 80 + } + ], + "resources": {} + } + ], + "restartPolicy": "Always" + } } }, + "status": {} + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": {}, "status": { - "loadBalancer": {} + "dockerImageRepository": "" + } + }, + { + "kind": "BuildConfig", + "apiVersion": "v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "io.kompose.service": "nginx" + } + }, + "spec": { + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange" + } + ], + "runPolicy": "Serial", + "source": { + "type": "Git", + "git": { + "uri": "git@github.com:kubernetes-incubator/kompose.git", + "ref": "HEAD" + }, + "contextDir": "script/test/fixtures/ngnix-node-redis/nginx" + }, + "strategy": { + "type": "Docker", + "dockerStrategy": {} + }, + "output": { + "to": { + "kind": "ImageStreamTag", + "name": "nginx:latest" + } + }, + "resources": {}, + "postCommit": {}, + "nodeSelector": null + }, + "status": { + "lastVersion": 0 } }, { @@ -216,7 +340,10 @@ "apiVersion": "v1", "metadata": { "name": "node1", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node1" + } }, "spec": { "triggers": [ @@ -231,7 +358,7 @@ "source": { "type": "Git", "git": { - "uri": "https://github.com/kubernetes-incubator/kompose.git", + "uri": "git@github.com:kubernetes-incubator/kompose.git", "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" @@ -337,7 +464,10 @@ "apiVersion": "v1", "metadata": { "name": "node2", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node2" + } }, "spec": { "triggers": [ @@ -352,7 +482,7 @@ "source": { "type": "Git", "git": { - "uri": "https://github.com/kubernetes-incubator/kompose.git", + "uri": "git@github.com:kubernetes-incubator/kompose.git", "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" @@ -458,7 +588,10 @@ "apiVersion": "v1", "metadata": { "name": "node3", - "creationTimestamp": null + "creationTimestamp": null, + "labels": { + "io.kompose.service": "node3" + } }, "spec": { "triggers": [ @@ -473,7 +606,7 @@ "source": { "type": "Git", "git": { - "uri": "https://github.com/kubernetes-incubator/kompose.git", + "uri": "git@github.com:kubernetes-incubator/kompose.git", "ref": "HEAD" }, "contextDir": "script/test/fixtures/ngnix-node-redis/node" @@ -586,127 +719,6 @@ "status": { "dockerImageRepository": "" } - }, - { - "kind": "DeploymentConfig", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "nginx" - } - }, - "spec": { - "strategy": { - "resources": {} - }, - "triggers": [ - { - "type": "ConfigChange" - }, - { - "type": "ImageChange", - "imageChangeParams": { - "automatic": true, - "containerNames": [ - "nginx" - ], - "from": { - "kind": "ImageStreamTag", - "name": "nginx:latest" - } - } - } - ], - "replicas": 1, - "test": false, - "selector": { - "io.kompose.service": "nginx" - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "io.kompose.service": "nginx" - } - }, - "spec": { - "containers": [ - { - "name": "nginx", - "image": " ", - "ports": [ - { - "containerPort": 80 - } - ], - "resources": {} - } - ], - "restartPolicy": "Always" - } - } - }, - "status": {} - }, - { - "kind": "ImageStream", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null, - "labels": { - "io.kompose.service": "nginx" - } - }, - "spec": {}, - "status": { - "dockerImageRepository": "" - } - }, - { - "kind": "BuildConfig", - "apiVersion": "v1", - "metadata": { - "name": "nginx", - "creationTimestamp": null - }, - "spec": { - "triggers": [ - { - "type": "ConfigChange" - }, - { - "type": "ImageChange" - } - ], - "runPolicy": "Serial", - "source": { - "type": "Git", - "git": { - "uri": "https://github.com/kubernetes-incubator/kompose.git", - "ref": "HEAD" - }, - "contextDir": "script/test/fixtures/ngnix-node-redis/nginx" - }, - "strategy": { - "type": "Docker", - "dockerStrategy": {} - }, - "output": { - "to": { - "kind": "ImageStreamTag", - "name": "nginx:latest" - } - }, - "resources": {}, - "postCommit": {}, - "nodeSelector": null - }, - "status": { - "lastVersion": 0 - } } ] -} \ No newline at end of file +}