Skip to content

Commit

Permalink
First draft, mostly duplicated code from Connector, compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
lucamolteni committed Mar 29, 2023
1 parent 9562514 commit aff0732
Show file tree
Hide file tree
Showing 17 changed files with 1,213 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,16 @@ components:
$ref: 'connector_mgmt.yaml#/components/schemas/KafkaConnectionSettings'
schema_registry:
$ref: "connector_mgmt.yaml#/components/schemas/SchemaRegistryConnectionSettings"
connector_id:
processor_id:
type: string
connector_resource_version:
processor_resource_version:
type: integer
format: int64
connector_type_id:
processor_type_id:
type: string
namespace_id:
type: string
connector_spec:
processor_spec:
type: object
operator_id:
description: an optional operator id that the connector should be run under.
Expand Down
18 changes: 18 additions & 0 deletions cos-fleet-manager-api/src/openapi/specs/connector_mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,24 @@ components:
items:
$ref: "#/components/schemas/ConnectorTypeLabelCount"


Processor:
allOf:
- $ref: "#/components/schemas/ObjectReference"
- $ref: "#/components/schemas/ConnectorMeta"
- $ref: "#/components/schemas/ConnectorConfiguration"
- $ref: "#/components/schemas/ConnectorStatus"

ProcessorList:
allOf:
- $ref: "#/components/schemas/List"
- type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/Connector"

#
# Connector Namespaces
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.bf2.cos.fleetshard.api;

import com.fasterxml.jackson.annotation.JsonInclude;

