Search in sources :

Example 36 with ConfigurationValue

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));
        }
    }
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) SCMConfiguration(com.thoughtworks.go.plugin.access.scm.SCMConfiguration) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations)

Example 37 with ConfigurationValue

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);
        }
    }
}
Also used : ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property) TaskProperty(com.thoughtworks.go.domain.TaskProperty) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty)

Example 38 with ConfigurationValue

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));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) Test(org.junit.Test)

Example 39 with ConfigurationValue

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;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey)

Example 40 with ConfigurationValue

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);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Configuration(com.thoughtworks.go.domain.config.Configuration) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Username(com.thoughtworks.go.server.domain.Username) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) Before(org.junit.Before)

Aggregations

ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)56 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)50 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)49 Test (org.junit.Test)47 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)28 Configuration (com.thoughtworks.go.domain.config.Configuration)20 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)14 GoCipher (com.thoughtworks.go.security.GoCipher)10 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)9 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)9 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)7 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)6 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)5 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)3 SCM (com.thoughtworks.go.domain.scm.SCM)3