Skip to content

Commit

Permalink
Merge pull request #199 from glasnt/topic/backup-no-backup
Browse files Browse the repository at this point in the history
Add flag to enable backups when deploying 🚩
  • Loading branch information
glasnt authored Jul 27, 2017
2 parents 675b07c + a3ce6c1 commit b27273a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions divio_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,17 @@ def sort_projects(items):


@project.command(name='deploy')
@click.option(
'--backup/--no-backup', default=None,
help='Take a backup on deployment.',
)
@click.argument('stage', default='test')
@click.pass_obj
def project_deploy(obj, stage):
def project_deploy(obj, stage, backup):
"""Deploy project"""
check_project_context(obj.project)
website_id = obj.project['id']
obj.client.deploy_project_or_get_progress(website_id, stage)
obj.client.deploy_project_or_get_progress(website_id, stage, backup)


@project.command(name='deploy-log')
Expand Down
11 changes: 7 additions & 4 deletions divio_cli/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def show_deploy_log(self, website_id, stage):
else:
click.secho('No {} server deployed yet, no log available.'.format(stage), fg='yellow')

def deploy_project_or_get_progress(self, website_id, stage):
def deploy_project_or_get_progress(self, website_id, stage, backup):
def fmt_progress(data):
if not data:
return 'Connecting to remote'
Expand All @@ -138,7 +138,7 @@ def fmt_progress(data):
)
else:
click.secho('Deploying {} server'.format(stage), fg='green')
self.deploy_project(website_id, stage)
self.deploy_project(website_id, stage, backup)
sleep(1)
response = self.deploy_project_progress(website_id, stage)
try:
Expand Down Expand Up @@ -183,11 +183,14 @@ def deploy_project_progress(self, website_id, stage):
data = request()
return data[stage]

def deploy_project(self, website_id, stage):
def deploy_project(self, website_id, stage, backup):
data = {'stage': stage}
if backup is not None:
data['backup'] = backup
request = api_requests.DeployProjectRequest(
self.session,
url_kwargs={'website_id': website_id},
data={'stage': stage}
data=data,
)
return request()

Expand Down

0 comments on commit b27273a

Please sign in to comment.