use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobInstanceMother method jobPlanWithAssociatedEntities.
public static JobPlan jobPlanWithAssociatedEntities(String jobName, long id, List<ArtifactPlan> artifactPlans, List<ArtifactPropertiesGenerator> artifactPropertiesGenerators) {
ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey("image"), new ConfigurationValue("elastic-agent"));
ElasticProfile elasticProfile = new ElasticProfile("elastic", "plugin", configurationProperty);
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("some_var", "blah");
return new DefaultJobPlan(new Resources(new Resource("foo"), new Resource("bar")), artifactPlans, artifactPropertiesGenerators, id, defaultJobIdentifier(jobName), null, variables, new EnvironmentVariables(), elasticProfile);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class FetchPluggableArtifactTaskTest method encryptSecureProperties_shouldEncryptSecureProperties.
@Test
void encryptSecureProperties_shouldEncryptSecureProperties() throws CryptoException {
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("secure_property1", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("secure_property2", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("plain", new Metadata(true, false)));
when(artifactPluginInfo.getFetchArtifactSettings()).thenReturn(new PluggableInstanceSettings(pluginConfigurations));
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "job");
PluggableArtifactConfig pluggableArtifactConfig = new PluggableArtifactConfig("s3", "aws");
pipelineConfig.getStage("stage").jobConfigByConfigName("job").artifactTypeConfigs().add(pluggableArtifactConfig);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.addPipelineWithoutValidation("foo", pipelineConfig);
cruiseConfig.getArtifactStores().add(new ArtifactStore("aws", artifactPluginInfo.getDescriptor().id()));
FetchPluggableArtifactTask task = new FetchPluggableArtifactTask(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "s3");
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("plain"), new ConfigurationValue("plain")));
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property1"), new ConfigurationValue("password")));
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property2"), new EncryptedConfigurationValue(new GoCipher().encrypt("secret"))));
ArrayList<ConfigurationProperty> expectedConfigurationProperties = new ArrayList<>();
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("plain"), new ConfigurationValue("plain")));
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property1"), new EncryptedConfigurationValue(new GoCipher().encrypt("password"))));
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property2"), new EncryptedConfigurationValue(new GoCipher().encrypt("secret"))));
task.addConfigurations(configurationProperties);
task.encryptSecureProperties(cruiseConfig, pipelineConfig, task);
assertThat(task.getConfiguration().size()).isEqualTo(3);
assertThat(task.getConfiguration()).isEqualTo(expectedConfigurationProperties);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class FetchPluggableArtifactTaskTest method encryptSecureProperties_shouldEncryptSecurePropertiesIfTheConfigIdentifersAreParams.
@Test
void encryptSecureProperties_shouldEncryptSecurePropertiesIfTheConfigIdentifersAreParams() throws CryptoException {
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("secure_property1", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("secure_property2", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("plain", new Metadata(true, false)));
when(artifactPluginInfo.getFetchArtifactSettings()).thenReturn(new PluggableInstanceSettings(pluginConfigurations));
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "job");
PluggableArtifactConfig pluggableArtifactConfig = new PluggableArtifactConfig("s3", "aws");
pipelineConfig.getStage("stage").jobConfigByConfigName("job").artifactTypeConfigs().add(pluggableArtifactConfig);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.addPipelineWithoutValidation("foo", pipelineConfig);
cruiseConfig.getArtifactStores().add(new ArtifactStore("aws", artifactPluginInfo.getDescriptor().id()));
FetchPluggableArtifactTask task = new FetchPluggableArtifactTask(new CaseInsensitiveString("#{pipeline}"), new CaseInsensitiveString("#{stage}"), new CaseInsensitiveString("#{job}"), "#{artifactId}");
FetchPluggableArtifactTask preprocessedTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "s3");
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("plain"), new ConfigurationValue("plain")));
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property1"), new ConfigurationValue("password")));
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property2"), new EncryptedConfigurationValue(new GoCipher().encrypt("secret"))));
ArrayList<ConfigurationProperty> expectedConfigurationProperties = new ArrayList<>();
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("plain"), new ConfigurationValue("plain")));
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property1"), new EncryptedConfigurationValue(new GoCipher().encrypt("password"))));
expectedConfigurationProperties.add(new ConfigurationProperty(new ConfigurationKey("secure_property2"), new EncryptedConfigurationValue(new GoCipher().encrypt("secret"))));
task.addConfigurations(configurationProperties);
PipelineConfig pipelineWhichHasTheFetchTask = PipelineConfigMother.createPipelineConfigWithStage("p2", "anotherStage");
pipelineWhichHasTheFetchTask.first().getJobs().first().addTask(task);
pipelineWhichHasTheFetchTask.setParams(new ParamsConfig(new ParamConfig("pipeline", "pipeline"), new ParamConfig("stage", "stage"), new ParamConfig("job", "job"), new ParamConfig("artifactId", "s3")));
task.encryptSecureProperties(cruiseConfig, pipelineWhichHasTheFetchTask, preprocessedTask);
assertThat(task.getConfiguration().size()).isEqualTo(3);
assertThat(task.getConfiguration()).isEqualTo(expectedConfigurationProperties);
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class ElasticProfileDTO method toDomainModel.
public ElasticProfile toDomainModel() {
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
this.properties.forEach((key, value) -> {
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
});
ElasticProfile elasticProfile = new ElasticProfile(this.id, this.clusterProfileId);
elasticProfile.addConfigurations(configurationProperties);
return elasticProfile;
}
use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.
the class JobAgentMetadata method clusterProfile.
public ClusterProfile clusterProfile() {
Map map = GSON.fromJson(clusterProfileMetadata, LinkedHashMap.class);
if (map == null || map.isEmpty()) {
return null;
}
String pluginId = (String) map.get("pluginId");
String id = (String) map.get("id");
Map<String, String> properties = (Map<String, String>) map.get("properties");
Collection<ConfigurationProperty> configProperties = properties.entrySet().stream().map(entry -> new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()))).collect(Collectors.toList());
return new ClusterProfile(id, pluginId, configProperties);
}
Aggregations