Skip to content

Commit 72ce7e4

Browse files
committed
Merge pull request #49 from totem/develop
0.4.0 Release
2 parents 0829617 + 73567fb commit 72ce7e4

File tree

10 files changed

+254
-43
lines changed

10 files changed

+254
-43
lines changed

apiary.apib

Lines changed: 197 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,210 @@
11
FORMAT: 1A
22

33
# cluster-orchestrator
4-
Notes API is a *short texts saving* service similar to its physical paper presence on your table.
5-
6-
# Group Notes
7-
Notes related resources of the **Notes API**
8-
9-
## Notes Collection [/notes]
10-
### List all Notes [GET]
11-
+ Response 200 (application/json)
12-
13-
[{
14-
"id": 1, "title": "Jogging in park"
15-
}, {
16-
"id": 2, "title": "Pick-up posters from post-office"
17-
}]
18-
19-
### Create a Note [POST]
20-
+ Request (application/json)
21-
22-
{ "title": "Buy cheese and bread for breakfast." }
23-
24-
+ Response 201 (application/json)
25-
26-
{ "id": 3, "title": "Buy cheese and bread for breakfast." }
4+
API for orchestrator used in totem v2. All public facing api use /external as route path prefix.
5+
6+
## Generic Internal Hook [POST /hooks/generic]
7+
API for posting custom callback hook to internal orchestrator api.
8+
9+
*Note: Orchestrator does not clone the repository and simply use git information
10+
as meta-information for locating totem.yml. This file need not be present in git repository and can be stored in other config providers like s3, etcd.*
11+
12+
+ Request
13+
14+
+ Headers
15+
16+
Content-Type: application/vnd.orch.generic.hook.v1+json
17+
Accept: application/vnd.orch.task.v1+json, application/json
18+
19+
+ Schema
20+
21+
{
22+
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
23+
"type": "object",
24+
"title": "Schema for Generic Hook payload",
25+
"id": "#generic-hook-v1",
26+
"properties": {
27+
"git": {
28+
"description": "Git meta-information used for locating totem.yml."
29+
"$ref": "#/definitions/git"
30+
},
31+
"name": {
32+
"description": "Name of the hook (e.g. image-factory)",
33+
"type": "string",
34+
"maxLength": 100
35+
},
36+
"type": {
37+
"description": "Type of the hook (e.g. builder, ci)",
38+
"enum": ["builder", "ci", "scm-create", "scm-push"]
39+
},
40+
"status": {
41+
"description": "Status for the hook (failed, success)",
42+
"enum": ["success", "failed"]
43+
},
44+
"result": {
45+
"description": "Result object",
46+
"type": "object"
47+
},
48+
"force-deploy": {
49+
"description": "Force deploy the image on receiving this hook (ignore status)",
50+
"type": "boolean"
51+
}
52+
},
53+
"additionalProperties": false,
54+
"required": ["name", "type", "git"],
55+
"definitions": {
56+
"git": {
57+
"properties": {
58+
"owner": {
59+
"title": "Owner/Organization of the SCM repository (e.g. totem)",
60+
"type": "string",
61+
"maxLength": 100
62+
},
63+
"repo": {
64+
"title": "SCM repository name (e.g.: spec-python)",
65+
"type": "string",
66+
"maxLength": 100
67+
},
68+
"ref": {
69+
"title": "Branch or tag name",
70+
"type": "string",
71+
"maxLength": 100
72+
},
73+
"commit": {
74+
"title": "Git SHA Commit ID",
75+
"type": ["string", "null"],
76+
"maxLength": 100
77+
}
78+
},
79+
"additionalProperties": false,
80+
"required": ["owner", "repo", "ref"]
81+
}
82+
}
83+
}
84+
85+
+ Body
86+
87+
{
88+
"git":{
89+
"owner": "totem",
90+
"repo": "totem-demo",
91+
"ref": "master",
92+
"commit": "75863c8b181c00a6e0f70ed3a876edc1b3a6a662"
93+
},
94+
"type": "builder",
95+
"name": "mybuilder",
96+
"status": "success",
97+
"force-deploy": true,
98+
"result": {
99+
"image": "totem/totem-demo:latest"
100+
}
101+
}
102+
103+
104+
+ Response 202 (application/vnd.orch.task.v1+json)
105+
106+
+ Headers
107+
108+
Location: /tasks/94ddd430-5e66-48d9-a1b4-f996b6bd2489
109+
110+
+ Body
111+
112+
{
113+
"task_id": "81b5de1c-a7af-4bc2-9593-644645f655bc"
114+
}
115+
116+
117+
## Get Asynchronous Task Status [GET /tasks/{task_id}]
27118

