Search in sources :

Example 16 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class JsonBasedTaskExtensionHandler_V1 method configPropertiesAsMap.

private Map configPropertiesAsMap(TaskConfig taskConfig) {
    HashMap properties = new HashMap();
    for (Property property : taskConfig.list()) {
        final HashMap propertyValue = new HashMap();
        propertyValue.put("value", property.getValue());
        propertyValue.put("secure", property.getOption(Property.SECURE));
        propertyValue.put("required", property.getOption(Property.REQUIRED));
        properties.put(property.getKey(), propertyValue);
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property)

Example 17 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class PluginSettings method populateSettingsMap.

public void populateSettingsMap(PluginSettingsConfiguration configuration) {
    for (Property property : configuration.list()) {
        String settingsKey = property.getKey();
        Map<String, String> map = getSettingsMapFor(settingsKey);
        map.put(VALUE_KEY, "");
    }
}
Also used : PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Property(com.thoughtworks.go.plugin.api.config.Property)

Example 18 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class ConfigurationPropertyBuilderTest method shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForSecureProperty.

@Test
public void shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForSecureProperty() {
    Property key = new Property("key");
    key.with(Property.SECURE, true);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", "enc_value", true);
    assertThat(property.errors().get("configurationValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.errors().get("encryptedValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.getConfigurationValue().getValue(), is("value"));
    assertThat(property.getEncryptedValue(), is("enc_value"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 19 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class ConfigurationPropertyBuilderTest method shouldCreateWithValueForAUnsecuredProperty.

@Test
public void shouldCreateWithValueForAUnsecuredProperty() {
    Property key = new Property("key");
    key.with(Property.SECURE, false);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", null, false);
    assertThat(property.getConfigurationValue().getValue(), is("value"));
    assertNull(property.getEncryptedConfigurationValue());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 20 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class TaskConfig method list.

public List<? extends Property> list() {
    ArrayList<TaskConfigProperty> list = new ArrayList<>();
    for (Property property : super.list()) {
        list.add((TaskConfigProperty) property);
    }
    Collections.sort(list);
    return list;
}
Also used : ArrayList(java.util.ArrayList) Property(com.thoughtworks.go.plugin.api.config.Property)

Aggregations

Property (com.thoughtworks.go.plugin.api.config.Property)26 Test (org.junit.Test)15 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)13 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)8 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)4 TaskProperty (com.thoughtworks.go.domain.TaskProperty)3 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)3 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)3 ArrayList (java.util.ArrayList)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)2 Configuration (com.thoughtworks.go.domain.config.Configuration)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)2 HashMap (java.util.HashMap)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)1 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)1 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)1 GoCipher (com.thoughtworks.go.security.GoCipher)1