use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.
the class P4TestRepo method materialConfig.
public P4MaterialConfig materialConfig(String p4view) {
P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(serverAndPort(), p4view);
p4MaterialConfig.setConfigAttributes(Collections.singletonMap(P4MaterialConfig.USERNAME, user));
p4MaterialConfig.setPassword(password);
p4MaterialConfig.setUseTickets(useTickets);
return p4MaterialConfig;
}
use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.
the class MaterialConfigsMother method p4MaterialConfig.
public static P4MaterialConfig p4MaterialConfig(String serverAndPort, String userName, String password, String view, boolean useTickets) {
final P4MaterialConfig material = new P4MaterialConfig(serverAndPort, view);
material.setConfigAttributes(m(P4MaterialConfig.USERNAME, userName, P4MaterialConfig.AUTO_UPDATE, "true"));
material.setPassword(password);
material.setUseTickets(useTickets);
return material;
}
use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.
the class ConfigConverter method toScmMaterialConfig.
private ScmMaterialConfig toScmMaterialConfig(CRScmMaterial crScmMaterial) {
String materialName = crScmMaterial.getName();
if (crScmMaterial instanceof CRGitMaterial) {
CRGitMaterial git = (CRGitMaterial) crScmMaterial;
String gitBranch = git.getBranch();
if (StringUtils.isBlank(gitBranch))
gitBranch = GitMaterialConfig.DEFAULT_BRANCH;
GitMaterialConfig gitConfig = new GitMaterialConfig(git.getUrl(), gitBranch, git.shallowClone());
setCommonMaterialMembers(gitConfig, crScmMaterial);
setCommonScmMaterialMembers(gitConfig, git);
return gitConfig;
} else if (crScmMaterial instanceof CRHgMaterial) {
CRHgMaterial hg = (CRHgMaterial) crScmMaterial;
return new HgMaterialConfig(new HgUrlArgument(hg.getUrl()), hg.isAutoUpdate(), toFilter(crScmMaterial), false, hg.getDirectory(), toMaterialName(materialName));
} else if (crScmMaterial instanceof CRP4Material) {
CRP4Material crp4Material = (CRP4Material) crScmMaterial;
P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(crp4Material.getServerAndPort(), crp4Material.getView(), cipher);
if (crp4Material.getEncryptedPassword() != null) {
p4MaterialConfig.setEncryptedPassword(crp4Material.getEncryptedPassword());
} else {
p4MaterialConfig.setPassword(crp4Material.getPassword());
}
p4MaterialConfig.setUserName(crp4Material.getUserName());
p4MaterialConfig.setUseTickets(crp4Material.getUseTickets());
setCommonMaterialMembers(p4MaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(p4MaterialConfig, crp4Material);
return p4MaterialConfig;
} else if (crScmMaterial instanceof CRSvnMaterial) {
CRSvnMaterial crSvnMaterial = (CRSvnMaterial) crScmMaterial;
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(crSvnMaterial.getUrl(), crSvnMaterial.getUserName(), crSvnMaterial.isCheckExternals(), cipher);
if (crSvnMaterial.getEncryptedPassword() != null) {
svnMaterialConfig.setEncryptedPassword(crSvnMaterial.getEncryptedPassword());
} else {
svnMaterialConfig.setPassword(crSvnMaterial.getPassword());
}
setCommonMaterialMembers(svnMaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(svnMaterialConfig, crSvnMaterial);
return svnMaterialConfig;
} else if (crScmMaterial instanceof CRTfsMaterial) {
CRTfsMaterial crTfsMaterial = (CRTfsMaterial) crScmMaterial;
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(cipher, new UrlArgument(crTfsMaterial.getUrl()), crTfsMaterial.getUserName(), crTfsMaterial.getDomain(), crTfsMaterial.getProjectPath());
if (crTfsMaterial.getEncryptedPassword() != null) {
tfsMaterialConfig.setEncryptedPassword(crTfsMaterial.getEncryptedPassword());
} else {
tfsMaterialConfig.setPassword(crTfsMaterial.getPassword());
}
setCommonMaterialMembers(tfsMaterialConfig, crTfsMaterial);
setCommonScmMaterialMembers(tfsMaterialConfig, crTfsMaterial);
return tfsMaterialConfig;
} else
throw new ConfigConvertionException(String.format("unknown scm material type '%s'", crScmMaterial));
}
use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.
the class PipelineConfigDependencyGraphTest method shouldReturnTheSetOfFingerprintsOfAllMaterials.
@Test
public void shouldReturnTheSetOfFingerprintsOfAllMaterials() throws Exception {
HgMaterialConfig common = MaterialConfigsMother.hgMaterialConfig();
SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common, up1DependencyMaterial, up2DependencyMaterial);
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common, firstOrderGitMaterial, uppestDependencyMaterial);
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common, uppestDependencyMaterial);
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common, firstOrderP4Material);
PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
assertThat(dependencyGraph.allMaterialFingerprints().size(), is(7));
assertThat(dependencyGraph.allMaterialFingerprints(), hasItems(common.getFingerprint(), firstOrderSVNMaterial.getFingerprint(), firstOrderGitMaterial.getFingerprint(), firstOrderP4Material.getFingerprint(), up1DependencyMaterial.getFingerprint(), up2DependencyMaterial.getFingerprint(), uppestDependencyMaterial.getFingerprint()));
}
use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldCollectAllTheErrorsInTheChilderHelper.
protected void shouldCollectAllTheErrorsInTheChilderHelper(CruiseConfig config) {
config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");
PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
pipelineConfig.errors().add("base", "Some base errors");
P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
pipelineConfig.addMaterialConfig(p4MaterialConfig);
p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");
StageConfig stage = pipelineConfig.first();
stage.errors().add("role", "Roles must be proper");
List<ConfigErrors> allErrors = config.validateAfterPreprocess();
assertThat(allErrors.size(), is(5));
assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
assertThat(allErrors.get(1).on("base"), is("Some base errors"));
assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
assertThat(allErrors.get(3).on(ScmMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
assertThat(allErrors.get(4).on("materialName"), is("material name does not follow pattern"));
}
Aggregations