Skip to content

Commit

Permalink
Merge pull request #49 from totem/develop
Browse files Browse the repository at this point in the history
0.4.0 Release
  • Loading branch information
sukrit007 committed Jan 21, 2016
2 parents 0829617 + 73567fb commit 72ce7e4
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 43 deletions.
230 changes: 197 additions & 33 deletions apiary.apib
Original file line number Diff line number Diff line change
@@ -1,46 +1,210 @@
FORMAT: 1A

# cluster-orchestrator
Notes API is a *short texts saving* service similar to its physical paper presence on your table.

# Group Notes
Notes related resources of the **Notes API**

## Notes Collection [/notes]
### List all Notes [GET]
+ Response 200 (application/json)

[{
"id": 1, "title": "Jogging in park"
}, {
"id": 2, "title": "Pick-up posters from post-office"
}]

### Create a Note [POST]
+ Request (application/json)

{ "title": "Buy cheese and bread for breakfast." }

+ Response 201 (application/json)

{ "id": 3, "title": "Buy cheese and bread for breakfast." }
API for orchestrator used in totem v2. All public facing api use /external as route path prefix.

## Generic Internal Hook [POST /hooks/generic]
API for posting custom callback hook to internal orchestrator api.

*Note: Orchestrator does not clone the repository and simply use git information
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.*

+ Request

+ Headers

Content-Type: application/vnd.orch.generic.hook.v1+json
Accept: application/vnd.orch.task.v1+json, application/json

+ Schema

{
"$schema": "http://json-schema.org/draft-04/hyper-schema#",
"type": "object",
"title": "Schema for Generic Hook payload",
"id": "#generic-hook-v1",
"properties": {
"git": {
"description": "Git meta-information used for locating totem.yml."
"$ref": "#/definitions/git"
},
"name": {
"description": "Name of the hook (e.g. image-factory)",
"type": "string",
"maxLength": 100
},
"type": {
"description": "Type of the hook (e.g. builder, ci)",
"enum": ["builder", "ci", "scm-create", "scm-push"]
},
"status": {
"description": "Status for the hook (failed, success)",
"enum": ["success", "failed"]
},
"result": {
"description": "Result object",
"type": "object"
},
"force-deploy": {
"description": "Force deploy the image on receiving this hook (ignore status)",
"type": "boolean"
}
},
"additionalProperties": false,
"required": ["name", "type", "git"],
"definitions": {
"git": {
"properties": {
"owner": {
"title": "Owner/Organization of the SCM repository (e.g. totem)",
"type": "string",
"maxLength": 100
},
"repo": {
"title": "SCM repository name (e.g.: spec-python)",
"type": "string",
"maxLength": 100
},
"ref": {
"title": "Branch or tag name",
"type": "string",
"maxLength": 100
},
"commit": {
"title": "Git SHA Commit ID",
"type": ["string", "null"],
"maxLength": 100
}
},
"additionalProperties": false,
"required": ["owner", "repo", "ref"]
}
}
}

+ Body

{
"git":{
"owner": "totem",
"repo": "totem-demo",
"ref": "master",
"commit": "75863c8b181c00a6e0f70ed3a876edc1b3a6a662"
},
"type": "builder",
"name": "mybuilder",
"status": "success",
"force-deploy": true,
"result": {
"image": "totem/totem-demo:latest"
}
}


+ Response 202 (application/vnd.orch.task.v1+json)

+ Headers

Location: /tasks/94ddd430-5e66-48d9-a1b4-f996b6bd2489

+ Body

{
"task_id": "81b5de1c-a7af-4bc2-9593-644645f655bc"
}


## Get Asynchronous Task Status [GET /tasks/{task_id}]

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

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

### Retrieve a Note [GET]
+ Response 200 (application/json)
+ Request

+ Header
+ Headers

Accept: application/json

X-My-Header: The Value
+ Response 200

+ Body

{
"output": {
"config": {
"deployers": {},
"enabled": true,
"hooks": {
"builder": {
"image-factory": {
"enabled": true
}
},
"ci": {
"travis": {
"enabled": false
}
},
"scm-create": {
"github-create": {
"enabled": true
}
},
"scm-push": {
"github-push": {
"enabled": true
}
}
},
"notifications": {},
"scm": {
"auth": {
"token": ""
},
"type": "github"
},
"security": {
"profile": "default"
}
},
"force-deploy": false,
"hooks": {
"builder": {
"image-factory": {
"status": "pending"
}
},
"ci": {},
"scm-create": {
"github-create": {
"status": "pending"
}
},
"scm-push": {
"github-push": {
"status": "pending"
}
}
},
"meta-info": {
"git": {
"commit": "c4084c20ba721be7c9d5d625c7749659cc4fd702",
"commit-set": [
"c4084c20ba721be7c9d5d625c7749659cc4fd702"
],
"owner": "totem",
"ref": "develop",
"repo": "cluster-orchestrator"
},
"job-id": "ac572a97-f285-4917-8ff4-4ecb8a142488"
},
"state": "NOOP"
},
"status": "READY"
}


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

