Example #1
0
def _check_github_config():
    if config.get('github', 'enabled', default='false') == 'false':
        if click.confirm('GitHub configuration is missing, do you want to '
                         'run the config assistant?', default=True):
            config.set('github', 'enabled', 'true')
            assistant()

    if not config.has('github', 'token'):
        fatal('error: github is not configured')
Example #2
0
def cli(ctx, all, unset, raw, option, value):
    """
    Get and set your AerisCloud options
    """
    if all:
        for section, values in config.dump().iteritems():
            for key, value in values.iteritems():
                _display_option(section, key, value)
        return

    if unset:
        if not option:
            click.secho('error: missing option name', fg='red', err=True)
            click.echo(cli.get_help(ctx))
            sys.exit(1)
        _unset_option(option)
        return

    if option:
        section, key = option.split('.')

        if not config.has(section, key) and not value:
            click.secho('error: unknown option %s' % option,
                        fg='red', err=True)
            sys.exit(1)

        if not value:
            value = config.get(section, key)
            if raw:
                click.echo(value)
            else:
                _display_option(section, key, value)
            return
        else:
            config.set(section, key, value)
            config.save()
            _display_option(section, key, config.get(section, key))
    else:
        click.echo(cli.get_help(ctx))
Example #3
0
def _ask_general_info(git_root):
    _title('General')

    # Take the basename of the git root as default name for the application
    default_name = os.path.basename(git_root) \
        .lower()

    app_name = None
    app_id = None

    click.secho('\nSelect your %s (only lowercase letters, numbers and '
                'dash are accepted).' % style('application name', bold=True))
    while True:
        app_name = get_input('[default: %s] > ' % default_name)
        if not app_name:
            app_name = default_name
        if re.match("^[a-z0-9-]+$", app_name):
            break
        else:
            click.echo('Only lowercase letters and numbers are accepted.')

    organization_list = AerisCompletableList(get_organization_list())

    click.secho('\nWhich organization contains the playbook you want to '
                'use to provision the boxes of this project?')
    organization = AerisPrompt('> ', completer=organization_list).get_input()

    if not organization:
        organization = config.get('config', 'default_organization',
                                  default=None)

    click.echo('\nProvide your %s.\n'
               'If you don\'t have one, ask your system operators!' %
               style('application ID', bold=True))
    while True:
        app_id = get_input('> ')
        if len(app_id) > 0:
            try:
                app_id = int(app_id)
                if app_id > 0:
                    break
                warning('Please enter a valid ID.')
            except ValueError:
                warning('Please enter a valid ID.')

    return app_name, organization, app_id