diff --git a/api/event-bus.html b/api/event-bus.html index 99bd6627e9..d7eefb6cf5 100644 --- a/api/event-bus.html +++ b/api/event-bus.html @@ -47,6 +47,20 @@

BusConfig +(Optional) + + + + +jetstream
+ + +JetStreamConfig + + + + +(Optional) @@ -55,6 +69,7 @@

ContainerTemplate

(Appears on: +JetStreamBus, NativeStrategy)

@@ -156,9 +171,23 @@

EventBus +(Optional)

NATS eventbus

+ + +jetstream
+ + +JetStreamBus + + + + +(Optional) + + @@ -204,9 +233,23 @@

EventBusSpec +(Optional)

NATS eventbus

+ + +jetstream
+ + +JetStreamBus + + + + +(Optional) + +

EventBusStatus @@ -254,6 +297,322 @@

EventBusStatus +

JetStreamAuth +

+

+(Appears on: +JetStreamConfig) +

+

+

+ + + + + + + + + + + + + +
FieldDescription
+token
+ + +Kubernetes core/v1.SecretKeySelector + + +
+(Optional) +

Secret for auth token

+
+

JetStreamBus +

+

+(Appears on: +EventBusSpec) +

+

+

JetStreamBus holds the JetStream EventBus information

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+version
+ +string + +
+

JetStream version, such as “2.7.3”

+
+replicas
+ +int32 + +
+

Redis StatefulSet size

+
+containerTemplate
+ + +ContainerTemplate + + +
+(Optional) +

ContainerTemplate contains customized spec for Nats JetStream container

+
+reloaderContainerTemplate
+ + +ContainerTemplate + + +
+(Optional) +

ReloaderContainerTemplate contains customized spec for config reloader container

+
+metricsContainerTemplate
+ + +ContainerTemplate + + +
+(Optional) +

MetricsContainerTemplate contains customized spec for metrics container

+
+persistence
+ + +PersistenceStrategy + + +
+(Optional) +
+metadata
+ +github.com/argoproj/argo-events/pkg/apis/common.Metadata + +
+

Metadata sets the pods’s metadata, i.e. annotations and labels

+
+nodeSelector
+ +map[string]string + +
+(Optional) +

NodeSelector is a selector which must be true for the pod to fit on a node. +Selector which must match a node’s labels for the pod to be scheduled on that node. +More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

+
+tolerations
+ + +[]Kubernetes core/v1.Toleration + + +
+(Optional) +

If specified, the pod’s tolerations.

+
+securityContext
+ + +Kubernetes core/v1.PodSecurityContext + + +
+(Optional) +

SecurityContext holds pod-level security attributes and common container settings. +Optional: Defaults to empty. See type description for default values of each field.

+
+imagePullSecrets
+ + +[]Kubernetes core/v1.LocalObjectReference + + +
+(Optional) +

ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. +If specified, these secrets will be passed to individual puller implementations for them to use. For example, +in the case of docker, only DockerConfig type secrets are honored. +More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod

+
+priorityClassName
+ +string + +
+(Optional) +

If specified, indicates the Redis pod’s priority. “system-node-critical” +and “system-cluster-critical” are two special keywords which indicate the +highest priorities with the former being the highest priority. Any other +name must be defined by creating a PriorityClass object with that name. +If not specified, the pod priority will be default or zero if there is no +default. +More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/

+
+priority
+ +int32 + +
+(Optional) +

The priority value. Various system components use this field to find the +priority of the Redis pod. When Priority Admission Controller is enabled, +it prevents users from setting this field. The admission controller populates +this field from PriorityClassName. +The higher the value, the higher the priority. +More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/

+
+affinity
+ + +Kubernetes core/v1.Affinity + + +
+(Optional) +

The pod’s scheduling constraints +More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

+
+serviceAccountName
+ +string + +
+(Optional) +

ServiceAccountName to apply to the StatefulSet

+
+settings
+ +string + +
+(Optional) +

JetStream configuration, if not specified, global settings in controller-config will be used. +See https://docs.nats.io/running-a-nats-service/configuration#jetstream. +Only configure “max_memory_store” or “max_file_store”, do not set “store_dir” as it has been hardcoded.

+
+

JetStreamConfig +

+

+(Appears on: +BusConfig) +

+

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+url
+ +string + +
+

JetStream (Nats) URL

+
+auth
+ + +JetStreamAuth + + +
+

NATSBus

@@ -689,6 +1048,7 @@

PersistenceStrategy

(Appears on: +JetStreamBus, NativeStrategy)

diff --git a/api/event-bus.md b/api/event-bus.md index 7215a8639d..00a069a197 100644 --- a/api/event-bus.md +++ b/api/event-bus.md @@ -61,6 +61,17 @@ Description NATSConfig +(Optional) + + + + +jetstream
+ JetStreamConfig + + + +(Optional) @@ -70,6 +81,7 @@ ContainerTemplate

(Appears on: +JetStreamBus, NativeStrategy)

@@ -163,11 +175,21 @@ Refer to the Kubernetes API documentation for the fields of the NATSBus +(Optional)

NATS eventbus

+ + +jetstream
+ JetStreamBus + + +(Optional) + + @@ -213,11 +235,21 @@ Description NATSBus +(Optional)

NATS eventbus

+ + +jetstream
+ JetStreamBus + + +(Optional) + +

@@ -268,6 +300,323 @@ Config holds the fininalized configuration of EventBus +

+JetStreamAuth +

+

+(Appears on: +JetStreamConfig) +

+

+

+ + + + + + + + + + + + + +
+Field + +Description +
+token
+ +Kubernetes core/v1.SecretKeySelector +
+(Optional) +

+Secret for auth token +

+
+

+JetStreamBus +

+

+(Appears on: +EventBusSpec) +

+

+

+JetStreamBus holds the JetStream EventBus information +

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field + +Description +
+version
string +
+

+JetStream version, such as “2.7.3” +

+
+replicas
int32 +
+

+Redis StatefulSet size +

+
+containerTemplate
+ ContainerTemplate + +
+(Optional) +

+ContainerTemplate contains customized spec for Nats JetStream container +

+
+reloaderContainerTemplate
+ ContainerTemplate + +
+(Optional) +

+ReloaderContainerTemplate contains customized spec for config reloader +container +

+
+metricsContainerTemplate
+ ContainerTemplate + +
+(Optional) +

+MetricsContainerTemplate contains customized spec for metrics container +

+
+persistence
+ PersistenceStrategy + +
+(Optional) +
+metadata
+github.com/argoproj/argo-events/pkg/apis/common.Metadata +
+

+Metadata sets the pods’s metadata, i.e. annotations and labels +

+
+nodeSelector
map\[string\]string +
+(Optional) +

+NodeSelector is a selector which must be true for the pod to fit on a +node. Selector which must match a node’s labels for the pod to be +scheduled on that node. More info: +https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +

+
+tolerations
+ +\[\]Kubernetes core/v1.Toleration +
+(Optional) +

+If specified, the pod’s tolerations. +

+
+securityContext
+ +Kubernetes core/v1.PodSecurityContext +
+(Optional) +

+SecurityContext holds pod-level security attributes and common container +settings. Optional: Defaults to empty. See type description for default +values of each field. +

+
+imagePullSecrets
+ +\[\]Kubernetes core/v1.LocalObjectReference +
+(Optional) +

+ImagePullSecrets is an optional list of references to secrets in the +same namespace to use for pulling any of the images used by this +PodSpec. If specified, these secrets will be passed to individual puller +implementations for them to use. For example, in the case of docker, +only DockerConfig type secrets are honored. More info: +https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod +

+
+priorityClassName
string +
+(Optional) +

+If specified, indicates the Redis pod’s priority. “system-node-critical” +and “system-cluster-critical” are two special keywords which indicate +the highest priorities with the former being the highest priority. Any +other name must be defined by creating a PriorityClass object with that +name. If not specified, the pod priority will be default or zero if +there is no default. More info: +https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ +

+
+priority
int32 +
+(Optional) +

+The priority value. Various system components use this field to find the +priority of the Redis pod. When Priority Admission Controller is +enabled, it prevents users from setting this field. The admission +controller populates this field from PriorityClassName. The higher the +value, the higher the priority. More info: +https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ +

+
+affinity
+ +Kubernetes core/v1.Affinity +
+(Optional) +

+The pod’s scheduling constraints More info: +https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ +

+
+serviceAccountName
string +
+(Optional) +

+ServiceAccountName to apply to the StatefulSet +

+
+settings
string +
+(Optional) +

+JetStream configuration, if not specified, global settings in +controller-config will be used. See +https://docs.nats.io/running-a-nats-service/configuration#jetstream. +Only configure “max_memory_store” or “max_file_store”, do not set +“store_dir” as it has been hardcoded. +

+
+

+JetStreamConfig +

+

+(Appears on: +BusConfig) +

+

+

+ + + + + + + + + + + + + + + + + +
+Field + +Description +
+url
string +
+

+JetStream (Nats) URL +

+
+auth
+ JetStreamAuth +
+

NATSBus

@@ -703,6 +1052,7 @@ PersistenceStrategy

(Appears on: +JetStreamBus, NativeStrategy)

