def promote_deployment(config, application, version, release, stage, execute):
'''Promote deployment to new stage'''
namespace = config.get('kubernetes_namespace')
deployment_name = '{}-{}-{}'.format(application, version, release)
info('Promoting deployment {} to {} stage..'.format(deployment_name, stage))
cluster_id = config.get('kubernetes_cluster')
namespace = config.get('kubernetes_namespace')
path = '/kubernetes-clusters/{}/namespaces/{}/resources'.format(cluster_id, namespace)
resources_update = ResourcesUpdate()
resources_update.set_label(deployment_name, 'stage', stage)
response = request(config, requests.patch, path, json=resources_update.to_dict())
change_request_id = response.json()['id']
if execute:
approve_and_execute(config, change_request_id)
else:
print(change_request_id)
评论列表
文章目录