### Remove a Note [DELETE]
+ Response 204
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ flake8
Sphinx==1.2.3

# For freezing time
freezegun==0.2.8
https://github.com/spulec/freezegun/archive/master.tar.gz

# Code Coverage
coveralls

flower==0.7.2
flower==0.7.2
2 changes: 1 addition & 1 deletion orchestrator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from celery.signals import setup_logging
import orchestrator.logger

__version__ = '0.3.10'
__version__ = '0.4.0'
__author__ = 'sukrit'

orchestrator.logger.init_logging()
Expand Down
3 changes: 2 additions & 1 deletion orchestrator/tasks/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def _deploy(self, job, deployer_name):
'templates': deployer['templates'],
'deployment': dict_merge(deployer['deployment']),
'security': job_config.get('security', {}),
'notifications': job_config.get('notifications', {})
'notifications': job_config.get('notifications', {}),
'environment': job_config.get('environment', {})
}
try:
response = requests.post(apps_url, data=json.dumps(data),
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Flask==0.10.1
Flask-Cors==1.9.0
gevent==1.0.1
uWSGI==2.0.7
gevent==1.0.2
uWSGI==2.0.12
python-etcd==0.3.3
future==0.15.0
PyYAML==3.11
Expand Down
21 changes: 21 additions & 0 deletions schemas/job-config-evaluated-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
},
"scm": {
"type": "object"
},
"environment": {
"type": "object",
"$ref": "#/definitions/environment",
"description": "Defines top level environment (key, value) support"
}
},
"required": ["enabled"],
Expand Down Expand Up @@ -403,6 +408,22 @@
}
},
"additionalProperties": true
},
"environment": {
"patternProperties": {
".*": {
"oneOf": [
{
"type": "string",
"maxLength": 4096
},
{
"$ref": "#/definitions/encrypted-type"
}
]
}
},
"additionalProperties": false
}
}
}
24 changes: 24 additions & 0 deletions schemas/job-config-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
},
"scm": {
"type": "object"
},
"environment": {
"type": "object",
"$ref": "#/definitions/environment",
"description": "Defines top level environment (key, value) support"
}
},
"required": ["enabled"],
Expand Down Expand Up @@ -509,6 +514,25 @@
}
},
"additionalProperties": true
},

"environment": {
"type": "object",
"patternProperties": {
".*": {
"oneOf": [
{
"type": "string",
"maxLength": 4096
},
{
"$ref": "#/definitions/encrypted-type"
}
]
}
},
"additionalProperties": false
}

}
}
4 changes: 2 additions & 2 deletions tests/integration/orchestrator/services/storage/test_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from freezegun import freeze_time
import pymongo
import pytz
from conf.appconfig import JOB_STATE_NEW, JOB_STATE_COMPLETE, JOB_STATE_FAILED, \
JOB_STATE_SCHEDULED
from conf.appconfig import JOB_STATE_NEW, JOB_STATE_COMPLETE, \
JOB_STATE_FAILED, JOB_STATE_SCHEDULED
from orchestrator.services.storage.mongo import create
from nose.tools import ok_, eq_
from orchestrator.util import dict_merge
Expand Down
1 change: 1 addition & 0 deletions tests/unit/orchestrator/services/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ def test_evaluate_config_with_deployers():
},
'deployer-name': 'deployer2',
'deployment': {}

}
}
})
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/orchestrator/views/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from flask import Flask
from mock import patch
from nose.tools import eq_
from conf.appconfig import MIME_JSON, MIME_FORM_URL_ENC, MIME_GENERIC_HOOK_V1, \
MIME_JOB_V1
from conf.appconfig import MIME_JSON, MIME_FORM_URL_ENC, \
MIME_GENERIC_HOOK_V1, MIME_JOB_V1
from orchestrator.server import app
from orchestrator.views.hooks import authorize

Expand Down

0 comments on commit 72ce7e4

Please sign in to comment.