Skip to content

Commit 5b99da8

Browse files
author
Matthew Fisher
committed
Merge pull request #2186 from bacongobbler/controllerv1
feat(controller): bump controller API to v1
2 parents 3eb6b21 + 85c4d07 commit 5b99da8

19 files changed

Lines changed: 344 additions & 346 deletions

builder/templates/builder

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if [ -f Procfile ]; then
8585
fi
8686

8787
# pull config from controller to be used during build
88-
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/config"
88+
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/config"
8989
RESPONSE=$(curl -s -XPOST \
9090
-H "Content-Type: application/json" \
9191
-H "X-Deis-Builder-Auth: {{ .deis_controller_builderKey }}" \
@@ -161,7 +161,7 @@ RELEASE_INFO=$(echo $RELEASE_INFO | sed -e 's/\"/\\\"/g')
161161
DOCKERFILE=$(echo $DOCKERFILE | sed -e 's/\"/\\\"/g' -e 's/ \\/ /g')
162162

163163
puts-step "Launching... "
164-
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/build"
164+
URL="{{ .deis_controller_protocol }}://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/build"
165165
DATA="{\"sha\":\"$SHORT_SHA\",\"receive_user\":\"$USER\",\"receive_repo\":\"$APP_NAME\",\"image\":\"$APP_NAME\",\"procfile\":\"$RELEASE_INFO\",\"dockerfile\":\"$DOCKERFILE\"}"
166166

167167
# notify the controller that the push was successful

builder/templates/receiver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ curl \
1212
-H 'Content-Type: application/json' \
1313
-H "X-Deis-Builder-Auth: {{ .deis_controller_builderKey }}" \
1414
-d "{\"receive_user\": \"$username\", \"receive_repo\": \"$app\", \"sha\": \"$sha\", \"fingerprint\": \"$fingerprint\", \"ssh_connection\": \"$SSH_CONNECTION\", \"ssh_original_command\": \"$SSH_ORIGINAL_COMMAND\"}" \
15-
--silent http://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/push >/dev/null
15+
--silent http://{{ .deis_controller_host }}:{{ .deis_controller_port }}/v1/hooks/push >/dev/null

client/deis.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def apps_create(self, args):
438438
try:
439439
progress = TextProgress()
440440
progress.start()
441-
response = self._dispatch('post', '/api/apps',
441+
response = self._dispatch('post', '/v1/apps',
442442
json.dumps(body))
443443
finally:
444444
progress.cancel()
@@ -503,7 +503,7 @@ def apps_destroy(self, args):
503503
progress = TextProgress()
504504
progress.start()
505505
before = time.time()
506-
response = self._dispatch('delete', "/api/apps/{}".format(app))
506+
response = self._dispatch('delete', "/v1/apps/{}".format(app))
507507
finally:
508508
progress.cancel()
509509
progress.join()
@@ -528,7 +528,7 @@ def apps_list(self, args):
528528
529529
Usage: deis apps:list
530530
"""
531-
response = self._dispatch('get', '/api/apps')
531+
response = self._dispatch('get', '/v1/apps')
532532
if response.status_code == requests.codes.ok: # @UndefinedVariable
533533
data = response.json()
534534
self._logger.info('=== Apps')
@@ -550,7 +550,7 @@ def apps_info(self, args):
550550
app = args.get('--app')
551551
if not app:
552552
app = self._session.app
553-
response = self._dispatch('get', "/api/apps/{}".format(app))
553+
response = self._dispatch('get', "/v1/apps/{}".format(app))
554554
if response.status_code == requests.codes.ok: # @UndefinedVariable
555555
self._logger.info("=== {} Application".format(app))
556556
self._logger.info(json.dumps(response.json(), indent=2) + '\n')
@@ -574,7 +574,7 @@ def apps_open(self, args):
574574
if not app:
575575
app = self._session.app
576576
# TODO: replace with a single API call to apps endpoint
577-
response = self._dispatch('get', "/api/apps/{}".format(app))
577+
response = self._dispatch('get', "/v1/apps/{}".format(app))
578578
if response.status_code == requests.codes.ok: # @UndefinedVariable
579579
url = response.json()['url']
580580
# use the OS's default handler to open this URL
@@ -597,7 +597,7 @@ def apps_logs(self, args):
597597
if not app:
598598
app = self._session.app
599599
response = self._dispatch('get',
600-
"/api/apps/{}/logs".format(app))
600+
"/v1/apps/{}/logs".format(app))
601601
if response.status_code == requests.codes.ok: # @UndefinedVariable
602602
# strip the last newline character
603603
for line in response.json().split('\n')[:-1]:
@@ -641,7 +641,7 @@ def apps_run(self, args):
641641
app = self._session.app
642642
body = {'command': command}
643643
response = self._dispatch('post',
644-
"/api/apps/{}/run".format(app),
644+
"/v1/apps/{}/run".format(app),
645645
json.dumps(body))
646646
if response.status_code == requests.codes.ok: # @UndefinedVariable
647647
rc, output = json.loads(response.content)
@@ -699,7 +699,7 @@ def auth_register(self, args):
699699
email = args.get('--email')
700700
if not email:
701701
email = raw_input('email: ')
702-
url = urlparse.urljoin(controller, '/api/auth/register')
702+
url = urlparse.urljoin(controller, '/v1/auth/register')
703703
payload = {'username': username, 'password': password, 'email': email}
704704
response = self._session.post(url, data=payload, allow_redirects=False)
705705
if response.status_code == requests.codes.created: # @UndefinedVariable
@@ -730,7 +730,7 @@ def auth_cancel(self, args):
730730
if username:
731731
confirm = raw_input("Cancel account \"{}\" at {}? (y/n) ".format(username, controller))
732732
if confirm == 'y':
733-
self._dispatch('delete', '/api/auth/cancel')
733+
self._dispatch('delete', '/v1/auth/cancel')
734734
self._settings['controller'] = None
735735
self._settings['token'] = None
736736
self._settings.save()
@@ -764,7 +764,7 @@ def auth_login(self, args):
764764
password = args.get('--password')
765765
if not password:
766766
password = getpass('password: ')
767-
url = urlparse.urljoin(controller, '/api/auth/login/')
767+
url = urlparse.urljoin(controller, '/v1/auth/login/')
768768
payload = {'username': username, 'password': password}
769769
# post credentials to the login URL
770770
response = self._session.post(url, data=payload, allow_redirects=False)
@@ -840,7 +840,7 @@ def builds_create(self, args):
840840
try:
841841
progress = TextProgress()
842842
progress.start()
843-
response = self._dispatch('post', "/api/apps/{}/builds".format(app), json.dumps(body))
843+
response = self._dispatch('post', "/v1/apps/{}/builds".format(app), json.dumps(body))
844844
finally:
845845
progress.cancel()
846846
progress.join()
@@ -863,7 +863,7 @@ def builds_list(self, args):
863863
app = args.get('--app')
864864
if not app:
865865
app = self._session.app
866-
response = self._dispatch('get', "/api/apps/{}/builds".format(app))
866+
response = self._dispatch('get', "/v1/apps/{}/builds".format(app))
867867
if response.status_code == requests.codes.ok: # @UndefinedVariable
868868
self._logger.info("=== {} Builds".format(app))
869869
data = response.json()
@@ -905,7 +905,7 @@ def config_list(self, args):
905905
app = self._session.app
906906

907907
oneline = args.get('--oneline')
908-
response = self._dispatch('get', "/api/apps/{}/config".format(app))
908+
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
909909
if response.status_code == requests.codes.ok: # @UndefinedVariable
910910
config = response.json()
911911
values = config['values']
@@ -955,7 +955,7 @@ def config_set(self, args):
955955
try:
956956
progress = TextProgress()
957957
progress.start()
958-
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
958+
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
959959
finally:
960960
progress.cancel()
961961
progress.join()
@@ -1001,7 +1001,7 @@ def config_unset(self, args):
10011001
progress = TextProgress()
10021002
progress.start()
10031003
response = self._dispatch(
1004-
'post', "/api/apps/{}/config".format(app), json.dumps(body))
1004+
'post', "/v1/apps/{}/config".format(app), json.dumps(body))
10051005
finally:
10061006
progress.cancel()
10071007
progress.join()
@@ -1051,7 +1051,7 @@ def config_pull(self, args):
10511051
env_dict[k] = v
10521052
except IOError:
10531053
pass
1054-
response = self._dispatch('get', "/api/apps/{}/config".format(app))
1054+
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
10551055
if response.status_code == requests.codes.ok: # @UndefinedVariable
10561056
config = response.json()['values']
10571057
for k, v in config.items():
@@ -1108,7 +1108,7 @@ def domains_add(self, args):
11081108
progress = TextProgress()
11091109
progress.start()
11101110
response = self._dispatch(
1111-
'post', "/api/apps/{app}/domains".format(app=app), json.dumps(body))
1111+
'post', "/v1/apps/{app}/domains".format(app=app), json.dumps(body))
11121112
finally:
11131113
progress.cancel()
11141114
progress.join()
@@ -1141,7 +1141,7 @@ def domains_remove(self, args):
11411141
progress = TextProgress()
11421142
progress.start()
11431143
response = self._dispatch(
1144-
'delete', "/api/apps/{app}/domains/{domain}".format(**locals()))
1144+
'delete', "/v1/apps/{app}/domains/{domain}".format(**locals()))
11451145
finally:
11461146
progress.cancel()
11471147
progress.join()
@@ -1164,7 +1164,7 @@ def domains_list(self, args):
11641164
if not app:
11651165
app = self._session.app
11661166
response = self._dispatch(
1167-
'get', "/api/apps/{app}/domains".format(app=app))
1167+
'get', "/v1/apps/{app}/domains".format(app=app))
11681168
if response.status_code == requests.codes.ok: # @UndefinedVariable
11691169
domains = response.json()['results']
11701170
self._logger.info("=== {} Domains".format(app))
@@ -1203,7 +1203,7 @@ def limits_list(self, args):
12031203
app = args.get('--app')
12041204
if not app:
12051205
app = self._session.app
1206-
response = self._dispatch('get', "/api/apps/{}/config".format(app))
1206+
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
12071207
if response.status_code == requests.codes.ok: # @UndefinedVariable
12081208
self._print_limits(app, response.json())
12091209
else:
@@ -1256,7 +1256,7 @@ def limits_set(self, args):
12561256
try:
12571257
progress = TextProgress()
12581258
progress.start()
1259-
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
1259+
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
12601260
finally:
12611261
progress.cancel()
12621262
progress.join()
@@ -1302,7 +1302,7 @@ def limits_unset(self, args):
13021302
try:
13031303
progress = TextProgress()
13041304
progress.start()
1305-
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
1305+
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
13061306
finally:
13071307
progress.cancel()
13081308
progress.join()
@@ -1360,7 +1360,7 @@ def ps_list(self, args, app=None):
13601360
if not app:
13611361
app = self._session.app
13621362
response = self._dispatch('get',
1363-
"/api/apps/{}/containers".format(app))
1363+
"/v1/apps/{}/containers".format(app))
13641364
if response.status_code != requests.codes.ok: # @UndefinedVariable
13651365
raise ResponseError(response)
13661366
processes = response.json()
@@ -1405,7 +1405,7 @@ def ps_scale(self, args):
14051405
progress.start()
14061406
before = time.time()
14071407
response = self._dispatch('post',
1408-
"/api/apps/{}/scale".format(app),
1408+
"/v1/apps/{}/scale".format(app),
14091409
json.dumps(body))
14101410
finally:
14111411
progress.cancel()
@@ -1443,7 +1443,7 @@ def tags_list(self, args):
14431443
app = args.get('--app')
14441444
if not app:
14451445
app = self._session.app
1446-
response = self._dispatch('get', "/api/apps/{}/config".format(app))
1446+
response = self._dispatch('get', "/v1/apps/{}/config".format(app))
14471447
if response.status_code == requests.codes.ok: # @UndefinedVariable
14481448
self._print_tags(app, response.json())
14491449
else:
@@ -1476,7 +1476,7 @@ def tags_set(self, args):
14761476
try:
14771477
progress = TextProgress()
14781478
progress.start()
1479-
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
1479+
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
14801480
finally:
14811481
progress.cancel()
14821482
progress.join()
@@ -1514,7 +1514,7 @@ def tags_unset(self, args):
15141514
try:
15151515
progress = TextProgress()
15161516
progress.start()
1517-
response = self._dispatch('post', "/api/apps/{}/config".format(app), json.dumps(body))
1517+
response = self._dispatch('post', "/v1/apps/{}/config".format(app), json.dumps(body))
15181518
finally:
15191519
progress.cancel()
15201520
progress.join()
@@ -1575,7 +1575,7 @@ def keys_add(self, args):
15751575
}
15761576
sys.stdout.write("Uploading {} to Deis...".format(selected_key.id))
15771577
sys.stdout.flush()
1578-
response = self._dispatch('post', '/api/keys', json.dumps(body))
1578+
response = self._dispatch('post', '/v1/keys', json.dumps(body))
15791579
if response.status_code == requests.codes.created: # @UndefinedVariable
15801580
self._logger.info('done')
15811581
else:
@@ -1629,7 +1629,7 @@ def keys_list(self, args):
16291629
16301630
Usage: deis keys:list
16311631
"""
1632-
response = self._dispatch('get', '/api/keys')
1632+
response = self._dispatch('get', '/v1/keys')
16331633
if response.status_code == requests.codes.ok: # @UndefinedVariable
16341634
data = response.json()
16351635
if data['count'] == 0:
@@ -1656,7 +1656,7 @@ def keys_remove(self, args):
16561656
key = args.get('<key>')
16571657
sys.stdout.write("Removing {} SSH Key... ".format(key))
16581658
sys.stdout.flush()
1659-
response = self._dispatch('delete', "/api/keys/{}".format(key))
1659+
response = self._dispatch('delete', "/v1/keys/{}".format(key))
16601660
if response.status_code == requests.codes.no_content: # @UndefinedVariable
16611661
self._logger.info('done')
16621662
else:
@@ -1771,10 +1771,10 @@ def _parse_perms_args(self, args):
17711771
admin = args.get('--admin')
17721772
if admin:
17731773
app = None
1774-
url = '/api/admin/perms'
1774+
url = '/v1/admin/perms'
17751775
else:
17761776
app = app[0] or self._session.app
1777-
url = "/api/apps/{}/perms".format(app)
1777+
url = "/v1/apps/{}/perms".format(app)
17781778
return app, url
17791779

17801780
def releases(self, args):
@@ -1810,7 +1810,7 @@ def releases_info(self, args):
18101810
if not app:
18111811
app = self._session.app
18121812
response = self._dispatch(
1813-
'get', "/api/apps/{app}/releases/{version}".format(**locals()))
1813+
'get', "/v1/apps/{app}/releases/{version}".format(**locals()))
18141814
if response.status_code == requests.codes.ok: # @UndefinedVariable
18151815
self._logger.info(json.dumps(response.json(), indent=2))
18161816
else:
@@ -1829,7 +1829,7 @@ def releases_list(self, args):
18291829
app = args.get('--app')
18301830
if not app:
18311831
app = self._session.app
1832-
response = self._dispatch('get', "/api/apps/{app}/releases".format(**locals()))
1832+
response = self._dispatch('get', "/v1/apps/{app}/releases".format(**locals()))
18331833
if response.status_code == requests.codes.ok: # @UndefinedVariable
18341834
self._logger.info("=== {} Releases".format(app))
18351835
data = response.json()
@@ -1863,7 +1863,7 @@ def releases_rollback(self, args):
18631863
body = {'version': int(version)}
18641864
else:
18651865
body = {}
1866-
url = "/api/apps/{app}/releases/rollback".format(**locals())
1866+
url = "/v1/apps/{app}/releases/rollback".format(**locals())
18671867
if version:
18681868
sys.stdout.write('Rolling back to v{version}... '.format(**locals()))
18691869
else:

controller/api/tests/test_api_middleware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_x_deis_version_header_good(self):
2727
Test that when the version header is sent, the request is accepted.
2828
"""
2929
response = self.client.get(
30-
'/api/apps',
30+
'/v1/apps',
3131
HTTP_X_DEIS_VERSION=__version__.rsplit('.', 1)[0],
3232
HTTP_AUTHORIZATION='token {}'.format(self.token),
3333
)
@@ -38,7 +38,7 @@ def test_x_deis_version_header_bad(self):
3838
Test that when an improper version header is sent, the request is declined.
3939
"""
4040
response = self.client.get(
41-
'/api/apps',
41+
'/v1/apps',
4242
HTTP_X_DEIS_VERSION='1234.5678',
4343
HTTP_AUTHORIZATION='token {}'.format(self.token),
4444
)
@@ -48,6 +48,6 @@ def test_x_deis_version_header_not_present(self):
4848
"""
4949
Test that when the version header is not present, the request is accepted.
5050
"""
51-
response = self.client.get('/api/apps',
51+
response = self.client.get('/v1/apps',
5252
HTTP_AUTHORIZATION='token {}'.format(self.token))
5353
self.assertEqual(response.status_code, 200)

0 commit comments

Comments
 (0)