import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.ShortNames;
import io.fabric8.kubernetes.model.annotation.Version;
import io.sundr.builder.annotations.Buildable;
import io.sundr.builder.annotations.BuildableReference;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder", refs = @BuildableReference(CustomResource.class),
editableEnabled = false)
@Version(Processor.VERSION)
@Group(Processor.GROUP)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ShortNames("prc")
public class Processor
extends CustomResource<ProcessorSpec, ProcessorStatus>
implements Namespaced {

public static final String VERSION = "v1alpha1";
public static final String GROUP = "cos.bf2.org";
public static final String API_VERSION = GROUP + "/" + VERSION;

public static final String DESIRED_STATE_READY = "ready";
public static final String DESIRED_STATE_DELETED = "deleted";
public static final String DESIRED_STATE_UNASSIGNED = "unassigned";
public static final String DESIRED_STATE_STOPPED = "stopped";

public static final String STATE_PROVISIONING = "provisioning";
public static final String STATE_DE_PROVISIONING = "deprovisioning";
public static final String STATE_DELETED = "deleted";
public static final String STATE_STOPPED = "stopped";
public static final String STATE_FAILED = "failed";
public static final String STATE_READY = "ready";

@Override
protected ProcessorSpec initSpec() {
return new ProcessorSpec();
}

@Override
protected ProcessorStatus initStatus() {
return new ProcessorStatus();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package org.bf2.cos.fleetshard.api;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import io.fabric8.kubernetes.model.annotation.PrinterColumn;
import io.sundr.builder.annotations.Buildable;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder")
@JsonPropertyOrder({
"processorTypeId",
"connectorResourceVersion",
"deploymentResourceVersion",
"desiredState",
"secret",
"configMapChecksum",
"unitOfWork"
})
public class ProcessorDeploymentSpec {

@PrinterColumn(name = "PROCESSOR_TYPE_ID")
private String processorTypeId;
private Long processorResourceVersion;
private Long deploymentResourceVersion;
private KafkaSpec kafka;
private SchemaRegistrySpec schemaRegistry;
private String desiredState;
private String secret;
private String configMapChecksum;
private String unitOfWork;

@JsonProperty
public String getProcessorTypeId() {
return processorTypeId;
}

@JsonProperty
public void setProcessorTypeId(String connectorTypeId) {
this.processorTypeId = connectorTypeId;
}

@JsonProperty
public Long getProcessorResourceVersion() {
return processorResourceVersion;
}

@JsonProperty
public void setProcessorResourceVersion(Long processorResourceVersion) {
this.processorResourceVersion = processorResourceVersion;
}

@JsonProperty
public Long getDeploymentResourceVersion() {
return deploymentResourceVersion;
}

@JsonProperty
public void setDeploymentResourceVersion(Long deploymentResourceVersion) {
this.deploymentResourceVersion = deploymentResourceVersion;
}

@JsonProperty
public KafkaSpec getKafka() {
return kafka;
}

@JsonProperty
public void setKafka(KafkaSpec kafka) {
this.kafka = kafka;
}

@JsonProperty
public SchemaRegistrySpec getSchemaRegistry() {
return schemaRegistry;
}

@JsonProperty
public void setSchemaRegistry(SchemaRegistrySpec schemaRegistry) {
this.schemaRegistry = schemaRegistry;
}

@JsonProperty
public String getDesiredState() {
return desiredState;
}

@JsonProperty
public void setDesiredState(String desiredState) {
this.desiredState = desiredState;
}

@JsonProperty
public String getSecret() {
return secret;
}

@JsonProperty
public void setSecret(String secret) {
this.secret = secret;
}

@JsonProperty
public String getConfigMapChecksum() {
return configMapChecksum;
}

@JsonProperty
public void setConfigMapChecksum(String configMapChecksum) {
this.configMapChecksum = configMapChecksum;
}

@JsonProperty
public String getUnitOfWork() {
return unitOfWork;
}

@JsonProperty
public void setUnitOfWork(String unitOfWork) {
this.unitOfWork = unitOfWork;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ProcessorDeploymentSpec that = (ProcessorDeploymentSpec) o;
return Objects.equals(processorTypeId, that.processorTypeId)
&& Objects.equals(processorResourceVersion, that.processorResourceVersion)
&& Objects.equals(deploymentResourceVersion, that.deploymentResourceVersion)
&& Objects.equals(kafka, that.kafka)
&& Objects.equals(schemaRegistry, that.schemaRegistry)
&& Objects.equals(desiredState, that.desiredState)
&& Objects.equals(secret, that.secret)
&& Objects.equals(configMapChecksum, that.configMapChecksum)
&& Objects.equals(unitOfWork, that.unitOfWork);
}

@Override
public int hashCode() {
return Objects.hash(processorTypeId,
processorResourceVersion,
deploymentResourceVersion,
kafka,
schemaRegistry,
desiredState,
secret,
configMapChecksum,
unitOfWork);
}

@Override
public String toString() {
return "DeploymentSpec{" +
"processorTypeId='" + processorTypeId + '\'' +
", processorResourceVersion=" + processorResourceVersion +
", deploymentResourceVersion=" + deploymentResourceVersion +
", kafka=" + kafka +
", schemaRegistry=" + schemaRegistry +
", desiredState='" + desiredState + '\'' +
", secret='" + secret + '\'' +
", configMapChecksum='" + configMapChecksum + '\'' +
", unitOfWork='" + unitOfWork + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.bf2.cos.fleetshard.api;

public interface ProcessorDeploymentSpecAware {
ProcessorDeploymentSpec getDeployment();

void setDeployment(ProcessorDeploymentSpec deployment);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.bf2.cos.fleetshard.api;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import io.fabric8.kubernetes.model.annotation.PrinterColumn;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;

@ToString
@EqualsAndHashCode
@Buildable(builderPackage = "io.fabric8.kubernetes.api.builder")
@JsonPropertyOrder({
"id",
"clusterId",
"processorId",
"deploymentId",
"deployment",
"operatorSelector"
})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProcessorSpec implements ProcessorDeploymentSpecAware {
@PrinterColumn(name = "CLUSTER_ID")
private String clusterId;

@PrinterColumn(name = "PROCESSOR_ID")
private String processorId;

@PrinterColumn(name = "DEPLOYMENT_ID")
private String deploymentId;

private ProcessorDeploymentSpec deployment = new ProcessorDeploymentSpec();

private OperatorSelector operatorSelector = new OperatorSelector();

@JsonProperty
public String getClusterId() {
return clusterId;
}

@JsonProperty
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
}

@JsonProperty
public String getProcessorId() {
return processorId;
}

@JsonProperty
public void setProcessorId(String processorId) {
this.processorId = processorId;
}

@JsonProperty
public String getDeploymentId() {
return deploymentId;
}

@JsonProperty
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}

@Override
@JsonProperty
public ProcessorDeploymentSpec getDeployment() {
return deployment;
}

@Override
@JsonProperty
public void setDeployment(ProcessorDeploymentSpec deployment) {
this.deployment = deployment;
}

@JsonProperty
public OperatorSelector getOperatorSelector() {
return operatorSelector;
}

@JsonProperty
public void setOperatorSelector(OperatorSelector operatorSelector) {
this.operatorSelector = operatorSelector;
}
}
Loading

0 comments on commit aff0732

Please sign in to comment.