Search in sources :

Example 16 with ConfigReposConfig

use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.

the class GoConfigMother method configWithConfigRepo.

public static CruiseConfig configWithConfigRepo() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setConfigRepos(new ConfigReposConfig(ConfigRepoConfig.createConfigRepoConfig(git("https://github.com/tomzo/gocd-indep-config-part.git"), "myplugin", "id2")));
    return cruiseConfig;
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig)

Example 17 with ConfigReposConfig

use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.

the class GoConfigWatchListTest method shouldNotifyConfigListenersWhenConfigChanges.

@Test
public void shouldNotifyConfigListenersWhenConfigChanges() throws Exception {
    final ChangedRepoConfigWatchListListener listener = mock(ChangedRepoConfigWatchListListener.class);
    watchList.registerListener(listener);
    when(cruiseConfig.getConfigRepos()).thenReturn(new ConfigReposConfig());
    watchList.onConfigChange(cruiseConfig);
    verify(listener, times(1)).onChangedRepoConfigWatchList(notNull(ConfigReposConfig.class));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) Test(org.junit.Test)

Example 18 with ConfigReposConfig

use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.

the class ConfigReposControllerV4 method index.

String index(Request req, Response res) {
    ConfigReposConfig repos = allRepos();
    ConfigReposConfig userSpecificRepos = repos.stream().filter(configRepoConfig -> authHelper.doesUserHasPermissions(currentUsername(), getAction(req), CONFIG_REPO, configRepoConfig.getId())).collect(toCollection(ConfigReposConfig::new));
    String etag = entityHashingService.hashForEntity(userSpecificRepos);
    setEtagHeader(res, etag);
    if (fresh(req, etag)) {
        return notModified(res);
    }
    return jsonizeAsTopLevelObject(req, w -> ConfigReposConfigRepresenterV4.toJSON(w, userSpecificRepos));
}
Also used : CrudController(com.thoughtworks.go.api.CrudController) EntityType(com.thoughtworks.go.config.exceptions.EntityType) MaterialConfigConverter(com.thoughtworks.go.server.service.MaterialConfigConverter) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageJson(com.thoughtworks.go.api.util.MessageJson) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) EntityHashingService(com.thoughtworks.go.server.service.EntityHashingService) Collectors.toCollection(java.util.stream.Collectors.toCollection) JsonReader(com.thoughtworks.go.api.representers.JsonReader) Request(spark.Request) SparkSpringController(com.thoughtworks.go.spark.spring.SparkSpringController) ApiVersion(com.thoughtworks.go.api.ApiVersion) MaterialUpdateService(com.thoughtworks.go.server.materials.MaterialUpdateService) Routes(com.thoughtworks.go.spark.Routes) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) ApiController(com.thoughtworks.go.api.ApiController) GsonTransformer(com.thoughtworks.go.api.util.GsonTransformer) HaltApiResponses.haltBecauseEntityAlreadyExists(com.thoughtworks.go.api.util.HaltApiResponses.haltBecauseEntityAlreadyExists) PartialConfigRepresenter(com.thoughtworks.go.apiv4.configrepos.representers.PartialConfigRepresenter) ConfigRepoService(com.thoughtworks.go.server.service.ConfigRepoService) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) ApiAuthenticationHelper(com.thoughtworks.go.api.spring.ApiAuthenticationHelper) Consumer(java.util.function.Consumer) HttpStatus(org.springframework.http.HttpStatus) OutputWriter(com.thoughtworks.go.api.base.OutputWriter) Component(org.springframework.stereotype.Component) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) Response(spark.Response) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) CONFIG_REPO(com.thoughtworks.go.config.policy.SupportedEntity.CONFIG_REPO) HaltApiResponses.haltBecauseEtagDoesNotMatch(com.thoughtworks.go.api.util.HaltApiResponses.haltBecauseEtagDoesNotMatch) ConfigReposConfigRepresenterV4(com.thoughtworks.go.apiv4.configrepos.representers.ConfigReposConfigRepresenterV4) Spark(spark.Spark) ConfigRepoConfigRepresenterV4(com.thoughtworks.go.apiv4.configrepos.representers.ConfigRepoConfigRepresenterV4) CachedDigestUtils.sha512_256Hex(com.thoughtworks.go.util.CachedDigestUtils.sha512_256Hex) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig)

Example 19 with ConfigReposConfig

use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.

the class BasicEnvironmentConfig method validate.

@Override
public void validate(ValidationContext validationContext) {
    // each of these references is defined in this.origin
    for (EnvironmentPipelineConfig pipelineRefConfig : this.pipelines) {
        ConfigReposConfig configRepos = validationContext.getConfigRepos();
        PipelineConfig pipelineConfig = validationContext.getPipelineConfigByName(pipelineRefConfig.getName());
        if (pipelineConfig == null) {
            // other rule will error that we reference unknown pipeline
            continue;
        }
        if (validationContext.shouldCheckConfigRepo()) {
            if (!configRepos.isReferenceAllowed(this.origin, pipelineConfig.getOrigin()))
                pipelineRefConfig.addError(EnvironmentPipelineConfig.ORIGIN, String.format("Environment defined in %s cannot reference a pipeline in %s", this.origin, displayNameFor(pipelineConfig.getOrigin())));
        }
    }
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig)

Example 20 with ConfigReposConfig

use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.

the class UpdateConfigRepoCommand method update.

@Override
public void update(CruiseConfig preprocessedConfig) {
    ConfigReposConfig configRepos = preprocessedConfig.getConfigRepos();
    configRepos.replace(configRepos.getConfigRepo(repoIdToUpdate), newConfigRepo);
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig)

Aggregations

ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)30 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)18 Test (org.junit.jupiter.api.Test)17 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)14 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)5 File (java.io.File)4 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 ConfigRepoService (com.thoughtworks.go.server.service.ConfigRepoService)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ApiController (com.thoughtworks.go.api.ApiController)1 ApiVersion (com.thoughtworks.go.api.ApiVersion)1 CrudController (com.thoughtworks.go.api.CrudController)1 OutputWriter (com.thoughtworks.go.api.base.OutputWriter)1 JsonReader (com.thoughtworks.go.api.representers.JsonReader)1 ApiAuthenticationHelper (com.thoughtworks.go.api.spring.ApiAuthenticationHelper)1 GsonTransformer (com.thoughtworks.go.api.util.GsonTransformer)1 HaltApiResponses.haltBecauseEntityAlreadyExists (com.thoughtworks.go.api.util.HaltApiResponses.haltBecauseEntityAlreadyExists)1