use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class DeletePackageConfigCommandTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
packageUuid = "random-uuid";
configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
packageDefinition = new PackageDefinition(packageUuid, "prettyjson", configuration);
result = new HttpLocalizedOperationResult();
PackageRepositories repositories = cruiseConfig.getPackageRepositories();
PackageRepository repository = new PackageRepository();
repository.addPackage(packageDefinition);
repositories.add(repository);
cruiseConfig.setPackageRepositories(repositories);
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class ScheduledPipelineLoaderIntegrationTest method shouldUpdateScmConfigurationOfPluggableScmMaterialsOnPipeline.
@Test
public void shouldUpdateScmConfigurationOfPluggableScmMaterialsOnPipeline() {
String jobName = "job-one";
PipelineConfig pipelineConfig = setupPipelineWithScmMaterial("pipeline_with_pluggable_scm_mat", "stage", jobName);
final Pipeline previousSuccessfulBuildWithOlderScmConfig = simulateSuccessfulPipelineRun(pipelineConfig);
PipelineConfig updatedPipelineConfig = configHelper.updatePipeline(pipelineConfig.name(), new GoConfigFileHelper.Updater<PipelineConfig>() {
@Override
public void update(PipelineConfig config) {
PluggableSCMMaterialConfig materialConfig = (PluggableSCMMaterialConfig) config.materialConfigs().first();
materialConfig.getSCMConfig().getConfiguration().getProperty("password").setConfigurationValue(new ConfigurationValue("new_value"));
}
});
final long jobId = rerunJob(jobName, pipelineConfig, previousSuccessfulBuildWithOlderScmConfig);
Pipeline loadedPipeline = (Pipeline) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
return loader.pipelineWithPasswordAwareBuildCauseByBuildId(jobId);
}
});
MaterialRevisions revisions = loadedPipeline.getBuildCause().getMaterialRevisions();
Configuration updatedConfiguration = ((PluggableSCMMaterial) revisions.findRevisionFor(updatedPipelineConfig.materialConfigs().first()).getMaterial()).getScmConfig().getConfiguration();
assertThat(updatedConfiguration.size(), is(2));
assertThat(updatedConfiguration.getProperty("password").getConfigurationValue(), is(new ConfigurationValue("new_value")));
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class PluggableTask method setTaskConfigAttributes.
@Override
protected void setTaskConfigAttributes(Map attributes) {
TaskConfig taskConfig = PluggableTaskConfigStore.store().preferenceFor(pluginConfiguration.getId()).getConfig();
for (Property property : taskConfig.list()) {
String key = property.getKey();
if (attributes.containsKey(key)) {
Boolean isSecure = property.getOption(Property.SECURE);
if (configuration.getProperty(key) == null) {
configuration.addNewConfiguration(property.getKey(), isSecure);
}
configuration.getProperty(key).setConfigurationValue(new ConfigurationValue((String) attributes.get(key)));
configuration.getProperty(key).handleSecureValueConfiguration(isSecure);
}
}
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class ConfigurationPropertyBuilder method create.
public ConfigurationProperty create(String key, String value, String encryptedValue, Boolean isSecure) {
ConfigurationProperty configurationProperty = new ConfigurationProperty();
configurationProperty.setConfigurationKey(new ConfigurationKey(key));
if (isNotBlank(value) && isNotBlank(encryptedValue)) {
configurationProperty.addError("configurationValue", "You may only specify `value` or `encrypted_value`, not both!");
configurationProperty.addError("encryptedValue", "You may only specify `value` or `encrypted_value`, not both!");
configurationProperty.setConfigurationValue(new ConfigurationValue(value));
configurationProperty.setEncryptedConfigurationValue(new EncryptedConfigurationValue(encryptedValue));
return configurationProperty;
}
if (isSecure) {
if (isNotBlank(encryptedValue)) {
configurationProperty.setEncryptedConfigurationValue(new EncryptedConfigurationValue(encryptedValue));
}
if (isNotBlank(value)) {
configurationProperty.setEncryptedConfigurationValue(new EncryptedConfigurationValue(encrypt(value)));
}
} else {
if (isNotBlank(encryptedValue)) {
configurationProperty.addError("encryptedValue", "encrypted_value cannot be specified to a unsecured property.");
configurationProperty.setEncryptedConfigurationValue(new EncryptedConfigurationValue(encryptedValue));
}
if (isNotBlank(value)) {
configurationProperty.setConfigurationValue(new ConfigurationValue(value));
}
}
return configurationProperty;
}
use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class JobAgentMetadata method elasticProfile.
public ElasticProfile elasticProfile() {
Gson gson = new Gson();
Map map = gson.fromJson(metadata, LinkedHashMap.class);
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 = MapUtil.collect(properties, new ListUtil.Transformer<Map.Entry<String, String>, ConfigurationProperty>() {
@Override
public ConfigurationProperty transform(Map.Entry<String, String> entry) {
return new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()));
}
});
return new ElasticProfile(id, pluginId, configProperties);
}
Aggregations