protected Optional<Profile> generateAwsProfile(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints, String spinnakerHome) { String name = "aws/kayenta-credentials" + spinnakerHome.replace("/", "_"); Canary canary = deploymentConfiguration.getCanary(); if (canary.isEnabled()) { AwsCanaryServiceIntegration awsCanaryServiceIntegration = (AwsCanaryServiceIntegration)getServiceIntegrationByClass(canary, AwsCanaryServiceIntegration.class); // TODO(lwander/duftler): Seems like this approach leaves us open to potential collision between kayenta aws // accounts, and front50 and clouddriver configuration. if (awsCanaryServiceIntegration.isS3Enabled()) { Optional<AwsCanaryAccount> optionalAwsCanaryAccount = awsCanaryServiceIntegration.getAccounts() .stream() .filter(a -> !StringUtils.isEmpty(a.getAccessKeyId()) && !StringUtils.isEmpty(a.getSecretAccessKey())) .findFirst(); if (optionalAwsCanaryAccount.isPresent()) { AwsCanaryAccount awsCanaryAccount = optionalAwsCanaryAccount.get(); String outputFile = awsCredentialsProfileFactoryBuilder.getOutputFile(spinnakerHome); awsCredentialsProfileFactoryBuilder.setProfileName(StringUtils.isNotBlank(awsCanaryAccount.getProfileName()) ? awsCanaryAccount.getProfileName() : "default"); return Optional.of(awsCredentialsProfileFactoryBuilder .setArtifact(SpinnakerArtifact.KAYENTA) .setAccessKeyId(awsCanaryAccount.getAccessKeyId()) .setSecretAccessKey(awsCanaryAccount.getSecretAccessKey()) .build() .getProfile(name, outputFile, deploymentConfiguration, endpoints)); } } } return Optional.empty(); }
protected Optional<Profile> generateAwsProfile(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints, String spinnakerHome) { String name = "aws/kayenta-credentials" + spinnakerHome.replace("/", "_"); Canary canary = deploymentConfiguration.getCanary(); if (canary.isEnabled()) { AwsCanaryServiceIntegration awsCanaryServiceIntegration = (AwsCanaryServiceIntegration)getServiceIntegrationByClass(canary, AwsCanaryServiceIntegration.class); // TODO(lwander/duftler): Seems like this approach leaves us open to potential collision between kayenta aws // accounts, and front50 and clouddriver configuration. if (awsCanaryServiceIntegration.isS3Enabled()) { Optional<AwsCanaryAccount> optionalAwsCanaryAccount = awsCanaryServiceIntegration.getAccounts() .stream() .filter(a -> !StringUtils.isEmpty(a.getAccessKeyId()) && !StringUtils.isEmpty(a.getSecretAccessKey())) .findFirst(); if (optionalAwsCanaryAccount.isPresent()) { AwsCanaryAccount awsCanaryAccount = optionalAwsCanaryAccount.get(); String outputFile = awsCredentialsProfileFactoryBuilder.getOutputFile(spinnakerHome); awsCredentialsProfileFactoryBuilder.setProfileName(StringUtils.isNotBlank(awsCanaryAccount.getProfileName()) ? awsCanaryAccount.getProfileName() : "default"); return Optional.of(awsCredentialsProfileFactoryBuilder .setArtifact(SpinnakerArtifact.KAYENTA) .setAccessKeyId(awsCanaryAccount.getAccessKeyId()) .setSecretAccessKey(awsCanaryAccount.getSecretAccessKey()) .build() .getProfile(name, outputFile, deploymentConfiguration, endpoints)); } } } return Optional.empty(); }
@Override protected AbstractCanaryAccount editAccount(AwsCanaryAccount account) { account.setBucket(isSet(bucket) ? bucket : account.getBucket()); account.setRegion(isSet(region) ? region : account.getRegion()); account.setRootFolder(isSet(rootFolder) ? rootFolder : account.getRootFolder()); account.setProfileName(isSet(profileName) ? profileName : account.getProfileName()); account.setEndpoint(isSet(endpoint) ? endpoint : account.getEndpoint()); account.setAccessKeyId(isSet(accessKeyId) ? accessKeyId : account.getAccessKeyId()); account.setSecretAccessKey(isSet(secretAccessKey) ? secretAccessKey : account.getSecretAccessKey()); return account; } }
@Override protected AbstractCanaryAccount editAccount(AwsCanaryAccount account) { account.setBucket(isSet(bucket) ? bucket : account.getBucket()); account.setRegion(isSet(region) ? region : account.getRegion()); account.setRootFolder(isSet(rootFolder) ? rootFolder : account.getRootFolder()); account.setProfileName(isSet(profileName) ? profileName : account.getProfileName()); account.setEndpoint(isSet(endpoint) ? endpoint : account.getEndpoint()); account.setAccessKeyId(isSet(accessKeyId) ? accessKeyId : account.getAccessKeyId()); account.setSecretAccessKey(isSet(secretAccessKey) ? secretAccessKey : account.getSecretAccessKey()); return account; } }