forked from gocd/gocd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ocd#5538) * On plugin load, make a config migration call to all elastic agent plugins to migrate cluster profile(s) and elastic agent profile(s) providing plugin settings, cluster profile(s) and elastic agent profile(s). * Save received migrated config back to the xml. * Migrate will always be made to plugin on plugin load even if the latest available config has already been migrated.
- Loading branch information
1 parent
10ad950
commit 89066ac
Showing
27 changed files
with
1,209 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...c/main/java/com/thoughtworks/go/plugin/access/elastic/models/ElasticAgentInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2019 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.thoughtworks.go.plugin.access.elastic.models; | ||
|
||
import com.thoughtworks.go.config.elastic.ClusterProfile; | ||
import com.thoughtworks.go.config.elastic.ElasticProfile; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ElasticAgentInformation { | ||
private final Map<String, Map<String, Object>> pluginSettings; | ||
private final List<ClusterProfile> clusterProfiles; | ||
private final List<ElasticProfile> elasticAgentProfiles; | ||
|
||
public ElasticAgentInformation(Map<String, Map<String, Object>> pluginSettings, List<ClusterProfile> clusterProfiles, List<ElasticProfile> elasticAgentProfiles) { | ||
this.pluginSettings = pluginSettings; | ||
this.clusterProfiles = clusterProfiles; | ||
this.elasticAgentProfiles = elasticAgentProfiles; | ||
} | ||
|
||
public Map<String, Map<String, Object>> getPluginSettings() { | ||
return pluginSettings; | ||
} | ||
|
||
public List<ClusterProfile> getClusterProfiles() { | ||
return clusterProfiles; | ||
} | ||
|
||
public List<ElasticProfile> getElasticAgentProfiles() { | ||
return elasticAgentProfiles; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ElasticAgentInformation that = (ElasticAgentInformation) o; | ||
return Objects.equals(pluginSettings, that.pluginSettings) && | ||
Objects.equals(clusterProfiles, that.clusterProfiles) && | ||
Objects.equals(elasticAgentProfiles, that.elasticAgentProfiles); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(pluginSettings, clusterProfiles, elasticAgentProfiles); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ElasticAgentInformation{" + | ||
"pluginSettings=" + pluginSettings + | ||
", clusterProfiles=" + clusterProfiles + | ||
", elasticAgentProfiles=" + elasticAgentProfiles + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ClusterProfileDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2019 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.thoughtworks.go.plugin.access.elastic.v5; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.thoughtworks.go.config.builder.ConfigurationPropertyBuilder; | ||
import com.thoughtworks.go.config.elastic.ClusterProfile; | ||
import com.thoughtworks.go.domain.config.ConfigurationProperty; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ClusterProfileDTO { | ||
@Expose | ||
@SerializedName("id") | ||
private String id; | ||
|
||
@Expose | ||
@SerializedName("plugin_id") | ||
private String pluginId; | ||
|
||
@Expose | ||
@SerializedName("properties") | ||
private Map<String, Map<String, Object>> properties; | ||
|
||
public ClusterProfileDTO() { | ||
} | ||
|
||
public ClusterProfileDTO(String id, String pluginId, Map<String, Map<String, Object>> properties) { | ||
this.id = id; | ||
this.pluginId = pluginId; | ||
this.properties = properties; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getPluginId() { | ||
return pluginId; | ||
} | ||
|
||
public Map<String, Map<String, Object>> getProperties() { | ||
return properties; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ClusterProfileDTO that = (ClusterProfileDTO) o; | ||
return Objects.equals(id, that.id) && | ||
Objects.equals(pluginId, that.pluginId) && | ||
Objects.equals(properties, that.properties); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, pluginId, properties); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ClusterProfileDTO{" + | ||
"id='" + id + '\'' + | ||
", pluginId='" + pluginId + '\'' + | ||
", properties=" + properties + | ||
'}'; | ||
} | ||
|
||
public ClusterProfile toDomainModel() { | ||
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>(); | ||
|
||
ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); | ||
this.properties.forEach((key, valueObject) -> { | ||
boolean isSecure = (boolean) valueObject.get("isSecure"); | ||
String value = isSecure ? null : (String) valueObject.get("value"); | ||
String encryptedValue = isSecure ? (String) valueObject.get("value") : null; | ||
|
||
configurationProperties.add(builder.create(key, value, encryptedValue, isSecure)); | ||
}); | ||
|
||
return new ClusterProfile(this.id, this.pluginId, configurationProperties); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
.../src/main/java/com/thoughtworks/go/plugin/access/elastic/v5/ConfigurationPropertyDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2019 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.thoughtworks.go.plugin.access.elastic.v5; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.thoughtworks.go.config.builder.ConfigurationPropertyBuilder; | ||
import com.thoughtworks.go.config.elastic.ClusterProfile; | ||
import com.thoughtworks.go.domain.config.ConfigurationProperty; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class ConfigurationPropertyDTO { | ||
@Expose | ||
@SerializedName("id") | ||
private String id; | ||
|
||
@Expose | ||
@SerializedName("plugin_id") | ||
private String pluginId; | ||
|
||
@Expose | ||
@SerializedName("properties") | ||
private Map<String, Map<String, Object>> properties; | ||
|
||
public ConfigurationPropertyDTO() { | ||
} | ||
|
||
public ConfigurationPropertyDTO(String id, String pluginId, Map<String, Map<String, Object>> properties) { | ||
this.id = id; | ||
this.pluginId = pluginId; | ||
this.properties = properties; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getPluginId() { | ||
return pluginId; | ||
} | ||
|
||
public Map<String, Map<String, Object>> getProperties() { | ||
return properties; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ConfigurationPropertyDTO that = (ConfigurationPropertyDTO) o; | ||
return Objects.equals(id, that.id) && | ||
Objects.equals(pluginId, that.pluginId) && | ||
Objects.equals(properties, that.properties); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id, pluginId, properties); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ClusterProfileDTO{" + | ||
"id='" + id + '\'' + | ||
", pluginId='" + pluginId + '\'' + | ||
", properties=" + properties + | ||
'}'; | ||
} | ||
|
||
public ClusterProfile toDomainModel() { | ||
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>(); | ||
|
||
ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); | ||
this.properties.forEach((key, valueObject) -> { | ||
boolean isSecure = (boolean) valueObject.get("isSecure"); | ||
String value = isSecure ? null : (String) valueObject.get("value"); | ||
String encryptedValue = isSecure ? (String) valueObject.get("value") : null; | ||
|
||
configurationProperties.add(builder.create(key, value, encryptedValue, isSecure)); | ||
}); | ||
|
||
return new ClusterProfile(this.id, this.pluginId, configurationProperties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.