use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class BasicPipelineConfigsTest method shouldUpdateName.
@Test
public void shouldUpdateName() {
PipelineConfigs group = createWithPipeline(PipelineConfigMother.pipelineConfig("pipeline1"));
group.setConfigAttributes(m(BasicPipelineConfigs.GROUP, "my-new-group"));
assertThat(group.getGroup(), is("my-new-group"));
group.setConfigAttributes(m());
assertThat(group.getGroup(), is("my-new-group"));
group.setConfigAttributes(null);
assertThat(group.getGroup(), is("my-new-group"));
group.setConfigAttributes(m(BasicPipelineConfigs.GROUP, null));
assertThat(group.getGroup(), is(nullValue()));
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class BasicPipelineConfigsTest method shouldSetOriginInAuthorization.
@Test
public void shouldSetOriginInAuthorization() {
PipelineConfig pipe = PipelineConfigMother.pipelineConfig("pipeline1");
PipelineConfigs group = new BasicPipelineConfigs(pipe);
group.setOrigins(new FileConfigOrigin());
assertThat(group.getAuthorization().getOrigin(), Is.<ConfigOrigin>is(new FileConfigOrigin()));
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MyGoController method render.
private ModelAndView render(HttpServletRequest request, Message message, HashMap<String, Object> data) {
User user = userService.load(getUserId(request));
user.populateModel(data);
for (String key : data.keySet()) {
if (StringUtils.isNotBlank(request.getParameter(key))) {
data.put(key, request.getParameter(key));
}
}
List<PipelineConfigs> groups = pipelineConfigService.viewableGroupsFor(getUserName());
data.put("pipelines", new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(getPipelineModelsSortedByNameFor(groups)));
data.put("l", localizer);
message.populateModel(data);
return new ModelAndView("mycruise/mycruise-tab", data);
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MyGoController method getPipelineModelsSortedByNameFor.
private List<PipelineViewModel> getPipelineModelsSortedByNameFor(List<PipelineConfigs> groups) {
List<PipelineViewModel> pipelineModels = new ArrayList<>();
List<PipelineViewModel.StageViewModel> anyPipelineStageModels = new ArrayList<>();
anyPipelineStageModels.add(new PipelineViewModel.StageViewModel(GoConstants.ANY_STAGE));
pipelineModels.add(new PipelineViewModel(GoConstants.ANY_PIPELINE, anyPipelineStageModels));
for (PipelineConfigs group : groups) {
for (PipelineConfig pipelineConfig : group) {
pipelineModels.add(new PipelineViewModel(CaseInsensitiveString.str(pipelineConfig.name()), getStagesModelsFor(pipelineConfig)));
}
}
Collections.sort(pipelineModels);
return pipelineModels;
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MaterialConfigService method getMaterialConfig.
public MaterialConfig getMaterialConfig(String username, String materialFingerprint, OperationResult result) {
MaterialConfig materialConfig = null;
boolean hasViewPermissionForMaterial = false;
for (PipelineConfigs pipelineGroup : goConfigService.groups()) {
boolean hasViewPermissionForGroup = securityService.hasViewPermissionForGroup(username, pipelineGroup.getGroup());
for (PipelineConfig pipelineConfig : pipelineGroup) {
for (MaterialConfig currentMaterialConfig : pipelineConfig.materialConfigs()) {
if (currentMaterialConfig.getFingerprint().equals(materialFingerprint)) {
materialConfig = currentMaterialConfig;
if (hasViewPermissionForGroup) {
hasViewPermissionForMaterial = true;
break;
}
}
}
}
}
if (materialConfig == null) {
result.notFound("Not Found", "Material not found", HealthStateType.general(HealthStateScope.GLOBAL));
return null;
}
if (!hasViewPermissionForMaterial) {
result.unauthorized("Unauthorized", "Do not have view permission to this material", HealthStateType.general(HealthStateScope.GLOBAL));
return null;
}
return materialConfig;
}
Aggregations