Beispiel #1
0
def lint_go() -> types.TaskDict:
    """Run Go linting."""
    return {
        'name': 'go',
        'title': utils.title_with_subtask_name('LINT'),
        'doc': lint_go.__doc__,
        'actions': [check_go_fmt, check_go_codegen],
        'task_dep':
        ['check_for:gofmt', 'check_for:operator-sdk', 'check_for:git'],
        'file_dep': list(constants.STORAGE_OPERATOR_SOURCES),
    }
Beispiel #2
0
def lint_shell() -> types.TaskDict:
    """Run shell scripts linting."""
    shell_scripts = [
        filepath for filepath in utils.git_ls() if '.sh' in filepath.suffixes
    ]
    return {
        'name': 'shell',
        'title': utils.title_with_subtask_name('LINT'),
        'doc': lint_shell.__doc__,
        'actions': [['tox', '-e', 'lint-shell']],
        'file_dep': shell_scripts,
    }
Beispiel #3
0
def lint_yaml() -> types.TaskDict:
    """Run YAML linting."""
    return {
        'name':
        'yaml',
        'title':
        utils.title_with_subtask_name('LINT'),
        'doc':
        lint_yaml.__doc__,
        'actions': [['tox', '-e', 'lint-yaml']],
        'file_dep': [
            constants.ROOT / 'eve/main.yml',
            constants.ROOT / 'salt/metalk8s/defaults.yaml'
        ],
    }
Beispiel #4
0
def format_go() -> types.TaskDict:
    """Format Go code using gofmt."""
    cwd = constants.STORAGE_OPERATOR_ROOT
    cmd = ' '.join(
        map(shlex.quote, [
            config.ExtCommand.GOFMT.value, '-s', '-w',
            *tuple(constants.STORAGE_OPERATOR_FMT_ARGS)
        ]))

    return {
        'name': 'go',
        'title': utils.title_with_subtask_name('FORMAT'),
        'doc': format_go.__doc__,
        'actions': [doit.action.CmdAction(cmd, cwd=cwd)],
        'task_dep': ['check_for:gofmt'],
        'file_dep': list(constants.STORAGE_OPERATOR_SOURCES),
    }
Beispiel #5
0
def lint_python() -> types.TaskDict:
    """Run Python linting."""
    buildchain = constants.ROOT / 'buildchain'
    python_sources: List[Path] = [
        buildchain / 'dodo.py',
        *buildchain.glob('buildchain/*.py'),
        *buildchain.glob('buildchain/targets/*.py'),
    ]
    cmd = ' '.join(map(shlex.quote, ['tox', '-e', 'lint-python']))
    env = {'PATH': os.environ['PATH'], 'OSTYPE': os.uname().sysname}
    return {
        'name': 'python',
        'title': utils.title_with_subtask_name('LINT'),
        'doc': lint_python.__doc__,
        'actions': [doit.action.CmdAction(cmd, env=env)],
        'file_dep': python_sources,
    }
Beispiel #6
0
def codegen_go() -> types.TaskDict:
    """Generate Go code using operator-sdk."""
    cwd = constants.STORAGE_OPERATOR_ROOT
    actions = []
    for target in ('k8s', 'openapi'):
        cmd = ' '.join(
            map(shlex.quote,
                [config.ExtCommand.OPERATOR_SDK.value, 'generate', target]))
        actions.append(doit.action.CmdAction(cmd, cwd=cwd))

    return {
        'name': 'go',
        'title': utils.title_with_subtask_name('CODEGEN'),
        'doc': codegen_go.__doc__,
        'actions': actions,
        'task_dep': ['check_for:operator-sdk'],
        'file_dep': list(constants.STORAGE_OPERATOR_SOURCES),
    }