Search in sources :

Example 1 with TemplatesConfig

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);
}
Also used : TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig)

Example 2 with 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));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) Node(com.thoughtworks.go.util.Node) PipelineStructureViewModel(com.thoughtworks.go.apiv1.internalpipelinestructure.models.PipelineStructureViewModel) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig)

Example 3 with TemplatesConfig

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);
}
Also used : TemplatesConfig(com.thoughtworks.go.config.TemplatesConfig) PipelineTemplateConfig(com.thoughtworks.go.config.PipelineTemplateConfig)

Aggregations

TemplatesConfig (com.thoughtworks.go.config.TemplatesConfig)3 PipelineStructureViewModel (com.thoughtworks.go.apiv1.internalpipelinestructure.models.PipelineStructureViewModel)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 EnvironmentsConfig (com.thoughtworks.go.config.EnvironmentsConfig)1 PipelineTemplateConfig (com.thoughtworks.go.config.PipelineTemplateConfig)1 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)1 Node (com.thoughtworks.go.util.Node)1