@Override public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) { String timezone = n.getTimezone(); if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) { p.addProblem(Problem.Severity.ERROR, "Timezone " + timezone + " does not match any known canonical timezone ID") .setRemediation("Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"); } }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); // We need to make modifications to this deployment configuration, but can't use helpful objects // like the accountService on a clone. Therefore, we'll make the modifications in place and // restore to the original state when the modifications are written out. Providers originalProviders = deploymentConfiguration.getProviders().cloneNode(Providers.class); Providers modifiedProviders = deploymentConfiguration.getProviders(); DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment(); if (deploymentEnvironment.getBootstrapOnly() != null && deploymentEnvironment.getBootstrapOnly()) { String bootstrapAccountName = deploymentEnvironment.getAccountName(); removeBootstrapOnlyAccount(modifiedProviders, deploymentConfiguration.getName(), bootstrapAccountName); } Artifacts artifacts = deploymentConfiguration.getArtifacts(); List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName()); files.addAll(backupRequiredFiles(artifacts, deploymentConfiguration.getName())); if (deploymentConfiguration.getProviders() != null) { processProviders(deploymentConfiguration.getProviders()); } profile.appendContents(yamlToString(modifiedProviders)) .appendContents(yamlToString(new ArtifactWrapper(artifacts))) .appendContents(profile.getBaseContents()) .setRequiredFiles(files); deploymentConfiguration.setProviders(originalProviders); }
public Notifications getNotifications(String deploymentName) { DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName); Notifications notifications = deploymentConfiguration.getNotifications(); if (notifications == null) { notifications = new Notifications(); deploymentConfiguration.setNotifications(notifications); } return notifications; }
public Halconfig() { DeploymentConfiguration defaultConfig = new DeploymentConfiguration(); currentDeployment = defaultConfig.getName(); deploymentConfigurations.add(defaultConfig); }
@Override public boolean isEnabled(DeploymentConfiguration deploymentConfiguration) { return deploymentConfiguration.getProviders().getDockerRegistry().isEnabled() || deploymentConfiguration.getCi().ciEnabled(); }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { StringResource configTemplate = new StringResource(profile.getBaseContents()); UiSecurity uiSecurity = deploymentConfiguration.getSecurity().getUiSecurity(); profile.setUser(ApacheSettings.APACHE_USER); Features features = deploymentConfiguration.getFeatures(); Notifications notifications = deploymentConfiguration.getNotifications(); Map<String, Object> bindings = new HashMap<>(); String version = deploymentConfiguration.getVersion(); bindings.put("timezone", deploymentConfiguration.getTimezone()); bindings.put("version", deploymentConfiguration.getVersion()); bindings.put("features.chaos", Boolean.toString(features.isChaos())); bindings.put("features.jobs", Boolean.toString(features.isJobs())); bindings.put("features.fiat", Boolean.toString(deploymentConfiguration.getSecurity().getAuthz().isEnabled())); bindings.put("features.pipelineTemplates", Boolean.toString(features.getPipelineTemplates() != null ? features.getPipelineTemplates() : false)); bindings.put("features.artifacts", Boolean.toString(features.getArtifacts() != null ? features.getArtifacts() : false)); KubernetesProvider kubernetesProvider = deploymentConfiguration.getProviders().getKubernetes(); bindings.put("kubernetes.default.account", kubernetesProvider.getPrimaryAccount()); bindings.put("kubernetes.default.namespace", "default"); GoogleProvider googleProvider = deploymentConfiguration.getProviders().getGoogle(); bindings.put("google.default.account", googleProvider.getPrimaryAccount()); bindings.put("google.default.region", "us-central1"); AzureProvider azureProvider = deploymentConfiguration.getProviders().getAzure(); bindings.put("azure.default.account", azureProvider.getPrimaryAccount());
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { return new Settings(deploymentConfiguration.getSecurity().getApiSecurity()) .setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(true); }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); List<String> files = new ArrayList<>(); profile.appendContents("global.spinnaker.timezone: " + deploymentConfiguration.getTimezone()); profile.appendContents("spinnaker.baseUrl: " + endpoints.getServiceSettings(Type.DECK).getBaseUrl()); Notifications notifications = deploymentConfiguration.getNotifications(); if (notifications != null) { files.addAll(backupRequiredFiles(notifications, deploymentConfiguration.getName())); profile.appendContents(yamlToString(notifications)); } Pubsubs pubsubs = deploymentConfiguration.getPubsub(); if (pubsubs != null) { files.addAll(backupRequiredFiles(pubsubs, deploymentConfiguration.getName())); profile.appendContents(yamlToString(new PubsubWrapper(pubsubs))); } profile.appendContents(profile.getBaseContents()) .setRequiredFiles(files); }
@Override public String getDeployLocation() { return StringUtils.isEmpty(deploymentConfiguration.getDeploymentEnvironment().getLocation()) ? "spinnaker" : deploymentConfiguration.getDeploymentEnvironment().getLocation(); } }
CustomSizing customSizing = details.getDeploymentConfiguration().getDeploymentEnvironment().getCustomSizing(); if (customSizing != null) { Map componentSizing = customSizing.getOrDefault(getService().getServiceName(), new HashMap()); .addBinding("volumes", volumes); String version = makeValidLabel(details.getDeploymentConfiguration().getVersion()); if (version.isEmpty()) { version = "unknown";
@Override public void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); Providers providers = deploymentConfiguration.getProviders(); if (providers.getDockerRegistry().isEnabled()) { profile.appendContents("dockerRegistry.enabled: true"); } Cis cis = deploymentConfiguration.getCi(); List<String> files = backupRequiredFiles(cis, deploymentConfiguration.getName()); profile.appendContents(yamlToString(cis)) .appendContents(profile.getBaseContents()) .setRequiredFiles(files); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); DeploymentConfiguration deploymentConfiguration = new OperationHandler<DeploymentConfiguration>() .setOperation(Daemon.getDeploymentConfiguration(currentDeployment, false)) .setFailureMesssage("Failed to get your deployment configuration for edits.") .get(); int hash = deploymentConfiguration.hashCode(); deploymentConfiguration.setTimezone(isSet(timezone) ? timezone : deploymentConfiguration.getTimezone()); if (deploymentConfiguration.hashCode() == hash) { AnsiUi.error("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setDeploymentConfiguration(currentDeployment, !noValidate, deploymentConfiguration)) .setFailureMesssage("Failed to apply edits to your deployment configuration") .setSuccessMessage("Successfully edited your deployment configuration") .get(); } }
@Override public ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { return new Settings().setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setEnabled(true); }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); profile.appendContents(profile.getBaseContents()); AwsProvider awsProvider = deploymentConfiguration.getProviders().getAws(); if (awsProvider.isEnabled()) { profile.appendContents("default.bake.account: " + awsProvider.getPrimaryAccount()); profile.appendContents("default.securityGroups: "); profile.appendContents("default.vpc.securityGroups: "); } Webhook webhook = deploymentConfiguration.getWebhook(); List<String> files = backupRequiredFiles(webhook, deploymentConfiguration.getName()); profile.setRequiredFiles(files); profile.appendContents(yamlToString(new WebhookWrapper(webhook))); String pipelineTemplates = Boolean.toString(deploymentConfiguration.getFeatures().getPipelineTemplates() != null ? deploymentConfiguration.getFeatures().getPipelineTemplates() : false); profile.appendContents("pipelineTemplates.enabled: " + pipelineTemplates); // For backward compatibility profile.appendContents("pipelineTemplate.enabled: " + pipelineTemplates); }
protected List<String> dockerRegistriesOptions(ConfigProblemSetBuilder psBuilder) { DeploymentConfiguration context = parentOfType(DeploymentConfiguration.class); DockerRegistryProvider dockerRegistryProvider = context.getProviders().getDockerRegistry(); if (dockerRegistryProvider != null) { return dockerRegistryProvider .getAccounts() .stream() .map(Account::getName) .collect(Collectors.toList()); } else { return null; } }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); Providers providers = deploymentConfiguration.getProviders(); Providers otherProviders = getImageProviders(profile.getVersion(), deploymentConfiguration.getName()); augmentProvidersBaseImages(providers, otherProviders); List<String> files = backupRequiredFiles(providers, deploymentConfiguration.getName()); profile.appendContents(yamlToString(providers)) .appendContents(profile.getBaseContents()) .setRequiredFiles(files); }
public String getVersion(String deploymentName) { DeploymentConfiguration deploymentConfiguration = getDeploymentConfiguration(deploymentName); return deploymentConfiguration.getVersion(); }
@Override public Settings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(deploymentConfiguration); Settings settings = new Settings(); settings.setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setLocation(kubernetesSharedServiceSettings.getDeployLocation()) .setEnabled(deploymentConfiguration.getMetricStores().isEnabled()); return settings; }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { super.setProfile(profile, deploymentConfiguration, endpoints); profile.appendContents(profile.getBaseContents()); AwsProvider awsProvider = deploymentConfiguration.getProviders().getAws(); if (awsProvider.isEnabled()) { profile.appendContents("default.bake.account: " + awsProvider.getPrimaryAccount()); profile.appendContents("default.securityGroups: "); profile.appendContents("default.vpc.securityGroups: "); } String pipelineTemplates = Boolean.toString(deploymentConfiguration.getFeatures().getPipelineTemplates() != null ? deploymentConfiguration.getFeatures().getPipelineTemplates() : false); profile.appendContents("pipelineTemplates.enabled: " + pipelineTemplates); // For backward compatibility profile.appendContents("pipelineTemplate.enabled: " + pipelineTemplates); } }