use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class ArtifactService method publishLatestHalyard.
public void publishLatestHalyard(String latestHalyard) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(FATAL, NO_WRITER_ENABLED);
}
Versions versionsCollection = versionsService.getVersions();
if (versionsCollection == null) {
throw new HalException(FATAL, NO_GCS_ENABLED);
}
versionsCollection.setLatestHalyard(latestHalyard);
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
use of org.bf2.operator.resources.v1alpha1.Versions 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.getServiceSettings(Type.GATE).getBaseUrl());
bindings.put("timezone", deploymentConfiguration.getTimezone());
bindings.put("version", deploymentConfiguration.getVersion());
Versions versions = versionsService.getVersions();
Optional<Versions.Version> validatedVersion;
if (versions != null) {
validatedVersion = versions.getVersion(version);
} else {
validatedVersion = Optional.empty();
}
if (validatedVersion.isPresent()) {
String changelog = validatedVersion.get().getChangelog();
bindings.put("changelog.gist.id", changelog.substring(changelog.lastIndexOf("/") + 1));
bindings.put("changelog.gist.name", String.format("%s.md", version));
} 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.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.artifactsRewrite", Boolean.toString(features.getArtifactsRewrite() != null ? features.getArtifactsRewrite() : false));
bindings.put("features.mineCanary", Boolean.toString(features.getMineCanary() != null ? features.getMineCanary() : false));
bindings.put("features.managedPipelineTemplatesV2UI", Boolean.toString(features.getManagedPipelineTemplatesV2UI() != null ? features.getManagedPipelineTemplatesV2UI() : false));
bindings.put("features.gremlin", Boolean.toString(features.getGremlin() != null ? features.getGremlin() : 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());
// 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 AWS
AwsProvider awsProvider = deploymentConfiguration.getProviders().getAws();
bindings.put("aws.default.account", awsProvider.getPrimaryAccount());
if (awsProvider.getPrimaryAccount() != null) {
AwsAccount awsAccount = (AwsAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "aws", awsProvider.getPrimaryAccount());
List<AwsProvider.AwsRegion> regionList = awsAccount.getRegions();
if (!regionList.isEmpty() && regionList.get(0) != null) {
bindings.put("aws.default.region", regionList.get(0).getName());
}
}
// Configure ECS
EcsProvider ecsProvider = deploymentConfiguration.getProviders().getEcs();
bindings.put("ecs.default.account", ecsProvider.getPrimaryAccount());
// Configure CloudFoundry
CloudFoundryProvider cloudFoundryProvider = deploymentConfiguration.getProviders().getCloudfoundry();
bindings.put("cloudfoundry.default.account", cloudFoundryProvider.getPrimaryAccount());
// Configure HuaweiCloud
HuaweiCloudProvider huaweiCloudProvider = deploymentConfiguration.getProviders().getHuaweicloud();
bindings.put("huaweicloud.default.account", huaweiCloudProvider.getPrimaryAccount());
if (huaweiCloudProvider.getPrimaryAccount() != null) {
HuaweiCloudAccount huaweiCloudAccount = (HuaweiCloudAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "huaweicloud", huaweiCloudProvider.getPrimaryAccount());
List<String> regionList = huaweiCloudAccount.getRegions();
if (!regionList.isEmpty()) {
bindings.put("huaweicloud.default.region", regionList.get(0));
}
}
// Configure TencentCloud
TencentCloudProvider tencentCloudProvider = deploymentConfiguration.getProviders().getTencentcloud();
bindings.put("tencentcloud.default.account", tencentCloudProvider.getPrimaryAccount());
if (tencentCloudProvider.getPrimaryAccount() != null) {
TencentCloudAccount tencentCloudAccount = (TencentCloudAccount) accountService.getProviderAccount(deploymentConfiguration.getName(), "tencentcloud", tencentCloudProvider.getPrimaryAccount());
List<String> regionList = tencentCloudAccount.getRegions();
if (!regionList.isEmpty() && regionList.get(0) != null) {
bindings.put("tencentcloud.default.region", regionList.get(0));
}
}
// Configure notifications
SlackNotification slackNotification = notifications.getSlack();
bindings.put("notifications.slack.enabled", slackNotification.isEnabled() + "");
bindings.put("notifications.slack.botName", slackNotification.getBotName());
TwilioNotification twilioNotification = notifications.getTwilio();
bindings.put("notifications.twilio.enabled", twilioNotification.isEnabled() + "");
GithubStatusNotification githubStatusNotification = notifications.getGithubStatus();
bindings.put("notifications.github-status.enabled", githubStatusNotification.isEnabled() + "");
// 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()));
}
use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaController method updateManagedKafkaStatus.
/**
* Extract from the current KafkaInstance overall status (Kafka, Canary and AdminServer)
* a corresponding list of ManagedKafkaCondition(s) to set on the ManagedKafka status
*
* @param managedKafka ManagedKafka instance
*/
private void updateManagedKafkaStatus(ManagedKafka managedKafka) {
// add status if not already available on the ManagedKafka resource
ManagedKafkaStatus status = Objects.requireNonNullElse(managedKafka.getStatus(), new ManagedKafkaStatusBuilder().build());
status.setUpdatedTimestamp(ConditionUtils.iso8601Now());
managedKafka.setStatus(status);
// add conditions if not already available
List<ManagedKafkaCondition> managedKafkaConditions = managedKafka.getStatus().getConditions();
if (managedKafkaConditions == null) {
managedKafkaConditions = new ArrayList<>();
status.setConditions(managedKafkaConditions);
}
Optional<ManagedKafkaCondition> optReady = ConditionUtils.findManagedKafkaCondition(managedKafkaConditions, ManagedKafkaCondition.Type.Ready);
ManagedKafkaCondition ready = null;
if (optReady.isPresent()) {
ready = optReady.get();
} else {
ready = ConditionUtils.buildCondition(ManagedKafkaCondition.Type.Ready, Status.Unknown);
managedKafkaConditions.add(ready);
}
// a not valid ManagedKafka skips the handling of it, so the status will report an error condition
OperandReadiness readiness = this.validity(managedKafka).orElse(kafkaInstance.getReadiness(managedKafka));
ConditionUtils.updateConditionStatus(ready, readiness.getStatus(), readiness.getReason(), readiness.getMessage());
// routes should always be set on the CR status, even if it's just an empty list
status.setRoutes(List.of());
int replicas = kafkaCluster.getReplicas(managedKafka);
if (ingressControllerManagerInstance.isResolvable()) {
IngressControllerManager ingressControllerManager = ingressControllerManagerInstance.get();
List<ManagedKafkaRoute> routes = ingressControllerManager.getManagedKafkaRoutesFor(managedKafka);
// expect route for each broker + 1 for bootstrap URL + 1 for Admin API server
int expectedNumRoutes = replicas + NUM_NON_BROKER_ROUTES;
if (routes.size() >= expectedNumRoutes && routes.stream().noneMatch(r -> "".equals(r.getRouter()))) {
status.setRoutes(routes);
}
}
if (Status.True.equals(readiness.getStatus())) {
status.setCapacity(new ManagedKafkaCapacityBuilder(managedKafka.getSpec().getCapacity()).withMaxDataRetentionSize(kafkaInstance.getKafkaCluster().calculateRetentionSize(managedKafka)).build());
// the versions in the status are updated incrementally copying the spec only when each stage ends
VersionsBuilder versionsBuilder = status.getVersions() != null ? new VersionsBuilder(status.getVersions()) : new VersionsBuilder(managedKafka.getSpec().getVersions());
if (!Reason.StrimziUpdating.equals(readiness.getReason()) && !this.strimziManager.hasStrimziChanged(managedKafka)) {
versionsBuilder.withStrimzi(managedKafka.getSpec().getVersions().getStrimzi());
}
if (!Reason.KafkaUpdating.equals(readiness.getReason()) && !this.kafkaManager.hasKafkaVersionChanged(managedKafka)) {
versionsBuilder.withKafka(managedKafka.getSpec().getVersions().getKafka());
}
if (!Reason.KafkaIbpUpdating.equals(readiness.getReason()) && !this.kafkaManager.hasKafkaIbpVersionChanged(managedKafka)) {
String kafkaIbp = managedKafka.getSpec().getVersions().getKafkaIbp() != null ? managedKafka.getSpec().getVersions().getKafkaIbp() : AbstractKafkaCluster.getKafkaIbpVersion(managedKafka.getSpec().getVersions().getKafka());
versionsBuilder.withKafkaIbp(kafkaIbp);
}
status.setVersions(versionsBuilder.build());
status.setAdminServerURI(kafkaInstance.getAdminServer().uri(managedKafka));
status.setServiceAccounts(managedKafka.getSpec().getServiceAccounts());
}
}
use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaSpecTest method testEquals.
@Test
public void testEquals() {
ManagedKafkaSpec spec1 = new ManagedKafkaSpec();
ManagedKafkaSpec spec2 = new ManagedKafkaSpec();
// if it's not equals, then the default equality is being used
assertEquals(spec1, spec2);
spec1.setVersions(new Versions());
spec2.setVersions(new Versions());
assertEquals(spec1, spec2);
spec1.getVersions().setKafka("2.2.2");
assertNotEquals(spec1, spec2);
}
use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class VersionsTest method testVersion.
@Test
public void testVersion() {
Versions versions = new Versions();
versions.setStrimzi("0.22.1");
assertTrue(versions.isStrimziVersionIn("0.22"));
versions.setStrimzi("strimzi-cluster-operator.v0.22.1");
assertTrue(versions.isStrimziVersionIn("0.22"));
versions.setStrimzi("strimzi-cluster-operator.v0.22.1-6");
assertTrue(versions.isStrimziVersionIn("0.22"));
versions.setStrimzi("strimzi-cluster-operator.v0.23.0");
assertFalse(versions.isStrimziVersionIn("0.22"));
}
Aggregations