Search in sources :

Example 46 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class ElasticProfileDTO method toDomainModel.

public ElasticProfile toDomainModel() {
    ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
    this.properties.forEach((key, value) -> {
        configurationProperties.add(new ConfigurationProperty(new ConfigurationKey(key), new ConfigurationValue(value)));
    });
    ElasticProfile elasticProfile = new ElasticProfile(this.id, this.clusterProfileId);
    elasticProfile.addConfigurations(configurationProperties);
    return elasticProfile;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ArrayList(java.util.ArrayList) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile)

Example 47 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class JobAgentMetadata method clusterProfile.

public ClusterProfile clusterProfile() {
    Map map = GSON.fromJson(clusterProfileMetadata, LinkedHashMap.class);
    if (map == null || map.isEmpty()) {
        return null;
    }
    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 = properties.entrySet().stream().map(entry -> new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()))).collect(Collectors.toList());
    return new ClusterProfile(id, pluginId, configProperties);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) GsonBuilder(com.google.gson.GsonBuilder) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) LinkedHashMap(java.util.LinkedHashMap) Objects(java.util.Objects) FieldNamingPolicy(com.google.gson.FieldNamingPolicy) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Gson(com.google.gson.Gson) Map(java.util.Map) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 48 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class JobAgentMetadata method elasticProfile.

public ElasticProfile elasticProfile() {
    Map map = GSON.fromJson(elasticAgentProfileMetadata, LinkedHashMap.class);
    String clusterProfileId = (String) map.get("clusterProfileId");
    String id = (String) map.get("id");
    Map<String, String> properties = (Map<String, String>) map.get("properties");
    Collection<ConfigurationProperty> configProperties = properties.entrySet().stream().map(entry -> new ConfigurationProperty(new ConfigurationKey(entry.getKey()), new ConfigurationValue(entry.getValue()))).collect(Collectors.toList());
    return new ElasticProfile(id, clusterProfileId, configProperties);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) GsonBuilder(com.google.gson.GsonBuilder) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) LinkedHashMap(java.util.LinkedHashMap) Objects(java.util.Objects) FieldNamingPolicy(com.google.gson.FieldNamingPolicy) ClusterProfile(com.thoughtworks.go.config.elastic.ClusterProfile) Gson(com.google.gson.Gson) Map(java.util.Map) ElasticProfile(com.thoughtworks.go.config.elastic.ElasticProfile) 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) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 49 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class DeletePackageConfigCommandTest method setup.

@BeforeEach
public void setup() throws Exception {
    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) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 50 with ConfigurationKey

use of com.thoughtworks.go.domain.config.ConfigurationKey in project gocd by gocd.

the class RoleConfigCommandTest method shouldEncryptRoleConfig.

@Test
public void shouldEncryptRoleConfig() throws CryptoException {
    setAuthorizationPluginInfo();
    cruiseConfig.server().security().securityAuthConfigs().add(new SecurityAuthConfig("ldap", "cd.go.github"));
    PluginRoleConfig role = new PluginRoleConfig("blackbird", "ldap");
    role.addConfigurations(asList(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("pub_v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("pub_v2")), new ConfigurationProperty(new ConfigurationKey("k3"), new ConfigurationValue("pub_v3"))));
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    RoleConfigCommand command = new StubCommand(goConfigService, role, extension, currentUser, result);
    assertThat(role.getProperty("k1").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k1").getConfigValue(), is("pub_v1"));
    assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
    assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
    assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
    assertThat(role.getProperty("k3").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k3").getConfigValue(), is("pub_v3"));
    assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
    command.encrypt(cruiseConfig);
    GoCipher goCipher = new GoCipher();
    assertThat(role.getProperty("k1").getEncryptedValue(), is(goCipher.encrypt("pub_v1")));
    assertThat(role.getProperty("k1").getConfigValue(), is(nullValue()));
    assertThat(role.getProperty("k1").getValue(), is("pub_v1"));
    assertThat(role.getProperty("k2").getEncryptedValue(), is(nullValue()));
    assertThat(role.getProperty("k2").getConfigValue(), is("pub_v2"));
    assertThat(role.getProperty("k2").getValue(), is("pub_v2"));
    assertThat(role.getProperty("k3").getEncryptedValue(), is(goCipher.encrypt("pub_v3")));
    assertThat(role.getProperty("k3").getConfigValue(), is(nullValue()));
    assertThat(role.getProperty("k3").getValue(), is("pub_v3"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)71 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)71 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)65 Test (org.junit.jupiter.api.Test)49 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)29 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)13 GoCipher (com.thoughtworks.go.security.GoCipher)13 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)12 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)12 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)11 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)9 ArrayList (java.util.ArrayList)9 Configuration (com.thoughtworks.go.domain.config.Configuration)8 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)8 Test (org.junit.Test)7 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)5 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)4