Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
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))
Exemple #5
0
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))
Exemple #6
0
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()
Exemple #7
0
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)
Exemple #8
0
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)
Exemple #9
0
def checkout_repo(staging_dir):
    if not os.path.exists(staging_dir):
        os.makedirs(staging_dir)

    call('git', '--work-tree', staging_dir, 'checkout', '-f')
Exemple #10
0
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)
Exemple #11
0
def login(host, token):
    call('docker', 'login', '-e', '*****@*****.**', '-u', '_token', '-p', token,
         host)
Exemple #12
0
def build(tag_name, context_dir):
    call('docker', 'build', '-t', tag_name, context_dir)
Exemple #13
0
def login(host, token):
    call('docker', 'login', '-e', '*****@*****.**', '-u', '_token',
         '-p', token, host)
Exemple #14
0
def build(tag_name, context_dir):
    call('docker', 'build', '-t', tag_name, context_dir)
Exemple #15
0
def do_upload(path):
    adjusted_path = os.path.join('~', path)
    return call('/bin/bash', '-c',
                'git-upload-pack-pack \'{}\''.format(adjusted_path))
Exemple #16
0
def do_upload(path):
    adjusted_path = os.path.join('~', path)
    return call('/bin/bash', '-c', 'git-upload-pack-pack \'{}\''.format(
        adjusted_path))