diff --git a/api/jsonschema/schema.json b/api/jsonschema/schema.json index 7e29797bdc..81996305ab 100644 --- a/api/jsonschema/schema.json +++ b/api/jsonschema/schema.json @@ -261,6 +261,9 @@ "io.argoproj.eventbus.v1alpha1.BusConfig": { "description": "BusConfig has the finalized configuration for EventBus", "properties": { + "jetstream": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamConfig" + }, "nats": { "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.NATSConfig" } @@ -348,6 +351,9 @@ "io.argoproj.eventbus.v1alpha1.EventBusSpec": { "description": "EventBusSpec refers to specification of eventbus resource", "properties": { + "jetstream": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamBus" + }, "nats": { "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.NATSBus", "description": "NATS eventbus" @@ -374,6 +380,109 @@ }, "type": "object" }, + "io.argoproj.eventbus.v1alpha1.JetStreamAuth": { + "properties": { + "token": { + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector", + "description": "Secret for auth token" + } + }, + "type": "object" + }, + "io.argoproj.eventbus.v1alpha1.JetStreamBus": { + "description": "JetStreamBus holds the JetStream EventBus information", + "properties": { + "affinity": { + "$ref": "#/definitions/io.k8s.api.core.v1.Affinity", + "description": "The pod's scheduling constraints More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/" + }, + "containerTemplate": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate", + "description": "ContainerTemplate contains customized spec for Nats JetStream container" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "type": "array", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "metadata": { + "$ref": "#/definitions/io.argoproj.common.Metadata", + "description": "Metadata sets the pods's metadata, i.e. annotations and labels" + }, + "metricsContainerTemplate": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate", + "description": "MetricsContainerTemplate contains customized spec for metrics container" + }, + "nodeSelector": { + "additionalProperties": { + "type": "string" + }, + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object" + }, + "persistence": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.PersistenceStrategy" + }, + "priority": { + "description": "The priority value. Various system components use this field to find the priority of the Redis pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + "format": "int32", + "type": "integer" + }, + "priorityClassName": { + "description": "If specified, indicates the Redis pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + "type": "string" + }, + "reloaderContainerTemplate": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate", + "description": "ReloaderContainerTemplate contains customized spec for config reloader container" + }, + "replicas": { + "description": "Redis StatefulSet size", + "format": "int32", + "type": "integer" + }, + "securityContext": { + "$ref": "#/definitions/io.k8s.api.core.v1.PodSecurityContext", + "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field." + }, + "serviceAccountName": { + "description": "ServiceAccountName to apply to the StatefulSet", + "type": "string" + }, + "settings": { + "description": "JetStream configuration, if not specified, global settings in controller-config will be used. See https://docs.nats.io/running-a-nats-service/configuration#jetstream. Only configure \"max_memory_store\" or \"max_file_store\", do not set \"store_dir\" as it has been hardcoded.", + "type": "string" + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + }, + "type": "array" + }, + "version": { + "description": "JetStream version, such as \"2.7.3\"", + "type": "string" + } + }, + "type": "object" + }, + "io.argoproj.eventbus.v1alpha1.JetStreamConfig": { + "properties": { + "auth": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamAuth" + }, + "url": { + "description": "JetStream (Nats) URL", + "type": "string" + } + }, + "type": "object" + }, "io.argoproj.eventbus.v1alpha1.NATSBus": { "description": "NATSBus holds the NATS eventbus information", "properties": { diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 9814a6aa18..8d48afb772 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -263,6 +263,9 @@ "description": "BusConfig has the finalized configuration for EventBus", "type": "object", "properties": { + "jetstream": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamConfig" + }, "nats": { "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.NATSConfig" } @@ -341,6 +344,9 @@ "description": "EventBusSpec refers to specification of eventbus resource", "type": "object", "properties": { + "jetstream": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamBus" + }, "nats": { "description": "NATS eventbus", "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.NATSBus" @@ -366,6 +372,109 @@ } } }, + "io.argoproj.eventbus.v1alpha1.JetStreamAuth": { + "type": "object", + "properties": { + "token": { + "description": "Secret for auth token", + "$ref": "#/definitions/io.k8s.api.core.v1.SecretKeySelector" + } + } + }, + "io.argoproj.eventbus.v1alpha1.JetStreamBus": { + "description": "JetStreamBus holds the JetStream EventBus information", + "type": "object", + "properties": { + "affinity": { + "description": "The pod's scheduling constraints More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/", + "$ref": "#/definitions/io.k8s.api.core.v1.Affinity" + }, + "containerTemplate": { + "description": "ContainerTemplate contains customized spec for Nats JetStream container", + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.LocalObjectReference" + }, + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge" + }, + "metadata": { + "description": "Metadata sets the pods's metadata, i.e. annotations and labels", + "$ref": "#/definitions/io.argoproj.common.Metadata" + }, + "metricsContainerTemplate": { + "description": "MetricsContainerTemplate contains customized spec for metrics container", + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate" + }, + "nodeSelector": { + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "persistence": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.PersistenceStrategy" + }, + "priority": { + "description": "The priority value. Various system components use this field to find the priority of the Redis pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + "type": "integer", + "format": "int32" + }, + "priorityClassName": { + "description": "If specified, indicates the Redis pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + "type": "string" + }, + "reloaderContainerTemplate": { + "description": "ReloaderContainerTemplate contains customized spec for config reloader container", + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.ContainerTemplate" + }, + "replicas": { + "description": "Redis StatefulSet size", + "type": "integer", + "format": "int32" + }, + "securityContext": { + "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + "$ref": "#/definitions/io.k8s.api.core.v1.PodSecurityContext" + }, + "serviceAccountName": { + "description": "ServiceAccountName to apply to the StatefulSet", + "type": "string" + }, + "settings": { + "description": "JetStream configuration, if not specified, global settings in controller-config will be used. See https://docs.nats.io/running-a-nats-service/configuration#jetstream. Only configure \"max_memory_store\" or \"max_file_store\", do not set \"store_dir\" as it has been hardcoded.", + "type": "string" + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.api.core.v1.Toleration" + } + }, + "version": { + "description": "JetStream version, such as \"2.7.3\"", + "type": "string" + } + } + }, + "io.argoproj.eventbus.v1alpha1.JetStreamConfig": { + "type": "object", + "properties": { + "auth": { + "$ref": "#/definitions/io.argoproj.eventbus.v1alpha1.JetStreamAuth" + }, + "url": { + "description": "JetStream (Nats) URL", + "type": "string" + } + } + }, "io.argoproj.eventbus.v1alpha1.NATSBus": { "description": "NATSBus holds the NATS eventbus information", "type": "object", diff --git a/common/common.go b/common/common.go index 885b76252e..46eb0bfa12 100644 --- a/common/common.go +++ b/common/common.go @@ -59,8 +59,16 @@ const ( NATSStreamingRaftLeaseTimeout = "1s" // Default NATS Streaming RAFT commit timeout NATSStreamingRaftCommitTimeout = "100ms" + // Default EventBus name DefaultEventBusName = "default" + + // key of server auth secret + JetStreamServerAuthSecretKey = "auth" + // key of client auth secret + JetStreamClientAuthSecretKey = "client-auth" + // key of nats-js.conf in the configmap + JetStreamConfigMapKey = "nats-js" ) // Sensor constants diff --git a/common/hash.go b/common/hash.go new file mode 100644 index 0000000000..5a0081e6a8 --- /dev/null +++ b/common/hash.go @@ -0,0 +1,21 @@ +package common + +import ( + "crypto/sha256" + "encoding/hex" +) + +func MustHash(v interface{}) string { + switch data := v.(type) { + case []byte: + hash := sha256.New() + if _, err := hash.Write(data); err != nil { + panic(err) + } + return hex.EncodeToString(hash.Sum(nil)) + case string: + return MustHash([]byte(data)) + default: + return MustHash([]byte(MustJSON(v))) + } +} diff --git a/common/hash_test.go b/common/hash_test.go new file mode 100644 index 0000000000..3788c876d7 --- /dev/null +++ b/common/hash_test.go @@ -0,0 +1,17 @@ +package common + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMustHash(t *testing.T) { + assert.Equal(t, "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", MustHash([]byte("abc"))) + assert.Equal(t, "d4ffe8e9ee0b48eba716706123a7187f32eae3bdcb0e7763e41e533267bd8a53", MustHash("efg")) + assert.Equal(t, "a8e084ec42eff43acd61526bef35e33ddf7a8135d6aba3b140a5cae4c8c5e10b", MustHash( + struct { + A string + B string + }{A: "aAa", B: "bBb"})) +} diff --git a/common/json.go b/common/json.go new file mode 100644 index 0000000000..124b5135e5 --- /dev/null +++ b/common/json.go @@ -0,0 +1,27 @@ +package common + +import "encoding/json" + +func MustJSON(in interface{}) string { + if data, err := json.Marshal(in); err != nil { + panic(err) + } else { + return string(data) + } +} + +// MustUnJSON unmarshalls JSON or panics. +// v - must be []byte or string +// in - must be a pointer. +func MustUnJSON(v interface{}, in interface{}) { + switch data := v.(type) { + case []byte: + if err := json.Unmarshal(data, in); err != nil { + panic(err) + } + case string: + MustUnJSON([]byte(data), in) + default: + panic("unknown type") + } +} diff --git a/common/json_test.go b/common/json_test.go new file mode 100644 index 0000000000..05cbef212b --- /dev/null +++ b/common/json_test.go @@ -0,0 +1,17 @@ +package common + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMustJson(t *testing.T) { + assert.Equal(t, "1", MustJSON(1)) +} + +func TestUnJSON(t *testing.T) { + var in int + MustUnJSON("1", &in) + assert.Equal(t, 1, in) +} diff --git a/common/string.go b/common/string.go new file mode 100644 index 0000000000..190f3e7ed4 --- /dev/null +++ b/common/string.go @@ -0,0 +1,17 @@ +package common + +import ( + "crypto/rand" + "math/big" +) + +// generate a random string with given length +func RandomString(length int) string { + seeds := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + result := make([]byte, length) + for i := 0; i < length; i++ { + num, _ := rand.Int(rand.Reader, big.NewInt(int64(len(seeds)))) + result[i] = seeds[num.Int64()] + } + return string(result) +} diff --git a/common/string_test.go b/common/string_test.go new file mode 100644 index 0000000000..3bdabcc8ff --- /dev/null +++ b/common/string_test.go @@ -0,0 +1,12 @@ +package common + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRandomString(t *testing.T) { + str := RandomString(20) + assert.Equal(t, 20, len(str)) +} diff --git a/controllers/config.go b/controllers/config.go new file mode 100644 index 0000000000..533abe1a0a --- /dev/null +++ b/controllers/config.go @@ -0,0 +1,117 @@ +package controllers + +import ( + "fmt" + "strings" + + "github.com/fsnotify/fsnotify" + "github.com/spf13/viper" +) + +type GlobalConfig struct { + EventBus *EventBusConfig `json:"eventBus"` +} + +type EventBusConfig struct { + NATS *NatsStreamingConfig `json:"nats"` + JetStream *JetStreamConfig `json:"jetstream"` +} + +type NatsStreamingConfig struct { + Versions []NatsStreamingVersion `json:"versions"` +} + +type NatsStreamingVersion struct { + Version string `json:"version"` + NatsStreamingImage string `json:"natsStreamingImage"` + MetricsExporterImage string `json:"metricsExporterImage"` +} + +type JetStreamConfig struct { + Settings string `json:"settings"` + Versions []JetStreamVersion `json:"versions"` +} + +type JetStreamVersion struct { + Version string `json:"version"` + NatsImage string `json:"natsImage"` + ConfigReloaderImage string `json:"configReloaderImage"` + MetricsExporterImage string `json:"metricsExporterImage"` + StartCommand string `json:"startCommand"` +} + +func (g *GlobalConfig) supportedNatsStreamingVersions() []string { + result := []string{} + if g.EventBus == nil || g.EventBus.NATS == nil { + return result + } + for _, v := range g.EventBus.NATS.Versions { + result = append(result, v.Version) + } + return result +} + +func (g *GlobalConfig) supportedJetStreamVersions() []string { + result := []string{} + if g.EventBus == nil || g.EventBus.JetStream == nil { + return result + } + for _, v := range g.EventBus.JetStream.Versions { + result = append(result, v.Version) + } + return result +} + +func (g *GlobalConfig) GetNatsStreamingVersion(version string) (*NatsStreamingVersion, error) { + if g.EventBus == nil || g.EventBus.NATS == nil { + return nil, fmt.Errorf("\"eventBus.nats\" not found in the configuration") + } + if len(g.EventBus.NATS.Versions) == 0 { + return nil, fmt.Errorf("nats streaming version configuration not found") + } + for _, r := range g.EventBus.NATS.Versions { + if r.Version == version { + return &r, nil + } + } + return nil, fmt.Errorf("unsupported version %q, supported versions: %q", version, strings.Join(g.supportedNatsStreamingVersions(), ",")) +} + +func (g *GlobalConfig) GetJetStreamVersion(version string) (*JetStreamVersion, error) { + if g.EventBus == nil || g.EventBus.JetStream == nil { + return nil, fmt.Errorf("\"eventBus.jetstream\" not found in the configuration") + } + if len(g.EventBus.JetStream.Versions) == 0 { + return nil, fmt.Errorf("jetstream version configuration not found") + } + for _, r := range g.EventBus.JetStream.Versions { + if r.Version == version { + return &r, nil + } + } + return nil, fmt.Errorf("unsupported version %q, supported versions: %q", version, strings.Join(g.supportedJetStreamVersions(), ",")) +} + +func LoadConfig(onErrorReloading func(error)) (*GlobalConfig, error) { + v := viper.New() + v.SetConfigName("controller-config") + v.SetConfigType("yaml") + v.AddConfigPath("/etc/argo-events") + err := v.ReadInConfig() + if err != nil { + return nil, fmt.Errorf("failed to load configuration file. %w", err) + } + r := &GlobalConfig{} + err = v.Unmarshal(r) + if err != nil { + return nil, fmt.Errorf("failed unmarshal configuration file. %w", err) + } + v.WatchConfig() + v.OnConfigChange(func(e fsnotify.Event) { + err = v.Unmarshal(r) + if err != nil { + onErrorReloading(err) + } + }) + return r, nil +} diff --git a/controllers/eventbus/cmd/start.go b/controllers/eventbus/cmd/start.go index 121465ded2..8ae19a9a56 100644 --- a/controllers/eventbus/cmd/start.go +++ b/controllers/eventbus/cmd/start.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "os" "go.uber.org/zap" appv1 "k8s.io/api/apps/v1" @@ -18,26 +17,20 @@ import ( argoevents "github.com/argoproj/argo-events" "github.com/argoproj/argo-events/common" "github.com/argoproj/argo-events/common/logging" + "github.com/argoproj/argo-events/controllers" "github.com/argoproj/argo-events/controllers/eventbus" eventbusv1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" eventsourcev1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" sensorv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" ) -const ( - natsStreamingEnvVar = "NATS_STREAMING_IMAGE" - natsMetricsExporterEnvVar = "NATS_METRICS_EXPORTER_IMAGE" -) - func Start(namespaced bool, managedNamespace string) { logger := logging.NewArgoEventsLogger().Named(eventbus.ControllerName) - natsStreamingImage, defined := os.LookupEnv(natsStreamingEnvVar) - if !defined { - logger.Fatalf("required environment variable '%s' not defined", natsStreamingEnvVar) - } - natsMetricsImage, defined := os.LookupEnv(natsMetricsExporterEnvVar) - if !defined { - logger.Fatalf("required environment variable '%s' not defined", natsMetricsExporterEnvVar) + config, err := controllers.LoadConfig(func(err error) { + logger.Errorf("Failed to reload global configuration file", zap.Error(err)) + }) + if err != nil { + logger.Fatalw("Failed to load global configuration file", zap.Error(err)) } opts := ctrl.Options{ MetricsBindAddress: fmt.Sprintf(":%d", common.ControllerMetricsPort), @@ -75,7 +68,7 @@ func Start(namespaced bool, managedNamespace string) { // A controller with DefaultControllerRateLimiter c, err := controller.New(eventbus.ControllerName, mgr, controller.Options{ - Reconciler: eventbus.NewReconciler(mgr.GetClient(), mgr.GetScheme(), natsStreamingImage, natsMetricsImage, logger), + Reconciler: eventbus.NewReconciler(mgr.GetClient(), mgr.GetScheme(), config, logger), }) if err != nil { logger.Fatalw("unable to set up individual controller", zap.Error(err)) diff --git a/controllers/eventbus/controller.go b/controllers/eventbus/controller.go index cdde1af81a..59c1aa7544 100644 --- a/controllers/eventbus/controller.go +++ b/controllers/eventbus/controller.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" + "github.com/argoproj/argo-events/controllers" "github.com/argoproj/argo-events/controllers/eventbus/installer" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" ) @@ -27,14 +28,13 @@ type reconciler struct { client client.Client scheme *runtime.Scheme - natsStreamingImage string - natsMetricsImage string - logger *zap.SugaredLogger + config *controllers.GlobalConfig + logger *zap.SugaredLogger } // NewReconciler returns a new reconciler -func NewReconciler(client client.Client, scheme *runtime.Scheme, natsStreamingImage, natsMetricsImage string, logger *zap.SugaredLogger) reconcile.Reconciler { - return &reconciler{client: client, scheme: scheme, natsStreamingImage: natsStreamingImage, natsMetricsImage: natsMetricsImage, logger: logger} +func NewReconciler(client client.Client, scheme *runtime.Scheme, config *controllers.GlobalConfig, logger *zap.SugaredLogger) reconcile.Reconciler { + return &reconciler{client: client, scheme: scheme, config: config, logger: logger} } func (r *reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { @@ -71,7 +71,7 @@ func (r *reconciler) reconcile(ctx context.Context, eventBus *v1alpha1.EventBus) log.Info("deleting eventbus") if controllerutil.ContainsFinalizer(eventBus, finalizerName) { // Finalizer logic should be added here. - if err := installer.Uninstall(ctx, eventBus, r.client, r.natsStreamingImage, r.natsMetricsImage, log); err != nil { + if err := installer.Uninstall(ctx, eventBus, r.client, r.config, log); err != nil { log.Errorw("failed to uninstall", zap.Error(err)) return err } @@ -87,7 +87,7 @@ func (r *reconciler) reconcile(ctx context.Context, eventBus *v1alpha1.EventBus) eventBus.Status.MarkDeployFailed("InvalidSpec", err.Error()) return err } - return installer.Install(ctx, eventBus, r.client, r.natsStreamingImage, r.natsMetricsImage, log) + return installer.Install(ctx, eventBus, r.client, r.config, log) } func (r *reconciler) needsUpdate(old, new *v1alpha1.EventBus) bool { diff --git a/controllers/eventbus/controller_test.go b/controllers/eventbus/controller_test.go index e8d510f812..3980625ea7 100644 --- a/controllers/eventbus/controller_test.go +++ b/controllers/eventbus/controller_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.uber.org/zap/zaptest" appv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiresource "k8s.io/apimachinery/pkg/api/resource" @@ -13,15 +14,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/argoproj/argo-events/common/logging" + "github.com/argoproj/argo-events/controllers" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" ) const ( - testBusName = "test-bus" - testStreamingImage = "test-steaming-image" - testNamespace = "testNamespace" - testURL = "http://test" + testBusName = "test-bus" + testNamespace = "testNamespace" + testURL = "http://test" ) var ( @@ -69,6 +69,30 @@ var ( }, }, } + + fakeConfig = &controllers.GlobalConfig{ + EventBus: &controllers.EventBusConfig{ + NATS: &controllers.NatsStreamingConfig{ + Versions: []controllers.NatsStreamingVersion{ + { + Version: "0.22.1", + NatsStreamingImage: "test-n-s-image", + MetricsExporterImage: "test-n-s-m-image", + }, + }, + }, + JetStream: &controllers.JetStreamConfig{ + Versions: []controllers.JetStreamVersion{ + { + Version: "testVersion", + NatsImage: "testJSImage", + ConfigReloaderImage: "test-nats-rl-image", + MetricsExporterImage: "testJSMetricsImage", + }, + }, + }, + }, + } ) func init() { @@ -83,10 +107,10 @@ func TestReconcileNative(t *testing.T) { ctx := context.TODO() cl := fake.NewClientBuilder().Build() r := &reconciler{ - client: cl, - scheme: scheme.Scheme, - natsStreamingImage: testStreamingImage, - logger: logging.NewArgoEventsLogger(), + client: cl, + scheme: scheme.Scheme, + config: fakeConfig, + logger: zaptest.NewLogger(t).Sugar(), } err := r.reconcile(ctx, testBus) assert.NoError(t, err) @@ -103,10 +127,10 @@ func TestReconcileExotic(t *testing.T) { ctx := context.TODO() cl := fake.NewClientBuilder().Build() r := &reconciler{ - client: cl, - scheme: scheme.Scheme, - natsStreamingImage: testStreamingImage, - logger: logging.NewArgoEventsLogger(), + client: cl, + scheme: scheme.Scheme, + config: fakeConfig, + logger: zaptest.NewLogger(t).Sugar(), } err := r.reconcile(ctx, testBus) assert.NoError(t, err) @@ -120,10 +144,10 @@ func TestNeedsUpdate(t *testing.T) { testBus := nativeBus.DeepCopy() cl := fake.NewClientBuilder().Build() r := &reconciler{ - client: cl, - scheme: scheme.Scheme, - natsStreamingImage: testStreamingImage, - logger: logging.NewArgoEventsLogger(), + client: cl, + scheme: scheme.Scheme, + config: fakeConfig, + logger: zaptest.NewLogger(t).Sugar(), } assert.False(t, r.needsUpdate(nativeBus, testBus)) controllerutil.AddFinalizer(testBus, finalizerName) diff --git a/controllers/eventbus/installer/assets/jetstream/nats.conf b/controllers/eventbus/installer/assets/jetstream/nats.conf new file mode 100644 index 0000000000..1eade13193 --- /dev/null +++ b/controllers/eventbus/installer/assets/jetstream/nats.conf @@ -0,0 +1,38 @@ +port: {{.ClientPort}} +pid_file: "/var/run/nats/nats.pid" +############### +# # +# Monitoring # +# # +############### +http: {{.MonitorPort}} +server_name: $POD_NAME +################################### +# # +# NATS JetStream # +# # +################################### +jetstream { + store_dir: "/data/jetstream/store" + {{.Settings}} +} + +################################### +# # +# NATS Cluster # +# # +################################### +cluster { + port: {{.ClusterPort}} + name: {{.ClusterName}} + routes: [{{.Routes}}] + cluster_advertise: $CLUSTER_ADVERTISE + connect_retries: 120 +} +lame_duck_duration: 120s +################## +# # +# Authorization # +# # +################## +include ./auth.conf \ No newline at end of file diff --git a/controllers/eventbus/installer/assets/jetstream/server-auth.conf b/controllers/eventbus/installer/assets/jetstream/server-auth.conf new file mode 100644 index 0000000000..b360722e5c --- /dev/null +++ b/controllers/eventbus/installer/assets/jetstream/server-auth.conf @@ -0,0 +1,12 @@ +system_account: sys +authorization { + token: "{{.Token}}" +} + +accounts: { + "sys": { + "users": [ + {"user": "sys", "pass":"{{.SysPassword}}"} + ] + } +} diff --git a/controllers/eventbus/installer/exotic_nats_test.go b/controllers/eventbus/installer/exotic_nats_test.go index 15eaba10a8..b85b12c0ec 100644 --- a/controllers/eventbus/installer/exotic_nats_test.go +++ b/controllers/eventbus/installer/exotic_nats_test.go @@ -17,7 +17,7 @@ const ( ) var ( - testExoticBus = &v1alpha1.EventBus{ + testNatsExoticBus = &v1alpha1.EventBus{ TypeMeta: metav1.TypeMeta{ APIVersion: v1alpha1.SchemeGroupVersion.String(), Kind: "EventBus", @@ -38,17 +38,18 @@ var ( func TestInstallationExotic(t *testing.T) { t.Run("installation with exotic nats config", func(t *testing.T) { - installer := NewExoticNATSInstaller(testExoticBus, logging.NewArgoEventsLogger()) + installer := NewExoticNATSInstaller(testNatsExoticBus, logging.NewArgoEventsLogger()) conf, err := installer.Install(context.TODO()) assert.NoError(t, err) assert.NotNil(t, conf.NATS) assert.Equal(t, conf.NATS.URL, testExoticURL) }) + } func TestUninstallationExotic(t *testing.T) { t.Run("uninstallation with exotic nats config", func(t *testing.T) { - installer := NewExoticNATSInstaller(testExoticBus, logging.NewArgoEventsLogger()) + installer := NewExoticNATSInstaller(testNatsExoticBus, logging.NewArgoEventsLogger()) err := installer.Uninstall(context.TODO()) assert.NoError(t, err) }) diff --git a/controllers/eventbus/installer/installer.go b/controllers/eventbus/installer/installer.go index 0f932c71eb..dae5dadf7c 100644 --- a/controllers/eventbus/installer/installer.go +++ b/controllers/eventbus/installer/installer.go @@ -8,6 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/argoproj/argo-events/common" + "github.com/argoproj/argo-events/controllers" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" eventsourcev1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" sensorv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" @@ -22,8 +23,8 @@ type Installer interface { } // Install function installs the event bus -func Install(ctx context.Context, eventBus *v1alpha1.EventBus, client client.Client, natsStreamingImage, natsMetricsImage string, logger *zap.SugaredLogger) error { - installer, err := getInstaller(eventBus, client, natsStreamingImage, natsMetricsImage, logger) +func Install(ctx context.Context, eventBus *v1alpha1.EventBus, client client.Client, config *controllers.GlobalConfig, logger *zap.SugaredLogger) error { + installer, err := getInstaller(eventBus, client, config, logger) if err != nil { logger.Errorw("failed to an installer", zap.Error(err)) return err @@ -38,13 +39,15 @@ func Install(ctx context.Context, eventBus *v1alpha1.EventBus, client client.Cli } // GetInstaller returns Installer implementation -func getInstaller(eventBus *v1alpha1.EventBus, client client.Client, natsStreamingImage, natsMetricsImage string, logger *zap.SugaredLogger) (Installer, error) { +func getInstaller(eventBus *v1alpha1.EventBus, client client.Client, config *controllers.GlobalConfig, logger *zap.SugaredLogger) (Installer, error) { if nats := eventBus.Spec.NATS; nats != nil { if nats.Exotic != nil { return NewExoticNATSInstaller(eventBus, logger), nil } else if nats.Native != nil { - return NewNATSInstaller(client, eventBus, natsStreamingImage, natsMetricsImage, getLabels(eventBus), logger), nil + return NewNATSInstaller(client, eventBus, config, getLabels(eventBus), logger), nil } + } else if js := eventBus.Spec.JetStream; js != nil { + return NewJetStreamInstaller(client, eventBus, config, getLabels(eventBus), logger), nil } return nil, errors.New("invalid eventbus spec") } @@ -65,7 +68,7 @@ func getLabels(bus *v1alpha1.EventBus) map[string]string { // separately. // // It could also be used to check if the EventBus object can be safely deleted. -func Uninstall(ctx context.Context, eventBus *v1alpha1.EventBus, client client.Client, natsStreamingImage, natsMetricsImage string, logger *zap.SugaredLogger) error { +func Uninstall(ctx context.Context, eventBus *v1alpha1.EventBus, client client.Client, config *controllers.GlobalConfig, logger *zap.SugaredLogger) error { linkedEventSources, err := linkedEventSources(ctx, eventBus.Namespace, eventBus.Name, client) if err != nil { logger.Errorw("failed to query linked EventSources", zap.Error(err)) @@ -84,7 +87,7 @@ func Uninstall(ctx context.Context, eventBus *v1alpha1.EventBus, client client.C return errors.Errorf("Can not delete an EventBus with %v Sensors connected", linkedSensors) } - installer, err := getInstaller(eventBus, client, natsStreamingImage, natsMetricsImage, logger) + installer, err := getInstaller(eventBus, client, config, logger) if err != nil { logger.Errorw("failed to get an installer", zap.Error(err)) return err diff --git a/controllers/eventbus/installer/installer_test.go b/controllers/eventbus/installer/installer_test.go index b6d279e846..dacd312796 100644 --- a/controllers/eventbus/installer/installer_test.go +++ b/controllers/eventbus/installer/installer_test.go @@ -5,31 +5,71 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.uber.org/zap/zaptest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/argoproj/argo-events/common/logging" + "github.com/argoproj/argo-events/controllers" eventsourcev1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" - "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" sensorv1alpha1 "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" ) +const ( + testJetStreamImage = "test-js-image" + testJSReloaderImage = "test-nats-rl-image" + testJetStreamExporterImage = "test-js-e-image" +) + +var ( + fakeConfig = &controllers.GlobalConfig{ + EventBus: &controllers.EventBusConfig{ + NATS: &controllers.NatsStreamingConfig{ + Versions: []controllers.NatsStreamingVersion{ + { + Version: "0.22.1", + NatsStreamingImage: "test-n-s-image", + MetricsExporterImage: "test-n-s-m-image", + }, + }, + }, + JetStream: &controllers.JetStreamConfig{ + Versions: []controllers.JetStreamVersion{ + { + Version: "2.7.3", + NatsImage: testJetStreamImage, + ConfigReloaderImage: testJSReloaderImage, + MetricsExporterImage: testJetStreamExporterImage, + }, + }, + }, + }, + } +) + func TestGetInstaller(t *testing.T) { t.Run("get installer", func(t *testing.T) { - installer, err := getInstaller(testEventBus, nil, "", "", logging.NewArgoEventsLogger()) + installer, err := getInstaller(testNatsEventBus, nil, fakeConfig, zaptest.NewLogger(t).Sugar()) assert.NoError(t, err) assert.NotNil(t, installer) _, ok := installer.(*natsInstaller) assert.True(t, ok) - installer, err = getInstaller(testExoticBus, nil, "", "", logging.NewArgoEventsLogger()) + installer, err = getInstaller(testNatsExoticBus, nil, fakeConfig, zaptest.NewLogger(t).Sugar()) assert.NoError(t, err) assert.NotNil(t, installer) _, ok = installer.(*exoticNATSInstaller) assert.True(t, ok) }) + + t.Run("get jetstream installer", func(t *testing.T) { + installer, err := getInstaller(testJetStreamEventBus, nil, fakeConfig, zaptest.NewLogger(t).Sugar()) + assert.NoError(t, err) + assert.NotNil(t, installer) + _, ok := installer.(*jetStreamInstaller) + assert.True(t, ok) + }) } func init() { @@ -87,18 +127,18 @@ func fakeSensor() *sensorv1alpha1.Sensor { Namespace: testNamespace, }, Spec: sensorv1alpha1.SensorSpec{ - Triggers: []v1alpha1.Trigger{ + Triggers: []sensorv1alpha1.Trigger{ { - Template: &v1alpha1.TriggerTemplate{ + Template: &sensorv1alpha1.TriggerTemplate{ Name: "fake-trigger", - K8s: &v1alpha1.StandardK8STrigger{ + K8s: &sensorv1alpha1.StandardK8STrigger{ Operation: "create", - Source: &v1alpha1.ArtifactLocation{}, + Source: &sensorv1alpha1.ArtifactLocation{}, }, }, }, }, - Dependencies: []v1alpha1.EventDependency{ + Dependencies: []sensorv1alpha1.EventDependency{ { Name: "fake-dep", EventSourceName: "fake-source", @@ -108,3 +148,46 @@ func fakeSensor() *sensorv1alpha1.Sensor { }, } } + +func TestInstall(t *testing.T) { + cl := fake.NewClientBuilder().Build() + ctx := context.TODO() + + t.Run("test nats error", func(t *testing.T) { + testObj := testNatsEventBus.DeepCopy() + testObj.Spec.NATS = nil + err := Install(ctx, testObj, cl, fakeConfig, zaptest.NewLogger(t).Sugar()) + assert.Error(t, err) + assert.Equal(t, "invalid eventbus spec", err.Error()) + }) + + t.Run("test nats install ok", func(t *testing.T) { + testObj := testNatsEventBus.DeepCopy() + err := Install(ctx, testObj, cl, fakeConfig, zaptest.NewLogger(t).Sugar()) + assert.NoError(t, err) + assert.True(t, testObj.Status.IsReady()) + assert.NotNil(t, testObj.Status.Config.NATS) + assert.NotEmpty(t, testObj.Status.Config.NATS.URL) + assert.NotNil(t, testObj.Status.Config.NATS.Auth) + assert.NotNil(t, testObj.Status.Config.NATS.AccessSecret) + }) + + t.Run("test jetstream error", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + testObj.Spec.JetStream = nil + err := Install(ctx, testObj, cl, fakeConfig, zaptest.NewLogger(t).Sugar()) + assert.Error(t, err) + assert.Equal(t, "invalid eventbus spec", err.Error()) + }) + + t.Run("test jetstream install ok", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + err := Install(ctx, testObj, cl, fakeConfig, zaptest.NewLogger(t).Sugar()) + assert.NoError(t, err) + assert.True(t, testObj.Status.IsReady()) + assert.NotNil(t, testObj.Status.Config.JetStream) + assert.NotEmpty(t, testObj.Status.Config.JetStream.URL) + assert.NotNil(t, testObj.Status.Config.JetStream.Auth) + assert.NotNil(t, testObj.Status.Config.JetStream.Auth.Token) + }) +} diff --git a/controllers/eventbus/installer/jetstream.go b/controllers/eventbus/installer/jetstream.go new file mode 100644 index 0000000000..1b0e0e84cd --- /dev/null +++ b/controllers/eventbus/installer/jetstream.go @@ -0,0 +1,637 @@ +package installer + +import ( + "bytes" + "context" + "embed" + "fmt" + "strconv" + "strings" + "text/template" + + "go.uber.org/zap" + appv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + apiresource "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/util/intstr" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/argoproj/argo-events/common" + "github.com/argoproj/argo-events/controllers" + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" +) + +const ( + jsClientPort = int32(4222) + jsClusterPort = int32(6222) + jsMonitorPort = int32(8222) + jsMetricsPort = int32(7777) +) + +var ( + //go:embed assets/jetstream/* + jetStremAssets embed.FS +) + +type jetStreamInstaller struct { + client client.Client + eventBus *v1alpha1.EventBus + config *controllers.GlobalConfig + labels map[string]string + logger *zap.SugaredLogger +} + +func NewJetStreamInstaller(client client.Client, eventBus *v1alpha1.EventBus, config *controllers.GlobalConfig, labels map[string]string, logger *zap.SugaredLogger) Installer { + return &jetStreamInstaller{ + client: client, + eventBus: eventBus, + config: config, + labels: labels, + logger: logger.With("eventbus", eventBus.Name), + } +} + +func (r *jetStreamInstaller) Install(ctx context.Context) (*v1alpha1.BusConfig, error) { + if js := r.eventBus.Spec.JetStream; js == nil { + return nil, fmt.Errorf("invalid jetstream eventbus spec") + } + if err := r.createAuthSecrets(ctx); err != nil { + r.logger.Errorw("failed to create jetstream auth secrets", zap.Error(err)) + r.eventBus.Status.MarkDeployFailed("JetStreamAuthSecretsFailed", err.Error()) + return nil, err + } + if err := r.createConfigMap(ctx); err != nil { + r.logger.Errorw("failed to create jetstream ConfigMap", zap.Error(err)) + r.eventBus.Status.MarkDeployFailed("JetStreamConfigMapFailed", err.Error()) + return nil, err + } + if err := r.createService(ctx); err != nil { + r.logger.Errorw("failed to create jetstream Service", zap.Error(err)) + r.eventBus.Status.MarkDeployFailed("JetStreamServiceFailed", err.Error()) + return nil, err + } + if err := r.createStatefulSet(ctx); err != nil { + r.logger.Errorw("failed to create jetstream StatefulSet", zap.Error(err)) + r.eventBus.Status.MarkDeployFailed("JetStreamStatefulSetFailed", err.Error()) + return nil, err + } + r.eventBus.Status.MarkDeployed("Succeeded", "JetStream is deployed") + return &v1alpha1.BusConfig{ + JetStream: &v1alpha1.JetStreamConfig{ + URL: fmt.Sprintf("nats://%s:%s", generateJetStreamServiceName(r.eventBus), strconv.Itoa(int(jsClientPort))), + Auth: &v1alpha1.JetStreamAuth{ + Token: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: generateJetStreamClientAuthSecretName(r.eventBus), + }, + Key: common.JetStreamClientAuthSecretKey, + }, + }, + }, + }, nil +} + +// buildJetStreamService builds a Service for Jet Stream +func (r *jetStreamInstaller) buildJetStreamServiceSpec() corev1.ServiceSpec { + return corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + {Name: "tcp-client", Port: jsClientPort}, + {Name: "cluster", Port: jsClusterPort}, + {Name: "metrics", Port: jsMetricsPort}, + {Name: "monitor", Port: jsMonitorPort}, + }, + Type: corev1.ServiceTypeClusterIP, + ClusterIP: corev1.ClusterIPNone, + Selector: r.labels, + } +} + +func (r *jetStreamInstaller) createService(ctx context.Context) error { + spec := r.buildJetStreamServiceSpec() + hash := common.MustHash(spec) + obj := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.eventBus.Namespace, + Name: generateJetStreamServiceName(r.eventBus), + Labels: r.labels, + Annotations: map[string]string{ + common.AnnotationResourceSpecHash: hash, + }, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(r.eventBus.GetObjectMeta(), v1alpha1.SchemaGroupVersionKind), + }, + }, + Spec: spec, + } + old := &corev1.Service{} + if err := r.client.Get(ctx, client.ObjectKeyFromObject(obj), old); err != nil { + if apierrors.IsNotFound(err) { + if err := r.client.Create(ctx, obj); err != nil { + return fmt.Errorf("failed to create jetstream service, err: %w", err) + } + r.logger.Info("created jetstream service successfully") + return nil + } else { + return fmt.Errorf("failed to check if jetstream service is existing, err: %w", err) + } + } + if old.GetAnnotations()[common.AnnotationResourceSpecHash] != hash { + old.Annotations[common.AnnotationResourceSpecHash] = hash + old.Spec = spec + if err := r.client.Update(ctx, old); err != nil { + return fmt.Errorf("failed to update jetstream service, err: %w", err) + } + r.logger.Info("updated jetstream service successfully") + } + return nil +} + +func (r *jetStreamInstaller) createStatefulSet(ctx context.Context) error { + jsVersion, err := r.config.GetJetStreamVersion(r.eventBus.Spec.JetStream.Version) + if err != nil { + return fmt.Errorf("failed to get jetstream version, err: %w", err) + } + spec := r.buildStatefulSetSpec(jsVersion) + hash := common.MustHash(spec) + obj := &appv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.eventBus.Namespace, + Name: generateJetStreamStatefulSetName(r.eventBus), + Labels: r.labels, + Annotations: map[string]string{ + common.AnnotationResourceSpecHash: hash, + }, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(r.eventBus.GetObjectMeta(), v1alpha1.SchemaGroupVersionKind), + }, + }, + Spec: spec, + } + old := &appv1.StatefulSet{} + if err := r.client.Get(ctx, client.ObjectKeyFromObject(obj), old); err != nil { + if apierrors.IsNotFound(err) { + if err := r.client.Create(ctx, obj); err != nil { + return fmt.Errorf("failed to create jetstream statefulset, err: %w", err) + } + r.logger.Info("created jetstream statefulset successfully") + return nil + } else { + return fmt.Errorf("failed to check if jetstream statefulset is existing, err: %w", err) + } + } + if old.GetAnnotations()[common.AnnotationResourceSpecHash] != hash { + old.Annotations[common.AnnotationResourceSpecHash] = hash + old.Spec = spec + if err := r.client.Update(ctx, old); err != nil { + return fmt.Errorf("failed to update jetstream statefulset, err: %w", err) + } + r.logger.Info("updated jetstream statefulset successfully") + } + return nil +} + +func (r *jetStreamInstaller) buildStatefulSetSpec(jsVersion *controllers.JetStreamVersion) appv1.StatefulSetSpec { + js := r.eventBus.Spec.JetStream + replicas := int32(js.GetReplicas()) + podTemplateLabels := make(map[string]string) + if js.Metadata != nil && + len(js.Metadata.Labels) > 0 { + for k, v := range js.Metadata.Labels { + podTemplateLabels[k] = v + } + } + for k, v := range r.labels { + podTemplateLabels[k] = v + } + var jsContainerPullPolicy, reloaderContainerPullPolicy, metricsContainerPullPolicy corev1.PullPolicy + var jsContainerSecurityContext, reloaderContainerSecurityContext, metricsContainerSecurityContext *corev1.SecurityContext + if js.ContainerTemplate != nil { + jsContainerPullPolicy = js.ContainerTemplate.ImagePullPolicy + jsContainerSecurityContext = js.ContainerTemplate.SecurityContext + } + if js.ReloaderContainerTemplate != nil { + reloaderContainerPullPolicy = js.ReloaderContainerTemplate.ImagePullPolicy + reloaderContainerSecurityContext = js.ReloaderContainerTemplate.SecurityContext + } + if js.MetricsContainerTemplate != nil { + metricsContainerPullPolicy = js.MetricsContainerTemplate.ImagePullPolicy + metricsContainerSecurityContext = js.MetricsContainerTemplate.SecurityContext + } + shareProcessNamespace := true + terminationGracePeriodSeconds := int64(60) + spec := appv1.StatefulSetSpec{ + PodManagementPolicy: appv1.ParallelPodManagement, + Replicas: &replicas, + ServiceName: generateJetStreamServiceName(r.eventBus), + Selector: &metav1.LabelSelector{ + MatchLabels: r.labels, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: podTemplateLabels, + }, + Spec: corev1.PodSpec{ + NodeSelector: js.NodeSelector, + Tolerations: js.Tolerations, + SecurityContext: js.SecurityContext, + ImagePullSecrets: js.ImagePullSecrets, + PriorityClassName: js.PriorityClassName, + Priority: js.Priority, + ServiceAccountName: js.ServiceAccountName, + Affinity: js.Affinity, + ShareProcessNamespace: &shareProcessNamespace, + TerminationGracePeriodSeconds: &terminationGracePeriodSeconds, + Volumes: []corev1.Volume{ + {Name: "pid", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}, + { + Name: "config-volume", + VolumeSource: corev1.VolumeSource{ + Projected: &corev1.ProjectedVolumeSource{ + Sources: []corev1.VolumeProjection{ + { + ConfigMap: &corev1.ConfigMapProjection{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: generateJetStreamConfigMapName(r.eventBus), + }, + Items: []corev1.KeyToPath{ + { + Key: common.JetStreamConfigMapKey, + Path: "nats-js.conf", + }, + }, + }, + }, + { + Secret: &corev1.SecretProjection{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: generateJetStreamServerAuthSecretName(r.eventBus), + }, + Items: []corev1.KeyToPath{ + { + Key: common.JetStreamServerAuthSecretKey, + Path: "auth.conf", + }, + }, + }, + }, + }, + }, + }, + }, + }, + Containers: []corev1.Container{ + { + Name: "main", + Image: jsVersion.NatsImage, + ImagePullPolicy: jsContainerPullPolicy, + Ports: []corev1.ContainerPort{ + {Name: "client", ContainerPort: jsClientPort}, + {Name: "cluster", ContainerPort: jsClusterPort}, + {Name: "monitor", ContainerPort: jsMonitorPort}, + }, + Command: []string{jsVersion.StartCommand, "--config", "/etc/nats-config/nats-js.conf"}, + Env: []corev1.EnvVar{ + {Name: "POD_NAME", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.name"}}}, + {Name: "SERVER_NAME", Value: "$(POD_NAME)"}, + {Name: "POD_NAMESPACE", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{FieldPath: "metadata.namespace"}}}, + {Name: "CLUSTER_ADVERTISE", Value: "$(POD_NAME)." + generateJetStreamServiceName(r.eventBus) + ".$(POD_NAMESPACE).svc"}, + }, + VolumeMounts: []corev1.VolumeMount{ + {Name: "config-volume", MountPath: "/etc/nats-config"}, + {Name: "pid", MountPath: "/var/run/nats"}, + }, + SecurityContext: jsContainerSecurityContext, + LivenessProbe: &corev1.Probe{ + ProbeHandler: corev1.ProbeHandler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/", + Port: intstr.FromInt(int(jsMonitorPort)), + }, + }, + InitialDelaySeconds: 10, + TimeoutSeconds: 5, + }, + Lifecycle: &corev1.Lifecycle{ + PreStop: &corev1.LifecycleHandler{ + Exec: &corev1.ExecAction{ + Command: []string{jsVersion.StartCommand, "-sl=ldm=/var/run/nats/nats.pid"}, + }, + }, + }, + }, + { + Name: "reloader", + Image: jsVersion.ConfigReloaderImage, + ImagePullPolicy: reloaderContainerPullPolicy, + SecurityContext: reloaderContainerSecurityContext, + Command: []string{"nats-server-config-reloader", "-pid", "/var/run/nats/nats.pid", "-config", "/etc/nats-config/nats-js.conf"}, + VolumeMounts: []corev1.VolumeMount{ + {Name: "config-volume", MountPath: "/etc/nats-config"}, + {Name: "pid", MountPath: "/var/run/nats"}, + }, + }, + { + Name: "metrics", + Image: jsVersion.MetricsExporterImage, + ImagePullPolicy: metricsContainerPullPolicy, + Ports: []corev1.ContainerPort{ + {Name: "metrics", ContainerPort: jsMetricsPort}, + }, + Args: []string{"-connz", "-routez", "-subz", "-varz", "-channelz", "-serverz", fmt.Sprintf("http://localhost:%s", strconv.Itoa(int(jsMonitorPort)))}, + SecurityContext: metricsContainerSecurityContext, + }, + }, + }, + }, + } + if js.Metadata != nil { + spec.Template.SetAnnotations(js.Metadata.Annotations) + } + if js.ContainerTemplate != nil { + spec.Template.Spec.Containers[0].Resources = js.ContainerTemplate.Resources + } + if js.MetricsContainerTemplate != nil { + spec.Template.Spec.Containers[1].Resources = js.MetricsContainerTemplate.Resources + } + if js.Persistence != nil { + volMode := corev1.PersistentVolumeFilesystem + // Default volume size + volSize := apiresource.MustParse("20Gi") + if js.Persistence.VolumeSize != nil { + volSize = *js.Persistence.VolumeSize + } + // Default to ReadWriteOnce + accessMode := corev1.ReadWriteOnce + if js.Persistence.AccessMode != nil { + accessMode = *js.Persistence.AccessMode + } + spec.VolumeClaimTemplates = []corev1.PersistentVolumeClaim{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: generateJetStreamPVCName(r.eventBus), + }, + Spec: corev1.PersistentVolumeClaimSpec{ + AccessModes: []corev1.PersistentVolumeAccessMode{ + accessMode, + }, + VolumeMode: &volMode, + StorageClassName: js.Persistence.StorageClassName, + Resources: corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceStorage: volSize, + }, + }, + }, + }, + } + volumeMounts := spec.Template.Spec.Containers[0].VolumeMounts + volumeMounts = append(volumeMounts, corev1.VolumeMount{Name: generateJetStreamPVCName(r.eventBus), MountPath: "/data/jetstream"}) + spec.Template.Spec.Containers[0].VolumeMounts = volumeMounts + } else { + // When the POD is runasnonroot, it can not create the dir /data/jetstream + // Use an emptyDirVolume + emptyDirVolName := "js-data" + volumes := spec.Template.Spec.Volumes + volumes = append(volumes, corev1.Volume{Name: emptyDirVolName, VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}}) + spec.Template.Spec.Volumes = volumes + volumeMounts := spec.Template.Spec.Containers[0].VolumeMounts + volumeMounts = append(volumeMounts, corev1.VolumeMount{Name: emptyDirVolName, MountPath: "/data/jetstream"}) + spec.Template.Spec.Containers[0].VolumeMounts = volumeMounts + } + return spec +} + +func (r *jetStreamInstaller) createAuthSecrets(ctx context.Context) error { + token := common.RandomString(24) + sysPassword := common.RandomString(24) + authTpl := template.Must(template.ParseFS(jetStremAssets, "assets/jetstream/server-auth.conf")) + var authTplOutput bytes.Buffer + if err := authTpl.Execute(&authTplOutput, struct { + Token string + SysPassword string + }{ + Token: token, + SysPassword: sysPassword, + }); err != nil { + return fmt.Errorf("failed to parse nats auth template, error: %w", err) + } + + serverAuthObj := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.eventBus.Namespace, + Name: generateJetStreamServerAuthSecretName(r.eventBus), + Labels: r.labels, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(r.eventBus.GetObjectMeta(), v1alpha1.SchemaGroupVersionKind), + }, + }, + Type: corev1.SecretTypeOpaque, + Data: map[string][]byte{ + common.JetStreamServerAuthSecretKey: authTplOutput.Bytes(), + }, + } + + clientAuthObj := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.eventBus.Namespace, + Name: generateJetStreamClientAuthSecretName(r.eventBus), + Labels: r.labels, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(r.eventBus.GetObjectMeta(), v1alpha1.SchemaGroupVersionKind), + }, + }, + Type: corev1.SecretTypeOpaque, + Data: map[string][]byte{ + common.JetStreamClientAuthSecretKey: []byte(token), + }, + } + + oldServerObjExisting, oldClientObjExisting := true, true + + oldSObj := &corev1.Secret{} + if err := r.client.Get(ctx, client.ObjectKeyFromObject(serverAuthObj), oldSObj); err != nil { + if apierrors.IsNotFound(err) { + oldServerObjExisting = false + } else { + return fmt.Errorf("failed to check if nats server auth secret is existing, err: %w", err) + } + } + + oldCObj := &corev1.Secret{} + if err := r.client.Get(ctx, client.ObjectKeyFromObject(clientAuthObj), oldCObj); err != nil { + if apierrors.IsNotFound(err) { + oldClientObjExisting = false + } else { + return fmt.Errorf("failed to check if nats client auth secret is existing, err: %w", err) + } + } + + if oldClientObjExisting && oldServerObjExisting { // Both existing, do nothing + return nil + } + + if oldClientObjExisting { + if err := r.client.Delete(ctx, oldSObj); err != nil { + return fmt.Errorf("failed to delete malformed nats server auth secret, err: %w", err) + } + r.logger.Infow("deleted malformed nats server auth secret successfully") + } + + if oldServerObjExisting { + if err := r.client.Delete(ctx, oldCObj); err != nil { + return fmt.Errorf("failed to delete malformed nats client auth secret, err: %w", err) + } + r.logger.Infow("deleted malformed nats client auth secret successfully") + } + + if err := r.client.Create(ctx, serverAuthObj); err != nil { + return fmt.Errorf("failed to create nats server auth secret, err: %w", err) + } + r.logger.Infow("created nats server auth secret successfully") + + if err := r.client.Create(ctx, clientAuthObj); err != nil { + return fmt.Errorf("failed to create nats client auth secret, err: %w", err) + } + r.logger.Infow("created nats client auth secret successfully") + return nil +} + +func (r *jetStreamInstaller) createConfigMap(ctx context.Context) error { + data := make(map[string]string) + svcName := generateJetStreamServiceName(r.eventBus) + ssName := generateJetStreamStatefulSetName(r.eventBus) + replicas := r.eventBus.Spec.JetStream.GetReplicas() + if replicas < 3 { + replicas = 3 + } + routes := []string{} + for j := 0; j < replicas; j++ { + routes = append(routes, fmt.Sprintf("nats://%s-%s.%s.%s.svc:%s", ssName, strconv.Itoa(j), svcName, r.eventBus.Namespace, strconv.Itoa(int(jsClusterPort)))) + } + settings := r.config.EventBus.JetStream.Settings + if x := r.eventBus.Spec.JetStream.Settings; x != nil { + settings = *x + } + + confTpl := template.Must(template.ParseFS(jetStremAssets, "assets/jetstream/nats.conf")) + var confTplOutput bytes.Buffer + if err := confTpl.Execute(&confTplOutput, struct { + ClusterName string + MonitorPort string + ClusterPort string + ClientPort string + Routes string + Settings string + }{ + ClusterName: r.eventBus.Name, + MonitorPort: strconv.Itoa(int(jsMonitorPort)), + ClusterPort: strconv.Itoa(int(jsClusterPort)), + ClientPort: strconv.Itoa(int(jsClientPort)), + Routes: strings.Join(routes, ","), + Settings: settings, + }); err != nil { + return fmt.Errorf("failed to parse nats config template, error: %w", err) + } + data[common.JetStreamConfigMapKey] = confTplOutput.String() + + hash := common.MustHash(data) + obj := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: r.eventBus.Namespace, + Name: generateJetStreamConfigMapName(r.eventBus), + Labels: r.labels, + Annotations: map[string]string{ + common.AnnotationResourceSpecHash: hash, + }, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(r.eventBus.GetObjectMeta(), v1alpha1.SchemaGroupVersionKind), + }, + }, + Data: data, + } + old := &corev1.ConfigMap{} + if err := r.client.Get(ctx, client.ObjectKeyFromObject(obj), old); err != nil { + if apierrors.IsNotFound(err) { + if err := r.client.Create(ctx, obj); err != nil { + return fmt.Errorf("failed to create jetstream configmap, err: %w", err) + } + r.logger.Info("created jetstream configmap successfully") + return nil + } else { + return fmt.Errorf("failed to check if jetstream configmap is existing, err: %w", err) + } + } + if old.GetAnnotations()[common.AnnotationResourceSpecHash] != hash { + old.Annotations[common.AnnotationResourceSpecHash] = hash + old.Data = data + if err := r.client.Update(ctx, old); err != nil { + return fmt.Errorf("failed to update jetstream configmap, err: %w", err) + } + r.logger.Info("updated jetstream configmap successfully") + } + return nil +} + +func (r *jetStreamInstaller) Uninstall(ctx context.Context) error { + return r.uninstallPVCs(ctx) +} + +func (r *jetStreamInstaller) uninstallPVCs(ctx context.Context) error { + // StatefulSet doesn't clean up PVC, needs to do it separately + // https://github.com/kubernetes/kubernetes/issues/55045 + pvcs, err := r.getPVCs(ctx) + if err != nil { + r.logger.Errorw("failed to get PVCs created by Nats statefulset when uninstalling", zap.Error(err)) + return err + } + for _, pvc := range pvcs { + err = r.client.Delete(ctx, &pvc) + if err != nil { + r.logger.Errorw("failed to delete pvc when uninstalling", zap.Any("pvcName", pvc.Name), zap.Error(err)) + return err + } + r.logger.Infow("pvc deleted", "pvcName", pvc.Name) + } + return nil +} + +// get PVCs created by streaming statefulset +// they have same labels as the statefulset +func (r *jetStreamInstaller) getPVCs(ctx context.Context) ([]corev1.PersistentVolumeClaim, error) { + pvcl := &corev1.PersistentVolumeClaimList{} + err := r.client.List(ctx, pvcl, &client.ListOptions{ + Namespace: r.eventBus.Namespace, + LabelSelector: labels.SelectorFromSet(r.labels), + }) + if err != nil { + return nil, err + } + return pvcl.Items, nil +} + +func generateJetStreamServerAuthSecretName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js-server-auth", eventBus.Name) +} + +func generateJetStreamClientAuthSecretName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js-client-auth", eventBus.Name) +} + +func generateJetStreamServiceName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js-svc", eventBus.Name) +} + +func generateJetStreamStatefulSetName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js", eventBus.Name) +} + +func generateJetStreamConfigMapName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js-config", eventBus.Name) +} + +func generateJetStreamPVCName(eventBus *v1alpha1.EventBus) string { + return fmt.Sprintf("eventbus-%s-js-vol", eventBus.Name) +} diff --git a/controllers/eventbus/installer/jetstream_test.go b/controllers/eventbus/installer/jetstream_test.go new file mode 100644 index 0000000000..2fbb76f568 --- /dev/null +++ b/controllers/eventbus/installer/jetstream_test.go @@ -0,0 +1,197 @@ +package installer + +import ( + "context" + "testing" + + "github.com/argoproj/argo-events/common" + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" + "github.com/stretchr/testify/assert" + "go.uber.org/zap/zaptest" + appv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client/fake" +) + +var ( + testJetStreamEventBus = &v1alpha1.EventBus{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "EventBus", + }, + ObjectMeta: metav1.ObjectMeta{ + Namespace: testNamespace, + Name: testName, + }, + Spec: v1alpha1.EventBusSpec{ + JetStream: &v1alpha1.JetStreamBus{ + Version: "2.7.3", + }, + }, + } +) + +func TestJetStreamBadInstallation(t *testing.T) { + t.Run("bad installation", func(t *testing.T) { + badEventBus := testJetStreamEventBus.DeepCopy() + badEventBus.Spec.JetStream = nil + installer := &jetStreamInstaller{ + client: fake.NewClientBuilder().Build(), + eventBus: badEventBus, + config: fakeConfig, + labels: testLabels, + logger: zaptest.NewLogger(t).Sugar(), + } + _, err := installer.Install(context.TODO()) + assert.Error(t, err) + }) +} + +func TestJetStreamGenerateNames(t *testing.T) { + n := generateJetStreamStatefulSetName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js", n) + n = generateJetStreamServerAuthSecretName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-server-auth", n) + n = generateJetStreamClientAuthSecretName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-client-auth", n) + n = generateJetStreamConfigMapName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-config", n) + n = generateJetStreamPVCName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-vol", n) + n = generateJetStreamServiceName(testJetStreamEventBus) + assert.Equal(t, "eventbus-"+testJetStreamEventBus.Name+"-js-svc", n) +} + +func TestJetStreamCreateObjects(t *testing.T) { + cl := fake.NewClientBuilder().Build() + ctx := context.TODO() + i := &jetStreamInstaller{ + client: cl, + eventBus: testJetStreamEventBus, + config: fakeConfig, + labels: testLabels, + logger: zaptest.NewLogger(t).Sugar(), + } + + t.Run("test create sts", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + i.eventBus = testObj + err := i.createStatefulSet(ctx) + assert.NoError(t, err) + sts := &appv1.StatefulSet{} + err = cl.Get(ctx, types.NamespacedName{Namespace: testObj.Namespace, Name: generateJetStreamStatefulSetName(testObj)}, sts) + assert.NoError(t, err) + assert.Equal(t, 3, len(sts.Spec.Template.Spec.Containers)) + assert.Contains(t, sts.Annotations, common.AnnotationResourceSpecHash) + assert.Equal(t, testJetStreamImage, sts.Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, testJSReloaderImage, sts.Spec.Template.Spec.Containers[1].Image) + assert.Equal(t, testJetStreamExporterImage, sts.Spec.Template.Spec.Containers[2].Image) + assert.True(t, len(sts.Spec.Template.Spec.Volumes) > 1) + }) + + t.Run("test create svc", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + i.eventBus = testObj + err := i.createService(ctx) + assert.NoError(t, err) + svc := &corev1.Service{} + err = cl.Get(ctx, types.NamespacedName{Namespace: testObj.Namespace, Name: generateJetStreamServiceName(testObj)}, svc) + assert.NoError(t, err) + assert.Equal(t, 4, len(svc.Spec.Ports)) + assert.Contains(t, svc.Annotations, common.AnnotationResourceSpecHash) + }) + + t.Run("test create auth secrets", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + i.eventBus = testObj + err := i.createAuthSecrets(ctx) + assert.NoError(t, err) + s := &corev1.Secret{} + err = cl.Get(ctx, types.NamespacedName{Namespace: testObj.Namespace, Name: generateJetStreamServerAuthSecretName(testObj)}, s) + assert.NoError(t, err) + assert.Equal(t, 1, len(s.Data)) + assert.Contains(t, s.Data, common.JetStreamServerAuthSecretKey) + s = &corev1.Secret{} + err = cl.Get(ctx, types.NamespacedName{Namespace: testObj.Namespace, Name: generateJetStreamClientAuthSecretName(testObj)}, s) + assert.NoError(t, err) + assert.Equal(t, 1, len(s.Data)) + assert.Contains(t, s.Data, common.JetStreamClientAuthSecretKey) + }) + + t.Run("test create configmap", func(t *testing.T) { + testObj := testJetStreamEventBus.DeepCopy() + i.eventBus = testObj + err := i.createConfigMap(ctx) + assert.NoError(t, err) + c := &corev1.ConfigMap{} + err = cl.Get(ctx, types.NamespacedName{Namespace: testObj.Namespace, Name: generateJetStreamConfigMapName(testObj)}, c) + assert.NoError(t, err) + assert.Equal(t, 1, len(c.Data)) + assert.Contains(t, c.Annotations, common.AnnotationResourceSpecHash) + }) +} + +func TestBuildJetStreamStatefulSetSpec(t *testing.T) { + cl := fake.NewClientBuilder().Build() + i := &jetStreamInstaller{ + client: cl, + eventBus: testJetStreamEventBus, + config: fakeConfig, + labels: testLabels, + logger: zaptest.NewLogger(t).Sugar(), + } + + t.Run("without persistence", func(t *testing.T) { + s := i.buildStatefulSetSpec(&fakeConfig.EventBus.JetStream.Versions[0]) + assert.Equal(t, int32(3), *s.Replicas) + assert.Equal(t, generateJetStreamServiceName(testJetStreamEventBus), s.ServiceName) + assert.Equal(t, testJetStreamImage, s.Template.Spec.Containers[0].Image) + assert.Equal(t, testJSReloaderImage, s.Template.Spec.Containers[1].Image) + assert.Equal(t, testJetStreamExporterImage, s.Template.Spec.Containers[2].Image) + assert.Equal(t, "test-controller", s.Selector.MatchLabels["controller"]) + assert.Equal(t, jsClientPort, s.Template.Spec.Containers[0].Ports[0].ContainerPort) + assert.Equal(t, jsClusterPort, s.Template.Spec.Containers[0].Ports[1].ContainerPort) + assert.Equal(t, jsMonitorPort, s.Template.Spec.Containers[0].Ports[2].ContainerPort) + assert.Equal(t, jsMetricsPort, s.Template.Spec.Containers[2].Ports[0].ContainerPort) + assert.False(t, len(s.VolumeClaimTemplates) > 0) + assert.True(t, len(s.Template.Spec.Volumes) > 0) + }) + + t.Run("with persistence", func(t *testing.T) { + st := "test" + i.eventBus.Spec.JetStream = &v1alpha1.JetStreamBus{ + Persistence: &v1alpha1.PersistenceStrategy{ + StorageClassName: &st, + }, + } + s := i.buildStatefulSetSpec(&fakeConfig.EventBus.JetStream.Versions[0]) + assert.True(t, len(s.VolumeClaimTemplates) > 0) + }) +} + +func TestJetStreamGetServiceSpec(t *testing.T) { + cl := fake.NewClientBuilder().Build() + i := &jetStreamInstaller{ + client: cl, + eventBus: testJetStreamEventBus, + config: fakeConfig, + labels: testLabels, + logger: zaptest.NewLogger(t).Sugar(), + } + spec := i.buildJetStreamServiceSpec() + assert.Equal(t, 4, len(spec.Ports)) + assert.Equal(t, corev1.ClusterIPNone, spec.ClusterIP) +} + +func Test_JSBufferGetReplicas(t *testing.T) { + s := v1alpha1.JetStreamBus{} + assert.Equal(t, 3, s.GetReplicas()) + five := int32(5) + s.Replicas = &five + assert.Equal(t, 5, s.GetReplicas()) + two := int32(2) + s.Replicas = &two + assert.Equal(t, 3, s.GetReplicas()) +} diff --git a/controllers/eventbus/installer/nats.go b/controllers/eventbus/installer/nats.go index e78fd1ca9c..748ce09de2 100644 --- a/controllers/eventbus/installer/nats.go +++ b/controllers/eventbus/installer/nats.go @@ -2,10 +2,8 @@ package installer import ( "context" - "crypto/rand" "errors" "fmt" - "math/big" "strconv" "strings" "time" @@ -22,6 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/argoproj/argo-events/common" + "github.com/argoproj/argo-events/controllers" controllerscommon "github.com/argoproj/argo-events/controllers/common" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" ) @@ -39,27 +38,28 @@ const ( serverAuthSecretKey = "auth" // key of stan.conf in the configmap configMapKey = "stan-config" + + // default nats streaming version to be installed + defaultNatsStreamingVersion = "0.22.1" ) // natsInstaller is used create a NATS installation. type natsInstaller struct { - client client.Client - eventBus *v1alpha1.EventBus - streamingImage string - metricsImage string - labels map[string]string - logger *zap.SugaredLogger + client client.Client + eventBus *v1alpha1.EventBus + config *controllers.GlobalConfig + labels map[string]string + logger *zap.SugaredLogger } // NewNATSInstaller returns a new NATS installer -func NewNATSInstaller(client client.Client, eventBus *v1alpha1.EventBus, streamingImage, metricsImage string, labels map[string]string, logger *zap.SugaredLogger) Installer { +func NewNATSInstaller(client client.Client, eventBus *v1alpha1.EventBus, config *controllers.GlobalConfig, labels map[string]string, logger *zap.SugaredLogger) Installer { return &natsInstaller{ - client: client, - eventBus: eventBus, - streamingImage: streamingImage, - metricsImage: metricsImage, - labels: labels, - logger: logger.Named("nats"), + client: client, + eventBus: eventBus, + config: config, + labels: labels, + logger: logger.Named("nats"), } } @@ -290,12 +290,7 @@ func (i *natsInstaller) createAuthSecrets(ctx context.Context, strategy v1alpha1 log.Infow("created server auth secret", "serverAuthSecretName", expectedSSecret.Name) return expectedSSecret, nil, nil case v1alpha1.AuthStrategyToken: - token, err := generateToken(64) - if err != nil { - i.eventBus.Status.MarkDeployFailed("BuildServerAuthSecretFailed", "Failed to generate auth token") - log.Errorw("error generating auth token", zap.Error(err)) - return nil, nil, err - } + token := common.RandomString(64) serverAuthText := fmt.Sprintf(`authorization { token: "%s" }`, token) @@ -618,6 +613,10 @@ func (i *natsInstaller) buildStatefulSet(serviceName, configmapName, authSecretN } func (i *natsInstaller) buildStatefulSetSpec(serviceName, configmapName, authSecretName string) (*appv1.StatefulSetSpec, error) { + natsStreamingVersion, err := i.config.GetNatsStreamingVersion(defaultNatsStreamingVersion) + if err != nil { + return nil, fmt.Errorf("failed to get nats streaming version, err: %w", err) + } // Streaming requires minimal size 3. replicas := i.eventBus.Spec.NATS.Native.Replicas if replicas < 3 { @@ -713,7 +712,7 @@ func (i *natsInstaller) buildStatefulSetSpec(serviceName, configmapName, authSec Containers: []corev1.Container{ { Name: "stan", - Image: i.streamingImage, + Image: natsStreamingVersion.NatsStreamingImage, ImagePullPolicy: stanContainerPullPolicy, Ports: []corev1.ContainerPort{ {Name: "client", ContainerPort: clientPort}, @@ -744,7 +743,7 @@ func (i *natsInstaller) buildStatefulSetSpec(serviceName, configmapName, authSec }, { Name: "metrics", - Image: i.metricsImage, + Image: natsStreamingVersion.MetricsExporterImage, ImagePullPolicy: metricsContainerPullPolicy, Ports: []corev1.ContainerPort{ {Name: "metrics", ContainerPort: common.EventBusMetricsPort}, @@ -922,20 +921,6 @@ func (i *natsInstaller) mergeEventBusLabels(given map[string]string) map[string] return result } -// generate a random string as token with given length -func generateToken(length int) (string, error) { - seeds := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - result := make([]byte, length) - for i := 0; i < length; i++ { - num, err := rand.Int(rand.Reader, big.NewInt(int64(len(seeds)))) - if err != nil { - return "", err - } - result[i] = seeds[num.Int64()] - } - return string(result), nil -} - func serverAuthSecretLabels(given map[string]string) map[string]string { result := map[string]string{"server-auth-secret": "yes"} for k, v := range given { diff --git a/controllers/eventbus/installer/nats_test.go b/controllers/eventbus/installer/nats_test.go index 591c29d491..21437facff 100644 --- a/controllers/eventbus/installer/nats_test.go +++ b/controllers/eventbus/installer/nats_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.uber.org/zap/zaptest" appv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -20,16 +21,14 @@ import ( ) const ( - testNamespace = "test-ns" - testName = "test-name" - testStreamingImage = "test-s-image" - testMetricsImage = "test-m-image" + testNamespace = "test-ns" + testName = "test-name" ) var ( testLabels = map[string]string{"controller": "test-controller"} - testEventBus = &v1alpha1.EventBus{ + testNatsEventBus = &v1alpha1.EventBus{ TypeMeta: metav1.TypeMeta{ APIVersion: v1alpha1.SchemeGroupVersion.String(), Kind: "EventBus", @@ -111,12 +110,11 @@ func init() { func TestBadInstallation(t *testing.T) { t.Run("bad installation", func(t *testing.T) { installer := &natsInstaller{ - client: fake.NewClientBuilder().Build(), - eventBus: testEventBusBad, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: fake.NewClientBuilder().Build(), + eventBus: testEventBusBad, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } _, err := installer.Install(context.TODO()) assert.Error(t, err) @@ -126,7 +124,7 @@ func TestBadInstallation(t *testing.T) { func TestInstallationAuthtoken(t *testing.T) { t.Run("auth token installation", func(t *testing.T) { cl := fake.NewClientBuilder().Build() - installer := NewNATSInstaller(cl, testEventBus, testStreamingImage, testMetricsImage, testLabels, logging.NewArgoEventsLogger()) + installer := NewNATSInstaller(cl, testNatsEventBus, fakeConfig, testLabels, zaptest.NewLogger(t).Sugar()) busconf, err := installer.Install(context.TODO()) assert.NoError(t, err) assert.NotNil(t, busconf.NATS) @@ -175,7 +173,7 @@ func TestInstallationAuthtoken(t *testing.T) { func TestInstallationAuthNone(t *testing.T) { t.Run("auth none installation", func(t *testing.T) { cl := fake.NewClientBuilder().Build() - installer := NewNATSInstaller(cl, testEventBusAuthNone, testStreamingImage, testMetricsImage, testLabels, logging.NewArgoEventsLogger()) + installer := NewNATSInstaller(cl, testEventBusAuthNone, fakeConfig, testLabels, zaptest.NewLogger(t).Sugar()) busconf, err := installer.Install(context.TODO()) assert.NoError(t, err) assert.NotNil(t, busconf.NATS) @@ -212,12 +210,11 @@ func TestBuildPersistStatefulSetSpec(t *testing.T) { t.Run("installation with persistence", func(t *testing.T) { cl := fake.NewClientBuilder().Build() installer := &natsInstaller{ - client: cl, - eventBus: testEventBusPersist, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: cl, + eventBus: testEventBusPersist, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } ss, err := installer.buildStatefulSet("svcName", "cmName", "secretName") assert.NoError(t, err) @@ -227,12 +224,11 @@ func TestBuildPersistStatefulSetSpec(t *testing.T) { t.Run("installation with image pull secrets", func(t *testing.T) { cl := fake.NewClientBuilder().Build() installer := &natsInstaller{ - client: cl, - eventBus: testEventBus, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: cl, + eventBus: testNatsEventBus, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } ss, err := installer.buildStatefulSet("svcName", "cmName", "secretName") assert.NoError(t, err) @@ -241,15 +237,14 @@ func TestBuildPersistStatefulSetSpec(t *testing.T) { t.Run("installation with priority class", func(t *testing.T) { cl := fake.NewClientBuilder().Build() - eb := testEventBus.DeepCopy() + eb := testNatsEventBus.DeepCopy() eb.Spec.NATS.Native.PriorityClassName = "test-class" installer := &natsInstaller{ - client: cl, - eventBus: eb, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: cl, + eventBus: eb, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } ss, err := installer.buildStatefulSet("svcName", "cmName", "secretName") assert.NoError(t, err) @@ -261,12 +256,11 @@ func TestBuildServiceAccountStatefulSetSpec(t *testing.T) { t.Run("installation with Service Account Name", func(t *testing.T) { cl := fake.NewClientBuilder().Build() installer := &natsInstaller{ - client: cl, - eventBus: testEventBus, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: cl, + eventBus: testNatsEventBus, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } ss, err := installer.buildStatefulSet("svcName", "cmName", "secretName") assert.NoError(t, err) @@ -278,12 +272,11 @@ func TestBuildConfigMap(t *testing.T) { t.Run("test build config map", func(t *testing.T) { cl := fake.NewClientBuilder().Build() installer := &natsInstaller{ - client: cl, - eventBus: testEventBus, - streamingImage: testStreamingImage, - metricsImage: testMetricsImage, - labels: testLabels, - logger: logging.NewArgoEventsLogger(), + client: cl, + eventBus: testNatsEventBus, + config: fakeConfig, + labels: testLabels, + logger: logging.NewArgoEventsLogger(), } cm, err := installer.buildConfigMap() assert.NoError(t, err) @@ -291,8 +284,8 @@ func TestBuildConfigMap(t *testing.T) { conf, ok := cm.Data[configMapKey] assert.True(t, ok) assert.True(t, strings.Contains(conf, "routes:")) - svcName := generateServiceName(testEventBus) - ssName := generateStatefulSetName(testEventBus) + svcName := generateServiceName(testNatsEventBus) + ssName := generateStatefulSetName(testNatsEventBus) r := fmt.Sprintf("nats://%s-%s.%s.%s.svc:%s", ssName, "0", svcName, testNamespace, strconv.Itoa(int(clusterPort))) lines := strings.Split(conf, `\n`) for _, l := range lines { @@ -303,10 +296,3 @@ func TestBuildConfigMap(t *testing.T) { } }) } - -func TestGenerateToken(t *testing.T) { - n := 30 - token, err := generateToken(n) - assert.NoError(t, err) - assert.Equal(t, len(token), n) -} diff --git a/controllers/eventbus/validate.go b/controllers/eventbus/validate.go index 55c7744942..6eb863f533 100644 --- a/controllers/eventbus/validate.go +++ b/controllers/eventbus/validate.go @@ -1,29 +1,39 @@ package eventbus import ( - "github.com/pkg/errors" + "fmt" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" ) // ValidateEventBus accepts an EventBus and performs validation against it func ValidateEventBus(eb *v1alpha1.EventBus) error { - if eb.Spec.NATS == nil { - return errors.New("invalid spec: missing \"spec.nats\"") + if eb.Spec.NATS == nil && eb.Spec.JetStream == nil { + return fmt.Errorf("invalid spec: either \"nats\" or \"jststream\" needs to be specified") } - if eb.Spec.NATS.Native != nil && eb.Spec.NATS.Exotic != nil { - return errors.New("\"spec.nats.native\" and \"spec.nats.exotic\" can not be defined together") - } - if eb.Spec.NATS.Native == nil && eb.Spec.NATS.Exotic == nil { - return errors.New("either \"native\" or \"exotic\" must be defined") + if x := eb.Spec.NATS; x != nil { + if x.Native != nil && x.Exotic != nil { + return fmt.Errorf("\"spec.nats.native\" and \"spec.nats.exotic\" can not be defined together") + } + if x.Native == nil && x.Exotic == nil { + return fmt.Errorf("either \"native\" or \"exotic\" must be defined") + } + if x.Exotic != nil { + e := x.Exotic + if e.ClusterID == nil { + return fmt.Errorf("\"spec.nats.exotic.clusterID\" is missing") + } + if e.URL == "" { + return fmt.Errorf("\"spec.nats.exotic.url\" is missing") + } + } } - if eb.Spec.NATS.Exotic != nil { - e := eb.Spec.NATS.Exotic - if e.ClusterID == nil { - return errors.New("\"spec.nats.exotic.clusterID\" is missing") + if x := eb.Spec.JetStream; x != nil { + if x.Version == "" { + return fmt.Errorf("invalid spec: a version for jetstream needs to be specified") } - if e.URL == "" { - return errors.New("\"spec.nats.exotic.url\" is missing") + if x.Replicas != nil && *x.Replicas < 3 { + return fmt.Errorf("invalid spec: a jetstream eventbus requires at least 3 replicas") } } return nil diff --git a/controllers/eventbus/validate_test.go b/controllers/eventbus/validate_test.go index e9799a4dad..e6ce1bd763 100644 --- a/controllers/eventbus/validate_test.go +++ b/controllers/eventbus/validate_test.go @@ -6,13 +6,14 @@ import ( "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/pointer" "github.com/argoproj/argo-events/common" "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" ) var ( - testEventBus = &v1alpha1.EventBus{ + testNatsEventBus = &v1alpha1.EventBus{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test-ns", Name: common.DefaultEventBusName, @@ -25,24 +26,49 @@ var ( }, }, } + + testJetStreamEventBus = &v1alpha1.EventBus{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "test-ns", + Name: common.DefaultEventBusName, + }, + Spec: v1alpha1.EventBusSpec{ + JetStream: &v1alpha1.JetStreamBus{ + Version: "2.7.3", + }, + }, + } ) func TestValidate(t *testing.T) { - t.Run("test good eventbus", func(t *testing.T) { - err := ValidateEventBus(testEventBus) + t.Run("test good nats eventbus", func(t *testing.T) { + err := ValidateEventBus(testNatsEventBus) + assert.NoError(t, err) + }) + + t.Run("test good js eventbus", func(t *testing.T) { + err := ValidateEventBus(testJetStreamEventBus) assert.NoError(t, err) }) - t.Run("test native exotic conflicting eventbus", func(t *testing.T) { - eb := testEventBus.DeepCopy() + t.Run("test bad eventbus", func(t *testing.T) { + eb := testNatsEventBus.DeepCopy() + eb.Spec.NATS = nil + err := ValidateEventBus(eb) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid spec: either") + }) + + t.Run("test native nats exotic conflicting eventbus", func(t *testing.T) { + eb := testNatsEventBus.DeepCopy() eb.Spec.NATS.Exotic = &v1alpha1.NATSConfig{} err := ValidateEventBus(eb) assert.Error(t, err) assert.True(t, strings.Contains(err.Error(), "can not be defined together")) }) - t.Run("test exotic eventbus no clusterID", func(t *testing.T) { - eb := testEventBus.DeepCopy() + t.Run("test exotic nats eventbus no clusterID", func(t *testing.T) { + eb := testNatsEventBus.DeepCopy() eb.Spec.NATS.Native = nil eb.Spec.NATS.Exotic = &v1alpha1.NATSConfig{} err := ValidateEventBus(eb) @@ -50,8 +76,8 @@ func TestValidate(t *testing.T) { assert.True(t, strings.Contains(err.Error(), "\"spec.nats.exotic.clusterID\" is missing")) }) - t.Run("test exotic eventbus empty URL", func(t *testing.T) { - eb := testEventBus.DeepCopy() + t.Run("test exotic nats eventbus empty URL", func(t *testing.T) { + eb := testNatsEventBus.DeepCopy() eb.Spec.NATS.Native = nil cID := "test-cluster-id" eb.Spec.NATS.Exotic = &v1alpha1.NATSConfig{ @@ -61,4 +87,26 @@ func TestValidate(t *testing.T) { assert.Error(t, err) assert.True(t, strings.Contains(err.Error(), "\"spec.nats.exotic.url\" is missing")) }) + + t.Run("test js eventbus no version", func(t *testing.T) { + eb := testJetStreamEventBus.DeepCopy() + eb.Spec.JetStream.Version = "" + err := ValidateEventBus(eb) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid spec: a version") + }) + + t.Run("test js eventbus replica", func(t *testing.T) { + eb := testJetStreamEventBus.DeepCopy() + eb.Spec.JetStream.Replicas = pointer.Int32(2) + err := ValidateEventBus(eb) + assert.Error(t, err) + assert.Contains(t, err.Error(), "invalid spec: a jetstream eventbus requires at least 3 replicas") + eb.Spec.JetStream.Replicas = pointer.Int32(3) + err = ValidateEventBus(eb) + assert.NoError(t, err) + eb.Spec.JetStream.Replicas = nil + err = ValidateEventBus(eb) + assert.NoError(t, err) + }) } diff --git a/go.mod b/go.mod index 67f3102cd2..d73daf7898 100644 --- a/go.mod +++ b/go.mod @@ -276,7 +276,7 @@ require ( k8s.io/component-base v0.23.3 // indirect k8s.io/klog v1.0.0 // indirect k8s.io/klog/v2 v2.40.1 // indirect - k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect + k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect ) diff --git a/manifests/base/eventbus-controller/controller-config.yaml b/manifests/base/eventbus-controller/controller-config.yaml new file mode 100644 index 0000000000..5b38bfdbb3 --- /dev/null +++ b/manifests/base/eventbus-controller/controller-config.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: argo-events-controller-config +data: + controller-config.yaml: |+ + eventBus: + nats: + versions: + - version: 0.22.1 + natsStreamingImage: nats-streaming:0.22.1 + metricsExporterImage: natsio/prometheus-nats-exporter:0.8.0 + jetstream: + # Default JetStream settings, could be overridden by EventBus JetStream specs + settings: | + # https://docs.nats.io/running-a-nats-service/configuration#jetstream + # Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. + # e.g. 1G. -1 means no limit, up to 75% of available memory + max_memory_store: -1 + # e.g. 20G. -1 means no limit, Up to 1TB if available + max_file_store: 1TB + versions: + - version: 2.7.3 + natsImage: nats:2.7.3 + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: /nats-server + - version: 2.7.3-alpine + natsImage: nats:2.7.3-alpine + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: nats-server diff --git a/manifests/base/eventbus-controller/eventbus-controller-deployment.yaml b/manifests/base/eventbus-controller/eventbus-controller-deployment.yaml index 18a01af2c1..0f77e046b4 100644 --- a/manifests/base/eventbus-controller/eventbus-controller-deployment.yaml +++ b/manifests/base/eventbus-controller/eventbus-controller-deployment.yaml @@ -27,10 +27,9 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: NATS_STREAMING_IMAGE - value: nats-streaming:0.22.1 - - name: NATS_METRICS_EXPORTER_IMAGE - value: natsio/prometheus-nats-exporter:0.8.0 + volumeMounts: + - mountPath: /etc/argo-events + name: controller-config-volume livenessProbe: httpGet: path: /healthz @@ -43,5 +42,7 @@ spec: port: 8081 initialDelaySeconds: 3 periodSeconds: 3 - - + volumes: + - name: controller-config-volume + configMap: + name: argo-events-controller-config diff --git a/manifests/base/eventbus-controller/kustomization.yaml b/manifests/base/eventbus-controller/kustomization.yaml index 26278a9d6e..837cfd25a4 100644 --- a/manifests/base/eventbus-controller/kustomization.yaml +++ b/manifests/base/eventbus-controller/kustomization.yaml @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - controller-config.yaml - eventbus-controller-deployment.yaml diff --git a/manifests/install.yaml b/manifests/install.yaml index 3ee32d379f..103ea64c24 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -276,6 +276,40 @@ subjects: name: argo-events-sa namespace: argo-events --- +apiVersion: v1 +data: + controller-config.yaml: | + eventBus: + nats: + versions: + - version: 0.22.1 + natsStreamingImage: nats-streaming:0.22.1 + metricsExporterImage: natsio/prometheus-nats-exporter:0.8.0 + jetstream: + # Default JetStream settings, could be overridden by EventBus JetStream specs + settings: | + # https://docs.nats.io/running-a-nats-service/configuration#jetstream + # Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. + # e.g. 1G. -1 means no limit, up to 75% of available memory + max_memory_store: -1 + # e.g. 20G. -1 means no limit, Up to 1TB if available + max_file_store: 1TB + versions: + - version: 2.7.3 + natsImage: nats:2.7.3 + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: /nats-server + - version: 2.7.3-alpine + natsImage: nats:2.7.3-alpine + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: nats-server +kind: ConfigMap +metadata: + name: argo-events-controller-config + namespace: argo-events +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -299,10 +333,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: NATS_STREAMING_IMAGE - value: nats-streaming:0.22.1 - - name: NATS_METRICS_EXPORTER_IMAGE - value: natsio/prometheus-nats-exporter:0.8.0 image: quay.io/argoproj/argo-events:latest imagePullPolicy: Always livenessProbe: @@ -318,10 +348,17 @@ spec: port: 8081 initialDelaySeconds: 3 periodSeconds: 3 + volumeMounts: + - mountPath: /etc/argo-events + name: controller-config-volume securityContext: runAsNonRoot: true runAsUser: 9731 serviceAccountName: argo-events-sa + volumes: + - configMap: + name: argo-events-controller-config + name: controller-config-volume --- apiVersion: apps/v1 kind: Deployment diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index ca282f2348..79d278dfa9 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -196,6 +196,40 @@ subjects: name: argo-events-sa namespace: argo-events --- +apiVersion: v1 +data: + controller-config.yaml: | + eventBus: + nats: + versions: + - version: 0.22.1 + natsStreamingImage: nats-streaming:0.22.1 + metricsExporterImage: natsio/prometheus-nats-exporter:0.8.0 + jetstream: + # Default JetStream settings, could be overridden by EventBus JetStream specs + settings: | + # https://docs.nats.io/running-a-nats-service/configuration#jetstream + # Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. + # e.g. 1G. -1 means no limit, up to 75% of available memory + max_memory_store: -1 + # e.g. 20G. -1 means no limit, Up to 1TB if available + max_file_store: 1TB + versions: + - version: 2.7.3 + natsImage: nats:2.7.3 + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: /nats-server + - version: 2.7.3-alpine + natsImage: nats:2.7.3-alpine + configReloaderImage: natsio/nats-server-config-reloader:0.6.3 + metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 + startCommand: nats-server +kind: ConfigMap +metadata: + name: argo-events-controller-config + namespace: argo-events +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -220,10 +254,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: NATS_STREAMING_IMAGE - value: nats-streaming:0.22.1 - - name: NATS_METRICS_EXPORTER_IMAGE - value: natsio/prometheus-nats-exporter:0.8.0 image: quay.io/argoproj/argo-events:latest imagePullPolicy: Always livenessProbe: @@ -239,10 +269,17 @@ spec: port: 8081 initialDelaySeconds: 3 periodSeconds: 3 + volumeMounts: + - mountPath: /etc/argo-events + name: controller-config-volume securityContext: runAsNonRoot: true runAsUser: 9731 serviceAccountName: argo-events-sa + volumes: + - configMap: + name: argo-events-controller-config + name: controller-config-volume --- apiVersion: apps/v1 kind: Deployment diff --git a/pkg/apis/eventbus/v1alpha1/container_template.go b/pkg/apis/eventbus/v1alpha1/container_template.go new file mode 100644 index 0000000000..0dac09f046 --- /dev/null +++ b/pkg/apis/eventbus/v1alpha1/container_template.go @@ -0,0 +1,10 @@ +package v1alpha1 + +import corev1 "k8s.io/api/core/v1" + +// ContainerTemplate defines customized spec for a container +type ContainerTemplate struct { + Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,1,opt,name=resources"` + ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty" protobuf:"bytes,2,opt,name=imagePullPolicy,casttype=PullPolicy"` + SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty" protobuf:"bytes,3,opt,name=securityContext"` +} diff --git a/pkg/apis/eventbus/v1alpha1/eventbus_types.go b/pkg/apis/eventbus/v1alpha1/eventbus_types.go new file mode 100644 index 0000000000..a366aebbdc --- /dev/null +++ b/pkg/apis/eventbus/v1alpha1/eventbus_types.go @@ -0,0 +1,93 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/argoproj/argo-events/pkg/apis/common" +) + +// EventBus is the definition of a eventbus resource +// +genclient +// +kubebuilder:resource:singular=eventbus,shortName=eb +// +kubebuilder:subresource:status +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:openapi-gen=true +type EventBus struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` + Spec EventBusSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` + // +optional + Status EventBusStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// EventBusList is the list of eventbus resources +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type EventBusList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` + + Items []EventBus `json:"items" protobuf:"bytes,2,rep,name=items"` +} + +// EventBusSpec refers to specification of eventbus resource +type EventBusSpec struct { + // NATS eventbus + // +optional + NATS *NATSBus `json:"nats,omitempty" protobuf:"bytes,1,opt,name=nats"` + // +optional + JetStream *JetStreamBus `json:"jetstream,omitempty" protobuf:"bytes,2,opt,name=jetstream"` +} + +// EventBusStatus holds the status of the eventbus resource +type EventBusStatus struct { + common.Status `json:",inline" protobuf:"bytes,1,opt,name=status"` + // Config holds the fininalized configuration of EventBus + Config BusConfig `json:"config,omitempty" protobuf:"bytes,2,opt,name=config"` +} + +// BusConfig has the finalized configuration for EventBus +type BusConfig struct { + // +optional + NATS *NATSConfig `json:"nats,omitempty" protobuf:"bytes,1,opt,name=nats"` + // +optional + JetStream *JetStreamConfig `json:"jetstream,omitempty" protobuf:"bytes,2,opt,name=jetstream"` +} + +const ( + // EventBusConditionDeployed has the status True when the EventBus + // has its RestfulSet/Deployment ans service created. + EventBusConditionDeployed common.ConditionType = "Deployed" + // EventBusConditionConfigured has the status True when the EventBus + // has its configuration ready. + EventBusConditionConfigured common.ConditionType = "Configured" +) + +// InitConditions sets conditions to Unknown state. +func (s *EventBusStatus) InitConditions() { + s.InitializeConditions(EventBusConditionDeployed, EventBusConditionConfigured) +} + +// MarkDeployed set the bus has been deployed. +func (s *EventBusStatus) MarkDeployed(reason, message string) { + s.MarkTrueWithReason(EventBusConditionDeployed, reason, message) +} + +// MarkDeploying set the bus is deploying +func (s *EventBusStatus) MarkDeploying(reason, message string) { + s.MarkUnknown(EventBusConditionDeployed, reason, message) +} + +// MarkDeployFailed set the bus deploy failed +func (s *EventBusStatus) MarkDeployFailed(reason, message string) { + s.MarkFalse(EventBusConditionDeployed, reason, message) +} + +// MarkConfigured set the bus configuration has been done. +func (s *EventBusStatus) MarkConfigured() { + s.MarkTrue(EventBusConditionConfigured) +} + +// MarkNotConfigured set the bus status not configured. +func (s *EventBusStatus) MarkNotConfigured(reason, message string) { + s.MarkFalse(EventBusConditionConfigured, reason, message) +} diff --git a/pkg/apis/eventbus/v1alpha1/types_test.go b/pkg/apis/eventbus/v1alpha1/eventbus_types_test.go similarity index 100% rename from pkg/apis/eventbus/v1alpha1/types_test.go rename to pkg/apis/eventbus/v1alpha1/eventbus_types_test.go diff --git a/pkg/apis/eventbus/v1alpha1/generated.pb.go b/pkg/apis/eventbus/v1alpha1/generated.pb.go index b504618bb0..71d1a0c4fb 100644 --- a/pkg/apis/eventbus/v1alpha1/generated.pb.go +++ b/pkg/apis/eventbus/v1alpha1/generated.pb.go @@ -216,10 +216,94 @@ func (m *EventBusStatus) XXX_DiscardUnknown() { var xxx_messageInfo_EventBusStatus proto.InternalMessageInfo +func (m *JetStreamAuth) Reset() { *m = JetStreamAuth{} } +func (*JetStreamAuth) ProtoMessage() {} +func (*JetStreamAuth) Descriptor() ([]byte, []int) { + return fileDescriptor_871e47633eb7aad4, []int{6} +} +func (m *JetStreamAuth) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *JetStreamAuth) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *JetStreamAuth) XXX_Merge(src proto.Message) { + xxx_messageInfo_JetStreamAuth.Merge(m, src) +} +func (m *JetStreamAuth) XXX_Size() int { + return m.Size() +} +func (m *JetStreamAuth) XXX_DiscardUnknown() { + xxx_messageInfo_JetStreamAuth.DiscardUnknown(m) +} + +var xxx_messageInfo_JetStreamAuth proto.InternalMessageInfo + +func (m *JetStreamBus) Reset() { *m = JetStreamBus{} } +func (*JetStreamBus) ProtoMessage() {} +func (*JetStreamBus) Descriptor() ([]byte, []int) { + return fileDescriptor_871e47633eb7aad4, []int{7} +} +func (m *JetStreamBus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *JetStreamBus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *JetStreamBus) XXX_Merge(src proto.Message) { + xxx_messageInfo_JetStreamBus.Merge(m, src) +} +func (m *JetStreamBus) XXX_Size() int { + return m.Size() +} +func (m *JetStreamBus) XXX_DiscardUnknown() { + xxx_messageInfo_JetStreamBus.DiscardUnknown(m) +} + +var xxx_messageInfo_JetStreamBus proto.InternalMessageInfo + +func (m *JetStreamConfig) Reset() { *m = JetStreamConfig{} } +func (*JetStreamConfig) ProtoMessage() {} +func (*JetStreamConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_871e47633eb7aad4, []int{8} +} +func (m *JetStreamConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *JetStreamConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *JetStreamConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_JetStreamConfig.Merge(m, src) +} +func (m *JetStreamConfig) XXX_Size() int { + return m.Size() +} +func (m *JetStreamConfig) XXX_DiscardUnknown() { + xxx_messageInfo_JetStreamConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_JetStreamConfig proto.InternalMessageInfo + func (m *NATSBus) Reset() { *m = NATSBus{} } func (*NATSBus) ProtoMessage() {} func (*NATSBus) Descriptor() ([]byte, []int) { - return fileDescriptor_871e47633eb7aad4, []int{6} + return fileDescriptor_871e47633eb7aad4, []int{9} } func (m *NATSBus) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -247,7 +331,7 @@ var xxx_messageInfo_NATSBus proto.InternalMessageInfo func (m *NATSConfig) Reset() { *m = NATSConfig{} } func (*NATSConfig) ProtoMessage() {} func (*NATSConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_871e47633eb7aad4, []int{7} + return fileDescriptor_871e47633eb7aad4, []int{10} } func (m *NATSConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -275,7 +359,7 @@ var xxx_messageInfo_NATSConfig proto.InternalMessageInfo func (m *NativeStrategy) Reset() { *m = NativeStrategy{} } func (*NativeStrategy) ProtoMessage() {} func (*NativeStrategy) Descriptor() ([]byte, []int) { - return fileDescriptor_871e47633eb7aad4, []int{8} + return fileDescriptor_871e47633eb7aad4, []int{11} } func (m *NativeStrategy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -303,7 +387,7 @@ var xxx_messageInfo_NativeStrategy proto.InternalMessageInfo func (m *PersistenceStrategy) Reset() { *m = PersistenceStrategy{} } func (*PersistenceStrategy) ProtoMessage() {} func (*PersistenceStrategy) Descriptor() ([]byte, []int) { - return fileDescriptor_871e47633eb7aad4, []int{9} + return fileDescriptor_871e47633eb7aad4, []int{12} } func (m *PersistenceStrategy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -335,6 +419,10 @@ func init() { proto.RegisterType((*EventBusList)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.EventBusList") proto.RegisterType((*EventBusSpec)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.EventBusSpec") proto.RegisterType((*EventBusStatus)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.EventBusStatus") + proto.RegisterType((*JetStreamAuth)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.JetStreamAuth") + proto.RegisterType((*JetStreamBus)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.JetStreamBus") + proto.RegisterMapType((map[string]string)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.JetStreamBus.NodeSelectorEntry") + proto.RegisterType((*JetStreamConfig)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.JetStreamConfig") proto.RegisterType((*NATSBus)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.NATSBus") proto.RegisterType((*NATSConfig)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.NATSConfig") proto.RegisterType((*NativeStrategy)(nil), "github.com.argoproj.argo_events.pkg.apis.eventbus.v1alpha1.NativeStrategy") @@ -347,103 +435,119 @@ func init() { } var fileDescriptor_871e47633eb7aad4 = []byte{ - // 1528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 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0x0d, 0xee, 0x82, 0x39, 0xdb, 0xc5, 0x2d, 0xb2, 0x1d, - 0x38, 0xce, 0x36, 0x75, 0x6c, 0xab, 0xab, 0x8f, 0x2f, 0x6b, 0x2b, 0x79, 0xf3, 0x86, 0x72, 0x9b, - 0xdb, 0x18, 0x54, 0xbf, 0xe9, 0x55, 0x2e, 0x65, 0x1b, 0xc2, 0x48, 0x0c, 0xd0, 0x30, 0xa0, 0xe0, - 0x60, 0xc4, 0x0a, 0x7c, 0x9b, 0x77, 0x45, 0x6e, 0xe4, 0x88, 0xeb, 0x13, 0x32, 0x89, 0x0f, 0x46, - 0x25, 0xd1, 0x18, 0x34, 0x35, 0x17, 0x44, 0x10, 0x43, 0x42, 0x34, 0x0c, 0x58, 0xfd, 0x73, 0x1c, - 0xe4, 0xd6, 0x45, 0xa5, 0xcd, 0x80, 0xc1, 0x1f, 0x40, 0x4e, 0x34, 0x4f, 0x13, 0x73, 0xac, 0xca, - 0xf5, 0x71, 0x8a, 0x29, 0xee, 0x81, 0x64, 0x8f, 0x84, 0xb5, 0xe0, 0xbe, 0xbf, 0x7b, 0x40, 0x2c, - 0x5e, 0x27, 0x1c, 0x9b, 0x50, 0xe5, 0x0f, 0x12, 0x19, 0x8a, 0x51, 0xe1, 0x01, 0x98, 0x64, 0x6d, - 0x62, 0xc9, 0x5a, 0x15, 0xae, 0xdf, 0x3d, 0x4d, 0x37, 0x44, 0x51, 0x37, 0xda, 0xc4, 0x32, 0x8b, - 0x8a, 0x75, 0x52, 0xac, 0x90, 0xe4, 0x80, 0x3e, 0x98, 0x66, 0x1c, 0xf3, 0x80, 0xa9, 0xaa, 0xdd, - 0x3b, 0x13, 0x36, 0x89, 0x68, 0xce, 0x2a, 0xbe, 0xe9, 0x70, 0x8d, 0x14, 0x53, 0xf5, 0x2f, 0x0d, - 0x14, 0x23, 0xd3, 0x4d, 0x9b, 0x71, 0xf8, 0x28, 0x53, 0x52, 0xe3, 0x64, 0x25, 0x15, 0xde, 0xb2, - 0xa0, 0xf3, 0x8a, 0x2a, 0x17, 0x49, 0x52, 0xe5, 0xb4, 0xc1, 0x94, 0xcd, 0x89, 0xcb, 0xf4, 0xf1, - 0xe5, 0x89, 0x95, 0xc2, 0xf5, 0xdb, 0x67, 0x91, 0xa1, 0x79, 0x4e, 0x11, 0x4e, 0x6d, 0x08, 0x68, - 0x14, 0x32, 0x54, 0x9f, 0x24, 0x89, 0x89, 0x1a, 0x43, 0x3c, 0x70, 0xae, 0xd7, 0x4e, 0x7b, 0xae, - 0x05, 0xf1, 0xf0, 0xa1, 0x7e, 0xa9, 0x81, 0xd9, 0xc1, 0xba, 0xc3, 0xc7, 0xf1, 0x9e, 0x86, 0xbc, - 0x9f, 0x9d, 0x9c, 0x37, 0x1c, 0xea, 0xc6, 0xdb, 0x37, 0x10, 0xba, 0x60, 0xda, 0x92, 0x23, 0x46, - 0xb5, 0xe8, 0xfa, 0x69, 0x12, 0x8b, 0xa7, 0x60, 0x42, 0x17, 0xae, 0x91, 0x22, 0xa9, 0xfe, 0xad, - 0x81, 0x19, 0x95, 0x3e, 0xf4, 0xc0, 0xb4, 0x87, 0xb9, 0xdd, 0x21, 0x2a, 0xb7, 0x53, 0xf5, 0xeb, - 0x96, 0x44, 0x6a, 0x70, 0x31, 0x97, 0x5b, 0x5d, 0x13, 0x08, 0xee, 0x50, 0x86, 0x14, 0x0b, 0x3c, - 0x00, 0xd3, 0xe4, 0x88, 0x72, 0x3b, 0x3a, 0x8d, 0x67, 0x35, 0x9b, 0x25, 0xd7, 0xba, 0x44, 0x46, - 0x8a, 0xa1, 0xfa, 0x5a, 0x03, 0x20, 0x31, 0x81, 0x97, 0xc0, 0x44, 0xe0, 0x3b, 0x32, 0xcf, 0xbc, - 0x59, 0x50, 0xb5, 0x99, 0x78, 0x80, 0x36, 0x91, 0x90, 0xc3, 0x8f, 0x40, 0xde, 0x72, 0x02, 0xc6, - 0x89, 0xbf, 0x71, 0x5b, 0x8d, 0xd5, 0x73, 0x62, 0x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, 0x17, 0x81, 0x9d, 0x97, - 0x60, 0x17, 0xfa, 0xbd, 0xca, 0x02, 0xca, 0xaa, 0xd1, 0x28, 0x1f, 0xf8, 0x05, 0x98, 0x17, 0xe2, - 0x4d, 0x82, 0x19, 0x89, 0x70, 0xfe, 0x27, 0x71, 0x16, 0x45, 0x27, 0xa2, 0x21, 0x1d, 0xca, 0x58, - 0xc3, 0x35, 0x50, 0x12, 0xb2, 0x35, 0xea, 0xba, 0x76, 0x9c, 0xd7, 0x05, 0x09, 0x21, 0x07, 0x39, - 0x1a, 0x56, 0xa2, 0xac, 0xfd, 0xd2, 0x2d, 0x50, 0xca, 0x8c, 0x2f, 0x38, 0x0f, 0x26, 0x0e, 0x49, - 0x37, 0x7c, 0x3d, 0x20, 0xf1, 0x09, 0x17, 0xc1, 0x54, 0x07, 0x3b, 0x01, 0x09, 0x2f, 0x4e, 0x14, - 0x2e, 0x6e, 0x8e, 0xdf, 0xd0, 0xaa, 0xbf, 0x8d, 0x83, 0x85, 0x11, 0x97, 0x9a, 0xc8, 0x8f, 0x71, - 0xea, 0xe3, 0x16, 0x49, 0x5a, 0x5b, 0x4b, 0xf2, 0x6b, 0x0c, 0xe9, 0x50, 0xc6, 0x1a, 0x3e, 0x06, - 0x20, 0xbc, 0xfc, 0xeb, 0xb4, 0xa9, 0x88, 0xcd, 0x5b, 0x62, 0xab, 0x57, 0x63, 0xe9, 0x9b, 0x5e, - 0xe5, 0xea, 0xa8, 0xff, 0x7c, 0x51, 0x3c, 0xfc, 0x21, 0x75, 0x02, 0x97, 0x24, 0x0e, 0x28, 0x05, - 0x09, 0xbf, 0x07, 0xa0, 0x23, 0xf5, 0x0d, 0xfb, 0xc7, 0xe8, 0x72, 0x7f, 0xeb, 0x9f, 0x07, 0x23, - 0xfa, 0x7b, 0x6a, 0x7c, 0x1d, 0x60, 0x8f, 0x8b, 0xf3, 0x21, 0x7b, 0xef, 0x61, 0x8c, 0x82, 0x52, - 0x88, 0xa6, 0xf1, 0xec, 0x55, 0x79, 0xec, 0xf9, 0xab, 0xf2, 0xd8, 0x8b, 0x57, 0xe5, 0xb1, 0x9f, - 0xfa, 0x65, 0xed, 0x59, 0xbf, 0xac, 0x3d, 0xef, 0x97, 0xb5, 0x17, 0xfd, 0xb2, 0xf6, 0xb2, 0x5f, - 0xd6, 0x9e, 0xbe, 0x2e, 0x8f, 0x7d, 0x9b, 0x8b, 0xae, 0x95, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, - 0x10, 0x2c, 0x4c, 0x24, 0xc8, 0x11, 0x00, 0x00, + // 1787 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x4f, 0x6f, 0x23, 0x49, + 0x15, 0x4f, 0x27, 0x8e, 0x63, 0x97, 0x9d, 0x38, 0xae, 0x64, 0xd9, 0x9e, 0x68, 0xc7, 0x5e, 0x19, + 0x2d, 0x0a, 0x62, 0xa6, 0xcd, 0xac, 0x10, 0x0c, 0x7b, 0x19, 0xd2, 0xd9, 0x0c, 0x93, 0x6c, 0x9c, + 0x0d, 0xe5, 0xec, 0x20, 0x96, 0x15, 0x43, 0xa5, 0x53, 0x71, 0x3a, 0x71, 0x77, 0x99, 0xae, 0x6a, + 0x2b, 0xe6, 0x84, 0xf8, 0x04, 0x2b, 0x84, 0x10, 0x7c, 0x02, 0x24, 0x3e, 0x00, 0x9f, 0x61, 0x0e, + 0x1c, 0xf6, 0xc6, 0x9e, 0xac, 0x1d, 0xaf, 0x90, 0x90, 0xb8, 0x70, 0x9e, 0x13, 0xaa, 0xea, 0xea, + 0x3f, 0x76, 0x77, 0x66, 0x32, 0x63, 0x87, 0xd1, 0x9e, 0xdc, 0xf5, 0xfe, 0xfc, 0xde, 0x9f, 0x7e, + 0xf5, 0xde, 0x6b, 0x83, 0xbd, 0x8e, 0xcd, 0xcf, 0xfc, 0x63, 0xc3, 0xa2, 0x4e, 0x13, 0x7b,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, 0xfe, 0x75, 0x6d, 0xee, 0xd3, 0x42, 0x38, 0x56, 0xfe, 0x17, 0x00, + 0x00, 0xff, 0xff, 0xd0, 0xc4, 0xea, 0x02, 0x23, 0x1a, 0x00, 0x00, } func (m *BusConfig) Marshal() (dAtA []byte, err error) { @@ -466,6 +570,18 @@ func (m *BusConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.JetStream != nil { + { + size, err := m.JetStream.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if m.NATS != nil { { size, err := m.NATS.MarshalToSizedBuffer(dAtA[:i]) @@ -651,6 +767,18 @@ func (m *EventBusSpec) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.JetStream != nil { + { + size, err := m.JetStream.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if m.NATS != nil { { size, err := m.NATS.MarshalToSizedBuffer(dAtA[:i]) @@ -709,7 +837,7 @@ func (m *EventBusStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *NATSBus) Marshal() (dAtA []byte, err error) { +func (m *JetStreamAuth) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -719,31 +847,19 @@ func (m *NATSBus) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *NATSBus) MarshalTo(dAtA []byte) (int, error) { +func (m *JetStreamAuth) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *NATSBus) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *JetStreamAuth) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Exotic != nil { + if m.Token != nil { { - size, err := m.Exotic.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenerated(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Native != nil { - { - size, err := m.Native.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -756,61 +872,7 @@ func (m *NATSBus) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *NATSConfig) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NATSConfig) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NATSConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AccessSecret != nil { - { - size, err := m.AccessSecret.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenerated(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.Auth != nil { - i -= len(*m.Auth) - copy(dAtA[i:], *m.Auth) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Auth))) - i-- - dAtA[i] = 0x1a - } - if m.ClusterID != nil { - i -= len(*m.ClusterID) - copy(dAtA[i:], *m.ClusterID) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.ClusterID))) - i-- - dAtA[i] = 0x12 - } - i -= len(m.URL) - copy(dAtA[i:], m.URL) - i = encodeVarintGenerated(dAtA, i, uint64(len(m.URL))) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *NativeStrategy) Marshal() (dAtA []byte, err error) { +func (m *JetStreamBus) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -820,84 +882,30 @@ func (m *NativeStrategy) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *NativeStrategy) MarshalTo(dAtA []byte) (int, error) { +func (m *JetStreamBus) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *JetStreamBus) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.RaftCommitTimeout != nil { - i -= len(*m.RaftCommitTimeout) - copy(dAtA[i:], *m.RaftCommitTimeout) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftCommitTimeout))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xba - } - if m.RaftLeaseTimeout != nil { - i -= len(*m.RaftLeaseTimeout) - copy(dAtA[i:], *m.RaftLeaseTimeout) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftLeaseTimeout))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb2 - } - if m.RaftElectionTimeout != nil { - i -= len(*m.RaftElectionTimeout) - copy(dAtA[i:], *m.RaftElectionTimeout) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftElectionTimeout))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xaa - } - if m.RaftHeartbeatTimeout != nil { - i -= len(*m.RaftHeartbeatTimeout) - copy(dAtA[i:], *m.RaftHeartbeatTimeout) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftHeartbeatTimeout))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa2 - } - if m.MaxPayload != nil { - i -= len(*m.MaxPayload) - copy(dAtA[i:], *m.MaxPayload) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxPayload))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x9a - } - if m.MaxSubs != nil { - i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxSubs)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x90 - } - if m.MaxBytes != nil { - i -= len(*m.MaxBytes) - copy(dAtA[i:], *m.MaxBytes) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxBytes))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a - } - if m.MaxMsgs != nil { - i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxMsgs)) + if m.Settings != nil { + i -= len(*m.Settings) + copy(dAtA[i:], *m.Settings) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Settings))) i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0x80 + dAtA[i] = 0x82 } + i -= len(m.ServiceAccountName) + copy(dAtA[i:], m.ServiceAccountName) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ServiceAccountName))) + i-- + dAtA[i] = 0x7a if m.Affinity != nil { { size, err := m.Affinity.MarshalToSizedBuffer(dAtA[:i]) @@ -908,22 +916,17 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x7a + dAtA[i] = 0x72 } if m.Priority != nil { i = encodeVarintGenerated(dAtA, i, uint64(*m.Priority)) i-- - dAtA[i] = 0x70 + dAtA[i] = 0x68 } i -= len(m.PriorityClassName) copy(dAtA[i:], m.PriorityClassName) i = encodeVarintGenerated(dAtA, i, uint64(len(m.PriorityClassName))) i-- - dAtA[i] = 0x6a - i -= len(m.ServiceAccountName) - copy(dAtA[i:], m.ServiceAccountName) - i = encodeVarintGenerated(dAtA, i, uint64(len(m.ServiceAccountName))) - i-- dAtA[i] = 0x62 if len(m.ImagePullSecrets) > 0 { for iNdEx := len(m.ImagePullSecrets) - 1; iNdEx >= 0; iNdEx-- { @@ -939,13 +942,6 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x5a } } - if m.MaxAge != nil { - i -= len(*m.MaxAge) - copy(dAtA[i:], *m.MaxAge) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxAge))) - i-- - dAtA[i] = 0x52 - } if m.SecurityContext != nil { { size, err := m.SecurityContext.MarshalToSizedBuffer(dAtA[:i]) @@ -956,19 +952,7 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a - } - if m.Metadata != nil { - { - size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenerated(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 + dAtA[i] = 0x52 } if len(m.Tolerations) > 0 { for iNdEx := len(m.Tolerations) - 1; iNdEx >= 0; iNdEx-- { @@ -981,7 +965,7 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x4a } } if len(m.NodeSelector) > 0 { @@ -1005,12 +989,12 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0xa i = encodeVarintGenerated(dAtA, i, uint64(baseI-i)) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 } } - if m.MetricsContainerTemplate != nil { + if m.Metadata != nil { { - size, err := m.MetricsContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1018,11 +1002,35 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } - if m.ContainerTemplate != nil { + if m.Persistence != nil { { - size, err := m.ContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Persistence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.MetricsContainerTemplate != nil { + { + size, err := m.MetricsContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.ReloaderContainerTemplate != nil { + { + size, err := m.ReloaderContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1032,9 +1040,9 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.Persistence != nil { + if m.ContainerTemplate != nil { { - size, err := m.Persistence.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1044,20 +1052,20 @@ func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.Auth != nil { - i -= len(*m.Auth) - copy(dAtA[i:], *m.Auth) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Auth))) + if m.Replicas != nil { + i = encodeVarintGenerated(dAtA, i, uint64(*m.Replicas)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } - i = encodeVarintGenerated(dAtA, i, uint64(m.Replicas)) + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Version))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *PersistenceStrategy) Marshal() (dAtA []byte, err error) { +func (m *JetStreamConfig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1067,19 +1075,19 @@ func (m *PersistenceStrategy) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PersistenceStrategy) MarshalTo(dAtA []byte) (int, error) { +func (m *JetStreamConfig) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PersistenceStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *JetStreamConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.VolumeSize != nil { + if m.Auth != nil { { - size, err := m.VolumeSize.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Auth.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1087,458 +1095,1886 @@ func (m *PersistenceStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if m.AccessMode != nil { - i -= len(*m.AccessMode) - copy(dAtA[i:], *m.AccessMode) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.AccessMode))) - i-- dAtA[i] = 0x12 } - if m.StorageClassName != nil { - i -= len(*m.StorageClassName) - copy(dAtA[i:], *m.StorageClassName) - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.StorageClassName))) - i-- - dAtA[i] = 0xa - } + i -= len(m.URL) + copy(dAtA[i:], m.URL) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.URL))) + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { - offset -= sovGenerated(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *NATSBus) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *BusConfig) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NATS != nil { - l = m.NATS.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n + +func (m *NATSBus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ContainerTemplate) Size() (n int) { - if m == nil { - return 0 - } +func (m *NATSBus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Resources.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.ImagePullPolicy) - n += 1 + l + sovGenerated(uint64(l)) - if m.SecurityContext != nil { - l = m.SecurityContext.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.Exotic != nil { + { + size, err := m.Exotic.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if m.Native != nil { + { + size, err := m.Native.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *EventBus) Size() (n int) { - if m == nil { - return 0 +func (m *NATSConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.ObjectMeta.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Spec.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Status.Size() - n += 1 + l + sovGenerated(uint64(l)) - return n + return dAtA[:n], nil } -func (m *EventBusList) Size() (n int) { - if m == nil { - return 0 - } +func (m *NATSConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NATSConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.ListMeta.Size() - n += 1 + l + sovGenerated(uint64(l)) - if len(m.Items) > 0 { - for _, e := range m.Items { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.AccessSecret != nil { + { + size, err := m.AccessSecret.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 } - return n -} - -func (m *EventBusSpec) Size() (n int) { - if m == nil { - return 0 + if m.Auth != nil { + i -= len(*m.Auth) + copy(dAtA[i:], *m.Auth) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Auth))) + i-- + dAtA[i] = 0x1a } - var l int - _ = l - if m.NATS != nil { - l = m.NATS.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.ClusterID != nil { + i -= len(*m.ClusterID) + copy(dAtA[i:], *m.ClusterID) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.ClusterID))) + i-- + dAtA[i] = 0x12 } - return n + i -= len(m.URL) + copy(dAtA[i:], m.URL) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.URL))) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *EventBusStatus) Size() (n int) { - if m == nil { - return 0 +func (m *NativeStrategy) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.Status.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Config.Size() - n += 1 + l + sovGenerated(uint64(l)) - return n + return dAtA[:n], nil } -func (m *NATSBus) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Native != nil { - l = m.Native.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Exotic != nil { - l = m.Exotic.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n +func (m *NativeStrategy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *NATSConfig) Size() (n int) { - if m == nil { - return 0 - } +func (m *NativeStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.URL) - n += 1 + l + sovGenerated(uint64(l)) - if m.ClusterID != nil { - l = len(*m.ClusterID) - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Auth != nil { - l = len(*m.Auth) - n += 1 + l + sovGenerated(uint64(l)) + if m.RaftCommitTimeout != nil { + i -= len(*m.RaftCommitTimeout) + copy(dAtA[i:], *m.RaftCommitTimeout) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftCommitTimeout))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xba } - if m.AccessSecret != nil { - l = m.AccessSecret.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.RaftLeaseTimeout != nil { + i -= len(*m.RaftLeaseTimeout) + copy(dAtA[i:], *m.RaftLeaseTimeout) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftLeaseTimeout))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb2 } - return n -} - -func (m *NativeStrategy) Size() (n int) { - if m == nil { - return 0 + if m.RaftElectionTimeout != nil { + i -= len(*m.RaftElectionTimeout) + copy(dAtA[i:], *m.RaftElectionTimeout) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftElectionTimeout))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xaa } - var l int - _ = l - n += 1 + sovGenerated(uint64(m.Replicas)) - if m.Auth != nil { - l = len(*m.Auth) - n += 1 + l + sovGenerated(uint64(l)) + if m.RaftHeartbeatTimeout != nil { + i -= len(*m.RaftHeartbeatTimeout) + copy(dAtA[i:], *m.RaftHeartbeatTimeout) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.RaftHeartbeatTimeout))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa2 } - if m.Persistence != nil { - l = m.Persistence.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.MaxPayload != nil { + i -= len(*m.MaxPayload) + copy(dAtA[i:], *m.MaxPayload) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxPayload))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a } - if m.ContainerTemplate != nil { - l = m.ContainerTemplate.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.MaxSubs != nil { + i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxSubs)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 } - if m.MetricsContainerTemplate != nil { - l = m.MetricsContainerTemplate.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.MaxBytes != nil { + i -= len(*m.MaxBytes) + copy(dAtA[i:], *m.MaxBytes) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxBytes))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a } - if len(m.NodeSelector) > 0 { - for k, v := range m.NodeSelector { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) - n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) - } + if m.MaxMsgs != nil { + i = encodeVarintGenerated(dAtA, i, uint64(*m.MaxMsgs)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 } - if len(m.Tolerations) > 0 { - for _, e := range m.Tolerations { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.Affinity != nil { + { + size, err := m.Affinity.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x7a } - if m.Metadata != nil { - l = m.Metadata.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.SecurityContext != nil { - l = m.SecurityContext.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.MaxAge != nil { - l = len(*m.MaxAge) - n += 1 + l + sovGenerated(uint64(l)) + if m.Priority != nil { + i = encodeVarintGenerated(dAtA, i, uint64(*m.Priority)) + i-- + dAtA[i] = 0x70 } + i -= len(m.PriorityClassName) + copy(dAtA[i:], m.PriorityClassName) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.PriorityClassName))) + i-- + dAtA[i] = 0x6a + i -= len(m.ServiceAccountName) + copy(dAtA[i:], m.ServiceAccountName) + i = encodeVarintGenerated(dAtA, i, uint64(len(m.ServiceAccountName))) + i-- + dAtA[i] = 0x62 if len(m.ImagePullSecrets) > 0 { - for _, e := range m.ImagePullSecrets { - l = e.Size() - n += 1 + l + sovGenerated(uint64(l)) + for iNdEx := len(m.ImagePullSecrets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ImagePullSecrets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a } } - l = len(m.ServiceAccountName) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.PriorityClassName) - n += 1 + l + sovGenerated(uint64(l)) - if m.Priority != nil { - n += 1 + sovGenerated(uint64(*m.Priority)) + if m.MaxAge != nil { + i -= len(*m.MaxAge) + copy(dAtA[i:], *m.MaxAge) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.MaxAge))) + i-- + dAtA[i] = 0x52 } - if m.Affinity != nil { - l = m.Affinity.Size() - n += 1 + l + sovGenerated(uint64(l)) + if m.SecurityContext != nil { + { + size, err := m.SecurityContext.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a } - if m.MaxMsgs != nil { - n += 2 + sovGenerated(uint64(*m.MaxMsgs)) + if m.Metadata != nil { + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 } - if m.MaxBytes != nil { - l = len(*m.MaxBytes) - n += 2 + l + sovGenerated(uint64(l)) + if len(m.Tolerations) > 0 { + for iNdEx := len(m.Tolerations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tolerations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } } - if m.MaxSubs != nil { - n += 2 + sovGenerated(uint64(*m.MaxSubs)) + if len(m.NodeSelector) > 0 { + keysForNodeSelector := make([]string, 0, len(m.NodeSelector)) + for k := range m.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + for iNdEx := len(keysForNodeSelector) - 1; iNdEx >= 0; iNdEx-- { + v := m.NodeSelector[string(keysForNodeSelector[iNdEx])] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintGenerated(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(keysForNodeSelector[iNdEx]) + copy(dAtA[i:], keysForNodeSelector[iNdEx]) + i = encodeVarintGenerated(dAtA, i, uint64(len(keysForNodeSelector[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintGenerated(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x32 + } } - if m.MaxPayload != nil { - l = len(*m.MaxPayload) - n += 2 + l + sovGenerated(uint64(l)) + if m.MetricsContainerTemplate != nil { + { + size, err := m.MetricsContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a } - if m.RaftHeartbeatTimeout != nil { - l = len(*m.RaftHeartbeatTimeout) - n += 2 + l + sovGenerated(uint64(l)) + if m.ContainerTemplate != nil { + { + size, err := m.ContainerTemplate.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 } - if m.RaftElectionTimeout != nil { - l = len(*m.RaftElectionTimeout) - n += 2 + l + sovGenerated(uint64(l)) + if m.Persistence != nil { + { + size, err := m.Persistence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - if m.RaftLeaseTimeout != nil { - l = len(*m.RaftLeaseTimeout) - n += 2 + l + sovGenerated(uint64(l)) + if m.Auth != nil { + i -= len(*m.Auth) + copy(dAtA[i:], *m.Auth) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.Auth))) + i-- + dAtA[i] = 0x12 } - if m.RaftCommitTimeout != nil { - l = len(*m.RaftCommitTimeout) - n += 2 + l + sovGenerated(uint64(l)) + i = encodeVarintGenerated(dAtA, i, uint64(m.Replicas)) + i-- + dAtA[i] = 0x8 + return len(dAtA) - i, nil +} + +func (m *PersistenceStrategy) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil } -func (m *PersistenceStrategy) Size() (n int) { +func (m *PersistenceStrategy) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PersistenceStrategy) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VolumeSize != nil { + { + size, err := m.VolumeSize.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenerated(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.AccessMode != nil { + i -= len(*m.AccessMode) + copy(dAtA[i:], *m.AccessMode) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.AccessMode))) + i-- + dAtA[i] = 0x12 + } + if m.StorageClassName != nil { + i -= len(*m.StorageClassName) + copy(dAtA[i:], *m.StorageClassName) + i = encodeVarintGenerated(dAtA, i, uint64(len(*m.StorageClassName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { + offset -= sovGenerated(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BusConfig) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.StorageClassName != nil { - l = len(*m.StorageClassName) + if m.NATS != nil { + l = m.NATS.Size() n += 1 + l + sovGenerated(uint64(l)) } - if m.AccessMode != nil { - l = len(*m.AccessMode) + if m.JetStream != nil { + l = m.JetStream.Size() n += 1 + l + sovGenerated(uint64(l)) } - if m.VolumeSize != nil { - l = m.VolumeSize.Size() + return n +} + +func (m *ContainerTemplate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Resources.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.ImagePullPolicy) + n += 1 + l + sovGenerated(uint64(l)) + if m.SecurityContext != nil { + l = m.SecurityContext.Size() n += 1 + l + sovGenerated(uint64(l)) } return n } -func sovGenerated(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenerated(x uint64) (n int) { - return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *BusConfig) String() string { - if this == nil { - return "nil" +func (m *EventBus) Size() (n int) { + if m == nil { + return 0 } - s := strings.Join([]string{`&BusConfig{`, - `NATS:` + strings.Replace(this.NATS.String(), "NATSConfig", "NATSConfig", 1) + `,`, - `}`, - }, "") - return s + var l int + _ = l + l = m.ObjectMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Spec.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Status.Size() + n += 1 + l + sovGenerated(uint64(l)) + return n } -func (this *ContainerTemplate) String() string { - if this == nil { - return "nil" + +func (m *EventBusList) Size() (n int) { + if m == nil { + return 0 } - s := strings.Join([]string{`&ContainerTemplate{`, - `Resources:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Resources), "ResourceRequirements", "v1.ResourceRequirements", 1), `&`, ``, 1) + `,`, - `ImagePullPolicy:` + fmt.Sprintf("%v", this.ImagePullPolicy) + `,`, - `SecurityContext:` + strings.Replace(fmt.Sprintf("%v", this.SecurityContext), "SecurityContext", "v1.SecurityContext", 1) + `,`, - `}`, - }, "") - return s -} -func (this *EventBus) String() string { - if this == nil { - return "nil" + var l int + _ = l + l = m.ListMeta.Size() + n += 1 + l + sovGenerated(uint64(l)) + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } } - s := strings.Join([]string{`&EventBus{`, - `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v11.ObjectMeta", 1), `&`, ``, 1) + `,`, - `Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "EventBusSpec", "EventBusSpec", 1), `&`, ``, 1) + `,`, - `Status:` + strings.Replace(strings.Replace(this.Status.String(), "EventBusStatus", "EventBusStatus", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s + return n } -func (this *EventBusList) String() string { - if this == nil { - return "nil" + +func (m *EventBusSpec) Size() (n int) { + if m == nil { + return 0 } - repeatedStringForItems := "[]EventBus{" - for _, f := range this.Items { - repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "EventBus", "EventBus", 1), `&`, ``, 1) + "," + var l int + _ = l + if m.NATS != nil { + l = m.NATS.Size() + n += 1 + l + sovGenerated(uint64(l)) } - repeatedStringForItems += "}" - s := strings.Join([]string{`&EventBusList{`, - `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v11.ListMeta", 1), `&`, ``, 1) + `,`, - `Items:` + repeatedStringForItems + `,`, - `}`, - }, "") - return s -} -func (this *EventBusSpec) String() string { - if this == nil { - return "nil" + if m.JetStream != nil { + l = m.JetStream.Size() + n += 1 + l + sovGenerated(uint64(l)) } - s := strings.Join([]string{`&EventBusSpec{`, - `NATS:` + strings.Replace(this.NATS.String(), "NATSBus", "NATSBus", 1) + `,`, - `}`, - }, "") - return s + return n } -func (this *EventBusStatus) String() string { - if this == nil { - return "nil" + +func (m *EventBusStatus) Size() (n int) { + if m == nil { + return 0 } - s := strings.Join([]string{`&EventBusStatus{`, - `Status:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Status), "Status", "common.Status", 1), `&`, ``, 1) + `,`, - `Config:` + strings.Replace(strings.Replace(this.Config.String(), "BusConfig", "BusConfig", 1), `&`, ``, 1) + `,`, - `}`, - }, "") - return s + var l int + _ = l + l = m.Status.Size() + n += 1 + l + sovGenerated(uint64(l)) + l = m.Config.Size() + n += 1 + l + sovGenerated(uint64(l)) + return n } -func (this *NATSBus) String() string { - if this == nil { - return "nil" + +func (m *JetStreamAuth) Size() (n int) { + if m == nil { + return 0 } - s := strings.Join([]string{`&NATSBus{`, - `Native:` + strings.Replace(this.Native.String(), "NativeStrategy", "NativeStrategy", 1) + `,`, - `Exotic:` + strings.Replace(this.Exotic.String(), "NATSConfig", "NATSConfig", 1) + `,`, - `}`, - }, "") - return s -} -func (this *NATSConfig) String() string { - if this == nil { - return "nil" + var l int + _ = l + if m.Token != nil { + l = m.Token.Size() + n += 1 + l + sovGenerated(uint64(l)) } - s := strings.Join([]string{`&NATSConfig{`, - `URL:` + fmt.Sprintf("%v", this.URL) + `,`, - `ClusterID:` + valueToStringGenerated(this.ClusterID) + `,`, - `Auth:` + valueToStringGenerated(this.Auth) + `,`, - `AccessSecret:` + strings.Replace(fmt.Sprintf("%v", this.AccessSecret), "SecretKeySelector", "v1.SecretKeySelector", 1) + `,`, - `}`, - }, "") - return s + return n } -func (this *NativeStrategy) String() string { - if this == nil { + +func (m *JetStreamBus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Version) + n += 1 + l + sovGenerated(uint64(l)) + if m.Replicas != nil { + n += 1 + sovGenerated(uint64(*m.Replicas)) + } + if m.ContainerTemplate != nil { + l = m.ContainerTemplate.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.ReloaderContainerTemplate != nil { + l = m.ReloaderContainerTemplate.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.MetricsContainerTemplate != nil { + l = m.MetricsContainerTemplate.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Persistence != nil { + l = m.Persistence.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.NodeSelector) > 0 { + for k, v := range m.NodeSelector { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } + } + if len(m.Tolerations) > 0 { + for _, e := range m.Tolerations { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.SecurityContext != nil { + l = m.SecurityContext.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.ImagePullSecrets) > 0 { + for _, e := range m.ImagePullSecrets { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + l = len(m.PriorityClassName) + n += 1 + l + sovGenerated(uint64(l)) + if m.Priority != nil { + n += 1 + sovGenerated(uint64(*m.Priority)) + } + if m.Affinity != nil { + l = m.Affinity.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + l = len(m.ServiceAccountName) + n += 1 + l + sovGenerated(uint64(l)) + if m.Settings != nil { + l = len(*m.Settings) + n += 2 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *JetStreamConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.URL) + n += 1 + l + sovGenerated(uint64(l)) + if m.Auth != nil { + l = m.Auth.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *NATSBus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Native != nil { + l = m.Native.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Exotic != nil { + l = m.Exotic.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *NATSConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.URL) + n += 1 + l + sovGenerated(uint64(l)) + if m.ClusterID != nil { + l = len(*m.ClusterID) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Auth != nil { + l = len(*m.Auth) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.AccessSecret != nil { + l = m.AccessSecret.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *NativeStrategy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovGenerated(uint64(m.Replicas)) + if m.Auth != nil { + l = len(*m.Auth) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.Persistence != nil { + l = m.Persistence.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.ContainerTemplate != nil { + l = m.ContainerTemplate.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.MetricsContainerTemplate != nil { + l = m.MetricsContainerTemplate.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.NodeSelector) > 0 { + for k, v := range m.NodeSelector { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) + n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) + } + } + if len(m.Tolerations) > 0 { + for _, e := range m.Tolerations { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.SecurityContext != nil { + l = m.SecurityContext.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.MaxAge != nil { + l = len(*m.MaxAge) + n += 1 + l + sovGenerated(uint64(l)) + } + if len(m.ImagePullSecrets) > 0 { + for _, e := range m.ImagePullSecrets { + l = e.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + } + l = len(m.ServiceAccountName) + n += 1 + l + sovGenerated(uint64(l)) + l = len(m.PriorityClassName) + n += 1 + l + sovGenerated(uint64(l)) + if m.Priority != nil { + n += 1 + sovGenerated(uint64(*m.Priority)) + } + if m.Affinity != nil { + l = m.Affinity.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + if m.MaxMsgs != nil { + n += 2 + sovGenerated(uint64(*m.MaxMsgs)) + } + if m.MaxBytes != nil { + l = len(*m.MaxBytes) + n += 2 + l + sovGenerated(uint64(l)) + } + if m.MaxSubs != nil { + n += 2 + sovGenerated(uint64(*m.MaxSubs)) + } + if m.MaxPayload != nil { + l = len(*m.MaxPayload) + n += 2 + l + sovGenerated(uint64(l)) + } + if m.RaftHeartbeatTimeout != nil { + l = len(*m.RaftHeartbeatTimeout) + n += 2 + l + sovGenerated(uint64(l)) + } + if m.RaftElectionTimeout != nil { + l = len(*m.RaftElectionTimeout) + n += 2 + l + sovGenerated(uint64(l)) + } + if m.RaftLeaseTimeout != nil { + l = len(*m.RaftLeaseTimeout) + n += 2 + l + sovGenerated(uint64(l)) + } + if m.RaftCommitTimeout != nil { + l = len(*m.RaftCommitTimeout) + n += 2 + l + sovGenerated(uint64(l)) + } + return n +} + +func (m *PersistenceStrategy) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StorageClassName != nil { + l = len(*m.StorageClassName) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.AccessMode != nil { + l = len(*m.AccessMode) + n += 1 + l + sovGenerated(uint64(l)) + } + if m.VolumeSize != nil { + l = m.VolumeSize.Size() + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func sovGenerated(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *BusConfig) String() string { + if this == nil { return "nil" } - repeatedStringForTolerations := "[]Toleration{" - for _, f := range this.Tolerations { - repeatedStringForTolerations += fmt.Sprintf("%v", f) + "," + s := strings.Join([]string{`&BusConfig{`, + `NATS:` + strings.Replace(this.NATS.String(), "NATSConfig", "NATSConfig", 1) + `,`, + `JetStream:` + strings.Replace(this.JetStream.String(), "JetStreamConfig", "JetStreamConfig", 1) + `,`, + `}`, + }, "") + return s +} +func (this *ContainerTemplate) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ContainerTemplate{`, + `Resources:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Resources), "ResourceRequirements", "v1.ResourceRequirements", 1), `&`, ``, 1) + `,`, + `ImagePullPolicy:` + fmt.Sprintf("%v", this.ImagePullPolicy) + `,`, + `SecurityContext:` + strings.Replace(fmt.Sprintf("%v", this.SecurityContext), "SecurityContext", "v1.SecurityContext", 1) + `,`, + `}`, + }, "") + return s +} +func (this *EventBus) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EventBus{`, + `ObjectMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ObjectMeta), "ObjectMeta", "v11.ObjectMeta", 1), `&`, ``, 1) + `,`, + `Spec:` + strings.Replace(strings.Replace(this.Spec.String(), "EventBusSpec", "EventBusSpec", 1), `&`, ``, 1) + `,`, + `Status:` + strings.Replace(strings.Replace(this.Status.String(), "EventBusStatus", "EventBusStatus", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *EventBusList) String() string { + if this == nil { + return "nil" + } + repeatedStringForItems := "[]EventBus{" + for _, f := range this.Items { + repeatedStringForItems += strings.Replace(strings.Replace(f.String(), "EventBus", "EventBus", 1), `&`, ``, 1) + "," + } + repeatedStringForItems += "}" + s := strings.Join([]string{`&EventBusList{`, + `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v11.ListMeta", 1), `&`, ``, 1) + `,`, + `Items:` + repeatedStringForItems + `,`, + `}`, + }, "") + return s +} +func (this *EventBusSpec) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EventBusSpec{`, + `NATS:` + strings.Replace(this.NATS.String(), "NATSBus", "NATSBus", 1) + `,`, + `JetStream:` + strings.Replace(this.JetStream.String(), "JetStreamBus", "JetStreamBus", 1) + `,`, + `}`, + }, "") + return s +} +func (this *EventBusStatus) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&EventBusStatus{`, + `Status:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Status), "Status", "common.Status", 1), `&`, ``, 1) + `,`, + `Config:` + strings.Replace(strings.Replace(this.Config.String(), "BusConfig", "BusConfig", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *JetStreamAuth) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&JetStreamAuth{`, + `Token:` + strings.Replace(fmt.Sprintf("%v", this.Token), "SecretKeySelector", "v1.SecretKeySelector", 1) + `,`, + `}`, + }, "") + return s +} +func (this *JetStreamBus) String() string { + if this == nil { + return "nil" + } + repeatedStringForTolerations := "[]Toleration{" + for _, f := range this.Tolerations { + repeatedStringForTolerations += fmt.Sprintf("%v", f) + "," + } + repeatedStringForTolerations += "}" + repeatedStringForImagePullSecrets := "[]LocalObjectReference{" + for _, f := range this.ImagePullSecrets { + repeatedStringForImagePullSecrets += fmt.Sprintf("%v", f) + "," + } + repeatedStringForImagePullSecrets += "}" + keysForNodeSelector := make([]string, 0, len(this.NodeSelector)) + for k := range this.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + mapStringForNodeSelector := "map[string]string{" + for _, k := range keysForNodeSelector { + mapStringForNodeSelector += fmt.Sprintf("%v: %v,", k, this.NodeSelector[k]) + } + mapStringForNodeSelector += "}" + s := strings.Join([]string{`&JetStreamBus{`, + `Version:` + fmt.Sprintf("%v", this.Version) + `,`, + `Replicas:` + valueToStringGenerated(this.Replicas) + `,`, + `ContainerTemplate:` + strings.Replace(this.ContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, + `ReloaderContainerTemplate:` + strings.Replace(this.ReloaderContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, + `MetricsContainerTemplate:` + strings.Replace(this.MetricsContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, + `Persistence:` + strings.Replace(this.Persistence.String(), "PersistenceStrategy", "PersistenceStrategy", 1) + `,`, + `Metadata:` + strings.Replace(fmt.Sprintf("%v", this.Metadata), "Metadata", "common.Metadata", 1) + `,`, + `NodeSelector:` + mapStringForNodeSelector + `,`, + `Tolerations:` + repeatedStringForTolerations + `,`, + `SecurityContext:` + strings.Replace(fmt.Sprintf("%v", this.SecurityContext), "PodSecurityContext", "v1.PodSecurityContext", 1) + `,`, + `ImagePullSecrets:` + repeatedStringForImagePullSecrets + `,`, + `PriorityClassName:` + fmt.Sprintf("%v", this.PriorityClassName) + `,`, + `Priority:` + valueToStringGenerated(this.Priority) + `,`, + `Affinity:` + strings.Replace(fmt.Sprintf("%v", this.Affinity), "Affinity", "v1.Affinity", 1) + `,`, + `ServiceAccountName:` + fmt.Sprintf("%v", this.ServiceAccountName) + `,`, + `Settings:` + valueToStringGenerated(this.Settings) + `,`, + `}`, + }, "") + return s +} +func (this *JetStreamConfig) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&JetStreamConfig{`, + `URL:` + fmt.Sprintf("%v", this.URL) + `,`, + `Auth:` + strings.Replace(this.Auth.String(), "JetStreamAuth", "JetStreamAuth", 1) + `,`, + `}`, + }, "") + return s +} +func (this *NATSBus) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&NATSBus{`, + `Native:` + strings.Replace(this.Native.String(), "NativeStrategy", "NativeStrategy", 1) + `,`, + `Exotic:` + strings.Replace(this.Exotic.String(), "NATSConfig", "NATSConfig", 1) + `,`, + `}`, + }, "") + return s +} +func (this *NATSConfig) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&NATSConfig{`, + `URL:` + fmt.Sprintf("%v", this.URL) + `,`, + `ClusterID:` + valueToStringGenerated(this.ClusterID) + `,`, + `Auth:` + valueToStringGenerated(this.Auth) + `,`, + `AccessSecret:` + strings.Replace(fmt.Sprintf("%v", this.AccessSecret), "SecretKeySelector", "v1.SecretKeySelector", 1) + `,`, + `}`, + }, "") + return s +} +func (this *NativeStrategy) String() string { + if this == nil { + return "nil" + } + repeatedStringForTolerations := "[]Toleration{" + for _, f := range this.Tolerations { + repeatedStringForTolerations += fmt.Sprintf("%v", f) + "," + } + repeatedStringForTolerations += "}" + repeatedStringForImagePullSecrets := "[]LocalObjectReference{" + for _, f := range this.ImagePullSecrets { + repeatedStringForImagePullSecrets += fmt.Sprintf("%v", f) + "," + } + repeatedStringForImagePullSecrets += "}" + keysForNodeSelector := make([]string, 0, len(this.NodeSelector)) + for k := range this.NodeSelector { + keysForNodeSelector = append(keysForNodeSelector, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) + mapStringForNodeSelector := "map[string]string{" + for _, k := range keysForNodeSelector { + mapStringForNodeSelector += fmt.Sprintf("%v: %v,", k, this.NodeSelector[k]) + } + mapStringForNodeSelector += "}" + s := strings.Join([]string{`&NativeStrategy{`, + `Replicas:` + fmt.Sprintf("%v", this.Replicas) + `,`, + `Auth:` + valueToStringGenerated(this.Auth) + `,`, + `Persistence:` + strings.Replace(this.Persistence.String(), "PersistenceStrategy", "PersistenceStrategy", 1) + `,`, + `ContainerTemplate:` + strings.Replace(this.ContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, + `MetricsContainerTemplate:` + strings.Replace(this.MetricsContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, + `NodeSelector:` + mapStringForNodeSelector + `,`, + `Tolerations:` + repeatedStringForTolerations + `,`, + `Metadata:` + strings.Replace(fmt.Sprintf("%v", this.Metadata), "Metadata", "common.Metadata", 1) + `,`, + `SecurityContext:` + strings.Replace(fmt.Sprintf("%v", this.SecurityContext), "PodSecurityContext", "v1.PodSecurityContext", 1) + `,`, + `MaxAge:` + valueToStringGenerated(this.MaxAge) + `,`, + `ImagePullSecrets:` + repeatedStringForImagePullSecrets + `,`, + `ServiceAccountName:` + fmt.Sprintf("%v", this.ServiceAccountName) + `,`, + `PriorityClassName:` + fmt.Sprintf("%v", this.PriorityClassName) + `,`, + `Priority:` + valueToStringGenerated(this.Priority) + `,`, + `Affinity:` + strings.Replace(fmt.Sprintf("%v", this.Affinity), "Affinity", "v1.Affinity", 1) + `,`, + `MaxMsgs:` + valueToStringGenerated(this.MaxMsgs) + `,`, + `MaxBytes:` + valueToStringGenerated(this.MaxBytes) + `,`, + `MaxSubs:` + valueToStringGenerated(this.MaxSubs) + `,`, + `MaxPayload:` + valueToStringGenerated(this.MaxPayload) + `,`, + `RaftHeartbeatTimeout:` + valueToStringGenerated(this.RaftHeartbeatTimeout) + `,`, + `RaftElectionTimeout:` + valueToStringGenerated(this.RaftElectionTimeout) + `,`, + `RaftLeaseTimeout:` + valueToStringGenerated(this.RaftLeaseTimeout) + `,`, + `RaftCommitTimeout:` + valueToStringGenerated(this.RaftCommitTimeout) + `,`, + `}`, + }, "") + return s +} +func (this *PersistenceStrategy) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PersistenceStrategy{`, + `StorageClassName:` + valueToStringGenerated(this.StorageClassName) + `,`, + `AccessMode:` + valueToStringGenerated(this.AccessMode) + `,`, + `VolumeSize:` + strings.Replace(fmt.Sprintf("%v", this.VolumeSize), "Quantity", "resource.Quantity", 1) + `,`, + `}`, + }, "") + return s +} +func valueToStringGenerated(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *BusConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BusConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BusConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NATS", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NATS == nil { + m.NATS = &NATSConfig{} + } + if err := m.NATS.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JetStream", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.JetStream == nil { + m.JetStream = &JetStreamConfig{} + } + if err := m.JetStream.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ContainerTemplate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ContainerTemplate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContainerTemplate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Resources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ImagePullPolicy", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ImagePullPolicy = k8s_io_api_core_v1.PullPolicy(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityContext", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SecurityContext == nil { + m.SecurityContext = &v1.SecurityContext{} + } + if err := m.SecurityContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventBus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBusList) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventBusList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBusList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, EventBus{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF } - repeatedStringForTolerations += "}" - repeatedStringForImagePullSecrets := "[]LocalObjectReference{" - for _, f := range this.ImagePullSecrets { - repeatedStringForImagePullSecrets += fmt.Sprintf("%v", f) + "," + return nil +} +func (m *EventBusSpec) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventBusSpec: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBusSpec: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NATS", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.NATS == nil { + m.NATS = &NATSBus{} + } + if err := m.NATS.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JetStream", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.JetStream == nil { + m.JetStream = &JetStreamBus{} + } + if err := m.JetStream.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - repeatedStringForImagePullSecrets += "}" - keysForNodeSelector := make([]string, 0, len(this.NodeSelector)) - for k := range this.NodeSelector { - keysForNodeSelector = append(keysForNodeSelector, k) + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBusStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: EventBusStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBusStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - github_com_gogo_protobuf_sortkeys.Strings(keysForNodeSelector) - mapStringForNodeSelector := "map[string]string{" - for _, k := range keysForNodeSelector { - mapStringForNodeSelector += fmt.Sprintf("%v: %v,", k, this.NodeSelector[k]) + + if iNdEx > l { + return io.ErrUnexpectedEOF } - mapStringForNodeSelector += "}" - s := strings.Join([]string{`&NativeStrategy{`, - `Replicas:` + fmt.Sprintf("%v", this.Replicas) + `,`, - `Auth:` + valueToStringGenerated(this.Auth) + `,`, - `Persistence:` + strings.Replace(this.Persistence.String(), "PersistenceStrategy", "PersistenceStrategy", 1) + `,`, - `ContainerTemplate:` + strings.Replace(this.ContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, - `MetricsContainerTemplate:` + strings.Replace(this.MetricsContainerTemplate.String(), "ContainerTemplate", "ContainerTemplate", 1) + `,`, - `NodeSelector:` + mapStringForNodeSelector + `,`, - `Tolerations:` + repeatedStringForTolerations + `,`, - `Metadata:` + strings.Replace(fmt.Sprintf("%v", this.Metadata), "Metadata", "common.Metadata", 1) + `,`, - `SecurityContext:` + strings.Replace(fmt.Sprintf("%v", this.SecurityContext), "PodSecurityContext", "v1.PodSecurityContext", 1) + `,`, - `MaxAge:` + valueToStringGenerated(this.MaxAge) + `,`, - `ImagePullSecrets:` + repeatedStringForImagePullSecrets + `,`, - `ServiceAccountName:` + fmt.Sprintf("%v", this.ServiceAccountName) + `,`, - `PriorityClassName:` + fmt.Sprintf("%v", this.PriorityClassName) + `,`, - `Priority:` + valueToStringGenerated(this.Priority) + `,`, - `Affinity:` + strings.Replace(fmt.Sprintf("%v", this.Affinity), "Affinity", "v1.Affinity", 1) + `,`, - `MaxMsgs:` + valueToStringGenerated(this.MaxMsgs) + `,`, - `MaxBytes:` + valueToStringGenerated(this.MaxBytes) + `,`, - `MaxSubs:` + valueToStringGenerated(this.MaxSubs) + `,`, - `MaxPayload:` + valueToStringGenerated(this.MaxPayload) + `,`, - `RaftHeartbeatTimeout:` + valueToStringGenerated(this.RaftHeartbeatTimeout) + `,`, - `RaftElectionTimeout:` + valueToStringGenerated(this.RaftElectionTimeout) + `,`, - `RaftLeaseTimeout:` + valueToStringGenerated(this.RaftLeaseTimeout) + `,`, - `RaftCommitTimeout:` + valueToStringGenerated(this.RaftCommitTimeout) + `,`, - `}`, - }, "") - return s + return nil } -func (this *PersistenceStrategy) String() string { - if this == nil { - return "nil" +func (m *JetStreamAuth) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: JetStreamAuth: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: JetStreamAuth: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Token == nil { + m.Token = &v1.SecretKeySelector{} + } + if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - s := strings.Join([]string{`&PersistenceStrategy{`, - `StorageClassName:` + valueToStringGenerated(this.StorageClassName) + `,`, - `AccessMode:` + valueToStringGenerated(this.AccessMode) + `,`, - `VolumeSize:` + strings.Replace(fmt.Sprintf("%v", this.VolumeSize), "Quantity", "resource.Quantity", 1) + `,`, - `}`, - }, "") - return s -} -func valueToStringGenerated(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" + + if iNdEx > l { + return io.ErrUnexpectedEOF } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) + return nil } -func (m *BusConfig) Unmarshal(dAtA []byte) error { +func (m *JetStreamBus) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1561,15 +2997,67 @@ func (m *BusConfig) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BusConfig: wiretype end group for non-group") + return fmt.Errorf("proto: JetStreamBus: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BusConfig: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: JetStreamBus: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NATS", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Version = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Replicas", wireType) + } + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Replicas = &v + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContainerTemplate", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1596,66 +3084,52 @@ func (m *BusConfig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.NATS == nil { - m.NATS = &NATSConfig{} + if m.ContainerTemplate == nil { + m.ContainerTemplate = &ContainerTemplate{} } - if err := m.NATS.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ContainerTemplate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReloaderContainerTemplate", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenerated + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthGenerated } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ContainerTemplate) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.ReloaderContainerTemplate == nil { + m.ReloaderContainerTemplate = &ContainerTemplate{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ContainerTemplate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ContainerTemplate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + if err := m.ReloaderContainerTemplate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resources", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MetricsContainerTemplate", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1682,15 +3156,18 @@ func (m *ContainerTemplate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Resources.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.MetricsContainerTemplate == nil { + m.MetricsContainerTemplate = &ContainerTemplate{} + } + if err := m.MetricsContainerTemplate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ImagePullPolicy", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Persistence", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -1700,27 +3177,31 @@ func (m *ContainerTemplate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } - m.ImagePullPolicy = k8s_io_api_core_v1.PullPolicy(dAtA[iNdEx:postIndex]) + if m.Persistence == nil { + m.Persistence = &PersistenceStrategy{} + } + if err := m.Persistence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SecurityContext", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1747,66 +3228,143 @@ func (m *ContainerTemplate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.SecurityContext == nil { - m.SecurityContext = &v1.SecurityContext{} + if m.Metadata == nil { + m.Metadata = &common.Metadata{} } - if err := m.SecurityContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NodeSelector", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenerated + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthGenerated } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBus) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenerated } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.NodeSelector == nil { + m.NodeSelector = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthGenerated + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthGenerated + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthGenerated + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBus: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBus: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.NodeSelector[mapkey] = mapvalue + iNdEx = postIndex + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ObjectMeta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Tolerations", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1833,13 +3391,14 @@ func (m *EventBus) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ObjectMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Tolerations = append(m.Tolerations, v1.Toleration{}) + if err := m.Tolerations[len(m.Tolerations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Spec", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SecurityContext", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1866,13 +3425,16 @@ func (m *EventBus) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Spec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.SecurityContext == nil { + m.SecurityContext = &v1.PodSecurityContext{} + } + if err := m.SecurityContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 11: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ImagePullSecrets", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1899,63 +3461,66 @@ func (m *EventBus) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ImagePullSecrets = append(m.ImagePullSecrets, v1.LocalObjectReference{}) + if err := m.ImagePullSecrets[len(m.ImagePullSecrets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriorityClassName", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenerated + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBusList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenerated } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.PriorityClassName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Priority", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBusList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBusList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Priority = &v + case 14: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Affinity", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1982,15 +3547,18 @@ func (m *EventBusList) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Affinity == nil { + m.Affinity = &v1.Affinity{} + } + if err := m.Affinity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: + case 15: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceAccountName", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -2000,81 +3568,29 @@ func (m *EventBusList) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } - m.Items = append(m.Items, EventBus{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ServiceAccountName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventBusSpec) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventBusSpec: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventBusSpec: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 16: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NATS", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Settings", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -2084,27 +3600,24 @@ func (m *EventBusSpec) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } - if m.NATS == nil { - m.NATS = &NATSBus{} - } - if err := m.NATS.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + s := string(dAtA[iNdEx:postIndex]) + m.Settings = &s iNdEx = postIndex default: iNdEx = preIndex @@ -2127,7 +3640,7 @@ func (m *EventBusSpec) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventBusStatus) Unmarshal(dAtA []byte) error { +func (m *JetStreamConfig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2150,17 +3663,17 @@ func (m *EventBusStatus) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventBusStatus: wiretype end group for non-group") + return fmt.Errorf("proto: JetStreamConfig: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventBusStatus: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: JetStreamConfig: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field URL", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated @@ -2170,28 +3683,27 @@ func (m *EventBusStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenerated } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.URL = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Auth", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2218,7 +3730,10 @@ func (m *EventBusStatus) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Auth == nil { + m.Auth = &JetStreamAuth{} + } + if err := m.Auth.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/pkg/apis/eventbus/v1alpha1/generated.proto b/pkg/apis/eventbus/v1alpha1/generated.proto index 170104d960..f6b0b56e06 100644 --- a/pkg/apis/eventbus/v1alpha1/generated.proto +++ b/pkg/apis/eventbus/v1alpha1/generated.proto @@ -32,7 +32,11 @@ option go_package = "v1alpha1"; // BusConfig has the finalized configuration for EventBus message BusConfig { + // +optional optional NATSConfig nats = 1; + + // +optional + optional JetStreamConfig jetstream = 2; } // ContainerTemplate defines customized spec for a container @@ -70,7 +74,11 @@ message EventBusList { // EventBusSpec refers to specification of eventbus resource message EventBusSpec { // NATS eventbus + // +optional optional NATSBus nats = 1; + + // +optional + optional JetStreamBus jetstream = 2; } // EventBusStatus holds the status of the eventbus resource @@ -81,6 +89,105 @@ message EventBusStatus { optional BusConfig config = 2; } +message JetStreamAuth { + // Secret for auth token + // +optional + optional k8s.io.api.core.v1.SecretKeySelector token = 1; +} + +// JetStreamBus holds the JetStream EventBus information +message JetStreamBus { + // JetStream version, such as "2.7.3" + optional string version = 1; + + // Redis StatefulSet size + // +kubebuilder:default=3 + optional int32 replicas = 2; + + // ContainerTemplate contains customized spec for Nats JetStream container + // +optional + optional ContainerTemplate containerTemplate = 3; + + // ReloaderContainerTemplate contains customized spec for config reloader container + // +optional + optional ContainerTemplate reloaderContainerTemplate = 4; + + // MetricsContainerTemplate contains customized spec for metrics container + // +optional + optional ContainerTemplate metricsContainerTemplate = 5; + + // +optional + optional PersistenceStrategy persistence = 6; + + // Metadata sets the pods's metadata, i.e. annotations and labels + optional github.com.argoproj.argo_events.pkg.apis.common.Metadata metadata = 7; + + // NodeSelector is a selector which must be true for the pod to fit on a node. + // Selector which must match a node's labels for the pod to be scheduled on that node. + // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + // +optional + map nodeSelector = 8; + + // If specified, the pod's tolerations. + // +optional + repeated k8s.io.api.core.v1.Toleration tolerations = 9; + + // SecurityContext holds pod-level security attributes and common container settings. + // Optional: Defaults to empty. See type description for default values of each field. + // +optional + optional k8s.io.api.core.v1.PodSecurityContext securityContext = 10; + + // ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. + // If specified, these secrets will be passed to individual puller implementations for them to use. For example, + // in the case of docker, only DockerConfig type secrets are honored. + // More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod + // +optional + // +patchMergeKey=name + // +patchStrategy=merge + repeated k8s.io.api.core.v1.LocalObjectReference imagePullSecrets = 11; + + // If specified, indicates the Redis pod's priority. "system-node-critical" + // and "system-cluster-critical" are two special keywords which indicate the + // highest priorities with the former being the highest priority. Any other + // name must be defined by creating a PriorityClass object with that name. + // If not specified, the pod priority will be default or zero if there is no + // default. + // More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ + // +optional + optional string priorityClassName = 12; + + // The priority value. Various system components use this field to find the + // priority of the Redis pod. When Priority Admission Controller is enabled, + // it prevents users from setting this field. The admission controller populates + // this field from PriorityClassName. + // The higher the value, the higher the priority. + // More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ + // +optional + optional int32 priority = 13; + + // The pod's scheduling constraints + // More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ + // +optional + optional k8s.io.api.core.v1.Affinity affinity = 14; + + // ServiceAccountName to apply to the StatefulSet + // +optional + optional string serviceAccountName = 15; + + // JetStream configuration, if not specified, global settings in controller-config will be used. + // See https://docs.nats.io/running-a-nats-service/configuration#jetstream. + // Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. + // +optional + optional string settings = 16; +} + +message JetStreamConfig { + // JetStream (Nats) URL + optional string url = 1; + + optional JetStreamAuth auth = 2; +} + // NATSBus holds the NATS eventbus information message NATSBus { // Native means to bring up a native NATS service diff --git a/pkg/apis/eventbus/v1alpha1/jetstream_eventbus.go b/pkg/apis/eventbus/v1alpha1/jetstream_eventbus.go new file mode 100644 index 0000000000..817a652515 --- /dev/null +++ b/pkg/apis/eventbus/v1alpha1/jetstream_eventbus.go @@ -0,0 +1,99 @@ +package v1alpha1 + +import ( + "github.com/argoproj/argo-events/pkg/apis/common" + corev1 "k8s.io/api/core/v1" +) + +// JetStreamBus holds the JetStream EventBus information +type JetStreamBus struct { + // JetStream version, such as "2.7.3" + Version string `json:"version,omitempty" protobuf:"bytes,1,opt,name=version"` + // Redis StatefulSet size + // +kubebuilder:default=3 + Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,2,opt,name=replicas"` + // ContainerTemplate contains customized spec for Nats JetStream container + // +optional + ContainerTemplate *ContainerTemplate `json:"containerTemplate,omitempty" protobuf:"bytes,3,opt,name=containerTemplate"` + // ReloaderContainerTemplate contains customized spec for config reloader container + // +optional + ReloaderContainerTemplate *ContainerTemplate `json:"reloaderContainerTemplate,omitempty" protobuf:"bytes,4,opt,name=reloaderContainerTemplate"` + // MetricsContainerTemplate contains customized spec for metrics container + // +optional + MetricsContainerTemplate *ContainerTemplate `json:"metricsContainerTemplate,omitempty" protobuf:"bytes,5,opt,name=metricsContainerTemplate"` + // +optional + Persistence *PersistenceStrategy `json:"persistence,omitempty" protobuf:"bytes,6,opt,name=persistence"` + // Metadata sets the pods's metadata, i.e. annotations and labels + Metadata *common.Metadata `json:"metadata,omitempty" protobuf:"bytes,7,opt,name=metadata"` + // NodeSelector is a selector which must be true for the pod to fit on a node. + // Selector which must match a node's labels for the pod to be scheduled on that node. + // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty" protobuf:"bytes,8,rep,name=nodeSelector"` + // If specified, the pod's tolerations. + // +optional + Tolerations []corev1.Toleration `json:"tolerations,omitempty" protobuf:"bytes,9,rep,name=tolerations"` + // SecurityContext holds pod-level security attributes and common container settings. + // Optional: Defaults to empty. See type description for default values of each field. + // +optional + SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty" protobuf:"bytes,10,opt,name=securityContext"` + // ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. + // If specified, these secrets will be passed to individual puller implementations for them to use. For example, + // in the case of docker, only DockerConfig type secrets are honored. + // More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod + // +optional + // +patchMergeKey=name + // +patchStrategy=merge + ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,11,rep,name=imagePullSecrets"` + // If specified, indicates the Redis pod's priority. "system-node-critical" + // and "system-cluster-critical" are two special keywords which indicate the + // highest priorities with the former being the highest priority. Any other + // name must be defined by creating a PriorityClass object with that name. + // If not specified, the pod priority will be default or zero if there is no + // default. + // More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ + // +optional + PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,12,opt,name=priorityClassName"` + // The priority value. Various system components use this field to find the + // priority of the Redis pod. When Priority Admission Controller is enabled, + // it prevents users from setting this field. The admission controller populates + // this field from PriorityClassName. + // The higher the value, the higher the priority. + // More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ + // +optional + Priority *int32 `json:"priority,omitempty" protobuf:"bytes,13,opt,name=priority"` + // The pod's scheduling constraints + // More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ + // +optional + Affinity *corev1.Affinity `json:"affinity,omitempty" protobuf:"bytes,14,opt,name=affinity"` + // ServiceAccountName to apply to the StatefulSet + // +optional + ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,15,opt,name=serviceAccountName"` + // JetStream configuration, if not specified, global settings in controller-config will be used. + // See https://docs.nats.io/running-a-nats-service/configuration#jetstream. + // Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. + // +optional + Settings *string `json:"settings,omitempty" protobuf:"bytes,16,opt,name=settings"` +} + +func (j JetStreamBus) GetReplicas() int { + if j.Replicas == nil { + return 3 + } + if *j.Replicas < 3 { + return 3 + } + return int(*j.Replicas) +} + +type JetStreamConfig struct { + // JetStream (Nats) URL + URL string `json:"url,omitempty" protobuf:"bytes,1,opt,name=url"` + Auth *JetStreamAuth `json:"auth,omitempty" protobuf:"bytes,2,opt,name=auth"` +} + +type JetStreamAuth struct { + // Secret for auth token + // +optional + Token *corev1.SecretKeySelector `json:"token,omitempty" protobuf:"bytes,1,opt,name=token"` +} diff --git a/pkg/apis/eventbus/v1alpha1/types.go b/pkg/apis/eventbus/v1alpha1/nats_eventbus.go similarity index 62% rename from pkg/apis/eventbus/v1alpha1/types.go rename to pkg/apis/eventbus/v1alpha1/nats_eventbus.go index fa96453286..df0fa70e61 100644 --- a/pkg/apis/eventbus/v1alpha1/types.go +++ b/pkg/apis/eventbus/v1alpha1/nats_eventbus.go @@ -1,49 +1,10 @@ package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" - apiresource "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/argoproj/argo-events/pkg/apis/common" + corev1 "k8s.io/api/core/v1" ) -// EventBus is the definition of a eventbus resource -// +genclient -// +kubebuilder:resource:singular=eventbus,shortName=eb -// +kubebuilder:subresource:status -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -type EventBus struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` - Spec EventBusSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` - // +optional - Status EventBusStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` -} - -// EventBusList is the list of eventbus resources -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type EventBusList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"` - - Items []EventBus `json:"items" protobuf:"bytes,2,rep,name=items"` -} - -// EventBusSpec refers to specification of eventbus resource -type EventBusSpec struct { - // NATS eventbus - NATS *NATSBus `json:"nats,omitempty" protobuf:"bytes,1,opt,name=nats"` -} - -// EventBusStatus holds the status of the eventbus resource -type EventBusStatus struct { - common.Status `json:",inline" protobuf:"bytes,1,opt,name=status"` - // Config holds the fininalized configuration of EventBus - Config BusConfig `json:"config,omitempty" protobuf:"bytes,2,opt,name=config"` -} - // NATSBus holds the NATS eventbus information type NATSBus struct { // Native means to bring up a native NATS service @@ -141,37 +102,11 @@ type NativeStrategy struct { RaftCommitTimeout *string `json:"raftCommitTimeout,omitempty" protobuf:"bytes,23,opt,name=raftCommitTimeout"` } -// ContainerTemplate defines customized spec for a container -type ContainerTemplate struct { - Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,1,opt,name=resources"` - ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty" protobuf:"bytes,2,opt,name=imagePullPolicy,casttype=PullPolicy"` - SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty" protobuf:"bytes,3,opt,name=securityContext"` -} - // GetReplicas return the replicas of statefulset func (in *NativeStrategy) GetReplicas() int { return int(in.Replicas) } -// PersistenceStrategy defines the strategy of persistence -type PersistenceStrategy struct { - // Name of the StorageClass required by the claim. - // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 - // +optional - StorageClassName *string `json:"storageClassName,omitempty" protobuf:"bytes,1,opt,name=storageClassName"` - // Available access modes such as ReadWriteOnce, ReadWriteMany - // https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes - // +optional - AccessMode *corev1.PersistentVolumeAccessMode `json:"accessMode,omitempty" protobuf:"bytes,2,opt,name=accessMode,casttype=k8s.io/api/core/v1.PersistentVolumeAccessMode"` - // Volume size, e.g. 10Gi - VolumeSize *apiresource.Quantity `json:"volumeSize,omitempty" protobuf:"bytes,3,opt,name=volumeSize"` -} - -// BusConfig has the finalized configuration for EventBus -type BusConfig struct { - NATS *NATSConfig `json:"nats,omitempty" protobuf:"bytes,1,opt,name=nats"` -} - // NATSConfig holds the config of NATS type NATSConfig struct { // NATS streaming url @@ -185,42 +120,3 @@ type NATSConfig struct { // +optional AccessSecret *corev1.SecretKeySelector `json:"accessSecret,omitempty" protobuf:"bytes,4,opt,name=accessSecret"` } - -const ( - // EventBusConditionDeployed has the status True when the EventBus - // has its RestfulSet/Deployment ans service created. - EventBusConditionDeployed common.ConditionType = "Deployed" - // EventBusConditionConfigured has the status True when the EventBus - // has its configuration ready. - EventBusConditionConfigured common.ConditionType = "Configured" -) - -// InitConditions sets conditions to Unknown state. -func (s *EventBusStatus) InitConditions() { - s.InitializeConditions(EventBusConditionDeployed, EventBusConditionConfigured) -} - -// MarkDeployed set the bus has been deployed. -func (s *EventBusStatus) MarkDeployed(reason, message string) { - s.MarkTrueWithReason(EventBusConditionDeployed, reason, message) -} - -// MarkDeploying set the bus is deploying -func (s *EventBusStatus) MarkDeploying(reason, message string) { - s.MarkUnknown(EventBusConditionDeployed, reason, message) -} - -// MarkDeployFailed set the bus deploy failed -func (s *EventBusStatus) MarkDeployFailed(reason, message string) { - s.MarkFalse(EventBusConditionDeployed, reason, message) -} - -// MarkConfigured set the bus configuration has been done. -func (s *EventBusStatus) MarkConfigured() { - s.MarkTrue(EventBusConditionConfigured) -} - -// MarkNotConfigured set the bus status not configured. -func (s *EventBusStatus) MarkNotConfigured(reason, message string) { - s.MarkFalse(EventBusConditionConfigured, reason, message) -} diff --git a/pkg/apis/eventbus/v1alpha1/openapi_generated.go b/pkg/apis/eventbus/v1alpha1/openapi_generated.go index 3700f11384..92242b7364 100644 --- a/pkg/apis/eventbus/v1alpha1/openapi_generated.go +++ b/pkg/apis/eventbus/v1alpha1/openapi_generated.go @@ -36,6 +36,9 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.EventBusList": schema_pkg_apis_eventbus_v1alpha1_EventBusList(ref), "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.EventBusSpec": schema_pkg_apis_eventbus_v1alpha1_EventBusSpec(ref), "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.EventBusStatus": schema_pkg_apis_eventbus_v1alpha1_EventBusStatus(ref), + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamAuth": schema_pkg_apis_eventbus_v1alpha1_JetStreamAuth(ref), + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamBus": schema_pkg_apis_eventbus_v1alpha1_JetStreamBus(ref), + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamConfig": schema_pkg_apis_eventbus_v1alpha1_JetStreamConfig(ref), "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSBus": schema_pkg_apis_eventbus_v1alpha1_NATSBus(ref), "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSConfig": schema_pkg_apis_eventbus_v1alpha1_NATSConfig(ref), "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NativeStrategy": schema_pkg_apis_eventbus_v1alpha1_NativeStrategy(ref), @@ -55,11 +58,16 @@ func schema_pkg_apis_eventbus_v1alpha1_BusConfig(ref common.ReferenceCallback) c Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSConfig"), }, }, + "jetstream": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamConfig"), + }, + }, }, }, }, Dependencies: []string{ - "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSConfig"}, + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamConfig", "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSConfig"}, } } @@ -205,11 +213,16 @@ func schema_pkg_apis_eventbus_v1alpha1_EventBusSpec(ref common.ReferenceCallback Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSBus"), }, }, + "jetstream": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamBus"), + }, + }, }, }, }, Dependencies: []string{ - "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSBus"}, + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamBus", "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.NATSBus"}, } } @@ -255,6 +268,200 @@ func schema_pkg_apis_eventbus_v1alpha1_EventBusStatus(ref common.ReferenceCallba } } +func schema_pkg_apis_eventbus_v1alpha1_JetStreamAuth(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "token": { + SchemaProps: spec.SchemaProps{ + Description: "Secret for auth token", + Ref: ref("k8s.io/api/core/v1.SecretKeySelector"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.SecretKeySelector"}, + } +} + +func schema_pkg_apis_eventbus_v1alpha1_JetStreamBus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "JetStreamBus holds the JetStream EventBus information", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "version": { + SchemaProps: spec.SchemaProps{ + Description: "JetStream version, such as \"2.7.3\"", + Type: []string{"string"}, + Format: "", + }, + }, + "replicas": { + SchemaProps: spec.SchemaProps{ + Description: "Redis StatefulSet size", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "containerTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "ContainerTemplate contains customized spec for Nats JetStream container", + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.ContainerTemplate"), + }, + }, + "reloaderContainerTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "ReloaderContainerTemplate contains customized spec for config reloader container", + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.ContainerTemplate"), + }, + }, + "metricsContainerTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "MetricsContainerTemplate contains customized spec for metrics container", + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.ContainerTemplate"), + }, + }, + "persistence": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.PersistenceStrategy"), + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Metadata sets the pods's metadata, i.e. annotations and labels", + Ref: ref("github.com/argoproj/argo-events/pkg/apis/common.Metadata"), + }, + }, + "nodeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "tolerations": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's tolerations.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + Ref: ref("k8s.io/api/core/v1.PodSecurityContext"), + }, + }, + "imagePullSecrets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + "priorityClassName": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, indicates the Redis pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + Type: []string{"string"}, + Format: "", + }, + }, + "priority": { + SchemaProps: spec.SchemaProps{ + Description: "The priority value. Various system components use this field to find the priority of the Redis pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "affinity": { + SchemaProps: spec.SchemaProps{ + Description: "The pod's scheduling constraints More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/", + Ref: ref("k8s.io/api/core/v1.Affinity"), + }, + }, + "serviceAccountName": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceAccountName to apply to the StatefulSet", + Type: []string{"string"}, + Format: "", + }, + }, + "settings": { + SchemaProps: spec.SchemaProps{ + Description: "JetStream configuration, if not specified, global settings in controller-config will be used. See https://docs.nats.io/running-a-nats-service/configuration#jetstream. Only configure \"max_memory_store\" or \"max_file_store\", do not set \"store_dir\" as it has been hardcoded.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/argoproj/argo-events/pkg/apis/common.Metadata", "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.ContainerTemplate", "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.PersistenceStrategy", "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.Toleration"}, + } +} + +func schema_pkg_apis_eventbus_v1alpha1_JetStreamConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "url": { + SchemaProps: spec.SchemaProps{ + Description: "JetStream (Nats) URL", + Type: []string{"string"}, + Format: "", + }, + }, + "auth": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamAuth"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1.JetStreamAuth"}, + } +} + func schema_pkg_apis_eventbus_v1alpha1_NATSBus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/pkg/apis/eventbus/v1alpha1/persistence_strategy.go b/pkg/apis/eventbus/v1alpha1/persistence_strategy.go new file mode 100644 index 0000000000..dd48d497cf --- /dev/null +++ b/pkg/apis/eventbus/v1alpha1/persistence_strategy.go @@ -0,0 +1,20 @@ +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + apiresource "k8s.io/apimachinery/pkg/api/resource" +) + +// PersistenceStrategy defines the strategy of persistence +type PersistenceStrategy struct { + // Name of the StorageClass required by the claim. + // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 + // +optional + StorageClassName *string `json:"storageClassName,omitempty" protobuf:"bytes,1,opt,name=storageClassName"` + // Available access modes such as ReadWriteOnce, ReadWriteMany + // https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes + // +optional + AccessMode *corev1.PersistentVolumeAccessMode `json:"accessMode,omitempty" protobuf:"bytes,2,opt,name=accessMode,casttype=k8s.io/api/core/v1.PersistentVolumeAccessMode"` + // Volume size, e.g. 10Gi + VolumeSize *apiresource.Quantity `json:"volumeSize,omitempty" protobuf:"bytes,3,opt,name=volumeSize"` +} diff --git a/pkg/apis/eventbus/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/eventbus/v1alpha1/zz_generated.deepcopy.go index cae887c48e..d576c81e43 100644 --- a/pkg/apis/eventbus/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/eventbus/v1alpha1/zz_generated.deepcopy.go @@ -35,6 +35,11 @@ func (in *BusConfig) DeepCopyInto(out *BusConfig) { *out = new(NATSConfig) (*in).DeepCopyInto(*out) } + if in.JetStream != nil { + in, out := &in.JetStream, &out.JetStream + *out = new(JetStreamConfig) + (*in).DeepCopyInto(*out) + } return } @@ -139,6 +144,11 @@ func (in *EventBusSpec) DeepCopyInto(out *EventBusSpec) { *out = new(NATSBus) (*in).DeepCopyInto(*out) } + if in.JetStream != nil { + in, out := &in.JetStream, &out.JetStream + *out = new(JetStreamBus) + (*in).DeepCopyInto(*out) + } return } @@ -170,6 +180,133 @@ func (in *EventBusStatus) DeepCopy() *EventBusStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JetStreamAuth) DeepCopyInto(out *JetStreamAuth) { + *out = *in + if in.Token != nil { + in, out := &in.Token, &out.Token + *out = new(v1.SecretKeySelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JetStreamAuth. +func (in *JetStreamAuth) DeepCopy() *JetStreamAuth { + if in == nil { + return nil + } + out := new(JetStreamAuth) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JetStreamBus) DeepCopyInto(out *JetStreamBus) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + if in.ContainerTemplate != nil { + in, out := &in.ContainerTemplate, &out.ContainerTemplate + *out = new(ContainerTemplate) + (*in).DeepCopyInto(*out) + } + if in.ReloaderContainerTemplate != nil { + in, out := &in.ReloaderContainerTemplate, &out.ReloaderContainerTemplate + *out = new(ContainerTemplate) + (*in).DeepCopyInto(*out) + } + if in.MetricsContainerTemplate != nil { + in, out := &in.MetricsContainerTemplate, &out.MetricsContainerTemplate + *out = new(ContainerTemplate) + (*in).DeepCopyInto(*out) + } + if in.Persistence != nil { + in, out := &in.Persistence, &out.Persistence + *out = new(PersistenceStrategy) + (*in).DeepCopyInto(*out) + } + if in.Metadata != nil { + in, out := &in.Metadata, &out.Metadata + *out = new(common.Metadata) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(v1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]v1.LocalObjectReference, len(*in)) + copy(*out, *in) + } + if in.Priority != nil { + in, out := &in.Priority, &out.Priority + *out = new(int32) + **out = **in + } + if in.Affinity != nil { + in, out := &in.Affinity, &out.Affinity + *out = new(v1.Affinity) + (*in).DeepCopyInto(*out) + } + if in.Settings != nil { + in, out := &in.Settings, &out.Settings + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JetStreamBus. +func (in *JetStreamBus) DeepCopy() *JetStreamBus { + if in == nil { + return nil + } + out := new(JetStreamBus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JetStreamConfig) DeepCopyInto(out *JetStreamConfig) { + *out = *in + if in.Auth != nil { + in, out := &in.Auth, &out.Auth + *out = new(JetStreamAuth) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JetStreamConfig. +func (in *JetStreamConfig) DeepCopy() *JetStreamConfig { + if in == nil { + return nil + } + out := new(JetStreamConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NATSBus) DeepCopyInto(out *NATSBus) { *out = *in