@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 buildAccount(Canary canary, String accountName) { AwsCanaryAccount account = (AwsCanaryAccount)new AwsCanaryAccount().setName(accountName); account.setBucket(bucket); account.setRegion(region); account.setRootFolder(isSet(rootFolder) ? rootFolder : account.getRootFolder()); account.setProfileName(profileName); account.setEndpoint(endpoint); account.setAccessKeyId(accessKeyId); account.setSecretAccessKey(secretAccessKey); AwsCanaryServiceIntegration awsCanaryServiceIntegration = (AwsCanaryServiceIntegration)CanaryUtils.getServiceIntegrationByClass(canary, AwsCanaryServiceIntegration.class); if (awsCanaryServiceIntegration.isS3Enabled()) { account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE); account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE); } return account; }
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 public void validate(ConfigProblemSetBuilder p, AwsCanaryServiceIntegration n) { if (n.isS3Enabled()) { List<AwsCanaryAccount> accountsWithBucket = n.getAccounts() .stream() .filter(a -> a.getBucket() != null) .collect(Collectors.toList()); if (CollectionUtils.isEmpty(accountsWithBucket)) { p.addProblem(Problem.Severity.ERROR, "At least one AWS account must specify a bucket if S3 is enabled."); } } } }
@Override protected AbstractCanaryAccount emptyAccount() { return new AwsCanaryAccount(); } }
awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE)); awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE)); } else { awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE)); awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
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 public void validate(ConfigProblemSetBuilder p, AwsCanaryServiceIntegration n) { if (n.isS3Enabled()) { List<AwsCanaryAccount> accountsWithBucket = n.getAccounts() .stream() .filter(a -> a.getBucket() != null) .collect(Collectors.toList()); if (CollectionUtils.isEmpty(accountsWithBucket)) { p.addProblem(Problem.Severity.ERROR, "At least one AWS account must specify a bucket if S3 is enabled."); } } } }
@Override protected AbstractCanaryAccount emptyAccount() { return new AwsCanaryAccount(); } }
awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE)); awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE)); } else { awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE)); awsCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
@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 buildAccount(Canary canary, String accountName) { AwsCanaryAccount account = (AwsCanaryAccount)new AwsCanaryAccount().setName(accountName); account.setBucket(bucket); account.setRegion(region); account.setRootFolder(isSet(rootFolder) ? rootFolder : account.getRootFolder()); account.setProfileName(profileName); account.setEndpoint(endpoint); account.setAccessKeyId(accessKeyId); account.setSecretAccessKey(secretAccessKey); AwsCanaryServiceIntegration awsCanaryServiceIntegration = (AwsCanaryServiceIntegration)CanaryUtils.getServiceIntegrationByClass(canary, AwsCanaryServiceIntegration.class); if (awsCanaryServiceIntegration.isS3Enabled()) { account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE); account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE); } return account; }