Search in sources :

Example 16 with FileConfigOrigin

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

the class GoConfigMother method addPipelineWithGroupAndTimer.

public PipelineConfig addPipelineWithGroupAndTimer(CruiseConfig cruiseConfig, String groupName, String pipelineName, MaterialConfigs materialConfigs, String stageName, TimerConfig timer, String... buildNames) {
    String cronSpec = timer == null ? null : timer.getTimerSpec();
    boolean shouldTriggerOnlyOnMaterialChanges = timer != null && timer.shouldTriggerOnlyOnChanges();
    StageConfig stageConfig = StageConfigMother.custom(stageName, defaultBuildPlans(buildNames));
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString(pipelineName), PipelineLabel.COUNT_TEMPLATE, cronSpec, shouldTriggerOnlyOnMaterialChanges, materialConfigs, asList(stageConfig));
    pipelineConfig.setOrigin(new FileConfigOrigin());
    cruiseConfig.addPipeline(groupName, pipelineConfig);
    return pipelineConfig;
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin)

Example 17 with FileConfigOrigin

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

the class MagicalGoConfigXmlLoaderTest method shouldSetConfigOriginInPipeline_AfterLoadingConfigFile.

@Test
public void shouldSetConfigOriginInPipeline_AfterLoadingConfigFile() throws Exception {
    CruiseConfig cruiseConfig = xmlLoader.loadConfigHolder(CONFIG).config;
    PipelineConfig pipelineConfig1 = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("pipeline1"));
    assertThat(pipelineConfig1.getOrigin(), Is.<ConfigOrigin>is(new FileConfigOrigin()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Example 18 with FileConfigOrigin

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

the class MaterialConfigsTest method shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile.

@Test
public void shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
    goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
    pipeline1.setOrigin(new RepoConfigOrigin());
    pipeline2.setOrigin(new FileConfigOrigin());
    pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
    pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
    DependencyMaterialConfig invalidDependency = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
    assertThat(invalidDependency.errors().isEmpty(), is(false));
    assertThat(invalidDependency.errors().on(DependencyMaterialConfig.ORIGIN), startsWith("Dependency from pipeline defined in"));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 19 with FileConfigOrigin

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

the class MagicalGoConfigXmlLoader method deserializeConfig.

public CruiseConfig deserializeConfig(String content) throws Exception {
    String md5 = CachedDigestUtils.md5Hex(content);
    Element element = parseInputStream(new ByteArrayInputStream(content.getBytes()));
    LOGGER.debug("[Config Save] Updating config cache with new XML");
    CruiseConfig configForEdit = classParser(element, BasicCruiseConfig.class, configCache, new GoCipher(), registry, new ConfigReferenceElements()).parse();
    setMd5(configForEdit, md5);
    configForEdit.setOrigins(new FileConfigOrigin());
    return configForEdit;
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) ByteArrayInputStream(java.io.ByteArrayInputStream) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Element(org.jdom2.Element) ConfigReferenceElements(com.thoughtworks.go.config.parser.ConfigReferenceElements)

Example 20 with FileConfigOrigin

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

the class PipelineConfigsTestBase method shouldNotErrorWhenAuthorizationIsDefinedLocally.

@Test
public void shouldNotErrorWhenAuthorizationIsDefinedLocally() {
    BasicPipelineConfigs group = new BasicPipelineConfigs(new FileConfigOrigin());
    group.setGroup("gr");
    group.setConfigAttributes(m(BasicPipelineConfigs.AUTHORIZATION, a(m(Authorization.NAME, "loser", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(ON, DISABLED, DISABLED)), m(Authorization.NAME, "boozer", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(OFF, ON, ON)), m(Authorization.NAME, "geezer", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(DISABLED, OFF, ON)), m(Authorization.NAME, "gang_of_losers", Authorization.TYPE, ROLE.toString(), Authorization.PRIVILEGES, privileges(DISABLED, OFF, ON)), m(Authorization.NAME, "blinds", Authorization.TYPE, ROLE.toString(), Authorization.PRIVILEGES, privileges(ON, ON, OFF)))));
    group.validate(null);
    assertThat(group.errors().isEmpty(), is(true));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Aggregations

FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)59 Test (org.junit.Test)51 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)23 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)5 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 Permissions (com.thoughtworks.go.config.security.Permissions)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)4 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MergeConfigOrigin (com.thoughtworks.go.config.merge.MergeConfigOrigin)1