Search in sources :

Example 1 with StackGresDbOpsMajorVersionUpgrade

use of io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade in project stackgres by ongres.

the class DbOpsMajorVersionUpgradeJob method getRunEnvVars.

@Override
protected List<EnvVar> getRunEnvVars(StackGresDbOpsContext context) {
    StackGresDbOps dbOps = context.getSource();
    StackGresDbOpsMajorVersionUpgrade majorVersionUpgrade = dbOps.getSpec().getMajorVersionUpgrade();
    return ImmutableList.<EnvVar>builder().add(new EnvVarBuilder().withName("LINK").withValue(Optional.ofNullable(majorVersionUpgrade).map(StackGresDbOpsMajorVersionUpgrade::getLink).map(String::valueOf).orElse("false")).build(), new EnvVarBuilder().withName("CLONE").withValue(Optional.ofNullable(majorVersionUpgrade).map(StackGresDbOpsMajorVersionUpgrade::getClone).map(String::valueOf).orElse("false")).build(), new EnvVarBuilder().withName("CHECK").withValue(Optional.ofNullable(majorVersionUpgrade).map(StackGresDbOpsMajorVersionUpgrade::getCheck).map(String::valueOf).orElse("false")).build(), new EnvVarBuilder().withName("CRD_GROUP").withValue(CommonDefinition.GROUP).build(), new EnvVarBuilder().withName("CLUSTER_CRD_NAME").withValue(HasMetadata.getPlural(StackGresCluster.class)).build(), new EnvVarBuilder().withName("CLUSTER_NAMESPACE").withValue(context.getSource().getMetadata().getNamespace()).build(), new EnvVarBuilder().withName("CLUSTER_NAME").withValue(context.getSource().getSpec().getSgCluster()).build(), new EnvVarBuilder().withName("SERVICE_ACCOUNT").withValueFrom(new EnvVarSourceBuilder().withFieldRef(new ObjectFieldSelector("v1", "spec.serviceAccountName")).build()).build(), new EnvVarBuilder().withName("POD_NAME").withValueFrom(new EnvVarSourceBuilder().withFieldRef(new ObjectFieldSelector("v1", "metadata.name")).build()).build(), new EnvVarBuilder().withName("DB_OPS_CRD_NAME").withValue(CustomResource.getCRDName(StackGresDbOps.class)).build(), new EnvVarBuilder().withName("DB_OPS_NAME").withValue(dbOps.getMetadata().getName()).build(), new EnvVarBuilder().withName("CLUSTER_POD_LABELS").withValue(labelFactory.patroniClusterLabels(context.getCluster()).entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(","))).build(), new EnvVarBuilder().withName("CLUSTER_PRIMARY_POD_LABELS").withValue(labelFactory.patroniPrimaryLabels(context.getCluster()).entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(","))).build(), new EnvVarBuilder().withName("PATRONI_CONTAINER_NAME").withValue(StackgresClusterContainers.PATRONI).build(), new EnvVarBuilder().withName("MAJOR_VERSION_UPGRADE_CONTAINER_NAME").withValue(StackgresClusterContainers.MAJOR_VERSION_UPGRADE).build(), new EnvVarBuilder().withName("LOCK_TIMEOUT").withValue(OperatorProperty.LOCK_TIMEOUT.getString()).build(), new EnvVarBuilder().withName("LOCK_SLEEP").withValue(OperatorProperty.LOCK_POLL_INTERVAL.getString()).build()).build();
}
Also used : PodSecurityContext(io.fabric8.kubernetes.api.model.PodSecurityContext) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresVersion(io.stackgres.operator.common.StackGresVersion) Singleton(javax.inject.Singleton) StackgresClusterContainers(io.stackgres.common.StackgresClusterContainers) StackGresDbOps(io.stackgres.common.crd.sgdbops.StackGresDbOps) Inject(javax.inject.Inject) StackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext) ImmutableList(com.google.common.collect.ImmutableList) DbOpsEnvironmentVariables(io.stackgres.operator.cluster.factory.DbOpsEnvironmentVariables) ClusterStatefulSetPath(io.stackgres.common.ClusterStatefulSetPath) StackGresDbOpsMajorVersionUpgrade(io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade) EnvVarSourceBuilder(io.fabric8.kubernetes.api.model.EnvVarSourceBuilder) LabelFactoryForDbOps(io.stackgres.common.LabelFactoryForDbOps) ResourceFactory(io.stackgres.operator.conciliation.factory.ResourceFactory) LabelFactoryForCluster(io.stackgres.common.LabelFactoryForCluster) ObjectFieldSelector(io.fabric8.kubernetes.api.model.ObjectFieldSelector) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) Collectors(java.util.stream.Collectors) JsonMapper(com.fasterxml.jackson.databind.json.JsonMapper) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) OperatorVersionBinder(io.stackgres.operator.conciliation.OperatorVersionBinder) CdiUtil(io.stackgres.common.CdiUtil) StackGresComponent(io.stackgres.common.StackGresComponent) List(java.util.List) Optional(java.util.Optional) OperatorProperty(io.stackgres.common.OperatorProperty) CommonDefinition(io.stackgres.common.crd.CommonDefinition) CustomResource(io.fabric8.kubernetes.client.CustomResource) ObjectFieldSelector(io.fabric8.kubernetes.api.model.ObjectFieldSelector) EnvVarSourceBuilder(io.fabric8.kubernetes.api.model.EnvVarSourceBuilder) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) StackGresDbOps(io.stackgres.common.crd.sgdbops.StackGresDbOps) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) StackGresDbOpsMajorVersionUpgrade(io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade)

