def add_git_remote(remote_name, remote_url): """Adds a given remote to the repository in the current directory.""" call( 'git', 'remote', 'add', remote_name, remote_url)
def push(tag_name, use_gcloud=False): """Pushes an image to a repository. Because Noel uses Google Container Registry, this has logic to use the Google Cloud SDK to push the image. If you're not using GCR, you'll need to make sure login is called before calling this. """ if not use_gcloud: call('docker', 'push', tag_name) else: # When not on GCE/GKE, use gcloud to push. gcloud will handle # authentication. call('gcloud', 'docker', 'push', tag_name)
def do_receive(path): adjusted_path = os.path.join('~', path) if not os.path.exists(path): create_repository(os.environ['HOME'], path) return call('/bin/bash', '-c', 'git-receive-pack \'{}\''.format(adjusted_path))
def do_receive(path): adjusted_path = os.path.join('~', path) if not os.path.exists(path): create_repository(os.environ['HOME'], path) return call('/bin/bash', '-c', 'git-receive-pack \'{}\''.format( adjusted_path))
def get_project_id(): """Gets the google cloud project either via the GCE metadata service or the Google Cloud SDK.""" project_id = get_gce_project_id() if project_id: return project_id return call( 'gcloud', 'config', 'list', 'project', '--format=value(core.project)', silent=True).strip().split('\n').pop()
def create_repository(repo_root, name): path = os.path.join(repo_root, name) hook_path = os.path.join(path, 'hooks', 'post-receive') os.makedirs(path) call('git', 'init', '--bare', path, silent=True) with open(hook_path, 'w') as f: f.write(RECEIVE_HOOK) call('chmod', '+x', hook_path, silent=True) call('chown', '-R', 'git:git', path, silent=True)
def checkout_repo(staging_dir): if not os.path.exists(staging_dir): os.makedirs(staging_dir) call('git', '--work-tree', staging_dir, 'checkout', '-f')
def add_git_remote(remote_name, remote_url): """Adds a given remote to the repository in the current directory.""" call('git', 'remote', 'add', remote_name, remote_url)
def login(host, token): call('docker', 'login', '-e', '*****@*****.**', '-u', '_token', '-p', token, host)
def build(tag_name, context_dir): call('docker', 'build', '-t', tag_name, context_dir)
def do_upload(path): adjusted_path = os.path.join('~', path) return call('/bin/bash', '-c', 'git-upload-pack-pack \'{}\''.format(adjusted_path))
def do_upload(path): adjusted_path = os.path.join('~', path) return call('/bin/bash', '-c', 'git-upload-pack-pack \'{}\''.format( adjusted_path))