Search in sources :

Example 1 with CRConfigurationProperty

use of com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty in project gocd by gocd.

the class CRPluggableTask method getErrors.

@Override
public void getErrors(ErrorCollection errors, String parentLocation) {
    String location = getLocation(parentLocation);
    errors.checkMissing(location, "plugin_configuration", plugin_configuration);
    if (this.plugin_configuration != null)
        this.plugin_configuration.getErrors(errors, location);
    if (this.configuration != null) {
        for (CRConfigurationProperty p : configuration) {
            p.getErrors(errors, location);
        }
    }
    validateKeyUniqueness(errors, location);
}
Also used : CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty)

Example 2 with CRConfigurationProperty

use of com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty in project gocd by gocd.

the class ConfigRepoPlugin method getCrConfigurations.

public static List<CRConfigurationProperty> getCrConfigurations(Configuration configuration) {
    List<CRConfigurationProperty> config = new ArrayList<>();
    for (ConfigurationProperty prop : configuration) {
        String configKeyName = prop.getConfigKeyName();
        if (!prop.isSecure())
            config.add(new CRConfigurationProperty(configKeyName, prop.getValue(), null));
        else {
            CRConfigurationProperty crProp = new CRConfigurationProperty(configKeyName, null, prop.getEncryptedValue());
            config.add(crProp);
        }
    }
    return config;
}
Also used : CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty) CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ArrayList(java.util.ArrayList)

Example 3 with CRConfigurationProperty

use of com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty in project gocd by gocd.

the class ConfigRepoPluginTest method shouldGetCRConfigurationFromConfigurationWhenInsecureValue.

@Test
public void shouldGetCRConfigurationFromConfigurationWhenInsecureValue() {
    Configuration configuration = new Configuration();
    configuration.addNewConfigurationWithValue("key1", "value1", false);
    List<CRConfigurationProperty> crConfigurations = ConfigRepoPlugin.getCrConfigurations(configuration);
    assertThat(crConfigurations.size(), is(1));
    CRConfigurationProperty prop = crConfigurations.get(0);
    assertThat(prop.getKey(), is("key1"));
    assertThat(prop.getValue(), is("value1"));
}
Also used : CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) Test(org.junit.Test)

Example 4 with CRConfigurationProperty

use of com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty in project gocd by gocd.

the class ConfigRepoPluginTest method shouldGetCRConfigurationFromConfigurationWhenSecureValue.

@Test
public void shouldGetCRConfigurationFromConfigurationWhenSecureValue() {
    Configuration configuration = new Configuration();
    configuration.addNewConfigurationWithValue("key1", "@$$%^1234", true);
    List<CRConfigurationProperty> crConfigurations = ConfigRepoPlugin.getCrConfigurations(configuration);
    assertThat(crConfigurations.size(), is(1));
    CRConfigurationProperty prop = crConfigurations.get(0);
    assertThat(prop.getKey(), is("key1"));
    assertThat(prop.getEncryptedValue(), is("@$$%^1234"));
}
Also used : CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) Test(org.junit.Test)

Example 5 with CRConfigurationProperty

use of com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty in project gocd by gocd.

the class ConfigRepoPlugin method load.

@Override
public PartialConfig load(File configRepoCheckoutDirectory, PartialConfigLoadContext context) {
    Collection<CRConfigurationProperty> cRconfigurations = getCrConfigurations(context.configuration());
    CRParseResult crPartialConfig = parseDirectory(configRepoCheckoutDirectory, cRconfigurations);
    return configConverter.toPartialConfig(crPartialConfig, context);
}
Also used : CRConfigurationProperty(com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty) CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult)

Aggregations

CRConfigurationProperty (com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty)5 Configuration (com.thoughtworks.go.domain.config.Configuration)2 Test (org.junit.Test)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)1 CRParseResult (com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult)1 ArrayList (java.util.ArrayList)1