Example 2 with StackGresDbOpsMajorVersionUpgrade

use of io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade in project stackgres by ongres.

the class DbOpsTransformer method getCustomResourceMajorVersionUpgrade.

private StackGresDbOpsMajorVersionUpgrade getCustomResourceMajorVersionUpgrade(DbOpsMajorVersionUpgrade source) {
    if (source == null) {
        return null;
    }
    StackGresDbOpsMajorVersionUpgrade transformation = new StackGresDbOpsMajorVersionUpgrade();
    transformation.setLink(source.getLink());
    transformation.setClone(source.getClone());
    transformation.setCheck(source.getCheck());
    return transformation;
}
Also used : StackGresDbOpsMajorVersionUpgrade(io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade)

Example 3 with StackGresDbOpsMajorVersionUpgrade

use of io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade in project stackgres by ongres.

the class DbOpsTransformer method getResourceMajorVersionUpgrade.

private DbOpsMajorVersionUpgrade getResourceMajorVersionUpgrade(StackGresDbOpsMajorVersionUpgrade source) {
    if (source == null) {
        return null;
    }
    DbOpsMajorVersionUpgrade transformation = new DbOpsMajorVersionUpgrade();
    transformation.setLink(source.getLink());
    transformation.setClone(source.getClone());
    transformation.setCheck(source.getCheck());
    return transformation;
}
Also used : StackGresDbOpsMajorVersionUpgrade(io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade) DbOpsMajorVersionUpgrade(io.stackgres.apiweb.dto.dbops.DbOpsMajorVersionUpgrade)

Aggregations

StackGresDbOpsMajorVersionUpgrade (io.stackgres.common.crd.sgdbops.StackGresDbOpsMajorVersionUpgrade)3 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)1 EnvVarSourceBuilder (io.fabric8.kubernetes.api.model.EnvVarSourceBuilder)1 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 ObjectFieldSelector (io.fabric8.kubernetes.api.model.ObjectFieldSelector)1 PodSecurityContext (io.fabric8.kubernetes.api.model.PodSecurityContext)1 CustomResource (io.fabric8.kubernetes.client.CustomResource)1 DbOpsMajorVersionUpgrade (io.stackgres.apiweb.dto.dbops.DbOpsMajorVersionUpgrade)1 CdiUtil (io.stackgres.common.CdiUtil)1 ClusterStatefulSetPath (io.stackgres.common.ClusterStatefulSetPath)1 LabelFactoryForCluster (io.stackgres.common.LabelFactoryForCluster)1 LabelFactoryForDbOps (io.stackgres.common.LabelFactoryForDbOps)1 OperatorProperty (io.stackgres.common.OperatorProperty)1 StackGresComponent (io.stackgres.common.StackGresComponent)1 StackgresClusterContainers (io.stackgres.common.StackgresClusterContainers)1 CommonDefinition (io.stackgres.common.crd.CommonDefinition)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1