use of com.thoughtworks.go.domain.config.ConfigurationValue in project gocd by gocd.
the class SCM method setPluginConfigurationAttributes.
protected void setPluginConfigurationAttributes(Map attributes) {
SCMConfigurations scmConfigurations = SCMMetadataStore.getInstance().getConfigurationMetadata(pluginConfiguration.getId());
if (scmConfigurations == null) {
throw new RuntimeException("metadata unavailable for plugin: " + pluginConfiguration.getId());
}
for (SCMConfiguration scmConfiguration : scmConfigurations.list()) {
String key = scmConfiguration.getKey();
if (attributes.containsKey(key)) {
if (configuration.getProperty(key) == null) {
configuration.addNewConfiguration(scmConfiguration.getKey(), scmConfiguration.getOption(Property.SECURE));
}
configuration.getProperty(key).setConfigurationValue(new ConfigurationValue((String) attributes.get(key)));
configuration.getProperty(key).handleSecureValueConfiguration(scmConfiguration.getOption(Property.SECURE));
}
}
}
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 CreateAgentMessageTest method shouldGetPluginId.
@Test
public void shouldGetPluginId() {
List<ConfigurationProperty> properties = Arrays.asList(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
ElasticProfile jobAgentConfig = new ElasticProfile("foo", "plugin-id", properties);
CreateAgentMessage message = new CreateAgentMessage("key", "env", jobAgentConfig, null);
assertThat(message.pluginId(), is(jobAgentConfig.getPluginId()));
Map<String, String> configurationAsMap = jobAgentConfig.getConfigurationAsMap(true);
assertThat(message.configuration(), is(configurationAsMap));
}
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.setEncryptedValue(new EncryptedConfigurationValue(encryptedValue));
return configurationProperty;
}
if (isSecure) {
if (isNotBlank(encryptedValue)) {
configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encryptedValue));
}
if (isNotBlank(value)) {
configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encrypt(value)));
}
} else {
if (isNotBlank(encryptedValue)) {
configurationProperty.addError("encryptedValue", "encrypted_value cannot be specified to a unsecured property.");
configurationProperty.setEncryptedValue(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 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);
}
Aggregations