private static AbstractCanaryServiceIntegration getServiceIntegrationByClass(Canary canary, Class<? extends AbstractCanaryServiceIntegration> serviceIntegrationClass) { return canary.getServiceIntegrations() .stream() .filter(s -> serviceIntegrationClass.isAssignableFrom(s.getClass())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration of type " + serviceIntegrationClass.getSimpleName() + " not found.")); } }
.get(); int originalHash = canary.hashCode(); canary.setReduxLoggerEnabled(isSet(reduxLoggerEnabled) ? reduxLoggerEnabled : canary.isReduxLoggerEnabled()); canary.setDefaultMetricsAccount(isSet(defaultMetricsAccount) ? defaultMetricsAccount : canary.getDefaultMetricsAccount()); canary.setDefaultStorageAccount(isSet(defaultStorageAccount) ? defaultStorageAccount : canary.getDefaultStorageAccount()); canary.setDefaultJudge(isSet(defaultJudge) ? defaultJudge : canary.getDefaultJudge()); canary.setDefaultMetricsStore(isSet(defaultMetricsStore) ? defaultMetricsStore: canary.getDefaultMetricsStore()); canary.setStagesEnabled(isSet(stagesEnabled) ? stagesEnabled : canary.isStagesEnabled()); canary.setAtlasWebComponentsUrl(isSet(atlasWebComponentsUrl) ? atlasWebComponentsUrl : canary.getAtlasWebComponentsUrl()); canary.setTemplatesEnabled(isSet(templatesEnabled) ? templatesEnabled : canary.isTemplatesEnabled()); canary.setShowAllConfigsEnabled(isSet(showAllConfigsEnabled) ? showAllConfigsEnabled : canary.isShowAllConfigsEnabled()); if (originalHash == canary.hashCode()) { AnsiUi.failure("No changes supplied."); return;
@Override public boolean isEnabled(DeploymentConfiguration deploymentConfiguration) { return deploymentConfiguration.getCanary().isEnabled(); }
bindings.put("canary.atlasWebComponentsUrl", canary.getAtlasWebComponentsUrl()); bindings.put("canary.featureEnabled", Boolean.toString(canary.isEnabled())); if (canary.isEnabled()) { bindings.put("canary.reduxLogger", canary.isReduxLoggerEnabled()); bindings.put("canary.defaultMetricsAccount", canary.getDefaultMetricsAccount()); bindings.put("canary.defaultStorageAccount", canary.getDefaultStorageAccount()); bindings.put("canary.defaultJudge", canary.getDefaultJudge()); bindings.put("canary.defaultMetricsStore", canary.getDefaultMetricsStore()); bindings.put("canary.stages", canary.isStagesEnabled()); bindings.put("canary.templatesEnabled", canary.isTemplatesEnabled()); bindings.put("canary.showAllCanaryConfigs", canary.isShowAllConfigsEnabled());
Set<String> accounts = new HashSet<>(); for (AbstractCanaryServiceIntegration svc : n.getServiceIntegrations()) { for (AbstractCanaryAccount account : (List<AbstractCanaryAccount>)svc.getAccounts()) { if (accounts.contains(account.getName())) { for (AbstractCanaryServiceIntegration s : n.getServiceIntegrations()) { if (s instanceof GoogleCanaryServiceIntegration) { GoogleCanaryServiceIntegration googleCanaryServiceIntegration = (GoogleCanaryServiceIntegration)s; if (n.isEnabled()) { if (!configurationAndObjectStoresAreConfigured) { p.addProblem(Problem.Severity.WARNING, "There is no account of type CONFIGURATION_STORE and OBJECT_STORE configured.")
bindings.put("canary.atlasWebComponentsUrl", canary.getAtlasWebComponentsUrl()); bindings.put("canary.featureEnabled", Boolean.toString(canary.isEnabled())); if (canary.isEnabled()) { bindings.put("canary.reduxLogger", canary.isReduxLoggerEnabled()); bindings.put("canary.defaultMetricsAccount", canary.getDefaultMetricsAccount()); bindings.put("canary.defaultStorageAccount", canary.getDefaultStorageAccount()); bindings.put("canary.defaultJudge", canary.getDefaultJudge()); bindings.put("canary.defaultMetricsStore", canary.getDefaultMetricsStore()); bindings.put("canary.stages", canary.isStagesEnabled()); bindings.put("canary.templatesEnabled", canary.isTemplatesEnabled()); bindings.put("canary.showAllCanaryConfigs", canary.isShowAllConfigsEnabled());
Set<String> accounts = new HashSet<>(); for (AbstractCanaryServiceIntegration svc : n.getServiceIntegrations()) { for (AbstractCanaryAccount account : (List<AbstractCanaryAccount>)svc.getAccounts()) { if (accounts.contains(account.getName())) { for (AbstractCanaryServiceIntegration s : n.getServiceIntegrations()) { if (s instanceof GoogleCanaryServiceIntegration) { GoogleCanaryServiceIntegration googleCanaryServiceIntegration = (GoogleCanaryServiceIntegration)s; if (n.isEnabled()) { if (!configurationAndObjectStoresAreConfigured) { p.addProblem(Problem.Severity.WARNING, "There is no account of type CONFIGURATION_STORE and OBJECT_STORE configured.")
.get(); int originalHash = canary.hashCode(); canary.setReduxLoggerEnabled(isSet(reduxLoggerEnabled) ? reduxLoggerEnabled : canary.isReduxLoggerEnabled()); canary.setDefaultMetricsAccount(isSet(defaultMetricsAccount) ? defaultMetricsAccount : canary.getDefaultMetricsAccount()); canary.setDefaultStorageAccount(isSet(defaultStorageAccount) ? defaultStorageAccount : canary.getDefaultStorageAccount()); canary.setDefaultJudge(isSet(defaultJudge) ? defaultJudge : canary.getDefaultJudge()); canary.setDefaultMetricsStore(isSet(defaultMetricsStore) ? defaultMetricsStore: canary.getDefaultMetricsStore()); canary.setStagesEnabled(isSet(stagesEnabled) ? stagesEnabled : canary.isStagesEnabled()); canary.setAtlasWebComponentsUrl(isSet(atlasWebComponentsUrl) ? atlasWebComponentsUrl : canary.getAtlasWebComponentsUrl()); canary.setTemplatesEnabled(isSet(templatesEnabled) ? templatesEnabled : canary.isTemplatesEnabled()); canary.setShowAllConfigsEnabled(isSet(showAllConfigsEnabled) ? showAllConfigsEnabled : canary.isShowAllConfigsEnabled()); if (originalHash == canary.hashCode()) { AnsiUi.failure("No changes supplied."); return;
public static AbstractCanaryServiceIntegration getServiceIntegrationByClass(Canary canary, Class<? extends AbstractCanaryServiceIntegration> serviceIntegrationClass) { return canary.getServiceIntegrations() .stream() .filter(s -> serviceIntegrationClass.isAssignableFrom(s.getClass())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration of type " + serviceIntegrationClass.getSimpleName() + " not found.")); }
@Override public boolean isEnabled(DeploymentConfiguration deploymentConfiguration) { return deploymentConfiguration.getCanary().isEnabled(); }
private static AbstractCanaryServiceIntegration getServiceIntegrationByClass(Canary canary, Class<? extends AbstractCanaryServiceIntegration> serviceIntegrationClass) { return canary.getServiceIntegrations() .stream() .filter(s -> serviceIntegrationClass.isAssignableFrom(s.getClass())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration of type " + serviceIntegrationClass.getSimpleName() + " not found.")); } }
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(); }
public static AbstractCanaryServiceIntegration getServiceIntegrationByClass(Canary canary, Class<? extends AbstractCanaryServiceIntegration> serviceIntegrationClass) { return canary.getServiceIntegrations() .stream() .filter(s -> serviceIntegrationClass.isAssignableFrom(s.getClass())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration of type " + serviceIntegrationClass.getSimpleName() + " not found.")); }
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(); }
private AbstractCanaryServiceIntegration getServiceIntegration(String deploymentName, String serviceIntegrationName) { Canary canary = canaryService.getCanary(deploymentName); return canary.getServiceIntegrations() .stream() .filter(s -> s.getName().equals(serviceIntegrationName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration " + serviceIntegrationName + " not found.")); }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { return new Settings().setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(deploymentConfiguration.getCanary().isEnabled()); }
private AbstractCanaryServiceIntegration getServiceIntegration(String deploymentName, String serviceIntegrationName) { Canary canary = canaryService.getCanary(deploymentName); return canary.getServiceIntegrations() .stream() .filter(s -> s.getName().equals(serviceIntegrationName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration " + serviceIntegrationName + " not found.")); }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { return new Settings().setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(deploymentConfiguration.getCanary().isEnabled()); }
public static AbstractCanaryServiceIntegration getServiceIntegrationByName(Canary canary, String currentDeployment, String serviceIntegrationName, boolean noValidate) { if (canary == null) { canary = new OperationHandler<Canary>() .setFailureMesssage("Failed to get canary.") .setOperation(Daemon.getCanary(currentDeployment, !noValidate)) .get(); } return canary.getServiceIntegrations() .stream() .filter(s -> s.getName().equals(serviceIntegrationName.toLowerCase())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Canary service integration " + serviceIntegrationName + " not found.")); } }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); profile.appendContents(profile.getBaseContents()); Canary canary = deploymentConfiguration.getCanary(); if (canary.isEnabled()) { List<String> files = new ArrayList<>(backupRequiredFiles(canary, deploymentConfiguration.getName())); KayentaConfigWrapper kayentaConfig = new KayentaConfigWrapper(endpoints.getServiceSettings(Type.KAYENTA), canary); profile.appendContents(yamlToString(kayentaConfig)).setRequiredFiles(files); } }