@@ -444,6 +444,9 @@ def apps_create(self, args):
444444 Options:
445445 --no-remote
446446 do not create a `deis` git remote.
447+
448+ -b --buildpack BUILDPACK
449+ a buildpack url to use for this app
447450 """
448451 body = {}
449452 app_name = None
@@ -464,31 +467,36 @@ def apps_create(self, args):
464467 finally :
465468 progress .cancel ()
466469 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 :
470+ if response .status_code != requests .codes .created :
490471 raise ResponseError (response )
491472
473+ data = response .json ()
474+ app_id = data ['id' ]
475+ self ._logger .info ("done, created {}" .format (app_id ))
476+
477+ buildpack = args .get ('--buildpack' )
478+ if buildpack :
479+ self ._config_set (app_id , {'BUILDPACK_URL' : buildpack })
480+
481+ # set a git remote if necessary
482+ try :
483+ self ._session .git_root ()
484+ except EnvironmentError :
485+ return
486+ hostname = urlparse .urlparse (self ._settings ['controller' ]).netloc .split (':' )[0 ]
487+ git_remote = "ssh://git@{hostname}:2222/{app_id}.git" .format (** locals ())
488+ if args .get ('--no-remote' ):
489+ self ._logger .info ('remote available at {}' .format (git_remote ))
490+ else :
491+ try :
492+ subprocess .check_call (
493+ ['git' , 'remote' , 'add' , '-f' , 'deis' , git_remote ],
494+ stdout = subprocess .PIPE )
495+ self ._logger .info ('Git remote deis added' )
496+ except subprocess .CalledProcessError :
497+ self ._logger .error ('Could not create Deis remote' )
498+ sys .exit (1 )
499+
492500 def apps_destroy (self , args ):
493501 """
494502 Destroys an application.
@@ -1031,7 +1039,14 @@ def config_set(self, args):
10311039 app = args .get ('--app' )
10321040 if not app :
10331041 app = self ._session .app
1034- body = {'values' : json .dumps (dictify (args ['<var>=<value>' ]))}
1042+ values = dictify (args ['<var>=<value>' ])
1043+ self ._config_set (app , values )
1044+
1045+ def _config_set (self , app , values ):
1046+ """
1047+ Internal logic to set environment variables for an application.
1048+ """
1049+ body = {'values' : json .dumps (values )}
10351050 sys .stdout .write ('Creating config... ' )
10361051 sys .stdout .flush ()
10371052 try :
0 commit comments