99from django .conf import settings
1010
1111
12- def publish_release (repository_path , config , tag , source_tag = 'latest' ):
12+ def publish_release (src_image , src_tag , config , target_image , target_tag ):
1313 """
1414 Publish a new release as a Docker image
1515
16- Given a source repository path, a dictionary of environment variables
17- and a target tag, create a new lightweight Docker image on the registry.
16+ Given a source image and dictionary of last-mile configuration,
17+ create a target Docker image on the registry.
1818
19- source_tag is the name of the previous older tag that this image should
20- be a child of. In most cases, this should be 'latest', but for rollbacks
21- this should be an older tag.
22-
23- For example, publish_release('gabrtv/myapp', {'ENVVAR': 'values'}, 'v23')
24- results in a new Docker image at: <registry_url> /gabrtv/myapp:v23
25- which contains the new configuration as ENV entries.
19+ For example publish_release('registry.local:5000/gabrtv/myapp',
20+ '<sha>'
21+ {'ENVVAR': 'values'},
22+ 'registry.local:5000/gabrtv/myapp',
23+ 'v23', )
24+ results in a new Docker image at 'registry.local:5000 /gabrtv/myapp:v23' which
25+ contains the new configuration as ENV entries.
2626 """
2727 try :
28- image_id = _get_tag (repository_path , source_tag )
28+ image_id = _get_tag (src_image , src_tag )
2929 except RuntimeError :
30- if source_tag == 'latest' :
30+ if src_tag == 'latest' :
3131 # no image exists yet, so let's build one!
32- _put_first_image (repository_path )
33- image_id = _get_tag (repository_path , 'latest' )
32+ _put_first_image (src_image )
33+ image_id = _get_tag (src_image , src_tag )
3434 else :
3535 raise
3636 image = _get_image (image_id )
@@ -39,7 +39,7 @@ def publish_release(repository_path, config, tag, source_tag='latest'):
3939 image ['id' ] = _new_id ()
4040 image ['config' ]['Env' ] = _construct_env (image ['config' ]['Env' ], config )
4141 # update and tag the new image
42- _commit (repository_path , image , _empty_tar_archive (), tag )
42+ _commit (target_image , image , _empty_tar_archive (), target_tag )
4343
4444
4545# registry access
@@ -88,7 +88,6 @@ def _get_tag(repository, tag):
8888 r = _api_call (url )
8989 if not r .status_code == 200 :
9090 raise RuntimeError ("GET Image Error ({}: {})" .format (r .status_code , r .text ))
91- print r .text
9291 return r .json ()
9392
9493
0 commit comments