use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.
the class PipelineHistoryService method allPipelineInstances.
private PipelineGroupModels allPipelineInstances(Username username) {
CruiseConfig currentConfig = goConfigService.currentCruiseConfig();
PipelineGroups groups = currentConfig.getGroups();
PipelineInstanceModels activePipelines = filterPermissions(pipelineDao.loadActivePipelines(), username);
PipelineGroupModels groupModels = new PipelineGroupModels();
for (PipelineConfig pipelineConfig : currentConfig.getAllPipelineConfigs()) {
CaseInsensitiveString pipelineName = pipelineConfig.name();
for (PipelineInstanceModel activePipeline : activePipelines.findAll(CaseInsensitiveString.str(pipelineName))) {
activePipeline.setTrackingTool(pipelineConfig.getTrackingTool());
activePipeline.setMingleConfig(pipelineConfig.getMingleConfig());
populatePlaceHolderStages(activePipeline);
String groupName = groups.findGroupNameByPipeline(pipelineName);
if (groupName == null) {
throw new RuntimeException("Unable to find group find pipeline " + pipelineName);
}
populatePreviousStageState(activePipeline);
populateLockStatus(activePipeline.getName(), username, activePipeline);
boolean canForce = schedulingCheckerService.canManuallyTrigger(CaseInsensitiveString.str(pipelineName), username);
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(CaseInsensitiveString.str(pipelineName));
groupModels.addPipelineInstance(groupName, activePipeline, canForce, securityService.hasOperatePermissionForPipeline(username.getUsername(), CaseInsensitiveString.str(pipelineName)), pauseInfo);
}
}
for (PipelineConfigs group : groups) {
populateMissingPipelines(username, groupModels, group);
}
return groupModels;
}
use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.
the class PipelineConfigServiceTest method shouldGetAllViewablePipelineConfigs.
@Test
public void shouldGetAllViewablePipelineConfigs() throws Exception {
CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
PipelineConfig p1 = PipelineConfigMother.pipelineConfig("P1");
PipelineConfig p2 = PipelineConfigMother.pipelineConfig("P2");
Username username = new Username(new CaseInsensitiveString("user"));
when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
when(cruiseConfig.getGroups()).thenReturn(new PipelineGroups(new BasicPipelineConfigs("group1", null, p1), new BasicPipelineConfigs("group2", null, p2)));
when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group1")).thenReturn(true);
when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group2")).thenReturn(false);
List<PipelineConfigs> pipelineConfigs = pipelineConfigService.viewableOrOperatableGroupsFor(username);
assertThat(pipelineConfigs.size(), is(1));
assertThat(pipelineConfigs.get(0).getGroup(), is("group1"));
}
use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.
the class PipelineConfigServiceTest method shouldGetAllViewableOrOperatablePipelineConfigs.
@Test
public void shouldGetAllViewableOrOperatablePipelineConfigs() throws Exception {
CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
PipelineConfig p1 = PipelineConfigMother.pipelineConfig("P1");
PipelineConfig p2 = PipelineConfigMother.pipelineConfig("P2");
PipelineConfig p3 = PipelineConfigMother.pipelineConfig("P3");
Username username = new Username(new CaseInsensitiveString("user"));
when(goConfigService.cruiseConfig()).thenReturn(cruiseConfig);
when(cruiseConfig.getGroups()).thenReturn(new PipelineGroups(new BasicPipelineConfigs("group1", null, p1), new BasicPipelineConfigs("group2", null, p2), new BasicPipelineConfigs("group3", null, p3)));
when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group1")).thenReturn(true);
when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group2")).thenReturn(false);
when(securityService.hasOperatePermissionForGroup(username.getUsername(), "group2")).thenReturn(false);
when(securityService.hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), "group3")).thenReturn(false);
when(securityService.hasOperatePermissionForGroup(username.getUsername(), "group3")).thenReturn(true);
List<PipelineConfigs> pipelineConfigs = pipelineConfigService.viewableOrOperatableGroupsFor(username);
assertThat(pipelineConfigs.size(), is(2));
assertThat(pipelineConfigs.get(0).getGroup(), is("group1"));
assertThat(pipelineConfigs.get(1).getGroup(), is("group3"));
}
use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.
the class PartialConfigMother method withPipeline.
public static PartialConfig withPipeline(String name, RepoConfigOrigin repoOrigin) {
PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name);
BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
pipes.setGroup("group");
PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
partialConfig.setOrigins(repoOrigin);
return partialConfig;
}
use of com.thoughtworks.go.domain.PipelineGroups in project gocd by gocd.
the class PartialConfigMother method withPipelineInGroup.
public static PartialConfig withPipelineInGroup(String pipelineName, String groupName) {
PipelineConfig pipe = PipelineConfigMother.pipelineConfig(pipelineName);
BasicPipelineConfigs pipes = new BasicPipelineConfigs(groupName, new Authorization(), pipe);
PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
partialConfig.setOrigins(createRepoOrigin());
return partialConfig;
}
Aggregations