use of com.walmartlabs.concord.repository.Snapshot in project concord by walmartlabs.
the class ProjectLoader method toResult.
private static Result toResult(com.walmartlabs.concord.project.ProjectLoader.Result r) {
List<Snapshot> snapshots = r.getSnapshots();
ProcessDefinition pd = new ProcessDefinitionV1(r.getProjectDefinition());
return new Result() {
@Override
public List<Snapshot> snapshots() {
return snapshots;
}
@Override
public ProcessDefinition projectDefinition() {
return pd;
}
};
}
use of com.walmartlabs.concord.repository.Snapshot in project concord by walmartlabs.
the class ProjectLoaderV2 method load.
public Result load(Path baseDir, ImportsNormalizer importsNormalizer, ImportsListener listener) throws Exception {
YamlParserV2 parser = new YamlParserV2();
// load the initial ProcessDefinition from the root concord.yml file
// it will be used to determine whether we need to load other resources (e.g. imports)
ProcessDefinition root = loadRoot(parser, baseDir);
List<Snapshot> snapshots = Collections.emptyList();
if (root != null) {
Imports imports = importsNormalizer.normalize(root.imports());
snapshots = importManager.process(imports, baseDir, listener);
}
List<Path> files = loadResources(baseDir, root != null ? root.resources() : Resources.builder().build());
Collections.sort(files);
List<ProcessDefinition> definitions = new ArrayList<>();
for (Path p : files) {
definitions.add(parser.parse(baseDir, p));
}
if (root != null) {
definitions.add(root);
}
if (definitions.isEmpty()) {
throw new IllegalStateException("Can't find any Concord process definition files in '" + baseDir + "'");
}
return new Result(snapshots, merge(definitions));
}
use of com.walmartlabs.concord.repository.Snapshot in project concord by walmartlabs.
the class DefaultImportManager method process.
@Override
public List<Snapshot> process(Imports imports, Path dest, ImportsListener listener) throws Exception {
if (listener == null) {
listener = ImportsListener.NOP_LISTENER;
}
List<Snapshot> result = new ArrayList<>();
List<Import> items = imports.items();
if (items == null || items.isEmpty()) {
return result;
}
listener.onStart(items);
for (Import i : items) {
listener.beforeImport(i);
Snapshot s;
try {
s = assertProcessor(i.type()).process(i, dest);
} catch (Exception e) {
throw new ImportProcessingException(i, e);
}
listener.afterImport(i);
result.add(s);
}
listener.onEnd(items);
return result;
}
use of com.walmartlabs.concord.repository.Snapshot in project concord by walmartlabs.
the class ProjectLoader method loadProject.
/**
* Loads the project definition using the supplied path. Processes the configured
* imports, templates and extra directories with project files.
*
* @param workDir the directory containing the project files. If {@code imports} are
* configured, the directory will be used as a target for repository
* checkouts.
*/
public Result loadProject(Path workDir, ImportsNormalizer importsNormalizer, ImportsListener listener) throws Exception {
workDir = workDir.normalize().toAbsolutePath();
ProjectDefinition initial = initialLoad(workDir);
Resources resources = initial.getResources();
Imports imports = importsNormalizer.normalize(initial.getImports());
List<Snapshot> snapshots = importManager.process(imports, workDir, listener);
ProjectDefinitionBuilder b = new ProjectDefinitionBuilder(parser);
List<String> projectPaths = resources.getProjectFilePaths();
if (projectPaths != null) {
for (String n : projectPaths) {
Path p = assertLocal(workDir, workDir.resolve(n));
if (Files.exists(p)) {
b.addProjects(p);
}
}
}
for (String n : Constants.Files.PROJECT_ROOT_FILE_NAMES) {
Path p = assertLocal(workDir, workDir.resolve(n));
if (Files.exists(p)) {
b.addProjectFile(workDir, p);
break;
}
}
List<String> definitionPaths = resources.getDefinitionPaths();
if (definitionPaths != null) {
for (String n : definitionPaths) {
Path p = assertLocal(workDir, workDir.resolve(n));
if (Files.exists(p)) {
b.addDefinitions(p);
}
}
}
List<String> profilesPaths = resources.getProfilesPaths();
if (profilesPaths != null) {
for (String n : profilesPaths) {
Path p = assertLocal(workDir, workDir.resolve(n));
if (Files.exists(p)) {
b.addProfiles(p);
}
}
}
ProjectDefinition pd = b.build();
// save the normalized imports, so the exact same workDir structure
// can be re-created later (e.g. by the Agent)
pd = new ProjectDefinition(pd, imports);
return new Result(snapshots, pd);
}
use of com.walmartlabs.concord.repository.Snapshot in project concord by walmartlabs.
the class ProjectLoader method toResult.
private static Result toResult(com.walmartlabs.concord.runtime.v2.ProjectLoaderV2.Result r) {
List<Snapshot> snapshots = r.getSnapshots();
ProcessDefinition pd = new ProcessDefinitionV2(r.getProjectDefinition());
return new Result() {
@Override
public List<Snapshot> snapshots() {
return snapshots;
}
@Override
public ProcessDefinition projectDefinition() {
return pd;
}
};
}
Aggregations