Esempio n. 1
0
File: app.py Progetto: apeming/cli
def register_release(ctx, appname, tag, git, f, literal, force):
    appname = get_appname(appname=appname)
    tag = get_git_tag(git_tag=tag)

    specs_text = get_specs_text(f, literal)
    if specs_text is None:
        errmsg = [
            "specs_text is required, please use one of the instructions to specify it.",
            "1. specify --literal or -f in coomand line",
            "2. make the current workdir in the source code dir which contains app.yaml"
        ]
        fatal('\n'.join(errmsg))
    kae = ctx.obj['kae_api']
    git = git or get_remote_url(remote=ctx.obj['remotename'])
    if not git:
        fatal("git url not found, please check repository or pass argument")
    branch = get_current_branch()
    with handle_console_err():
        kae.register_release(appname,
                             tag,
                             git,
                             specs_text,
                             branch=branch,
                             force=force)
    click.echo(info('Register %s %s %s done.' % (appname, tag, git)))
Esempio n. 2
0
def register_release(ctx, appname, tag, git, f, literal):
    appname = get_appname(appname=appname)
    tag = get_git_tag(git_tag=tag)

    specs_text = get_specs_text(f, literal)
    kae = ctx.obj['kae_api']
    git = git or get_remote_url(remote=ctx.obj['remotename'])
    if not git:
        fatal("git url not found, please check repository or pass argument")
    branch = get_current_branch()
    with handle_console_err():
        kae.register_release(appname, tag, git, specs_text, branch=branch)
    click.echo(info('Register %s %s %s done.' % (appname, tag, git)))
Esempio n. 3
0
File: job.py Progetto: kaecloud/cli
def create_job(ctx, jobname, git, f, literal):
    specs_text = get_specs_text(f, literal)
    kae = ctx.obj['kae_api']
    git = git or get_remote_url(remote=ctx.obj['remotename'])
    if not git:
        fatal("git url not found, please check repository or pass argument")
    branch = get_current_branch()
    with handle_console_err():
        kae.create_job(jobname=jobname,
                       git=git,
                       specs_text=specs_text,
                       branch=branch)
    click.echo(info('Create job done.'))
Esempio n. 4
0
File: test.py Progetto: kaecloud/cli
def test(appname, tag, f, literal):
    """build test image and run test script in app.yaml"""
    repo_dir = os.getcwd()
    if f:
        repo_dir = os.path.dirname(os.path.abspath(f))

    appname = get_appname(cwd=repo_dir, appname=appname)
    tag = get_git_tag(cwd=repo_dir, git_tag=tag, required=False)
    if tag is None:
        tag = 'latest'

    specs_text = get_specs_text(f, literal)
    if specs_text is None:
        errmsg = [
            "specs_text is required, please use one of the instructions to specify it.",
            "1. specify --literal or -f in coomand line",
            "2. make the current workdir in the source code dir which contains app.yaml"
        ]
        fatal('\n'.join(errmsg))
    try:
        yaml_dict = yaml.load(specs_text)
    except yaml.YAMLError as e:
        fatal('specs text is invalid yaml {}'.format(str(e)))
    try:
        specs = app_specs_schema.load(yaml_dict).data
    except Exception as e:
        fatal('specs text is invalid: {}'.format(str(e)))
    if "test" not in specs:
        fatal("no test specified in app.yaml")
    builds = specs['test']['builds']
    if len(builds) == 0:
        builds = specs["builds"]
    for build in builds:
        image_tag = build.tag if build.tag else tag
        dockerfile = build.get('dockerfile', None)
        if dockerfile is None:
            dockerfile = os.path.join(repo_dir, "Dockerfile")
        full_image_name = "{}:{}".format(build.name, image_tag)
        build_image(full_image_name, repo_dir, None, dockerfile=dockerfile)

    default_image_name = "{}:{}".format(appname, tag)
    for entrypoint in specs['test']['entrypoints']:
        image = entrypoint.image if entrypoint.image else default_image_name
        cmd = entrypoint.script
        volumes = entrypoint.get('volumes', [])
        run_container(image, volumes, cmd)