use of com.thoughtworks.go.config.TemplatesConfig in project gocd by gocd.
the class DeleteTemplateConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
preprocessedTemplateConfig = findAddedTemplate(modifiedConfig);
TemplatesConfig templatesConfig = modifiedConfig.getTemplates();
templatesConfig.removeTemplateNamed(preprocessedTemplateConfig.name());
modifiedConfig.setTemplates(templatesConfig);
}
use of com.thoughtworks.go.config.TemplatesConfig in project gocd by gocd.
the class InternalPipelineStructureControllerV1 method index.
public String index(Request request, Response response) throws IOException {
String pipelineGroupAuthorizationType = request.queryParamOrDefault("pipeline_group_authorization", "view");
String templateAuthorizationType = request.queryParamOrDefault("template_authorization", "view");
Supplier<PipelineGroups> pipelineGroupsSupplier = pipelineGroupAuthorizationRegistry.get(pipelineGroupAuthorizationType);
Supplier<TemplatesConfig> templatesConfigSupplier = templateAuthorizationRegistry.get(templateAuthorizationType);
if (pipelineGroupsSupplier == null || templatesConfigSupplier == null) {
HaltApiResponses.haltBecauseOfReason("Bad query parameter.");
}
EnvironmentsConfig environments = new EnvironmentsConfig();
environments.addAll(environmentConfigService.getEnvironments());
Hashtable<CaseInsensitiveString, Node> dependencyTable = goConfigService.getCurrentConfig().getDependencyTable();
PipelineStructureViewModel pipelineStructureViewModel = new PipelineStructureViewModel().setPipelineGroups(pipelineGroupsSupplier.get()).setTemplatesConfig(templatesConfigSupplier.get()).setEnvironmentsConfig(environments).setPipelineDependencyTable(dependencyTable);
boolean withAdditionalInfo = parseBoolean(request.queryParams("with_additional_info"));
if (!withAdditionalInfo) {
return writerForTopLevelObject(request, response, outputWriter -> InternalPipelineStructuresRepresenter.toJSON(outputWriter, pipelineStructureViewModel));
}
Collection<String> users = userService.allUsernames();
Collection<String> roles = userService.allRoleNames();
return writerForTopLevelObject(request, response, outputWriter -> InternalPipelineStructuresRepresenter.toJSON(outputWriter, pipelineStructureViewModel, users, roles));
}
use of com.thoughtworks.go.config.TemplatesConfig in project gocd by gocd.
the class UpdateTemplateConfigCommand method update.
@Override
public void update(CruiseConfig modifiedConfig) {
PipelineTemplateConfig existingTemplateConfig = findAddedTemplate(modifiedConfig);
templateConfig.setAuthorization(existingTemplateConfig.getAuthorization());
TemplatesConfig templatesConfig = modifiedConfig.getTemplates();
templatesConfig.removeTemplateNamed(existingTemplateConfig.name());
templatesConfig.add(templateConfig);
modifiedConfig.setTemplates(templatesConfig);
}
Aggregations