Skip to content

Commit cc68a62

Browse files
author
Matthew Fisher
committed
Merge pull request #3747 from bacongobbler/2830-require-tag-on-pull
fix(client): require the tag for builds:create
2 parents 9688565 + 7b5990c commit cc68a62

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

client/deis.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,22 @@ def encode(obj):
296296
return obj
297297

298298

299+
def parse_repository_tag(repo):
300+
"""Parses a given docker image and splits the tag from the repository.
301+
302+
See github.com/docker/docker-py#be73aaf, lines 188-197
303+
"""
304+
column_index = repo.rfind(':')
305+
if column_index < 0:
306+
return repo, None
307+
tag = repo[column_index + 1:]
308+
slash_index = tag.find('/')
309+
if slash_index < 0:
310+
return repo[:column_index], tag
311+
312+
return repo, None
313+
314+
299315
def readable_datetime(datetime_str):
300316
"""
301317
Return a human-readable datetime string from an ECMA-262 (JavaScript)
@@ -964,15 +980,20 @@ def builds_create(self, args):
964980
965981
Arguments:
966982
<image>
967-
A fully-qualified docker image, either from Docker Hub (e.g. deis/example-go)
968-
or from an in-house registry (e.g. myregistry.example.com:5000/example-go).
983+
A fully-qualified docker image, either from Docker Hub (e.g. deis/example-go:latest)
984+
or from an in-house registry (e.g. myregistry.example.com:5000/example-go:latest).
985+
This image must include the tag.
969986
970987
Options:
971988
-a --app=<app>
972989
The uniquely identifiable name for the application.
973990
-p --procfile=<procfile>
974991
A YAML string used to supply a Procfile to the application.
975992
"""
993+
_, tag = parse_repository_tag(args['<image>'])
994+
if tag is None:
995+
self._logger.error('<image> must contain a tag')
996+
sys.exit(1)
976997
app = args.get('--app')
977998
if not app:
978999
app = self._session.app

0 commit comments

Comments
 (0)