use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration in project halyard by spinnaker.
the class Front50ProfileFactory method setProfile.
@Override
public void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
PersistentStorage persistentStorage = deploymentConfiguration.getPersistentStorage();
if (persistentStorage.getPersistentStoreType() == null) {
throw new HalException(Problem.Severity.FATAL, "No persistent storage type was configured.");
}
List<String> files = backupRequiredFiles(persistentStorage, deploymentConfiguration.getName());
Map<String, Map<String, Object>> persistentStorageMap = new HashMap<>();
NodeIterator children = persistentStorage.getChildren();
Node child = children.getNext();
while (child != null) {
if (child instanceof PersistentStore) {
PersistentStore persistentStore = (PersistentStore) child;
URI connectionUri = null;
if (persistentStore instanceof RedisPersistentStore) {
try {
connectionUri = new URI(endpoints.getServices().getRedis().getBaseUrl());
} catch (URISyntaxException e) {
throw new RuntimeException("Malformed redis URL, this is a bug.");
}
}
persistentStore.setConnectionInfo(connectionUri);
PersistentStore.PersistentStoreType persistentStoreType = persistentStore.persistentStoreType();
Map persistentStoreMap = objectMapper.convertValue(persistentStore, Map.class);
persistentStoreMap.put("enabled", persistentStoreType.equals(persistentStorage.getPersistentStoreType()));
persistentStorageMap.put(persistentStoreType.getId(), persistentStoreMap);
}
child = children.getNext();
}
Map<String, Object> spinnakerObjectMap = new HashMap<>();
spinnakerObjectMap.put("spinnaker", persistentStorageMap);
super.setProfile(profile, deploymentConfiguration, endpoints);
profile.appendContents(yamlToString(spinnakerObjectMap)).appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration in project halyard by spinnaker.
the class IgorProfileFactory method setProfile.
@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);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration in project halyard by spinnaker.
the class KayentaProfileFactory method setProfile.
@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()) {
KayentaConfigWrapper kayentaConfig = new KayentaConfigWrapper(endpoints.getServices().getKayenta(), canary);
profile.appendContents(yamlToString(kayentaConfig));
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration in project halyard by spinnaker.
the class ClouddriverBootstrapProfileFactory method setProfile.
@Override
@SuppressWarnings("unchecked")
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
super.setProfile(profile, deploymentConfiguration, endpoints);
DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
if (deploymentEnvironment.getType() != DeploymentEnvironment.DeploymentType.Distributed) {
throw new IllegalStateException("There is no need to produce a bootstrapping clouddriver for a non-remote deployment of Spinnaker. This is a bug.");
}
// 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();
String deploymentName = deploymentConfiguration.getName();
String bootstrapAccountName = deploymentEnvironment.getAccountName();
Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName);
bootstrapAccount.makeBootstrappingAccount(artifactSourcesConfig);
Provider bootstrapProvider = (Provider) bootstrapAccount.getParent();
disableAllProviders(modifiedProviders);
bootstrapProvider.setEnabled(true);
bootstrapProvider.setAccounts(Collections.singletonList(bootstrapAccount));
if (bootstrapAccount instanceof ContainerAccount) {
ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount;
List<DockerRegistryAccount> bootstrapRegistries = containerAccount.getDockerRegistries().stream().map(ref -> (DockerRegistryAccount) accountService.getProviderAccount(deploymentName, DOCKER_REGISTRY, ref.getAccountName())).collect(Collectors.toList());
DockerRegistryProvider dockerProvider = modifiedProviders.getDockerRegistry();
dockerProvider.setEnabled(true);
dockerProvider.setAccounts(bootstrapRegistries);
}
if (bootstrapAccount instanceof SupportsConsul) {
SupportsConsul consulAccount = (SupportsConsul) bootstrapAccount;
ConsulConfig config = consulAccount.getConsul();
if (config == null) {
config = new ConsulConfig();
consulAccount.setConsul(config);
}
consulAccount.getConsul().setEnabled(true);
} else {
log.warn("Attempting to perform a distributed deployment to account \"" + bootstrapAccount.getName() + "\" without a discovery mechanism");
}
List<String> files = backupRequiredFiles(modifiedProviders, deploymentConfiguration.getName());
profile.appendContents(yamlToString(modifiedProviders)).appendContents("services.fiat.enabled: false").appendContents(profile.getBaseContents()).setRequiredFiles(files);
deploymentConfiguration.setProviders(originalProviders);
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration in project halyard by spinnaker.
the class DeckProfileFactory method setProfile.
@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();
// Configure global settings
bindings.put("gate.baseUrl", endpoints.getServices().getGate().getBaseUrl());
bindings.put("timezone", deploymentConfiguration.getTimezone());
bindings.put("version", deploymentConfiguration.getVersion());
Optional<Versions.Version> validatedVersion = versionsService.getVersions().getVersion(version);
if (validatedVersion.isPresent()) {
String changelog = validatedVersion.get().getChangelog();
bindings.put("changelog.gist.id", changelog.substring(changelog.lastIndexOf("/") + 1));
bindings.put("changelog.gist.name", "changelog.md");
} else {
bindings.put("changelog.gist.id", "");
bindings.put("changelog.gist.name", "");
}
// Configure feature-flags
bindings.put("features.auth", Boolean.toString(features.isAuth(deploymentConfiguration)));
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));
bindings.put("features.mineCanary", Boolean.toString(features.getMineCanary() != null ? features.getMineCanary() : false));
// Configure Kubernetes
KubernetesProvider kubernetesProvider = deploymentConfiguration.getProviders().getKubernetes();
bindings.put("kubernetes.default.account", kubernetesProvider.getPrimaryAccount());
bindings.put("kubernetes.default.namespace", "default");
bindings.put("kubernetes.default.proxy", "localhost:8001");
// Configure GCE
GoogleProvider googleProvider = deploymentConfiguration.getProviders().getGoogle();
bindings.put("google.default.account", googleProvider.getPrimaryAccount());
bindings.put("google.default.region", "us-central1");
bindings.put("google.default.zone", "us-central1-f");
// Configure Azure
AzureProvider azureProvider = deploymentConfiguration.getProviders().getAzure();
bindings.put("azure.default.account", azureProvider.getPrimaryAccount());
bindings.put("azure.default.region", "westus");
// Configure Appengine
AppengineProvider appengineProvider = deploymentConfiguration.getProviders().getAppengine();
bindings.put("appengine.default.account", appengineProvider.getPrimaryAccount());
bindings.put("appengine.enabled", Boolean.toString(appengineProvider.getPrimaryAccount() != null));
// Configure DC/OS
final DCOSProvider dcosProvider = deploymentConfiguration.getProviders().getDcos();
bindings.put("dcos.default.account", dcosProvider.getPrimaryAccount());
// TODO(willgorman) need to set the proxy url somehow
// Configure Openstack
OpenstackProvider openstackProvider = deploymentConfiguration.getProviders().getOpenstack();
bindings.put("openstack.default.account", openstackProvider.getPrimaryAccount());
if (openstackProvider.getPrimaryAccount() != null) {
OpenstackAccount openstackAccount = (OpenstackAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "openstack", openstackProvider.getPrimaryAccount());
String firstRegion = openstackAccount.getRegions().get(0);
bindings.put("openstack.default.region", firstRegion);
}
// Configure notifications
bindings.put("notifications.enabled", notifications.isEnabled() + "");
SlackNotification slackNotification = notifications.getSlack();
bindings.put("notifications.slack.enabled", slackNotification.isEnabled() + "");
bindings.put("notifications.slack.botName", slackNotification.getBotName());
// Configure canary
Canary canary = deploymentConfiguration.getCanary();
bindings.put("canary.atlasWebComponentsUrl", canary.getAtlasWebComponentsUrl());
bindings.put("canary.featureEnabled", Boolean.toString(canary.isEnabled()));
if (canary.isEnabled()) {
// TODO(duftler): Automatically choose the first metrics/storage/judge here if unspecified?
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());
}
profile.appendContents(configTemplate.setBindings(bindings).toString()).setRequiredFiles(backupRequiredFiles(uiSecurity, deploymentConfiguration.getName()));
}
Aggregations