Skip to content

Commit

Permalink
Kubernetes API paths are now part of K8S global dict
Browse files Browse the repository at this point in the history
  • Loading branch information
psyhomb committed Sep 16, 2017
1 parent 4330770 commit 280de00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ Specification descriptor:
"namespace": null,
"objects": {
"deployments": {
"api_path": "apis/apps/v1beta1",
"specification": {
"### Kubernetes deployment object spec goes here"
}
},
"services": {
"api_path": "api/v1",
"specification": {
"### Kubernetes service object spec goes here"
}
Expand Down
8 changes: 5 additions & 3 deletions examples/echoserver.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"namespace": null,
"objects": {
"deployments": {
"api_path": "apis/apps/v1beta1",
"specification": {
"kind": "Deployment",
"apiVersion": "apps/v1beta1",
"metadata": {
"name": "echoserver",
"creationTimestamp": null,
Expand All @@ -30,7 +31,7 @@
"containers": [
{
"name": "echoserver",
"image": "gcr.io/google_containers/echoserver:1.6",
"image": "gcr.io/google_containers/echoserver:1.8",
"ports": [
{
"containerPort": 8080,
Expand Down Expand Up @@ -71,8 +72,9 @@
}
},
"services": {
"api_path": "api/v1",
"specification": {
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "echoserver",
"creationTimestamp": null,
Expand Down
11 changes: 2 additions & 9 deletions k8s-deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ def spec_validator(data):
'deployments': {
'type': 'object',
'properties': {
'api_path': {
'type': 'string'
},
'specification': {
'type': 'object'
}
Expand All @@ -110,9 +107,6 @@ def spec_validator(data):
'services': {
'type': 'object',
'properties': {
'api_path': {
'type': 'string'
},
'specification': {
'type': 'object'
}
Expand Down Expand Up @@ -170,7 +164,7 @@ def create_object(k8s_host, **kwargs):
objects = kwargs['objects']

for obj in objects:
api_path = objects[obj]['api_path']
api_path = K8S_API[obj]
url = '{}/{}/namespaces/{}/{}'.format(
k8s_host, api_path,
namespace, obj
Expand Down Expand Up @@ -230,8 +224,8 @@ def delete_object(k8s_host, **kwargs):
objects = kwargs['objects']

for obj in objects.keys() + ['replicasets']:
api_path = K8S_API[obj]
if obj == 'replicasets':
api_path = K8S_API['replicasets']
rs_label_selector = (kwargs['objects']['deployments']
['specification']['spec']['selector']['matchLabels']
)
Expand All @@ -245,7 +239,6 @@ def delete_object(k8s_host, **kwargs):
)
obj_name = req('GET', url)['items'][0]['metadata']['name']
else:
api_path = objects[obj]['api_path']
obj_name = (kwargs['objects']['services']
['specification']['metadata']['name']
)
Expand Down

0 comments on commit 280de00

Please sign in to comment.