@@ -444,6 +444,8 @@ def apps_create(self, args):
444444 Options:
445445 --no-remote
446446 do not create a `deis` git remote.
447+ -b --buildpack BUILDPACK
448+ a buildpack url to use for this app
447449 """
448450 body = {}
449451 app_name = None
@@ -464,31 +466,36 @@ def apps_create(self, args):
464466 finally :
465467 progress .cancel ()
466468 progress .join ()
467- if response .status_code == requests .codes .created :
468- data = response .json ()
469- app_id = data ['id' ]
470- self ._logger .info ("done, created {}" .format (app_id ))
471- # set a git remote if necessary
472- try :
473- self ._session .git_root ()
474- except EnvironmentError :
475- return
476- hostname = urlparse .urlparse (self ._settings ['controller' ]).netloc .split (':' )[0 ]
477- git_remote = "ssh://git@{hostname}:2222/{app_id}.git" .format (** locals ())
478- if args .get ('--no-remote' ):
479- self ._logger .info ('remote available at {}' .format (git_remote ))
480- else :
481- try :
482- subprocess .check_call (
483- ['git' , 'remote' , 'add' , '-f' , 'deis' , git_remote ],
484- stdout = subprocess .PIPE )
485- self ._logger .info ('Git remote deis added' )
486- except subprocess .CalledProcessError :
487- self ._logger .error ('Could not create Deis remote' )
488- sys .exit (1 )
489- else :
469+ if response .status_code != requests .codes .created :
490470 raise ResponseError (response )
491471
472+ data = response .json ()
473+ app_id = data ['id' ]
474+ self ._logger .info ("done, created {}" .format (app_id ))
475+
476+ buildpack = args .get ('--buildpack' )
477+ if buildpack :
478+ self ._config_set (app_id , {'BUILDPACK_URL' : buildpack })
479+
480+ # set a git remote if necessary
481+ try :
482+ self ._session .git_root ()
483+ except EnvironmentError :
484+ return
485+ hostname = urlparse .urlparse (self ._settings ['controller' ]).netloc .split (':' )[0 ]
486+ git_remote = "ssh://git@{hostname}:2222/{app_id}.git" .format (** locals ())
487+ if args .get ('--no-remote' ):
488+ self ._logger .info ('remote available at {}' .format (git_remote ))
489+ else :
490+ try :
491+ subprocess .check_call (
492+ ['git' , 'remote' , 'add' , '-f' , 'deis' , git_remote ],
493+ stdout = subprocess .PIPE )
494+ self ._logger .info ('Git remote deis added' )
495+ except subprocess .CalledProcessError :
496+ self ._logger .error ('Could not create Deis remote' )
497+ sys .exit (1 )
498+
492499 def apps_destroy (self , args ):
493500 """
494501 Destroys an application.
@@ -1028,7 +1035,14 @@ def config_set(self, args):
10281035 app = args .get ('--app' )
10291036 if not app :
10301037 app = self ._session .app
1031- body = {'values' : json .dumps (dictify (args ['<var>=<value>' ]))}
1038+ values = dictify (args ['<var>=<value>' ])
1039+ self ._config_set (app , values )
1040+
1041+ def _config_set (self , app , values ):
1042+ """
1043+ Internal logic to set environment variables for an application.
1044+ """
1045+ body = {'values' : json .dumps (values )}
10321046 sys .stdout .write ('Creating config... ' )
10331047 sys .stdout .flush ()
10341048 try :
0 commit comments