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