Example #1
0
def load_artifact_config(artman_config_path, artifact_name):
    artman_config = _read_artman_config(artman_config_path)
    artifact_config = Artifact()
    artifact_config.CopyFrom(artman_config.common)
    valid_values = []
    for artifact in artman_config.artifacts:
        valid_values.append(artifact.name)
        if artifact.name == artifact_name:
            artifact_config.MergeFrom(artifact)
            _validate_artifact_config(artifact_config)
            return _normalize_artifact_config(artifact_config,
                                              artman_config_path)

    raise ValueError(
        'No artifact with `%s` configured in artman yaml. Valid values are %s'
        % (artifact_name, valid_values))
Example #2
0
def load_artifact_config(artman_config_path, artifact_name, aspect=None):
    artman_config = _read_artman_config(artman_config_path)
    artifact_config = Artifact()
    artifact_config.CopyFrom(artman_config.common)

    if artifact_name not in ARTIFACT_MAPPING:
        raise ValueError(
            'Artifact type `%s` not supported. Valid values are %s' %
            (artifact_name, ARTIFACT_MAPPING.keys()))
    loaded_artifact = Artifact(**ARTIFACT_MAPPING[artifact_name])

    for artifact in artman_config.artifacts:
        if artifact.name == artifact_name:
            loaded_artifact.MergeFrom(artifact)
            break

    if aspect:
        loaded_artifact.aspect = Artifact.Aspect.Value(aspect)

    artifact_config.MergeFrom(loaded_artifact)
    _validate_artifact_config(artifact_config)
    return _normalize_artifact_config(artifact_config, artman_config_path)