use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.VaultConfigMountSet in project halyard by spinnaker.
the class GoogleDistributedService method getMetadata.
default List<Metadata.Items> getMetadata(AccountDeploymentDetails<GoogleAccount> details, SpinnakerRuntimeSettings runtimeSettings, List<ConfigSource> configSources, Integer version) {
List<Metadata.Items> metadataItems = new ArrayList<>();
String deploymentName = details.getDeploymentName();
Metadata.Items items = new Metadata.Items().setKey("startup-script").setValue(getStartupScript());
metadataItems.add(items);
items = new Metadata.Items().setKey("ssh-keys").setValue(GoogleProviderUtils.getSshPublicKey());
metadataItems.add(items);
if (!configSources.isEmpty()) {
DaemonTaskHandler.message("Mounting config in vault server");
GoogleVaultServerService vaultService = getVaultServerService();
VaultServerService.Vault vault = vaultService.connectToPrimaryService(details, runtimeSettings);
String secretName = secretName("config-mounts", version);
VaultConfigMountSet mountSet = VaultConfigMountSet.fromConfigSources(configSources);
secretName = vaultService.writeVaultConfigMountSet(deploymentName, vault, secretName, mountSet);
VaultConnectionDetails connectionDetails = buildConnectionDetails(details, runtimeSettings, secretName);
DaemonTaskHandler.message("Placing vault connection details into instance metadata");
items = new Metadata.Items().setKey("vault_address").setValue(connectionDetails.getAddress());
metadataItems.add(items);
items = new Metadata.Items().setKey("vault_token").setValue(connectionDetails.getToken());
metadataItems.add(items);
items = new Metadata.Items().setKey("vault_secret").setValue(connectionDetails.getSecret());
metadataItems.add(items);
}
GoogleConsulServerService consulServerService = getConsulServerService();
RunningServiceDetails consulServerDetails = consulServerService.getRunningServiceDetails(details, runtimeSettings);
Integer latestConsulVersion = consulServerDetails.getLatestEnabledVersion();
if (latestConsulVersion != null) {
List<RunningServiceDetails.Instance> instances = consulServerDetails.getInstances().get(latestConsulVersion);
String instancesValue = String.join(" ", instances.stream().map(RunningServiceDetails.Instance::getId).collect(Collectors.toList()));
items = new Metadata.Items().setKey(// TODO(lwander) change to consul_members for consistency w/ vault
"consul-members").setValue(instancesValue);
DaemonTaskHandler.message("Placing consul connection details into instance metadata");
metadataItems.add(items);
}
return metadataItems;
}
Aggregations