28-
## Note [/notes/{id}]
29-
A single Note object with all its details
119+
Gets status for asynchronous job created as a result of posting a new callback hook to orchestrator.
120+
*Note: The job status can also be obtained from elasticsearch if totem is setup to sync mongo with ES.*
30121

31122
+ Parameters
32-
+ id (required, number, `1`) ... Numeric `id` of the Note to perform action with. Has example value.
123+
+ task_id (required, string, `c47d3c50-2877-4119-850e-71aaae3d53ba`) ... Task ID (`task_id`)
33124

34-
### Retrieve a Note [GET]
35-
+ Response 200 (application/json)
125+
+ Request
36126

37-
+ Header
127+
+ Headers
128+
129+
Accept: application/json
38130

39-
X-My-Header: The Value
131+
+ Response 200
40132

41133
+ Body
134+
135+
{
136+
"output": {
137+
"config": {
138+
"deployers": {},
139+
"enabled": true,
140+
"hooks": {
141+
"builder": {
142+
"image-factory": {
143+
"enabled": true
144+
}
145+
},
146+
"ci": {
147+
"travis": {
148+
"enabled": false
149+
}
150+
},
151+
"scm-create": {
152+
"github-create": {
153+
"enabled": true
154+
}
155+
},
156+
"scm-push": {
157+
"github-push": {
158+
"enabled": true
159+
}
160+
}
161+
},
162+
"notifications": {},
163+
"scm": {
164+
"auth": {
165+
"token": ""
166+
},
167+
"type": "github"
168+
},
169+
"security": {
170+
"profile": "default"
171+
}
172+
},
173+
"force-deploy": false,
174+
"hooks": {
175+
"builder": {
176+
"image-factory": {
177+
"status": "pending"
178+
}
179+
},
180+
"ci": {},
181+
"scm-create": {
182+
"github-create": {
183+
"status": "pending"
184+
}
185+
},
186+
"scm-push": {
187+
"github-push": {
188+
"status": "pending"
189+
}
190+
}
191+
},
192+
"meta-info": {
193+
"git": {
194+
"commit": "c4084c20ba721be7c9d5d625c7749659cc4fd702",
195+
"commit-set": [
196+
"c4084c20ba721be7c9d5d625c7749659cc4fd702"
197+
],
198+
"owner": "totem",
199+
"ref": "develop",
200+
"repo": "cluster-orchestrator"
201+
},
202+
"job-id": "ac572a97-f285-4917-8ff4-4ecb8a142488"
203+
},
204+
"state": "NOOP"
205+
},
206+
"status": "READY"
207+
}
208+
42209

43-
{ "id": 2, "title": "Pick-up posters from post-office" }
44210

45-
### Remove a Note [DELETE]
46-
+ Response 204

dev-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ flake8
44
Sphinx==1.2.3
55

66
# For freezing time
7-
freezegun==0.2.8
7+
https://github.com/spulec/freezegun/archive/master.tar.gz
88

99
# Code Coverage
1010
coveralls
1111

12-
flower==0.7.2
12+
flower==0.7.2

orchestrator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from celery.signals import setup_logging
33
import orchestrator.logger
44

5-
__version__ = '0.3.10'
5+
__version__ = '0.4.0'
66
__author__ = 'sukrit'
77

88
orchestrator.logger.init_logging()

orchestrator/tasks/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def _deploy(self, job, deployer_name):
461461
'templates': deployer['templates'],
462462
'deployment': dict_merge(deployer['deployment']),
463463
'security': job_config.get('security', {}),
464-
'notifications': job_config.get('notifications', {})
464+
'notifications': job_config.get('notifications', {}),
465+
'environment': job_config.get('environment', {})
465466
}
466467
try:
467468
response = requests.post(apps_url, data=json.dumps(data),

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Flask==0.10.1
22
Flask-Cors==1.9.0
3-
gevent==1.0.1
4-
uWSGI==2.0.7
3+
gevent==1.0.2
4+
uWSGI==2.0.12
55
python-etcd==0.3.3
66
future==0.15.0
77
PyYAML==3.11

schemas/job-config-evaluated-v1.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
},
2828
"scm": {
2929
"type": "object"
30+
},
31+
"environment": {
32+
"type": "object",
33+
"$ref": "#/definitions/environment",
34+
"description": "Defines top level environment (key, value) support"
3035
}
3136
},
3237
"required": ["enabled"],
@@ -403,6 +408,22 @@
403408
}
404409
},
405410
"additionalProperties": true
411+
},
412+
"environment": {
413+
"patternProperties": {
414+
".*": {
415+
"oneOf": [
416+
{
417+
"type": "string",
418+
"maxLength": 4096
419+
},
420+
{
421+
"$ref": "#/definitions/encrypted-type"
422+
}
423+
]
424+
}
425+
},
426+
"additionalProperties": false
406427
}
407428
}
408429
}

schemas/job-config-v1.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
},
3535
"scm": {
3636
"type": "object"
37+
},
38+
"environment": {
39+
"type": "object",
40+
"$ref": "#/definitions/environment",
41+
"description": "Defines top level environment (key, value) support"
3742
}
3843
},
3944
"required": ["enabled"],
@@ -509,6 +514,25 @@
509514
}
510515
},
511516
"additionalProperties": true
517+
},
518+
519+
"environment": {
520+
"type": "object",
521+
"patternProperties": {
522+
".*": {
523+
"oneOf": [
524+
{
525+
"type": "string",
526+
"maxLength": 4096
527+
},
528+
{
529+
"$ref": "#/definitions/encrypted-type"
530+
}
531+
]
532+
}
533+
},
534+
"additionalProperties": false
512535
}
536+
513537
}
514538
}

tests/integration/orchestrator/services/storage/test_mongo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from freezegun import freeze_time
44
import pymongo
55
import pytz
6-
from conf.appconfig import JOB_STATE_NEW, JOB_STATE_COMPLETE, JOB_STATE_FAILED, \
7-
JOB_STATE_SCHEDULED
6+
from conf.appconfig import JOB_STATE_NEW, JOB_STATE_COMPLETE, \
7+
JOB_STATE_FAILED, JOB_STATE_SCHEDULED
88
from orchestrator.services.storage.mongo import create
99
from nose.tools import ok_, eq_
1010
from orchestrator.util import dict_merge

tests/unit/orchestrator/services/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ def test_evaluate_config_with_deployers():
397397
},
398398
'deployer-name': 'deployer2',
399399
'deployment': {}
400+
400401
}
401402
}
402403
})

tests/unit/orchestrator/views/test_hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from flask import Flask
33
from mock import patch
44
from nose.tools import eq_
5-
from conf.appconfig import MIME_JSON, MIME_FORM_URL_ENC, MIME_GENERIC_HOOK_V1, \
6-
MIME_JOB_V1
5+
from conf.appconfig import MIME_JSON, MIME_FORM_URL_ENC, \
6+
MIME_GENERIC_HOOK_V1, MIME_JOB_V1
77
from orchestrator.server import app
88
from orchestrator.views.hooks import authorize
99

0 commit comments

Comments
 (0)