diff --git a/Makefile b/Makefile index 2bd1944bf..d6ffb2f14 100644 --- a/Makefile +++ b/Makefile @@ -654,7 +654,6 @@ copyright: ## Check copyright headers -X .tpl \ -X .txt \ -X .yaml \ - -X pkg/apis/coherence/legacy/zz_generated.deepcopy.go \ -X pkg/data/assets/ \ -X zz_generated. diff --git a/api/v1/coherence_types.go b/api/v1/coherence_types.go index 641753b14..ba4505775 100644 --- a/api/v1/coherence_types.go +++ b/api/v1/coherence_types.go @@ -2753,6 +2753,63 @@ func (in Resources) Create(kind ResourceType, name string, mgr manager.Manager, return nil } +// ----- PersistentVolumeClaim struct --------------------------------------- + +// PersistentVolumeClaim is a request for and claim to a persistent volume +// +k8s:openapi-gen=true +type PersistentVolumeClaim struct { + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + Metadata PersistentVolumeClaimObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + // Spec defines the desired characteristics of a volume requested by a pod author. + // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims + Spec corev1.PersistentVolumeClaimSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` +} + +// ToPVC converts this PersistentVolumeClaim to a k8s PersistentVolumeClaim. +func (in *PersistentVolumeClaim) ToPVC() corev1.PersistentVolumeClaim { + return corev1.PersistentVolumeClaim{ + ObjectMeta: in.Metadata.toObjectMeta(), + Spec: in.Spec, + } +} + +// ----- PersistentVolumeClaimObjectMeta struct ----------------------------- + +// PersistentVolumeClaimObjectMeta is metadata for the PersistentVolumeClaim. +// +k8s:openapi-gen=true +type PersistentVolumeClaimObjectMeta struct { + // Name must be unique within a namespace. Is required when creating resources, although + // some resources may allow a client to request the generation of an appropriate name + // automatically. Name is primarily intended for creation idempotence and configuration + // definition. + // Cannot be updated. + // More info: http://kubernetes.io/docs/user-guide/identifiers#names + Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` + + // Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. May match selectors of replication controllers + // and services. + // More info: http://kubernetes.io/docs/user-guide/labels + // +optional + Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` + + // Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + // More info: http://kubernetes.io/docs/user-guide/annotations + // +optional + Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` +} + +func (in *PersistentVolumeClaimObjectMeta) toObjectMeta() metav1.ObjectMeta { + return metav1.ObjectMeta{ + Name: in.Name, + Annotations: in.Annotations, + Labels: in.Labels, + } +} + // ----- helper methods ----------------------------------------------------- // Int32PtrToStringWithDefault converts an int32 pointer to a string using the default if the pointer is nil. diff --git a/api/v1/coherence_webhook_test.go b/api/v1/coherence_webhook_test.go index 76905da15..e7ad63894 100644 --- a/api/v1/coherence_webhook_test.go +++ b/api/v1/coherence_webhook_test.go @@ -447,7 +447,7 @@ func TestValidateVolumeClaimUpdateWhenVolumeClaimsNilAndEmpty(t *testing.T) { current := &coh.Coherence{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{}, + VolumeClaimTemplates: []coh.PersistentVolumeClaim{}, }, } @@ -466,10 +466,10 @@ func TestValidateVolumeClaimUpdateWhenVolumeClaimsAdded(t *testing.T) { current := &coh.Coherence{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ + VolumeClaimTemplates: []coh.PersistentVolumeClaim{ { - ObjectMeta: metav1.ObjectMeta{Name: "foo"}, - Spec: corev1.PersistentVolumeClaimSpec{}, + Metadata: coh.PersistentVolumeClaimObjectMeta{Name: "foo"}, + Spec: corev1.PersistentVolumeClaimSpec{}, }, }, }, @@ -495,10 +495,10 @@ func TestValidateVolumeClaimUpdateWhenVolumeClaimsRemoved(t *testing.T) { prev := &coh.Coherence{ ObjectMeta: metav1.ObjectMeta{Name: "foo"}, Spec: coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ + VolumeClaimTemplates: []coh.PersistentVolumeClaim{ { - ObjectMeta: metav1.ObjectMeta{Name: "foo"}, - Spec: corev1.PersistentVolumeClaimSpec{}, + Metadata: coh.PersistentVolumeClaimObjectMeta{Name: "foo"}, + Spec: corev1.PersistentVolumeClaimSpec{}, }, }, }, diff --git a/api/v1/coherenceresourcespec_types.go b/api/v1/coherenceresourcespec_types.go index 946a90d1b..41550c084 100644 --- a/api/v1/coherenceresourcespec_types.go +++ b/api/v1/coherenceresourcespec_types.go @@ -186,11 +186,14 @@ type CoherenceResourceSpec struct { // +optional Volumes []corev1.Volume `json:"volumes,omitempty"` // VolumeClaimTemplates defines extra PVC mappings that will be added to the Coherence Pod. - // The content of this yaml should match the normal k8s volumeClaimTemplates section of a Pod definition - // as described in https://kubernetes.io/docs/concepts/storage/persistent-volumes/ + // The content of this yaml should match the normal k8s volumeClaimTemplates section of a StatefulSet spec + // as described in https://kubernetes.io/docs/concepts/storage/persistent-volumes/ + // Every claim in this list must have at least one matching (by name) volumeMount in one + // container in the template. A claim in this list takes precedence over any volumes in the + // template, with the same name. // +listType=atomic // +optional - VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` + VolumeClaimTemplates []PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` // VolumeMounts defines extra volume mounts to map to the additional volumes or PVCs declared above // in store.volumes and store.volumeClaimTemplates // +listType=map @@ -734,7 +737,9 @@ func (in *CoherenceResourceSpec) CreateStatefulSet(deployment *Coherence) Resour // append any additional Volumes sts.Spec.Template.Spec.Volumes = append(sts.Spec.Template.Spec.Volumes, in.Volumes...) // append any additional PVCs - sts.Spec.VolumeClaimTemplates = append(sts.Spec.VolumeClaimTemplates, in.VolumeClaimTemplates...) + for _, v := range in.VolumeClaimTemplates { + sts.Spec.VolumeClaimTemplates = append(sts.Spec.VolumeClaimTemplates, v.ToPVC()) + } return Resource{ Kind: ResourceTypeStatefulSet, diff --git a/api/v1/create_statefulset_volumeclaimtemplates_test.go b/api/v1/create_statefulset_volumeclaimtemplates_test.go index 61f2e1d1b..e5072256f 100644 --- a/api/v1/create_statefulset_volumeclaimtemplates_test.go +++ b/api/v1/create_statefulset_volumeclaimtemplates_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -9,14 +9,13 @@ package v1_test import ( coh "github.com/oracle/coherence-operator/api/v1" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "testing" ) func TestCreateStatefulSetWithEmptyVolumeClaimTemplates(t *testing.T) { spec := coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{}, + VolumeClaimTemplates: []coh.PersistentVolumeClaim{}, } // Create the test deployment @@ -30,8 +29,8 @@ func TestCreateStatefulSetWithEmptyVolumeClaimTemplates(t *testing.T) { func TestCreateStatefulSetWithOneVolumeClaimTemplate(t *testing.T) { - volumeOne := corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ + volumeOne := coh.PersistentVolumeClaim{ + Metadata: coh.PersistentVolumeClaimObjectMeta{ Name: "PVCOne", }, Spec: corev1.PersistentVolumeClaimSpec{ @@ -41,14 +40,14 @@ func TestCreateStatefulSetWithOneVolumeClaimTemplate(t *testing.T) { } spec := coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{volumeOne}, + VolumeClaimTemplates: []coh.PersistentVolumeClaim{volumeOne}, } // Create the test deployment deployment := createTestDeployment(spec) // Create expected StatefulSet stsExpected := createMinimalExpectedStatefulSet(deployment) - stsExpected.Spec.VolumeClaimTemplates = append(stsExpected.Spec.VolumeClaimTemplates, volumeOne) + stsExpected.Spec.VolumeClaimTemplates = append(stsExpected.Spec.VolumeClaimTemplates, volumeOne.ToPVC()) // assert that the StatefulSet is as expected assertStatefulSetCreation(t, deployment, stsExpected) @@ -56,8 +55,8 @@ func TestCreateStatefulSetWithOneVolumeClaimTemplate(t *testing.T) { func TestCreateStatefulSetWithTwoVolumeClaimTemplates(t *testing.T) { - volumeOne := corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ + volumeOne := coh.PersistentVolumeClaim{ + Metadata: coh.PersistentVolumeClaimObjectMeta{ Name: "PVCOne", }, Spec: corev1.PersistentVolumeClaimSpec{ @@ -66,8 +65,8 @@ func TestCreateStatefulSetWithTwoVolumeClaimTemplates(t *testing.T) { }, } - volumeTwo := corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ + volumeTwo := coh.PersistentVolumeClaim{ + Metadata: coh.PersistentVolumeClaimObjectMeta{ Name: "PVCTwo", }, Spec: corev1.PersistentVolumeClaimSpec{ @@ -77,14 +76,14 @@ func TestCreateStatefulSetWithTwoVolumeClaimTemplates(t *testing.T) { } spec := coh.CoherenceResourceSpec{ - VolumeClaimTemplates: []corev1.PersistentVolumeClaim{volumeOne, volumeTwo}, + VolumeClaimTemplates: []coh.PersistentVolumeClaim{volumeOne, volumeTwo}, } // Create the test deployment deployment := createTestDeployment(spec) // Create expected StatefulSet stsExpected := createMinimalExpectedStatefulSet(deployment) - stsExpected.Spec.VolumeClaimTemplates = append(stsExpected.Spec.VolumeClaimTemplates, volumeOne, volumeTwo) + stsExpected.Spec.VolumeClaimTemplates = append(stsExpected.Spec.VolumeClaimTemplates, volumeOne.ToPVC(), volumeTwo.ToPVC()) // assert that the StatefulSet is as expected assertStatefulSetCreation(t, deployment, stsExpected) diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 06c8ce62b..2ce94c220 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -301,7 +301,7 @@ func (in *CoherenceResourceSpec) DeepCopyInto(out *CoherenceResourceSpec) { } if in.VolumeClaimTemplates != nil { in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates - *out = make([]corev1.PersistentVolumeClaim, len(*in)) + *out = make([]PersistentVolumeClaim, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1031,6 +1031,52 @@ func (in *PersistentStorageSpec) DeepCopy() *PersistentStorageSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistentVolumeClaim) DeepCopyInto(out *PersistentVolumeClaim) { + *out = *in + in.Metadata.DeepCopyInto(&out.Metadata) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistentVolumeClaim. +func (in *PersistentVolumeClaim) DeepCopy() *PersistentVolumeClaim { + if in == nil { + return nil + } + out := new(PersistentVolumeClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistentVolumeClaimObjectMeta) DeepCopyInto(out *PersistentVolumeClaimObjectMeta) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistentVolumeClaimObjectMeta. +func (in *PersistentVolumeClaimObjectMeta) DeepCopy() *PersistentVolumeClaimObjectMeta { + if in == nil { + return nil + } + out := new(PersistentVolumeClaimObjectMeta) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodDNSConfig) DeepCopyInto(out *PodDNSConfig) { *out = *in diff --git a/config/crd/bases/coherence.oracle.com_coherence.yaml b/config/crd/bases/coherence.oracle.com_coherence.yaml index 17d4a1967..14f35126b 100644 --- a/config/crd/bases/coherence.oracle.com_coherence.yaml +++ b/config/crd/bases/coherence.oracle.com_coherence.yaml @@ -10385,27 +10385,45 @@ spec: type: string volumeClaimTemplates: description: VolumeClaimTemplates defines extra PVC mappings that - will be added to the Coherence Pod. The content of this yaml should - match the normal k8s volumeClaimTemplates section of a Pod definition as - described in https://kubernetes.io/docs/concepts/storage/persistent-volumes/ + will be added to the Coherence Pod. The content of this yaml should + match the normal k8s volumeClaimTemplates section of a StatefulSet + spec as described in https://kubernetes.io/docs/concepts/storage/persistent-volumes/ + Every claim in this list must have at least one matching (by name) + volumeMount in one container in the template. A claim in this list + takes precedence over any volumes in the template, with the same + name. items: - description: PersistentVolumeClaim is a user's request for and claim - to a persistent volume + description: PersistentVolumeClaim is a request for and claim to + a persistent volume properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this - representation of an object. Servers should convert recognized - schemas to the latest internal value, and may reject unrecognized - values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource - this object represents. Servers may infer this from the endpoint - the client submits requests to. Cannot be updated. In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + description: 'Annotations is an unstructured key value map + stored with a resource that may be set by external tools + to store and retrieve arbitrary metadata. They are not + queryable and should be preserved when modifying objects. + More info: http://kubernetes.io/docs/user-guide/annotations' + type: object + labels: + additionalProperties: + type: string + description: 'Map of string keys and values that can be + used to organize and categorize (scope and select) objects. + May match selectors of replication controllers and services. + More info: http://kubernetes.io/docs/user-guide/labels' + type: object + name: + description: 'Name must be unique within a namespace. Is + required when creating resources, although some resources + may allow a client to request the generation of an appropriate + name automatically. Name is primarily intended for creation + idempotence and configuration definition. Cannot be updated. + More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string type: object spec: description: 'Spec defines the desired characteristics of a @@ -10533,69 +10551,6 @@ spec: PersistentVolume backing this claim. type: string type: object - status: - description: 'Status represents the current information/status - of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' - properties: - accessModes: - description: 'AccessModes contains the actual access modes - the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' - items: - type: string - type: array - capacity: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: Represents the actual resources of the underlying - volume. - type: object - conditions: - description: Current Condition of persistent volume claim. - If underlying persistent volume is being resized then - the Condition will be set to 'ResizeStarted'. - items: - description: PersistentVolumeClaimCondition contails details - about state of pvc - properties: - lastProbeTime: - description: Last time we probed the condition. - format: date-time - type: string - lastTransitionTime: - description: Last time the condition transitioned - from one status to another. - format: date-time - type: string - message: - description: Human-readable message indicating details - about last transition. - type: string - reason: - description: Unique, this should be a short, machine - understandable string that gives the reason for - condition's last transition. If it reports "ResizeStarted" - that means the underlying persistent volume is being - resized. - type: string - status: - type: string - type: - description: PersistentVolumeClaimConditionType is - a valid value of PersistentVolumeClaimCondition.Type - type: string - required: - - status - - type - type: object - type: array - phase: - description: Phase represents the current phase of PersistentVolumeClaim. - type: string - type: object type: object type: array x-kubernetes-list-type: atomic diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 62de72fd0..57f58d4a7 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -34,4 +34,4 @@ commonLabels: app.kubernetes.io/instance: coherence-operator-crd app.kubernetes.io/name: coherence-operator app.kubernetes.io/part-of: coherence-operator - app.kubernetes.io/version: 3.2.3 + app.kubernetes.io/version: 3.2.4 diff --git a/docs/about/04_coherence_spec.adoc b/docs/about/04_coherence_spec.adoc index d859d8728..5b9be7cde 100644 --- a/docs/about/04_coherence_spec.adoc +++ b/docs/about/04_coherence_spec.adoc @@ -44,6 +44,8 @@ TIP: This document was generated from comments in the Go structs in the pkg/api/ * <> * <> * <> +* <> +* <> * <> * <> * <> @@ -104,9 +106,7 @@ see: <> m| []<> | false m| volumeMounts | VolumeMounts defines extra volume mounts to map to the additional volumes or PVCs declared above + in store.volumes and store.volumeClaimTemplates + m| []https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#volumemount-v1-core[corev1.VolumeMount] | false m| healthPort | The port that the health check endpoint will bind to. m| *int32 | false @@ -503,6 +503,33 @@ m| volume | Volume allows the configuration of a normal k8s volume mapping for p <> +=== PersistentVolumeClaim + +PersistentVolumeClaim is a request for and claim to a persistent volume + +[cols="1,10,1,1"options="header"] +|=== +| Field | Description | Type | Required +m| metadata | Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata m| <> | false +m| spec | Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims m| https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#persistentvolumeclaimspec-v1-core[corev1.PersistentVolumeClaimSpec] | false +|=== + +<
> + +=== PersistentVolumeClaimObjectMeta + +PersistentVolumeClaimObjectMeta is metadata for the PersistentVolumeClaim. + +[cols="1,10,1,1"options="header"] +|=== +| Field | Description | Type | Required +m| name | Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names m| string | false +m| labels | Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels m| map[string]string | false +m| annotations | Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations m| map[string]string | false +|=== + +<
> + === PodDNSConfig PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy. diff --git a/pkg/apis/coherence/legacy/coherence_types.go b/pkg/apis/coherence/legacy/coherence_types.go deleted file mode 100644 index fc0d2194e..000000000 --- a/pkg/apis/coherence/legacy/coherence_types.go +++ /dev/null @@ -1,1865 +0,0 @@ -/* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -package legacy - -import ( - corev1 "k8s.io/api/core/v1" - "time" -) - -// Common Coherence API structs - -// NOTE: This file is used to generate the CRDs use by the Operator. The CRD files should not be manually edited -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// ----- constants ---------------------------------------------------------- - -const ( - // The default number of replicas that will be created for a role if no value is specified in the spec - DefaultReplicas int32 = 3 - - // The default health check port. - DefaultHealthPort int32 = 6676 - - // The defaultrole name that will be used for a role if no value is specified in the spec - DefaultRoleName = "storage" - - // The suffix appended to a cluster name to give the WKA service name - WKAServiceNameSuffix = "-wka" - - // The key of the label used to hold the Coherence cluster name - CoherenceClusterLabel string = "coherenceCluster" - - // The key of the label used to hold the Coherence role name - CoherenceRoleLabel string = "coherenceRole" - - // The key of the label used to hold the component name - CoherenceComponentLabel string = "component" - - // The key of the label used to hold the Coherence Operator version name - CoherenceOperatorVersionLabel string = "coherenceOperatorVersion" -) - -// ----- helper functions --------------------------------------------------- - -// Return a map that is two maps merged. -// If both maps are nil then nil is returned. -// Where there are duplicate keys those in m1 take precedence. -// Keys that map to "" will not be added to the merged result -func MergeMap(m1, m2 map[string]string) map[string]string { - if m1 == nil && m2 == nil { - return nil - } - - merged := make(map[string]string) - - for k, v := range m2 { - if v != "" { - merged[k] = v - } - } - - for k, v := range m1 { - if v != "" { - merged[k] = v - } else { - delete(merged, k) - } - } - - return merged -} - -// ----- ApplicationSpec struct --------------------------------------------- - -// The specification of the application deployed into the Coherence -// role members. -type ApplicationSpec struct { - // The application type to execute. - // This field would be set if using the Coherence Graal image and running a none-Java - // application. For example if the application was a Node application this field - // would be set to "node". The default is to run a plain Java application. - // +optional - Type *string `json:"type,omitempty"` - // Class is the Coherence container main class. The default value is - // com.tangosol.net.DefaultCacheServer. - // If the application type is non-Java this would be the name of the corresponding language specific - // runnable, for example if the application type is "node" the main may be a Javascript file. - // +optional - Main *string `json:"main,omitempty"` - // Args is the optional arguments to pass to the main class. - // +listType=atomic - // +optional - Args []string `json:"args,omitempty"` - // The inlined application image definition - ImageSpec `json:",inline"` - // The application folder in the custom artifacts Docker image containing - // application artifacts. - // This will effectively become the working directory of the Coherence container. - // If not set the application directory default value is "/app". - // +optional - AppDir *string `json:"appDir,omitempty"` - // The folder in the custom artifacts Docker image containing jar - // files to be added to the classpath of the Coherence container. - // If not set the lib directory default value is "/app/lib". - // +optional - LibDir *string `json:"libDir,omitempty"` - // The folder in the custom artifacts Docker image containing - // configuration files to be added to the classpath of the Coherence container. - // If not set the config directory default value is "/app/conf". - // +optional - ConfigDir *string `json:"configDir,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this ApplicationSpec struct with any nil or not set -// values set by the corresponding value in the defaults Images struct. -func (in *ApplicationSpec) DeepCopyWithDefaults(defaults *ApplicationSpec) *ApplicationSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ApplicationSpec{} - clone.ImageSpec = *in.ImageSpec.DeepCopyWithDefaults(&defaults.ImageSpec) - - if in.Type != nil { - clone.Type = in.Type - } else { - clone.Type = defaults.Type - } - - if in.Main != nil { - clone.Main = in.Main - } else { - clone.Main = defaults.Main - } - - if in.Args != nil { - clone.Args = in.Args - } else { - clone.Args = defaults.Args - } - - if in.AppDir != nil { - clone.AppDir = in.AppDir - } else { - clone.AppDir = defaults.AppDir - } - - if in.LibDir != nil { - clone.LibDir = in.LibDir - } else { - clone.LibDir = defaults.LibDir - } - - if in.ConfigDir != nil { - clone.ConfigDir = in.ConfigDir - } else { - clone.ConfigDir = defaults.ConfigDir - } - - return &clone -} - -// ----- CoherenceSpec struct ----------------------------------------------- - -// The Coherence specific configuration. -type CoherenceSpec struct { - // The Coherence images configuration. - ImageSpec `json:",inline"` - // A boolean flag indicating whether members of this role are storage enabled. - // This value will set the corresponding coherence.distributed.localstorage System property. - // If not specified the default value is true. - // This flag is also used to configure the ScalingPolicy value if a value is not specified. If the - // StorageEnabled field is not specified or is true the scaling will be safe, if StorageEnabled is - // set to false scaling will be parallel. - // +optional - StorageEnabled *bool `json:"storageEnabled,omitempty"` - // CacheConfig is the name of the cache configuration file to use - // +optional - CacheConfig *string `json:"cacheConfig,omitempty"` - // OverrideConfig is name of the Coherence operational configuration override file, - // the default is tangosol-coherence-override.xml - // +optional - OverrideConfig *string `json:"overrideConfig,omitempty"` - // The Coherence log level, default being 5 (info level). - // +optional - LogLevel *int32 `json:"logLevel,omitempty"` - // Persistence values configure the on-disc data persistence settings. - // The bool Enabled enables or disabled on disc persistence of data. - // +optional - Persistence *PersistentStorageSpec `json:"persistence,omitempty"` - // Snapshot values configure the on-disc persistence data snapshot (backup) settings. - // The bool Enabled enables or disabled a different location for - // persistence snapshot data. If set to false then snapshot files will be written - // to the same volume configured for persistence data in the Persistence section. - // +optional - Snapshot *PersistentStorageSpec `json:"snapshot,omitempty"` - // Management configures Coherence management over REST - // Note: Coherence management over REST will be available in 12.2.1.4. - // +optional - Management *PortSpecWithSSL `json:"management,omitempty"` - // Metrics configures Coherence metrics publishing - // Note: Coherence metrics publishing will be available in 12.2.1.4. - // +optional - Metrics *PortSpecWithSSL `json:"metrics,omitempty"` - // Exclude members of this role from being part of the cluster's WKA list. - ExcludeFromWKA *bool `json:"excludeFromWKA,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this CoherenceSpec struct with any nil or not set -// values set by the corresponding value in the defaults CoherenceSpec struct. -func (in *CoherenceSpec) DeepCopyWithDefaults(defaults *CoherenceSpec) *CoherenceSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := CoherenceSpec{} - clone.ImageSpec = *in.ImageSpec.DeepCopyWithDefaults(&defaults.ImageSpec) - clone.Persistence = in.Persistence.DeepCopyWithDefaults(defaults.Persistence) - clone.Snapshot = in.Snapshot.DeepCopyWithDefaults(defaults.Snapshot) - clone.Management = in.Management.DeepCopyWithDefaults(defaults.Management) - clone.Metrics = in.Metrics.DeepCopyWithDefaults(defaults.Metrics) - - if in.StorageEnabled != nil { - clone.StorageEnabled = in.StorageEnabled - } else { - clone.StorageEnabled = defaults.StorageEnabled - } - - if in.CacheConfig != nil { - clone.CacheConfig = in.CacheConfig - } else { - clone.CacheConfig = defaults.CacheConfig - } - - if in.OverrideConfig != nil { - clone.OverrideConfig = in.OverrideConfig - } else { - clone.OverrideConfig = defaults.OverrideConfig - } - - if in.LogLevel != nil { - clone.LogLevel = in.LogLevel - } else { - clone.LogLevel = defaults.LogLevel - } - - if in.ExcludeFromWKA != nil { - clone.ExcludeFromWKA = in.ExcludeFromWKA - } else { - clone.ExcludeFromWKA = defaults.ExcludeFromWKA - } - - return &clone -} - -// IsWKAMember returns true if this role is a WKA list member. -func (in *CoherenceSpec) IsWKAMember() bool { - return in != nil && (in.ExcludeFromWKA == nil || !*in.ExcludeFromWKA) -} - -// ----- JVMSpec struct ----------------------------------------------------- - -// The JVM configuration. -type JVMSpec struct { - // Args specifies the options (System properties, -XX: args etc) to pass to the JVM. - // +listType=atomic - // +optional - Args []string `json:"args,omitempty"` - // The settings for enabling debug mode in the JVM. - // +optional - Debug *JvmDebugSpec `json:"debug,omitempty"` - // If set to true Adds the -XX:+UseContainerSupport JVM option to ensure that the JVM - // respects any container resource limits. - // The default value is true - // +optional - UseContainerLimits *bool `json:"useContainerLimits,omitempty"` - // If set to true, enabled continuour flight recorder recordings. - // This will add the JVM options -XX:+UnlockCommercialFeatures -XX:+FlightRecorder - // -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=/dumps - // +optional - FlightRecorder *bool `json:"flightRecorder,omitempty"` - // Set JVM garbage collector options. - // +optional - Gc *JvmGarbageCollectorSpec `json:"gc,omitempty"` - // +optional - DiagnosticsVolume *corev1.VolumeSource `json:"diagnosticsVolume,omitempty"` - // Configure the JVM memory options. - // +optional - Memory *JvmMemorySpec `json:"memory,omitempty"` - // Configure JMX using JMXMP. - // +optional - Jmxmp *JvmJmxmpSpec `json:"jmxmp,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JVMSpec struct with any nil or not set -// values set by the corresponding value in the defaults JVMSpec struct. -func (in *JVMSpec) DeepCopyWithDefaults(defaults *JVMSpec) *JVMSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JVMSpec{} - clone.Debug = in.Debug.DeepCopyWithDefaults(defaults.Debug) - clone.Gc = in.Gc.DeepCopyWithDefaults(defaults.Gc) - clone.Memory = in.Memory.DeepCopyWithDefaults(defaults.Memory) - clone.Jmxmp = in.Jmxmp.DeepCopyWithDefaults(defaults.Jmxmp) - - if in.UseContainerLimits != nil { - clone.UseContainerLimits = in.UseContainerLimits - } else { - clone.UseContainerLimits = defaults.UseContainerLimits - } - - if in.FlightRecorder != nil { - clone.FlightRecorder = in.FlightRecorder - } else { - clone.FlightRecorder = defaults.FlightRecorder - } - - if in.DiagnosticsVolume != nil { - clone.DiagnosticsVolume = in.DiagnosticsVolume - } else { - clone.DiagnosticsVolume = defaults.DiagnosticsVolume - } - - // Merge Args - if in.Args != nil { - clone.Args = []string{} - clone.Args = append(clone.Args, defaults.Args...) - clone.Args = append(clone.Args, in.Args...) - } else if defaults.Args != nil { - clone.Args = []string{} - clone.Args = append(clone.Args, defaults.Args...) - } - - return &clone -} - -// ----- ImageSpec struct --------------------------------------------------- - -// CoherenceInternalImageSpec defines the settings for a Docker image -type ImageSpec struct { - // Docker image name. - // More info: https://kubernetes.io/docs/concepts/containers/images - // +optional - Image *string `json:"image,omitempty"` - // Image pull policy. - // One of Always, Never, IfNotPresent. - // More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - // +optional - ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"` -} - -// Ensure that the image value is set. -func (in *ImageSpec) EnsureImage(image *string) bool { - if in != nil && in.Image == nil { - in.Image = image - return true - } - return false -} - -// DeepCopyWithDefaults returns a copy of this ImageSpec struct with any nil or not set values set -// by the corresponding value in the defaults ImageSpec struct. -func (in *ImageSpec) DeepCopyWithDefaults(defaults *ImageSpec) *ImageSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ImageSpec{} - - if in.Image != nil { - clone.Image = in.Image - } else { - clone.Image = defaults.Image - } - - if in.ImagePullPolicy != nil { - clone.ImagePullPolicy = in.ImagePullPolicy - } else { - clone.ImagePullPolicy = defaults.ImagePullPolicy - } - - return &clone -} - -// ----- LoggingSpec struct ------------------------------------------------- - -// LoggingSpec defines the settings for the Coherence Pod logging -type LoggingSpec struct { - // ConfigFile allows the location of the Java util logging configuration file to be overridden. - // If this value is not set the logging.properties file embedded in this chart will be used. - // If this value is set the configuration will be located by trying the following locations in order: - // 1. If store.logging.configMapName is set then the config map will be mounted as a volume and the logging - // properties file will be located as a file location relative to the ConfigMap volume mount point. - // 2. If userArtifacts.imageName is set then using this value as a file name relative to the location of the - // configuration files directory in the user artifacts image. - // 3. Using this value as an absolute file name. - // +optional - ConfigFile *string `json:"configFile,omitempty"` - // ConfigMapName allows a config map to be mounted as a volume containing the logging - // configuration file to use. - // +optional - ConfigMapName *string `json:"configMapName,omitempty"` - // Configures whether Fluentd is enabled and the configuration - // of the Fluentd side-car container - // +optional - Fluentd *FluentdSpec `json:"fluentd,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this LoggingSpec struct with any nil or not set values set -// by the corresponding value in the defaults LoggingSpec struct. -func (in *LoggingSpec) DeepCopyWithDefaults(defaults *LoggingSpec) *LoggingSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := LoggingSpec{} - clone.Fluentd = in.Fluentd.DeepCopyWithDefaults(defaults.Fluentd) - - if in.ConfigFile != nil { - clone.ConfigFile = in.ConfigFile - } else { - clone.ConfigFile = defaults.ConfigFile - } - - if in.ConfigMapName != nil { - clone.ConfigMapName = in.ConfigMapName - } else { - clone.ConfigMapName = defaults.ConfigMapName - } - - return &clone -} - -// ----- PersistentStorageSpec struct --------------------------------------- - -// PersistenceStorageSpec defines the persistence settings for the Coherence -type PersistentStorageSpec struct { - // +optional - Enabled *bool `json:"enabled,omitempty"` - // PersistentVolumeClaim allows the configuration of a normal k8s persistent volume claim - // for persistence data. - // +optional - PersistentVolumeClaim *corev1.PersistentVolumeClaimSpec `json:"persistentVolumeClaim,omitempty"` // from k8s.io/api/core/v1 - // Volume allows the configuration of a normal k8s volume mapping - // for persistence data instead of a persistent volume claim. If a value is defined - // for store.persistence.volume then no PVC will be created and persistence data - // will instead be written to this volume. It is up to the deployer to understand - // the consequences of this and how the guarantees given when using PVCs differ - // to the storage guarantees for the particular volume type configured here. - // +optional - Volume *corev1.VolumeSource `json:"volume,omitempty"` // from k8s.io/api/core/v1 -} - -// DeepCopyWithDefaults returns a copy of this PersistentStorageSpec struct with any nil or not set values set -// by the corresponding value in the defaults PersistentStorageSpec struct. -func (in *PersistentStorageSpec) DeepCopyWithDefaults(defaults *PersistentStorageSpec) *PersistentStorageSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := PersistentStorageSpec{} - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.PersistentVolumeClaim != nil { - clone.PersistentVolumeClaim = in.PersistentVolumeClaim - } else { - clone.PersistentVolumeClaim = defaults.PersistentVolumeClaim - } - - if in.Volume != nil { - clone.Volume = in.Volume - } else { - clone.Volume = defaults.Volume - } - - return &clone -} - -// ----- SSLSpec struct ----------------------------------------------------- - -// SSLSpec defines the SSL settings for a Coherence component over REST endpoint. -type SSLSpec struct { - // Enabled is a boolean flag indicating whether enables or disables SSL on the Coherence management - // over REST endpoint, the default is false (disabled). - // +optional - Enabled *bool `json:"enabled,omitempty"` - // Secrets is the name of the k8s secrets containing the Java key stores and password files. - // This value MUST be provided if SSL is enabled on the Coherence management over REST endpoint. - // +optional - Secrets *string `json:"secrets,omitempty"` - // Keystore is the name of the Java key store file in the k8s secret to use as the SSL keystore - // when configuring component over REST to use SSL. - // +optional - KeyStore *string `json:"keyStore,omitempty"` - // KeyStorePasswordFile is the name of the file in the k8s secret containing the keystore - // password when configuring component over REST to use SSL. - // +optional - KeyStorePasswordFile *string `json:"keyStorePasswordFile,omitempty"` - // KeyStorePasswordFile is the name of the file in the k8s secret containing the key - // password when configuring component over REST to use SSL. - // +optional - KeyPasswordFile *string `json:"keyPasswordFile,omitempty"` - // KeyStoreAlgorithm is the name of the keystore algorithm for the keystore in the k8s secret - // used when configuring component over REST to use SSL. If not set the default is SunX509 - // +optional - KeyStoreAlgorithm *string `json:"keyStoreAlgorithm,omitempty"` - // KeyStoreProvider is the name of the keystore provider for the keystore in the k8s secret - // used when configuring component over REST to use SSL. - // +optional - KeyStoreProvider *string `json:"keyStoreProvider,omitempty"` - // KeyStoreType is the name of the Java keystore type for the keystore in the k8s secret used - // when configuring component over REST to use SSL. If not set the default is JKS. - // +optional - KeyStoreType *string `json:"keyStoreType,omitempty"` - // TrustStore is the name of the Java trust store file in the k8s secret to use as the SSL - // trust store when configuring component over REST to use SSL. - // +optional - TrustStore *string `json:"trustStore,omitempty"` - // TrustStorePasswordFile is the name of the file in the k8s secret containing the trust store - // password when configuring component over REST to use SSL. - // +optional - TrustStorePasswordFile *string `json:"trustStorePasswordFile,omitempty"` - // TrustStoreAlgorithm is the name of the keystore algorithm for the trust store in the k8s - // secret used when configuring component over REST to use SSL. If not set the default is SunX509. - // +optional - TrustStoreAlgorithm *string `json:"trustStoreAlgorithm,omitempty"` - // TrustStoreProvider is the name of the keystore provider for the trust store in the k8s - // secret used when configuring component over REST to use SSL. - // +optional - TrustStoreProvider *string `json:"trustStoreProvider,omitempty"` - // TrustStoreType is the name of the Java keystore type for the trust store in the k8s secret - // used when configuring component over REST to use SSL. If not set the default is JKS. - // +optional - TrustStoreType *string `json:"trustStoreType,omitempty"` - // RequireClientCert is a boolean flag indicating whether the client certificate will be - // authenticated by the server (two-way SSL) when configuring component over REST to use SSL. - // If not set the default is false - // +optional - RequireClientCert *bool `json:"requireClientCert,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this SSLSpec struct with any nil or not set values set -// by the corresponding value in the defaults SSLSpec struct. -func (in *SSLSpec) DeepCopyWithDefaults(defaults *SSLSpec) *SSLSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := SSLSpec{} - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.Secrets != nil { - clone.Secrets = in.Secrets - } else { - clone.Secrets = defaults.Secrets - } - - if in.KeyStore != nil { - clone.KeyStore = in.KeyStore - } else { - clone.KeyStore = defaults.KeyStore - } - - if in.KeyStorePasswordFile != nil { - clone.KeyStorePasswordFile = in.KeyStorePasswordFile - } else { - clone.KeyStorePasswordFile = defaults.KeyStorePasswordFile - } - - if in.KeyPasswordFile != nil { - clone.KeyPasswordFile = in.KeyPasswordFile - } else { - clone.KeyPasswordFile = defaults.KeyPasswordFile - } - - if in.KeyStoreAlgorithm != nil { - clone.KeyStoreAlgorithm = in.KeyStoreAlgorithm - } else { - clone.KeyStoreAlgorithm = defaults.KeyStoreAlgorithm - } - - if in.KeyStoreProvider != nil { - clone.KeyStoreProvider = in.KeyStoreProvider - } else { - clone.KeyStoreProvider = defaults.KeyStoreProvider - } - - if in.KeyStoreType != nil { - clone.KeyStoreType = in.KeyStoreType - } else { - clone.KeyStoreType = defaults.KeyStoreType - } - - if in.TrustStore != nil { - clone.TrustStore = in.TrustStore - } else { - clone.TrustStore = defaults.TrustStore - } - - if in.TrustStorePasswordFile != nil { - clone.TrustStorePasswordFile = in.TrustStorePasswordFile - } else { - clone.TrustStorePasswordFile = defaults.TrustStorePasswordFile - } - - if in.TrustStoreAlgorithm != nil { - clone.TrustStoreAlgorithm = in.TrustStoreAlgorithm - } else { - clone.TrustStoreAlgorithm = defaults.TrustStoreAlgorithm - } - - if in.TrustStoreProvider != nil { - clone.TrustStoreProvider = in.TrustStoreProvider - } else { - clone.TrustStoreProvider = defaults.TrustStoreProvider - } - - if in.TrustStoreType != nil { - clone.TrustStoreType = in.TrustStoreType - } else { - clone.TrustStoreType = defaults.TrustStoreType - } - - if in.RequireClientCert != nil { - clone.RequireClientCert = in.RequireClientCert - } else { - clone.RequireClientCert = defaults.RequireClientCert - } - - return &clone -} - -// ----- PortSpec struct ---------------------------------------------------- -// PortSpec defines the port settings for a Coherence component -type PortSpec struct { - // Port specifies the port used. - // +optional - Port int32 `json:"port,omitempty"` - // Protocol for container port. Must be UDP or TCP. Defaults to "TCP" - // +optional - Protocol *string `json:"protocol,omitempty"` - // Service specifies the service used to expose the port. - // +optional - Service *ServiceSpec `json:"service,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this PortSpec struct with any nil or not set values set -// by the corresponding value in the defaults PortSpec struct. -func (in *PortSpec) DeepCopyWithDefaults(defaults *PortSpec) *PortSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := PortSpec{} - - if in.Port != 0 { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.Protocol != nil { - clone.Protocol = in.Protocol - } else { - clone.Protocol = defaults.Protocol - } - - if in.Service != nil { - clone.Service = in.Service - } else { - clone.Service = defaults.Service - } - - return &clone -} - -// ----- NamedPortSpec struct ---------------------------------------------------- -// NamedPortSpec defines a named port for a Coherence component -type NamedPortSpec struct { - // Name specifies the name of th port. - // +optional - Name string `json:"name,omitempty"` - PortSpec `json:",inline"` -} - -// DeepCopyWithDefaults returns a copy of this NamedPortSpec struct with any nil or not set values set -// by the corresponding value in the defaults NamedPortSpec struct. -func (in *NamedPortSpec) DeepCopyWithDefaults(defaults *NamedPortSpec) *NamedPortSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := NamedPortSpec{} - - if in.Name != "" { - clone.Name = in.Name - } else { - clone.Name = defaults.Name - } - - if in.Port != 0 { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.Protocol != nil { - clone.Protocol = in.Protocol - } else { - clone.Protocol = defaults.Protocol - } - - if in.Service != nil { - clone.Service = in.Service.DeepCopyWithDefaults(defaults.Service) - } else { - clone.Service = defaults.Service - } - - return &clone -} - -// Merge merges two arrays of NamedPortSpec structs. -// Any NamedPortSpec instances in both arrays that share the same name will be merged, -// the field set in the primary NamedPortSpec will take precedence over those in the -// secondary NamedPortSpec. -func MergeNamedPortSpecs(primary, secondary []NamedPortSpec) []NamedPortSpec { - if primary == nil { - return secondary - } - - if secondary == nil { - return primary - } - - if len(primary) == 0 && len(secondary) == 0 { - return []NamedPortSpec{} - } - - var mr []NamedPortSpec - mr = append(mr, primary...) - - for i := range secondary { - p := secondary[i] - found := false - for i, pp := range primary { - if pp.Name == p.Name { - clone := pp.DeepCopyWithDefaults(&p) - mr[i] = *clone - found = true - break - } - } - - if !found { - mr = append(mr, p) - } - } - - return mr -} - -// ----- JvmDebugSpec struct --------------------------------------------------- - -// The JVM Debug specific configuration. -// See: -type JvmDebugSpec struct { - // Enabled is a flag to enable or disable running the JVM in debug mode. Default is disabled. - // +optional - Enabled *bool `json:"enabled,omitempty"` - // A boolean true if the target VM is to be suspended immediately before the main class is loaded; - // false otherwise. The default value is false. - // +optional - Suspend *bool `json:"suspend,omitempty"` - // Attach specifies the address of the debugger that the JVM should attempt to connect back to - // instead of listening on a port. - // +optional - Attach *string `json:"attach,omitempty"` - // The port that the debugger will listen on; the default is 5005. - // +optional - Port *int32 `json:"port,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JvmDebugSpec struct with any nil or not set values set -// by the corresponding value in the defaults JvmDebugSpec struct. -func (in *JvmDebugSpec) DeepCopyWithDefaults(defaults *JvmDebugSpec) *JvmDebugSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JvmDebugSpec{} - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.Suspend != nil { - clone.Suspend = in.Suspend - } else { - clone.Suspend = defaults.Suspend - } - - if in.Port != nil { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.Attach != nil { - clone.Attach = in.Attach - } else { - clone.Attach = defaults.Attach - } - - return &clone -} - -// ----- JVM GC struct ------------------------------------------------------ - -// Options for managing the JVM garbage collector. -type JvmGarbageCollectorSpec struct { - // The name of the JVM garbage collector to use. - // G1 - adds the -XX:+UseG1GC option - // CMS - adds the -XX:+UseConcMarkSweepGC option - // Parallel - adds the -XX:+UseParallelGC - // Default - use the JVMs default collector - // The field value is case insensitive - // If not set G1 is used. - // If set to a value other than those above then - // the default collector for the JVM will be used. - // +optional - Collector *string `json:"enabled,omitempty"` - // Args specifies the GC options to pass to the JVM. - // +optional - Args []string `json:"args,omitempty"` - // Enable the following GC logging args -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps - // -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime - // -XX:+PrintGCApplicationConcurrentTime - // Default is true - // +optional - Logging *bool `json:"logging,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JvmGarbageCollectorSpec struct with any nil or not set values set -// by the corresponding value in the defaults JvmGarbageCollectorSpec struct. -func (in *JvmGarbageCollectorSpec) DeepCopyWithDefaults(defaults *JvmGarbageCollectorSpec) *JvmGarbageCollectorSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JvmGarbageCollectorSpec{} - - if in.Collector != nil { - clone.Collector = in.Collector - } else { - clone.Collector = defaults.Collector - } - - if in.Args != nil { - clone.Args = in.Args - } else { - clone.Args = defaults.Args - } - - if in.Logging != nil { - clone.Logging = in.Logging - } else { - clone.Logging = defaults.Logging - } - - return &clone -} - -// ----- JVM MemoryGC struct ------------------------------------------------ - -// Options for managing the JVM memory. -type JvmMemorySpec struct { - // HeapSize is the min/max heap value to pass to the JVM. - // The format should be the same as that used for Java's -Xms and -Xmx JVM options. - // If not set the JVM defaults are used. - // +optional - HeapSize *string `json:"heapSize,omitempty"` - // StackSize is the stack sixe value to pass to the JVM. - // The format should be the same as that used for Java's -Xss JVM option. - // If not set the JVM defaults are used. - // +optional - StackSize *string `json:"stackSize,omitempty"` - // MetaspaceSize is the min/max metaspace size to pass to the JVM. - // This sets the -XX:MetaspaceSize and -XX:MaxMetaspaceSize=size JVM options. - // If not set the JVM defaults are used. - // +optional - MetaspaceSize *string `json:"metaspaceSize,omitempty"` - // DirectMemorySize sets the maximum total size (in bytes) of the New I/O (the java.nio package) direct-buffer - // allocations. This value sets the -XX:MaxDirectMemorySize JVM option. - // If not set the JVM defaults are used. - // +optional - DirectMemorySize *string `json:"directMemorySize,omitempty"` - // Adds the -XX:NativeMemoryTracking=mode JVM options - // where mode is on of "off", "summary" or "detail", the default is "summary" - // If not set to "off" also add -XX:+PrintNMTStatistics - // +optional - NativeMemoryTracking *string `json:"nativeMemoryTracking,omitempty"` - // Configure the JVM behaviour when an OutOfMemoryError occurs. - // +optional - OnOutOfMemory *JvmOutOfMemorySpec `json:"onOutOfMemory,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JvmMemorySpec struct with any nil or not set values set -// by the corresponding value in the defaults JvmMemorySpec struct. -func (in *JvmMemorySpec) DeepCopyWithDefaults(defaults *JvmMemorySpec) *JvmMemorySpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JvmMemorySpec{} - clone.OnOutOfMemory = in.OnOutOfMemory.DeepCopyWithDefaults(defaults.OnOutOfMemory) - - if in.HeapSize != nil { - clone.HeapSize = in.HeapSize - } else { - clone.HeapSize = defaults.HeapSize - } - - if in.StackSize != nil { - clone.StackSize = in.StackSize - } else { - clone.StackSize = defaults.StackSize - } - - if in.MetaspaceSize != nil { - clone.MetaspaceSize = in.MetaspaceSize - } else { - clone.MetaspaceSize = defaults.MetaspaceSize - } - - if in.DirectMemorySize != nil { - clone.DirectMemorySize = in.DirectMemorySize - } else { - clone.DirectMemorySize = defaults.DirectMemorySize - } - - if in.NativeMemoryTracking != nil { - clone.NativeMemoryTracking = in.NativeMemoryTracking - } else { - clone.NativeMemoryTracking = defaults.NativeMemoryTracking - } - - return &clone -} - -// ----- JVM Out Of Memory struct ------------------------------------------- - -// Options for managing the JVM behaviour when an OutOfMemoryError occurs. -type JvmOutOfMemorySpec struct { - // If set to true the JVM will exit when an OOM error occurs. - // Default is true - // +optional - Exit *bool `json:"exit,omitempty"` - // If set to true adds the -XX:+HeapDumpOnOutOfMemoryError JVM option to cause a heap dump - // to be created when an OOM error occurs. - // Default is true - // +optional - HeapDump *bool `json:"heapDump,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JvmOutOfMemorySpec struct with any nil or not set values set -// by the corresponding value in the defaults JvmOutOfMemorySpec struct. -func (in *JvmOutOfMemorySpec) DeepCopyWithDefaults(defaults *JvmOutOfMemorySpec) *JvmOutOfMemorySpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JvmOutOfMemorySpec{} - - if in.Exit != nil { - clone.Exit = in.Exit - } else { - clone.Exit = defaults.Exit - } - - if in.HeapDump != nil { - clone.HeapDump = in.HeapDump - } else { - clone.HeapDump = defaults.HeapDump - } - - return &clone -} - -// ----- JvmJmxmpSpec struct ------------------------------------------------------- - -// Options for configuring JMX using JMXMP. -type JvmJmxmpSpec struct { - // If set to true the JMXMP support will be enabled. - // Default is false - // +optional - Enabled *bool `json:"enabled,omitempty"` - // The port tht the JMXMP MBeanServer should bind to. - // If not set the default port is 9099 - // +optional - Port *int32 `json:"port,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this JvmJmxmpSpec struct with any nil or not set values set -// by the corresponding value in the defaults JvmJmxmpSpec struct. -func (in *JvmJmxmpSpec) DeepCopyWithDefaults(defaults *JvmJmxmpSpec) *JvmJmxmpSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := JvmJmxmpSpec{} - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.Port != nil { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - return &clone -} - -// ----- PortSpecWithSSL struct ---------------------------------------------------- - -// PortSpecWithSSL defines a port with SSL settings for a Coherence component -type PortSpecWithSSL struct { - // Enable or disable flag. - // +optional - Enabled *bool `json:"enabled,omitempty"` - // The port to bind to. - // +optional - Port *int32 `json:"port,omitempty"` - // SSL configures SSL settings for a Coherence component - // +optional - SSL *SSLSpec `json:"ssl,omitempty"` -} - -// IsSSLEnabled returns true if this port is SSL enabled -func (in *PortSpecWithSSL) IsSSLEnabled() bool { - if in == nil || in.SSL == nil { - return false - } - return in.SSL.Enabled != nil && *in.SSL.Enabled -} - -// DeepCopyWithDefaults returns a copy of this PortSpecWithSSL struct with any nil or not set values set -// by the corresponding value in the defaults PortSpecWithSSL struct. -func (in *PortSpecWithSSL) DeepCopyWithDefaults(defaults *PortSpecWithSSL) *PortSpecWithSSL { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := PortSpecWithSSL{} - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.Port != nil { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.SSL != nil { - clone.SSL = in.SSL - } else { - clone.SSL = defaults.SSL - } - - return &clone -} - -// ----- ServiceSpec struct ------------------------------------------------- -// ServiceSpec defines the settings for a Service -type ServiceSpec struct { - // Enabled controls whether to create the service yaml or not - // +optional - Enabled *bool `json:"enabled,omitempty"` - // An optional name to use to override the generated service name. - // +optional - Name *string `json:"name,omitempty"` - // The service port value - // +optional - Port *int32 `json:"port,omitempty"` - // Type is the K8s service type (typically ClusterIP or LoadBalancer) - // The default is "ClusterIP". - // +optional - Type *corev1.ServiceType `json:"type,omitempty"` - // LoadBalancerIP is the IP address of the load balancer - // +optional - LoadBalancerIP *string `json:"loadBalancerIP,omitempty"` - // The extra labels to add to the service. - // More info: http://kubernetes.io/docs/user-guide/labels - // +optional - Labels map[string]string `json:"labels,omitempty"` - // Annotations is free form yaml that will be added to the service annotations - // +optional - Annotations map[string]string `json:"annotations,omitempty"` - // Supports "ClientIP" and "None". Used to maintain session affinity. - // Enable client IP based session affinity. - // Must be ClientIP or None. - // Defaults to None. - // More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies - // +optional - SessionAffinity *corev1.ServiceAffinity `json:"sessionAffinity,omitempty"` - // If specified and supported by the platform, this will restrict traffic through the cloud-provider - // load-balancer will be restricted to the specified client IPs. This field will be ignored if the - // cloud-provider does not support the feature." - // More info: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/ - // +listType=atomic - // +optional - LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"` - // externalName is the external reference that kubedns or equivalent will - // return as a CNAME record for this service. No proxying will be involved. - // Must be a valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123) - // and requires Type to be ExternalName. - // +optional - ExternalName *string `json:"externalName,omitempty"` - // externalTrafficPolicy denotes if this Service desires to route external - // traffic to node-local or cluster-wide endpoints. "Local" preserves the - // client source IP and avoids a second hop for LoadBalancer and Nodeport - // type services, but risks potentially imbalanced traffic spreading. - // "Cluster" obscures the client source IP and may cause a second hop to - // another node, but should have good overall load-spreading. - // +optional - ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"` - // healthCheckNodePort specifies the healthcheck nodePort for the service. - // If not specified, HealthCheckNodePort is created by the service api - // backend with the allocated nodePort. Will use user-specified nodePort value - // if specified by the client. Only effects when Type is set to LoadBalancer - // and ExternalTrafficPolicy is set to Local. - // +optional - HealthCheckNodePort *int32 `json:"healthCheckNodePort,omitempty"` - // publishNotReadyAddresses, when set to true, indicates that DNS implementations - // must publish the notReadyAddresses of subsets for the Endpoints associated with - // the Service. The default value is false. - // The primary use case for setting this field is to use a StatefulSet's Headless Service - // to propagate SRV records for its Pods without respect to their readiness for purpose - // of peer discovery. - // +optional - PublishNotReadyAddresses *bool `json:"publishNotReadyAddresses,omitempty"` - // sessionAffinityConfig contains the configurations of session affinity. - // +optional - SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"` -} - -// Set the Type of the service. -func (in *ServiceSpec) SetServiceType(t corev1.ServiceType) { - if in != nil { - in.Type = &t - } -} - -// DeepCopyWithDefaults returns a copy of this ServiceSpec struct with any nil or not set values set -// by the corresponding value in the defaults ServiceSpec struct. -func (in *ServiceSpec) DeepCopyWithDefaults(defaults *ServiceSpec) *ServiceSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ServiceSpec{} - // Annotations are a map and are merged - clone.Annotations = MergeMap(in.Annotations, defaults.Annotations) - // Labels are a map and are merged - clone.Labels = MergeMap(in.Labels, defaults.Labels) - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.Type != nil { - clone.Type = in.Type - } else { - clone.Type = defaults.Type - } - - if in.Name != nil { - clone.Name = in.Name - } else { - clone.Name = defaults.Name - } - - if in.Port != nil { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.LoadBalancerIP != nil { - clone.LoadBalancerIP = in.LoadBalancerIP - } else { - clone.LoadBalancerIP = defaults.LoadBalancerIP - } - - if in.Port != nil { - clone.Port = in.Port - } else { - clone.Port = defaults.Port - } - - if in.SessionAffinity != nil { - clone.SessionAffinity = in.SessionAffinity - } else { - clone.SessionAffinity = defaults.SessionAffinity - } - - if in.LoadBalancerSourceRanges != nil { - clone.LoadBalancerSourceRanges = in.LoadBalancerSourceRanges - } else { - clone.LoadBalancerSourceRanges = defaults.LoadBalancerSourceRanges - } - - if in.ExternalName != nil { - clone.ExternalName = in.ExternalName - } else { - clone.ExternalName = defaults.ExternalName - } - - if in.ExternalTrafficPolicy != nil { - clone.ExternalTrafficPolicy = in.ExternalTrafficPolicy - } else { - clone.ExternalTrafficPolicy = defaults.ExternalTrafficPolicy - } - - if in.HealthCheckNodePort != nil { - clone.HealthCheckNodePort = in.HealthCheckNodePort - } else { - clone.HealthCheckNodePort = defaults.HealthCheckNodePort - } - - if in.PublishNotReadyAddresses != nil { - clone.PublishNotReadyAddresses = in.PublishNotReadyAddresses - } else { - clone.PublishNotReadyAddresses = defaults.PublishNotReadyAddresses - } - - if in.SessionAffinityConfig != nil { - clone.SessionAffinityConfig = in.SessionAffinityConfig - } else { - clone.SessionAffinityConfig = defaults.SessionAffinityConfig - } - - return &clone -} - -// ----- ScalingSpec ----------------------------------------------------- - -// The configuration to control safe scaling. -type ScalingSpec struct { - // ScalingPolicy describes how the replicas of the cluster role will be scaled. - // The default if not specified is based upon the value of the StorageEnabled field. - // If StorageEnabled field is not specified or is true the default scaling will be safe, if StorageEnabled is - // set to false the default scaling will be parallel. - // +optional - Policy *ScalingPolicy `json:"policy,omitempty"` - // The probe to use to determine whether a role is Status HA. - // If not set the default handler will be used. - // In most use-cases the default handler would suffice but in - // advanced use-cases where the application code has a different - // concept of Status HA to just checking Coherence services then - // a different handler may be specified. - // +optional - Probe *ScalingProbe `json:"probe,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this ScalingSpec struct with any nil or not set values set -// by the corresponding value in the defaults ScalingSpec struct. -func (in *ScalingSpec) DeepCopyWithDefaults(defaults *ScalingSpec) *ScalingSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ScalingSpec{} - clone.Probe = in.Probe.DeepCopyWithDefaults(defaults.Probe) - - if in.Policy != nil { - clone.Policy = in.Policy - } else { - clone.Policy = defaults.Policy - } - - return &clone -} - -// ----- Probe ---------------------------------------------------- - -// ScalingProbe is the handler that will be used to determine how to check for StatusHA in a CoherenceRole. -// StatusHA checking is primarily used during scaling of a role, a role must be in a safe Status HA state -// before scaling takes place. If StatusHA handler is disabled for a role (by specifically setting Enabled -// to false then no check will take place and a role will be assumed to be safe). -type ScalingProbe struct { - corev1.Handler `json:",inline"` - // Number of seconds after which the handler times out (only applies to http and tcp handlers). - // Defaults to 1 second. Minimum value is 1. - // +optional - TimeoutSeconds *int `json:"timeoutSeconds,omitempty"` -} - -// Returns the timeout value in seconds. -func (in *ScalingProbe) GetTimeout() time.Duration { - if in == nil || in.TimeoutSeconds == nil || *in.TimeoutSeconds <= 0 { - return time.Second - } - - return time.Second * time.Duration(*in.TimeoutSeconds) -} - -// DeepCopyWithDefaults returns a copy of this ReadinessProbeSpec struct with any nil or not set values set -// by the corresponding value in the defaults ReadinessProbeSpec struct. -func (in *ScalingProbe) DeepCopyWithDefaults(defaults *ScalingProbe) *ScalingProbe { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ScalingProbe{} - - if in.TimeoutSeconds != nil { - clone.TimeoutSeconds = in.TimeoutSeconds - } else { - clone.TimeoutSeconds = defaults.TimeoutSeconds - } - - if in.Handler.HTTPGet != nil { - clone.Handler.HTTPGet = in.Handler.HTTPGet - } else { - clone.Handler.HTTPGet = defaults.Handler.HTTPGet - } - - if in.Handler.TCPSocket != nil { - clone.Handler.TCPSocket = in.Handler.TCPSocket - } else { - clone.Handler.TCPSocket = defaults.Handler.TCPSocket - } - - if in.Handler.Exec != nil { - clone.Handler.Exec = in.Handler.Exec - } else { - clone.Handler.Exec = defaults.Handler.Exec - } - - return &clone -} - -// ----- ReadinessProbeSpec struct ------------------------------------------ - -// ReadinessProbeSpec defines the settings for the Coherence Pod readiness probe -type ReadinessProbeSpec struct { - // The action taken to determine the health of a container - ProbeHandler `json:",inline"` - // Number of seconds after the container has started before liveness probes are initiated. - // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - // +optional - InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"` - // Number of seconds after which the probe times out. - // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - // +optional - TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` - // How often (in seconds) to perform the probe. - // +optional - PeriodSeconds *int32 `json:"periodSeconds,omitempty"` - // Minimum consecutive successes for the probe to be considered successful after having failed. - // +optional - SuccessThreshold *int32 `json:"successThreshold,omitempty"` - // Minimum consecutive failures for the probe to be considered failed after having succeeded. - // +optional - FailureThreshold *int32 `json:"failureThreshold,omitempty"` -} - -type ProbeHandler struct { - // One and only one of the following should be specified. - // Exec specifies the action to take. - // +optional - Exec *corev1.ExecAction `json:"exec,omitempty"` - // HTTPGet specifies the http request to perform. - // +optional - HTTPGet *corev1.HTTPGetAction `json:"httpGet,omitempty"` - // TCPSocket specifies an action involving a TCP port. - // TCP hooks not yet supported - // +optional - TCPSocket *corev1.TCPSocketAction `json:"tcpSocket,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this ReadinessProbeSpec struct with any nil or not set values set -// by the corresponding value in the defaults ReadinessProbeSpec struct. -func (in *ReadinessProbeSpec) DeepCopyWithDefaults(defaults *ReadinessProbeSpec) *ReadinessProbeSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := ReadinessProbeSpec{} - - if in.InitialDelaySeconds != nil { - clone.InitialDelaySeconds = in.InitialDelaySeconds - } else { - clone.InitialDelaySeconds = defaults.InitialDelaySeconds - } - - if in.TimeoutSeconds != nil { - clone.TimeoutSeconds = in.TimeoutSeconds - } else { - clone.TimeoutSeconds = defaults.TimeoutSeconds - } - - if in.PeriodSeconds != nil { - clone.PeriodSeconds = in.PeriodSeconds - } else { - clone.PeriodSeconds = defaults.PeriodSeconds - } - - if in.SuccessThreshold != nil { - clone.SuccessThreshold = in.SuccessThreshold - } else { - clone.SuccessThreshold = defaults.SuccessThreshold - } - - if in.FailureThreshold != nil { - clone.FailureThreshold = in.FailureThreshold - } else { - clone.FailureThreshold = defaults.FailureThreshold - } - - return &clone -} - -// ----- FluentdSpec struct ------------------------------------------------- - -// FluentdSpec defines the settings for the fluentd image -type FluentdSpec struct { - ImageSpec `json:",inline"` - // Controls whether or not log capture via a Fluentd sidecar container to an EFK stack is enabled. - // If this flag i set to true it is expected that the coherence-monitoring-config secret exists in - // the namespace that the cluster is being deployed to. This secret is either created by the - // Coherence Operator Helm chart if it was installed with the correct parameters or it should - // have already been created manually. - Enabled *bool `json:"enabled,omitempty"` - // The Fluentd configuration file configuring source for application log. - // +optional - ConfigFile *string `json:"configFile,omitempty"` - // This value should be source.tag from fluentd.application.configFile. - // +optional - Tag *string `json:"tag,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this FluentdSpec struct with any nil or not set values set -// by the corresponding value in the defaults FluentdSpec struct. -func (in *FluentdSpec) DeepCopyWithDefaults(defaults *FluentdSpec) *FluentdSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := FluentdSpec{} - clone.ImageSpec = *in.ImageSpec.DeepCopyWithDefaults(&defaults.ImageSpec) - - if in.Enabled != nil { - clone.Enabled = in.Enabled - } else { - clone.Enabled = defaults.Enabled - } - - if in.ConfigFile != nil { - clone.ConfigFile = in.ConfigFile - } else { - clone.ConfigFile = defaults.ConfigFile - } - - if in.Tag != nil { - clone.Tag = in.Tag - } else { - clone.Tag = defaults.Tag - } - - return &clone -} - -// ----- ScalingPolicy type ------------------------------------------------- - -// ScalingPolicy describes a policy for scaling a cluster role -type ScalingPolicy string - -// Scaling policy constants -const ( - // Safe means that a role will be scaled up or down in a safe manner to ensure no data loss. - SafeScaling ScalingPolicy = "Safe" - // Parallel means that a role will be scaled up or down by adding or removing members in parallel. - // If the members of the role are storage enabled then this could cause data loss - ParallelScaling ScalingPolicy = "Parallel" - // ParallelUpSafeDown means that a role will be scaled up by adding or removing members in parallel - // but will be scaled down in a safe manner to ensure no data loss. - ParallelUpSafeDownScaling ScalingPolicy = "ParallelUpSafeDown" -) - -// ----- LocalObjectReference ----------------------------------------------- - -// LocalObjectReference contains enough information to let you locate the -// referenced object inside the same namespace. -type LocalObjectReference struct { - // Name of the referent. - // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - // +optional - Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` -} - -// ----- NetworkSpec -------------------------------------------------------- - -// NetworkSpec configures various networking and DNS settings for Pods in a role. -type NetworkSpec struct { - // Specifies the DNS parameters of a pod. Parameters specified here will be merged to the - // generated DNS configuration based on DNSPolicy. - // +optional - DNSConfig *PodDNSConfig `json:"dnsConfig,omitempty"` - // Set DNS policy for the pod. Defaults to "ClusterFirst". Valid values are 'ClusterFirstWithHostNet', - // 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy - // selected with DNSPolicy. To have DNS options set along with hostNetwork, you have to specify DNS - // policy explicitly to 'ClusterFirstWithHostNet'. - // +optional - DNSPolicy *string `json:"dnsPolicy,omitempty"` - // HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. - // This is only valid for non-hostNetwork pods. - // +listType=map - // +listMapKey=ip - // +optional - HostAliases []corev1.HostAlias `json:"hostAliases,omitempty"` - // Host networking requested for this pod. Use the host's network namespace. If this option is set, - // the ports that will be used must be specified. Default to false. - // +optional - HostNetwork *bool `json:"hostNetwork,omitempty"` - // Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value. - // +optional - Hostname *string `json:"hostname,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this NetworkSpec struct with any nil or not set values set -// by the corresponding value in the defaults NetworkSpec struct. -func (in *NetworkSpec) DeepCopyWithDefaults(defaults *NetworkSpec) *NetworkSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := NetworkSpec{} - clone.DNSConfig = in.DNSConfig.DeepCopyWithDefaults(defaults.DNSConfig) - - if in.DNSPolicy != nil { - clone.DNSPolicy = in.DNSPolicy - } else { - clone.DNSPolicy = defaults.DNSPolicy - } - - // merge HostAlias list - m := make(map[string]corev1.HostAlias) - if defaults.HostAliases != nil { - for _, h := range defaults.HostAliases { - m[h.IP] = h - } - } - if in.HostAliases != nil { - for _, h := range in.HostAliases { - m[h.IP] = h - } - } - if len(m) > 0 { - i := 0 - clone.HostAliases = make([]corev1.HostAlias, len(m)) - for _, h := range m { - clone.HostAliases[i] = h - i++ - } - } - - if in.HostNetwork != nil { - clone.HostNetwork = in.HostNetwork - } else { - clone.HostNetwork = defaults.HostNetwork - } - - if in.Hostname != nil { - clone.Hostname = in.Hostname - } else { - clone.Hostname = defaults.Hostname - } - - return &clone -} - -// ----- PodDNSConfig ------------------------------------------------------- - -// PodDNSConfig defines the DNS parameters of a pod in addition to -// those generated from DNSPolicy. -type PodDNSConfig struct { - // A list of DNS name server IP addresses. - // This will be appended to the base nameservers generated from DNSPolicy. - // Duplicated nameservers will be removed. - // +listType=atomic - // +optional - Nameservers []string `json:"nameservers,omitempty"` - // A list of DNS search domains for host-name lookup. - // This will be appended to the base search paths generated from DNSPolicy. - // Duplicated search paths will be removed. - // +listType=atomic - // +optional - Searches []string `json:"searches,omitempty"` - // A list of DNS resolver options. - // This will be merged with the base options generated from DNSPolicy. - // Duplicated entries will be removed. Resolution options given in Options - // will override those that appear in the base DNSPolicy. - // +listType=map - // +listMapKey=name - // +optional - Options []corev1.PodDNSConfigOption `json:"options,omitempty"` -} - -// DeepCopyWithDefaults returns a copy of this PodDNSConfig struct with any nil or not set values set -// by the corresponding value in the defaults PodDNSConfig struct. -func (in *PodDNSConfig) DeepCopyWithDefaults(defaults *PodDNSConfig) *PodDNSConfig { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := PodDNSConfig{} - - // merge Options list - m := make(map[string]corev1.PodDNSConfigOption) - if defaults.Options != nil { - for _, opt := range defaults.Options { - m[opt.Name] = opt - } - } - if in.Options != nil { - for _, opt := range in.Options { - m[opt.Name] = opt - } - } - if len(m) > 0 { - i := 0 - clone.Options = make([]corev1.PodDNSConfigOption, len(m)) - for _, opt := range m { - clone.Options[i] = opt - i++ - } - } - - if in.Nameservers != nil { - clone.Nameservers = []string{} - clone.Nameservers = append(clone.Nameservers, defaults.Nameservers...) - clone.Nameservers = append(clone.Nameservers, in.Nameservers...) - } else if defaults.Nameservers != nil { - clone.Nameservers = []string{} - clone.Nameservers = append(clone.Nameservers, defaults.Nameservers...) - } - - if in.Searches != nil { - clone.Searches = []string{} - clone.Searches = append(clone.Searches, defaults.Searches...) - clone.Searches = append(clone.Searches, in.Searches...) - } else if defaults.Searches != nil { - clone.Searches = []string{} - clone.Searches = append(clone.Searches, defaults.Searches...) - } - - return &clone -} - -// ----- StartQuorum -------------------------------------------------------- - -// StartQuorum defines the order that roles will be created when initially -// creating a new cluster. -type StartQuorum struct { - // The list of roles to start first. - // +optional - Role string `json:"role"` - // The number of the dependency Pods that should have been started - // before this roles will be started. - // +optional - PodCount int32 `json:"podCount,omitempty"` -} - -// ----- StartStatus -------------------------------------------------------- - -// StartQuorumStatus tracks the state of a role's start quorums. -type StartQuorumStatus struct { - // The inlined start quorum. - StartQuorum `json:",inline"` - // Whether this quorum's condition has been met - Ready bool `json:"ready"` -} diff --git a/pkg/apis/coherence/legacy/coherencecluster_types.go b/pkg/apis/coherence/legacy/coherencecluster_types.go deleted file mode 100644 index ea5a974b5..000000000 --- a/pkg/apis/coherence/legacy/coherencecluster_types.go +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -package legacy - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "time" -) - -// NOTE: This file is used to generate the CRDs use by the Operator. The CRD files should not be manually edited -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// CoherenceClusterSpec defines the desired state of CoherenceCluster -type CoherenceClusterSpec struct { - // 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 - // +listType=map - // +listMapKey=name - // +optional - ImagePullSecrets []LocalObjectReference `json:"imagePullSecrets,omitempty"` - // The name to use for the service account to use when RBAC is enabled - // The role bindings must already have been created as this chart does not create them it just - // sets the serviceAccountName value in the Pod spec. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - // Whether or not to auto-mount the Kubernetes API credentials for a service account - // +optional - AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"` - // The timeout to apply to rest requests made back to the operator from Coherence Pods. - // +optional - OperatorRequestTimeout *int32 `json:"operatorRequestTimeout,omitempty"` - // This spec is either the spec of a single role cluster or is used as the - // default values applied to roles in Roles array. - CoherenceRoleSpec `json:",inline"` - // Roles is the list of different roles in the cluster - // There must be at least one role in a cluster. - // +listType=map - // +listMapKey=role - // +optional - Roles []CoherenceRoleSpec `json:"roles,omitempty"` -} - -// CoherenceCluster is the Schema for the coherenceclusters API -// -// -// -// -type CoherenceCluster struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec CoherenceClusterSpec `json:"spec,omitempty"` - Status CoherenceClusterStatus `json:"status,omitempty"` -} - -// CoherenceClusterList contains a list of CoherenceCluster -type CoherenceClusterList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []CoherenceCluster `json:"items"` -} - -// CoherenceClusterStatus defines the observed state of CoherenceCluster -type CoherenceClusterStatus struct { - // The number of roles in this cluster - Roles int32 `json:"roles,omitempty"` - // The number of roles in this cluster in the Ready state - Ready int32 `json:"ready,omitempty"` - // The status of the roles in the cluster - // +listType=map - // +listMapKey=role - RoleStatus []ClusterRoleStatus `json:"roleStatus,omitempty"` -} - -// Set the CoherenceRoleSpec -func (in *CoherenceClusterStatus) SetRoleStatus(roleName string, ready bool, pods int32, status RoleStatus) { - found := false - - if len(in.RoleStatus) > 0 { - for index, role := range in.RoleStatus { - if role.Role == roleName { - s := in.RoleStatus[index] - s.Transition(ready, pods, status) - in.RoleStatus[index] = s - found = true - break - } - } - } - - if !found { - s := ClusterRoleStatus{Role: roleName} - s.Transition(ready, pods, status) - in.RoleStatus = append(in.RoleStatus, s) - } - - // update the ready role count - readyCount := int32(0) - for _, r := range in.RoleStatus { - if r.Ready { - readyCount++ - } - } - in.Ready = readyCount -} - -// ClusterRoleStatus defines the observed state of role within the cluster -type ClusterRoleStatus struct { - // The role name - Role string `json:"role,omitempty"` - // A flag indicating the role's ready state - Ready bool `json:"ready,omitempty"` - // The number of ready Pods. - Count int32 `json:"count,omitempty"` - // A status description - Status RoleStatus `json:"status,omitempty"` - // The status transitions for the role - // +optional - // +listType=map - // +listMapKey=status - // +patchMergeKey=type - // +patchStrategy=merge - Conditions []ClusterRoleStatusCondition `json:"conditions,omitempty"` -} - -func (in *ClusterRoleStatus) Transition(ready bool, count int32, status RoleStatus) { - in.Ready = ready - lastStatus := in.Status - in.Status = status - in.Count = count - - if lastStatus != status { - now := metav1.NewTime(time.Now()) - found := false - for index, condition := range in.Conditions { - if condition.Status == status { - condition.LastTransitionTime = now - in.Conditions[index] = condition - found = true - break - } - } - - if !found { - in.Conditions = append(in.Conditions, ClusterRoleStatusCondition{Status: status, LastTransitionTime: now}) - } - } -} - -func (in *ClusterRoleStatus) GetCondition(status RoleStatus) ClusterRoleStatusCondition { - for _, c := range in.Conditions { - if c.Status == status { - return c - } - } - return ClusterRoleStatusCondition{ - Status: status, - LastTransitionTime: metav1.Time{}, - } -} - -// ClusterRoleStatusCondition defines a specific role status condition -type ClusterRoleStatusCondition struct { - // The status description - Status RoleStatus `json:"status,omitempty"` - // Last time the condition transitioned from one status to another. - // +optional - LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` -} - -func (in *CoherenceCluster) GetWkaServiceName() string { - if in == nil { - return "" - } - return in.Name + WKAServiceNameSuffix -} - -// Obtain a map of the CoherenceRoleSpec structs in the cluster. -// These CoherenceRoleSpec instances are copies of those in this -// cluster and not references. -func (in *CoherenceCluster) GetRoles() map[string]CoherenceRoleSpec { - m := make(map[string]CoherenceRoleSpec) - if in == nil { - return m - } - - if len(in.Spec.Roles) == 0 { - spec := in.Spec.CoherenceRoleSpec - m[spec.GetRoleName()] = *spec.DeepCopy() - } else { - defaults := in.Spec.CoherenceRoleSpec - for _, role := range in.Spec.Roles { - spec := role.DeepCopyWithDefaults(&defaults) - m[spec.GetRoleName()] = *spec - } - } - - return m -} - -// Obtain the full name for a role. -func (in *CoherenceCluster) GetFullRoleName(role string) string { - if in == nil { - return role - } - return in.Name + "-" + role -} - -// Obtain the CoherenceRoleSpec for the first role spec. -// This method is useful to obtain the role from a cluster -// that only has a single role spec. -func (in *CoherenceCluster) GetFirstRole() CoherenceRoleSpec { - if in == nil { - return CoherenceRoleSpec{} - } - - if len(in.Spec.Roles) == 0 { - return in.Spec.CoherenceRoleSpec - } - return in.Spec.Roles[0] -} - -// Obtain the CoherenceRoleSpec for the specified role name -func (in *CoherenceCluster) GetRole(name string) CoherenceRoleSpec { - if len(in.Spec.Roles) > 0 { - for _, role := range in.Spec.Roles { - if role.GetRoleName() == name { - return role - } - } - } else if name == in.Spec.CoherenceRoleSpec.GetRoleName() { - return in.Spec.CoherenceRoleSpec - } - return CoherenceRoleSpec{Role: name} -} - -// Set the CoherenceRoleSpec -func (in *CoherenceCluster) SetRole(spec CoherenceRoleSpec) { - name := spec.GetRoleName() - if len(in.Spec.Roles) > 0 { - for index, role := range in.Spec.Roles { - if role.GetRoleName() == name { - in.Spec.Roles[index] = spec - break - } - } - } else if name == in.Spec.CoherenceRoleSpec.GetRoleName() { - in.Spec.CoherenceRoleSpec = spec - } -} - -// Obtain the total number of replicas across all roles in the cluster -func (in *CoherenceCluster) GetClusterSize() int { - var size = 0 - for _, role := range in.GetRoles() { - size += int(role.GetReplicas()) - } - return size -} - -// Obtain the ClusterRoleStatus for the specified role name -func (in *CoherenceCluster) GetRoleStatus(name string) ClusterRoleStatus { - if len(in.Status.RoleStatus) > 0 { - for _, role := range in.Status.RoleStatus { - if role.Role == name { - return role - } - } - } - role := ClusterRoleStatus{Role: name} - return role -} - -// Update the status for a role -func (in *CoherenceCluster) SetRoleStatus(roleName string, ready bool, pods int32, status RoleStatus) { - if in != nil { - in.Status.SetRoleStatus(roleName, ready, pods, status) - } -} diff --git a/pkg/apis/coherence/legacy/coherencerole_types.go b/pkg/apis/coherence/legacy/coherencerole_types.go deleted file mode 100644 index 96bfd6807..000000000 --- a/pkg/apis/coherence/legacy/coherencerole_types.go +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -package legacy - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// NOTE: This file is used to generate the CRDs use by the Operator. The CRD files should not be manually edited -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// CoherenceRole is the Schema for the coherenceroles API -// -// -// -// -// -// -// -// -type CoherenceRole struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec CoherenceRoleSpec `json:"spec,omitempty"` - Status CoherenceRoleStatus `json:"status,omitempty"` -} - -// CoherenceRoleList contains a list of CoherenceRole -type CoherenceRoleList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []CoherenceRole `json:"items"` -} - -// CoherenceRoleStatus defines the observed state of CoherenceRole -type CoherenceRoleStatus struct { - // The name of the cluster. - ClusterName string `json:"clusterName,omitempty"` - // The current status. - Status RoleStatus `json:"status,omitempty"` - // Replicas is the desired size of the Coherence cluster. - Replicas int32 `json:"replicas"` - // CurrentReplicas is the current size of the Coherence cluster. - CurrentReplicas int32 `json:"currentReplicas"` - // ReadyReplicas is the number of Pods created by the StatefulSet. - ReadyReplicas int32 `json:"readyReplicas"` - // label query over pods that should match the replicas count. This is same - // as the label selector but in the string format to avoid introspection - // by clients. The string will be in the same format as the query-param syntax. - // More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors - Selector string `json:"selector,omitempty"` - // The status of the start quorums for this role. - StartQuorum []StartQuorumStatus `json:"startQuorum,omitempty"` -} - -// GetCoherenceClusterName obtains the Coherence cluster name from the label for a CoherenceRole. -func (in *CoherenceRole) GetCoherenceClusterName() string { - if in == nil { - return "" - } - - if in.Labels != nil { - if name, ok := in.Labels[CoherenceClusterLabel]; ok { - return name - } - } - - l := len(in.Name) - len(in.Spec.GetRoleName()) - name := in.Name[0 : l-1] - - return name -} - -// RoleStatus is the status value for a CoherenceRoleStatus. -type RoleStatus string - -const ( - RoleStatusCreated RoleStatus = "Created" - RoleStatusReady RoleStatus = "Ready" - RoleStatusScaling RoleStatus = "Scaling" - RoleStatusRollingUpgrade RoleStatus = "RollingUpgrade" - RoleStatusFailed RoleStatus = "Failed" - RoleStatusWaiting RoleStatus = "Waiting" -) diff --git a/pkg/apis/coherence/legacy/coherencerolespec_types.go b/pkg/apis/coherence/legacy/coherencerolespec_types.go deleted file mode 100644 index 35ead4821..000000000 --- a/pkg/apis/coherence/legacy/coherencerolespec_types.go +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -package legacy - -import ( - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/util/intstr" -) - -// NOTE: This file is used to generate the CRDs use by the Operator. The CRD files should not be manually edited -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// CoherenceRoleSpec defines a role in a Coherence cluster. A role is one or -// more Pods that perform the same functionality, for example storage members. -type CoherenceRoleSpec struct { - // The name of this role. - // This value will be used to set the Coherence role property for all members of this role - // +optional - Role string `json:"role,omitempty"` - // The desired number of cluster members of this role. - // This is a pointer to distinguish between explicit zero and not specified. - // Default value is 3. - // +optional - Replicas *int32 `json:"replicas,omitempty"` - // The optional application definition - // +optional - Application *ApplicationSpec `json:"application,omitempty"` - // The optional application definition - // +optional - Coherence *CoherenceSpec `json:"coherence,omitempty"` - // The configuration for the Coherence utils image - // +optional - CoherenceUtils *ImageSpec `json:"coherenceUtils,omitempty"` - // Logging allows configuration of Coherence and java util logging. - // +optional - Logging *LoggingSpec `json:"logging,omitempty"` - // The JVM specific options - // +optional - JVM *JVMSpec `json:"jvm,omitempty"` - // Ports specifies additional port mappings for the Pod and additional Services for those ports - // +listType=map - // +listMapKey=name - // +optional - Ports []NamedPortSpec `json:"ports,omitempty"` - // Env is additional environment variable mappings that will be passed to - // the Coherence container in the Pod - // To specify extra variables add them as name value pairs the same as they - // would be added to a Pod containers spec, for example these values: - // - // env: - // - name "FOO" - // value: "foo-value" - // - name: "BAR" - // value "bar-value" - // - // will add the environment variable mappings FOO="foo-value" and BAR="bar-value" - // +listType=map - // +listMapKey=name - // +optional - Env []corev1.EnvVar `json:"env,omitempty"` - // The port that the health check endpoint will bind to. - // +optional - HealthPort *int32 `json:"healthPort,omitempty"` - // The readiness probe config to be used for the Pods in this role. - // ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ - // +optional - ReadinessProbe *ReadinessProbeSpec `json:"readinessProbe,omitempty"` - // The liveness probe config to be used for the Pods in this role. - // ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/ - // +optional - LivenessProbe *ReadinessProbeSpec `json:"livenessProbe,omitempty"` - // The configuration to control safe scaling. - // +optional - Scaling *ScalingSpec `json:"scaling,omitempty"` - // Resources is the optional resource requests and limits for the containers - // ref: http://kubernetes.io/docs/user-guide/compute-resources/ - // - // By default the cpu requests is set to zero and the cpu limit set to 32. This - // is because it appears that K8s defaults cpu to one and since Java 10 the JVM - // now correctly picks up cgroup cpu limits then the JVM will only see one cpu. - // By setting resources.requests.cpu=0 and resources.limits.cpu=32 it ensures that - // the JVM will see the either the number of cpus on the host if this is <= 32 or - // the JVM will see 32 cpus if the host has > 32 cpus. The limit is set to zero - // so that there is no hard-limit applied. - // - // No default memory limits are applied. - // +optional - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` - // Annotations are free-form yaml that will be added to the store release as annotations - // Any annotations should be placed BELOW this annotations: key. For example if we wanted to - // include annotations for Prometheus it would look like this: - // - // annotations: - // prometheus.io/scrape: "true" - // prometheus.io/port: "2408" - // +optional - Annotations map[string]string `json:"annotations,omitempty"` - // The extra labels to add to the all of the Pods in this roles. - // Labels here will add to or override those defined for the cluster. - // More info: http://kubernetes.io/docs/user-guide/labels - // +optional - Labels map[string]string `json:"labels,omitempty"` - // Volumes defines extra volume mappings that will be added to the Coherence Pod. - // The content of this yaml should match the normal k8s volumes section of a Pod definition - // as described in https://kubernetes.io/docs/concepts/storage/volumes/ - // +listType=map - // +listMapKey=name - // +optional - Volumes []corev1.Volume `json:"volumes,omitempty"` - // VolumeClaimTemplates defines extra PVC mappings that will be added to the Coherence Pod. - // The content of this yaml should match the normal k8s volumeClaimTemplates section of a Pod definition - // as described in https://kubernetes.io/docs/concepts/storage/persistent-volumes/ - // +listType=map - // +listMapKey=metaData.name - // +optional - VolumeClaimTemplates []corev1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty"` - // VolumeMounts defines extra volume mounts to map to the additional volumes or PVCs declared above - // in store.volumes and store.volumeClaimTemplates - // +listType=map - // +listMapKey=name - // +optional - VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"` - // Affinity controls Pod scheduling preferences. - // ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity - // +optional - Affinity *corev1.Affinity `json:"affinity,omitempty"` - // NodeSelector is the Node labels for pod assignment - // ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - // Tolerations is for nodes that have taints on them. - // Useful if you want to dedicate nodes to just run the coherence container - // For example: - // tolerations: - // - key: "key" - // operator: "Equal" - // value: "value" - // effect: "NoSchedule" - // - // ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ - // +listType=map - // +listMapKey=key - // +optional - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - // SecurityContext is the PodSecurityContext that will be added to all of the Pods in this role. - // See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - // +optional - SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"` - // Share a single process namespace between all of the containers in a pod. When this is set containers will - // be able to view and signal processes from other containers in the same pod, and the first process in each - // container will not be assigned PID 1. HostPID and ShareProcessNamespace cannot both be set. - // Optional: Default to false. - // +optional - ShareProcessNamespace *bool `json:"shareProcessNamespace,omitempty"` - // Use the host's ipc namespace. Optional: Default to false. - // +optional - HostIPC *bool `json:"hostIPC,omitempty"` - // Configure various networks and DNS settings for Pods in this rolw. - // +optional - Network *NetworkSpec `json:"network,omitempty"` - // The roles that must be started before this role can start. - // +listType=map - // +listMapKey=role - // +optional - StartQuorum []StartQuorum `json:"startQuorum,omitempty"` -} - -// Obtain the number of replicas required for a role. -// The Replicas field is a pointer and may be nil so this method will -// return either the actual Replica value or the default (DefaultReplicas const) -// if the Replicas field is nil. -func (in *CoherenceRoleSpec) GetReplicas() int32 { - if in == nil { - return 0 - } - if in.Replicas == nil { - return DefaultReplicas - } - return *in.Replicas -} - -// Set the number of replicas required for a role. -func (in *CoherenceRoleSpec) SetReplicas(replicas int32) { - if in != nil { - in.Replicas = &replicas - } -} - -// Obtain the full name for a role. -func (in *CoherenceRoleSpec) GetFullRoleName(cluster *CoherenceCluster) string { - if in == nil { - return "" - } - - return cluster.GetFullRoleName(in.GetRoleName()) -} - -// Obtain the name for a role. -// If the Role field is not set the default name is returned. -func (in *CoherenceRoleSpec) GetRoleName() string { - if in == nil { - return DefaultRoleName - } - if in.Role == "" { - return DefaultRoleName - } - return in.Role -} - -func (in *CoherenceRoleSpec) GetCoherenceImage() *string { - if in != nil && in.Coherence != nil { - return in.Coherence.Image - } - return nil -} - -// Ensure that the Coherence image is set for the role. -// This ensures that the image is fixed to either that specified in the cluster spec or to the current default -// and means that the Helm controller does not upgrade the images if the Operator is upgraded. -func (in *CoherenceRoleSpec) EnsureCoherenceImage(coherenceImage *string) bool { - if in.Coherence == nil { - in.Coherence = &CoherenceSpec{} - } - - return in.Coherence.EnsureImage(coherenceImage) -} - -func (in *CoherenceRoleSpec) GetCoherenceUtilsImage() *string { - if in != nil && in.CoherenceUtils != nil { - return in.CoherenceUtils.Image - } - return nil -} - -// Ensure that the Coherence Utils image is set for the role. -// This ensures that the image is fixed to either that specified in the cluster spec or to the current default -// and means that the Helm controller does not upgrade the images if the Operator is upgraded. -func (in *CoherenceRoleSpec) EnsureCoherenceUtilsImage(utilsImage *string) bool { - if in.CoherenceUtils == nil { - in.CoherenceUtils = &ImageSpec{} - } - - return in.CoherenceUtils.EnsureImage(utilsImage) -} - -func (in *CoherenceRoleSpec) GetEffectiveScalingPolicy() ScalingPolicy { - if in == nil { - return SafeScaling - } - - var policy ScalingPolicy - - if in.Scaling == nil || in.Scaling.Policy == nil { - // the scaling policy is not set the look at the storage enabled flag - if in.Coherence == nil || in.Coherence.StorageEnabled == nil || *in.Coherence.StorageEnabled { - // storage enabled is either not set or is true so do safe scaling - policy = ParallelUpSafeDownScaling - } else { - // storage enabled is false so do parallel scaling - policy = ParallelScaling - } - } else { - // scaling policy is set so use it - policy = *in.Scaling.Policy - } - - return policy -} - -// Returns the port that the health check endpoint will bind to. -func (in *CoherenceRoleSpec) GetHealthPort() int32 { - if in == nil || in.HealthPort == nil || *in.HealthPort <= 0 { - return DefaultHealthPort - } - return *in.HealthPort -} - -// Returns the ScalingProbe to use for checking Status HA for the role. -// This method will not return nil. -func (in *CoherenceRoleSpec) GetScalingProbe() *ScalingProbe { - if in == nil || in.Scaling == nil || in.Scaling.Probe == nil { - return in.GetDefaultScalingProbe() - } - return in.Scaling.Probe -} - -// Obtain a default ScalingProbe -func (in *CoherenceRoleSpec) GetDefaultScalingProbe() *ScalingProbe { - timeout := 10 - - defaultStatusHA := ScalingProbe{ - TimeoutSeconds: &timeout, - Handler: corev1.Handler{ - HTTPGet: &corev1.HTTPGetAction{ - Path: "/ha", - Port: intstr.FromString("health"), - }, - }, - } - - return defaultStatusHA.DeepCopy() -} - -// DeepCopyWithDefaults returns a copy of this CoherenceRoleSpec with any nil or not set values set -// by the corresponding value in the defaults spec. -func (in *CoherenceRoleSpec) DeepCopyWithDefaults(defaults *CoherenceRoleSpec) *CoherenceRoleSpec { - if in == nil { - if defaults != nil { - return defaults.DeepCopy() - } - return nil - } - - if defaults == nil { - return in.DeepCopy() - } - - clone := CoherenceRoleSpec{} - - // Copy EVERY field from "in" to the clone. - // If a field is not set use the value from the default - // If the field is a struct it should implement DeepCopyWithDefaults so call that method - - // Affinity is NOT merged - if in.Affinity != nil { - clone.Affinity = in.Affinity - } else { - clone.Affinity = defaults.Affinity - } - - // Annotations are a map and are merged - clone.Annotations = MergeMap(in.Annotations, defaults.Annotations) - // Application is merged - clone.Application = in.Application.DeepCopyWithDefaults(defaults.Application) - clone.Coherence = in.Coherence.DeepCopyWithDefaults(defaults.Coherence) - clone.CoherenceUtils = in.CoherenceUtils.DeepCopyWithDefaults(defaults.CoherenceUtils) - // Environment variables are merged - clone.Env = in.mergeEnvVar(in.Env, defaults.Env) - clone.JVM = in.JVM.DeepCopyWithDefaults(defaults.JVM) - // Labels are a map and are merged - clone.Labels = MergeMap(in.Labels, defaults.Labels) - clone.Logging = in.Logging.DeepCopyWithDefaults(defaults.Logging) - // Network configuration is merged - clone.Network = in.Network.DeepCopyWithDefaults(defaults.Network) - - // The quorum is NEVER taken from defaults - clone.StartQuorum = in.StartQuorum - - // NodeSelector is a map and is NOT merged - clone.NodeSelector = MergeMap(in.NodeSelector, defaults.NodeSelector) - if in.NodeSelector != nil { - clone.NodeSelector = in.NodeSelector - } else { - clone.NodeSelector = defaults.NodeSelector - } - - // Ports are named ports in an array and are merged - if in.Ports != nil { - clone.Ports = MergeNamedPortSpecs(in.Ports, defaults.Ports) - } else { - clone.Ports = defaults.Ports - } - - // ReadinessProbe is merged - clone.ReadinessProbe = in.ReadinessProbe.DeepCopyWithDefaults(defaults.ReadinessProbe) - - // Application is NOT merged - if in.Replicas != nil { - clone.Replicas = in.Replicas - } else { - clone.Replicas = defaults.Replicas - } - - // Resources is NOT merged - if in.Resources != nil { - clone.Resources = in.Resources - } else { - clone.Resources = defaults.Resources - } - - // Role is NOT merged - if in.Role != "" { - clone.Role = in.Role - } else { - clone.Role = defaults.Role - } - - // Tolerations is an array but is NOT merged - if in.Tolerations != nil { - clone.Tolerations = make([]corev1.Toleration, len(in.Tolerations)) - for i := 0; i < len(in.Tolerations); i++ { - clone.Tolerations[i] = *in.Tolerations[i].DeepCopy() - } - } else if defaults.Tolerations != nil { - clone.Tolerations = make([]corev1.Toleration, len(defaults.Tolerations)) - for i := 0; i < len(defaults.Tolerations); i++ { - clone.Tolerations[i] = *defaults.Tolerations[i].DeepCopy() - } - } - - // SecurityContext is NOT merged - if in.SecurityContext != nil { - clone.SecurityContext = in.SecurityContext - } else { - clone.SecurityContext = defaults.SecurityContext - } - - if in.ShareProcessNamespace != nil { - clone.ShareProcessNamespace = in.ShareProcessNamespace - } else { - clone.ShareProcessNamespace = defaults.ShareProcessNamespace - } - - if in.HostIPC != nil { - clone.HostIPC = in.HostIPC - } else { - clone.HostIPC = defaults.HostIPC - } - - // VolumeClaimTemplates is an array of named PersistentVolumeClaims and is merged - clone.VolumeClaimTemplates = in.mergePersistentVolumeClaims(in.VolumeClaimTemplates, defaults.VolumeClaimTemplates) - // VolumeMounts is an array of named VolumeMounts and is merged - clone.VolumeMounts = in.mergeVolumeMounts(in.VolumeMounts, defaults.VolumeMounts) - // Volumes is an array of named VolumeMounts and is merged - clone.Volumes = in.mergeVolumes(in.Volumes, defaults.Volumes) - - return &clone -} - -func (in *CoherenceRoleSpec) mergeEnvVar(primary, secondary []corev1.EnvVar) []corev1.EnvVar { - if primary == nil { - return secondary - } - - if secondary == nil { - return primary - } - - if len(primary) == 0 && len(secondary) == 0 { - return []corev1.EnvVar{} - } - - var merged []corev1.EnvVar - merged = append(merged, primary...) - - for _, p := range secondary { - found := false - for _, pp := range primary { - if pp.Name == p.Name { - found = true - break - } - } - - if !found { - merged = append(merged, p) - } - } - - return merged -} - -func (in *CoherenceRoleSpec) mergePersistentVolumeClaims(primary, secondary []corev1.PersistentVolumeClaim) []corev1.PersistentVolumeClaim { - if primary == nil { - return secondary - } - - if secondary == nil { - return primary - } - - if len(primary) == 0 && len(secondary) == 0 { - return []corev1.PersistentVolumeClaim{} - } - - var merged []corev1.PersistentVolumeClaim - merged = append(merged, primary...) - - for _, p := range secondary { - found := false - for _, pp := range primary { - if pp.Name == p.Name { - found = true - break - } - } - - if !found { - merged = append(merged, p) - } - } - - return merged -} - -func (in *CoherenceRoleSpec) mergeVolumeMounts(primary, secondary []corev1.VolumeMount) []corev1.VolumeMount { - if primary == nil { - return secondary - } - - if secondary == nil { - return primary - } - - if len(primary) == 0 && len(secondary) == 0 { - return []corev1.VolumeMount{} - } - - var merged []corev1.VolumeMount - merged = append(merged, primary...) - - for _, p := range secondary { - found := false - for _, pp := range primary { - if pp.Name == p.Name { - found = true - break - } - } - - if !found { - merged = append(merged, p) - } - } - - return merged -} - -func (in *CoherenceRoleSpec) mergeVolumes(primary, secondary []corev1.Volume) []corev1.Volume { - if primary == nil { - return secondary - } - - if secondary == nil { - return primary - } - - if len(primary) == 0 && len(secondary) == 0 { - return []corev1.Volume{} - } - - var merged []corev1.Volume - merged = append(merged, primary...) - - for _, p := range secondary { - found := false - for _, pp := range primary { - if pp.Name == p.Name { - found = true - break - } - } - - if !found { - merged = append(merged, p) - } - } - - return merged -} diff --git a/pkg/apis/coherence/legacy/converter.go b/pkg/apis/coherence/legacy/converter.go deleted file mode 100644 index 65d0acee6..000000000 --- a/pkg/apis/coherence/legacy/converter.go +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright (c) 2020 Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -package legacy - -import ( - "fmt" - v1 "github.com/oracle/coherence-operator/api/v1" - "github.com/pkg/errors" - "io" - "io/ioutil" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/yaml" - "k8s.io/utils/pointer" - "os" - y2 "sigs.k8s.io/yaml" - "strings" -) - -func Convert(fileName string, out io.Writer) error { - _, err := os.Stat(fileName) - if err != nil { - return err - } - - data, err := ioutil.ReadFile(fileName) - if err != nil { - return errors.Wrap(err, "Failed to read file "+fileName) - } - - cc := &CoherenceCluster{} - decoder := yaml.NewYAMLToJSONDecoder(strings.NewReader(string(data))) - err = decoder.Decode(cc) - if err != nil { - return errors.Wrap(err, "Failed to parse CoherenceCluster from file "+fileName) - } - - roles := cc.GetRoles() - sep := false - for i := range roles { - role := roles[i] - if sep { - _, err = fmt.Fprintln(out, "---") - if err != nil { - return err - } - } else { - sep = true - } - - c, err := convertRole(&role, cc) - if err != nil { - return err - } - bytes, err := y2.Marshal(c) - if err != nil { - return err - } - - fmt.Print(string(bytes)) - } - - return nil -} - -func convertRole(r *CoherenceRoleSpec, cc *CoherenceCluster) (*v1.Coherence, error) { - clusterName := cc.Name - c := &v1.Coherence{ - TypeMeta: metav1.TypeMeta{ - Kind: "Coherence", - APIVersion: "coherence.oracle.com/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: r.GetFullRoleName(cc), - Namespace: cc.Namespace, - Labels: cc.Labels, - Annotations: cc.Annotations, - }, - Spec: v1.CoherenceResourceSpec{ - Image: doImage(r), - ImagePullPolicy: doImagePullPolicy(r), - ImagePullSecrets: doPullSecrets(cc), - Replicas: r.Replicas, - Cluster: &clusterName, - Role: r.GetRoleName(), - Coherence: doCoherence(r), - Application: doApplication(r), - JVM: doJVM(r), - Ports: doPorts(r), - Scaling: doScaling(r), - StartQuorum: doStartQuorum(r, cc), - Env: r.Env, - Labels: r.Labels, - Annotations: r.Annotations, - Volumes: r.Volumes, - VolumeClaimTemplates: r.VolumeClaimTemplates, - VolumeMounts: r.VolumeMounts, - HealthPort: r.HealthPort, - ReadinessProbe: doReadiness(r), - LivenessProbe: doLiveness(r), - Resources: r.Resources, - Affinity: r.Affinity, - NodeSelector: r.NodeSelector, - Tolerations: r.Tolerations, - SecurityContext: r.SecurityContext, - ShareProcessNamespace: r.ShareProcessNamespace, - HostIPC: r.HostIPC, - Network: doNetwork(r), - ServiceAccountName: cc.Spec.ServiceAccountName, - AutomountServiceAccountToken: cc.Spec.AutomountServiceAccountToken, - OperatorRequestTimeout: cc.Spec.OperatorRequestTimeout, - InitContainers: nil, - SideCars: nil, - ConfigMapVolumes: nil, - SecretVolumes: nil, - CoherenceUtils: nil, - }, - } - - return c, nil -} - -func doCoherence(r *CoherenceRoleSpec) *v1.CoherenceSpec { - if r.Coherence == nil { - return nil - } - - return &v1.CoherenceSpec{ - CacheConfig: r.Coherence.CacheConfig, - OverrideConfig: r.Coherence.OverrideConfig, - StorageEnabled: r.Coherence.StorageEnabled, - LogLevel: r.Coherence.LogLevel, - ExcludeFromWKA: r.Coherence.ExcludeFromWKA, - Persistence: doPersistence(r.Coherence.Persistence, r.Coherence.Snapshot), - Management: doPortSpecWithSSL(r.Coherence.Management), - Metrics: doPortSpecWithSSL(r.Coherence.Metrics), - } -} - -func doPersistence(p *PersistentStorageSpec, s *PersistentStorageSpec) *v1.PersistenceSpec { - if p == nil && s == nil { - return nil - } - - spec := &v1.PersistenceSpec{} - - if p != nil { - if p.Enabled != nil && *p.Enabled { - spec.Mode = pointer.StringPtr("active") - } - spec.PersistentVolumeClaim = p.PersistentVolumeClaim - spec.Volume = p.Volume - } - - if s != nil && s.Enabled != nil && *s.Enabled { - spec.Snapshots = &v1.PersistentStorageSpec{ - PersistentVolumeClaim: s.PersistentVolumeClaim, - Volume: s.Volume, - } - } - - return spec -} - -func doPortSpecWithSSL(p *PortSpecWithSSL) *v1.PortSpecWithSSL { - if p == nil { - return nil - } - - spec := &v1.PortSpecWithSSL{ - Enabled: p.Enabled, - Port: p.Port, - } - - if p.SSL != nil { - spec.SSL = &v1.SSLSpec{ - Enabled: p.SSL.Enabled, - Secrets: p.SSL.Secrets, - KeyStore: p.SSL.KeyStore, - KeyStorePasswordFile: p.SSL.KeyStorePasswordFile, - KeyPasswordFile: p.SSL.KeyPasswordFile, - KeyStoreAlgorithm: p.SSL.KeyStoreAlgorithm, - KeyStoreProvider: p.SSL.KeyStoreProvider, - KeyStoreType: p.SSL.KeyStoreType, - TrustStore: p.SSL.TrustStore, - TrustStorePasswordFile: p.SSL.TrustStorePasswordFile, - TrustStoreAlgorithm: p.SSL.TrustStoreAlgorithm, - TrustStoreProvider: p.SSL.TrustStoreProvider, - TrustStoreType: p.SSL.TrustStoreType, - RequireClientCert: p.SSL.RequireClientCert, - } - } - - return spec -} - -func doJVM(r *CoherenceRoleSpec) *v1.JVMSpec { - if r.JVM == nil { - return nil - } - - jvm := &v1.JVMSpec{ - Args: r.JVM.Args, - UseContainerLimits: r.JVM.UseContainerLimits, - DiagnosticsVolume: r.JVM.DiagnosticsVolume, - Jmxmp: nil, - } - - if r.JVM.Memory != nil { - jvm.Memory = &v1.JvmMemorySpec{ - HeapSize: r.JVM.Memory.HeapSize, - StackSize: r.JVM.Memory.StackSize, - MetaspaceSize: r.JVM.Memory.MetaspaceSize, - DirectMemorySize: r.JVM.Memory.DirectMemorySize, - NativeMemoryTracking: r.JVM.Memory.NativeMemoryTracking, - } - - if r.JVM.Memory.OnOutOfMemory != nil { - jvm.Memory.OnOutOfMemory = &v1.JvmOutOfMemorySpec{ - Exit: r.JVM.Memory.OnOutOfMemory.Exit, - HeapDump: r.JVM.Memory.OnOutOfMemory.HeapDump, - } - } - } - - if r.JVM.Jmxmp != nil { - jvm.Jmxmp = &v1.JvmJmxmpSpec{ - Enabled: r.JVM.Jmxmp.Enabled, - Port: r.JVM.Jmxmp.Port, - } - } - - if r.JVM.Gc != nil { - jvm.Gc = &v1.JvmGarbageCollectorSpec{ - Collector: r.JVM.Gc.Collector, - Args: r.JVM.Gc.Args, - Logging: r.JVM.Gc.Logging, - } - } - - if r.JVM.Debug != nil { - jvm.Debug = &v1.JvmDebugSpec{ - Enabled: r.JVM.Debug.Enabled, - Suspend: r.JVM.Debug.Suspend, - Attach: r.JVM.Debug.Attach, - Port: r.JVM.Debug.Port, - } - } - - return jvm -} - -func doPorts(r *CoherenceRoleSpec) []v1.NamedPortSpec { - var ports []v1.NamedPortSpec - for _, port := range r.Ports { - nps := v1.NamedPortSpec{ - Name: port.Name, - Port: port.Port, - } - - if port.Protocol != nil { - p := corev1.Protocol(*port.Protocol) - nps.Protocol = &p - } - - if port.Service != nil { - nps.Service = &v1.ServiceSpec{ - Enabled: port.Service.Enabled, - Name: port.Service.Name, - Port: port.Service.Port, - Type: port.Service.Type, - LoadBalancerIP: port.Service.LoadBalancerIP, - Labels: port.Service.Labels, - Annotations: port.Service.Annotations, - SessionAffinity: port.Service.SessionAffinity, - LoadBalancerSourceRanges: port.Service.LoadBalancerSourceRanges, - ExternalName: port.Service.ExternalName, - ExternalTrafficPolicy: port.Service.ExternalTrafficPolicy, - HealthCheckNodePort: port.Service.HealthCheckNodePort, - PublishNotReadyAddresses: port.Service.PublishNotReadyAddresses, - SessionAffinityConfig: port.Service.SessionAffinityConfig, - } - } - - ports = append(ports, nps) - } - - return ports -} - -func doImage(r *CoherenceRoleSpec) *string { - switch { - case r.Application != nil && r.Application.Image != nil: - return r.Application.Image - case r.Coherence != nil && r.Coherence.Image != nil: - return r.Coherence.Image - default: - return nil - } -} - -func doImagePullPolicy(r *CoherenceRoleSpec) *corev1.PullPolicy { - switch { - case r.Application != nil && r.Application.ImagePullPolicy != nil: - return r.Application.ImagePullPolicy - case r.Coherence != nil && r.Coherence.ImagePullPolicy != nil: - return r.Coherence.ImagePullPolicy - default: - return nil - } -} - -func doApplication(r *CoherenceRoleSpec) *v1.ApplicationSpec { - if r.Application == nil { - return nil - } - - if r.Application.Main != nil || len(r.Application.Args) > 0 { - return &v1.ApplicationSpec{ - Main: r.Application.Main, - Args: r.Application.Args, - } - } - return nil -} - -func doScaling(r *CoherenceRoleSpec) *v1.ScalingSpec { - if r.Scaling == nil { - return nil - } - - scaling := &v1.ScalingSpec{} - if r.Scaling.Policy != nil { - policy := v1.ScalingPolicy(*r.Scaling.Policy) - scaling.Policy = &policy - } - - probe := &v1.Probe{} - if r.Scaling.Probe != nil { - probe.TimeoutSeconds = r.Scaling.Probe.TimeoutSeconds - probe.Exec = r.Scaling.Probe.Exec - probe.HTTPGet = r.Scaling.Probe.HTTPGet - probe.TCPSocket = r.Scaling.Probe.TCPSocket - } - - return scaling -} - -func doPullSecrets(cc *CoherenceCluster) []v1.LocalObjectReference { - var pullSecrets []v1.LocalObjectReference - for _, ps := range cc.Spec.ImagePullSecrets { - pullSecrets = append(pullSecrets, v1.LocalObjectReference{ - Name: ps.Name, - }) - } - return pullSecrets -} - -func doStartQuorum(r *CoherenceRoleSpec, cc *CoherenceCluster) []v1.StartQuorum { - if r.StartQuorum == nil { - return nil - } - - var quorum []v1.StartQuorum - for _, sq := range r.StartQuorum { - quorum = append(quorum, v1.StartQuorum{ - Deployment: cc.GetFullRoleName(sq.Role), - PodCount: sq.PodCount, - }) - } - - return quorum -} - -func doReadiness(r *CoherenceRoleSpec) *v1.ReadinessProbeSpec { - if r.ReadinessProbe == nil { - return nil - } - - rp := r.ReadinessProbe - - return &v1.ReadinessProbeSpec{ - ProbeHandler: v1.ProbeHandler{ - Exec: rp.Exec, - HTTPGet: rp.HTTPGet, - TCPSocket: rp.TCPSocket, - }, - InitialDelaySeconds: rp.InitialDelaySeconds, - TimeoutSeconds: rp.TimeoutSeconds, - PeriodSeconds: rp.PeriodSeconds, - SuccessThreshold: rp.SuccessThreshold, - FailureThreshold: rp.FailureThreshold, - } -} - -func doLiveness(r *CoherenceRoleSpec) *v1.ReadinessProbeSpec { - if r.LivenessProbe == nil { - return nil - } - - lp := r.LivenessProbe - - return &v1.ReadinessProbeSpec{ - ProbeHandler: v1.ProbeHandler{ - Exec: lp.Exec, - HTTPGet: lp.HTTPGet, - TCPSocket: lp.TCPSocket, - }, - InitialDelaySeconds: lp.InitialDelaySeconds, - TimeoutSeconds: lp.TimeoutSeconds, - PeriodSeconds: lp.PeriodSeconds, - SuccessThreshold: lp.SuccessThreshold, - FailureThreshold: lp.FailureThreshold, - } -} - -func doNetwork(r *CoherenceRoleSpec) *v1.NetworkSpec { - if r.Network == nil { - return nil - } - - n := r.Network - - spec := &v1.NetworkSpec{ - HostAliases: n.HostAliases, - HostNetwork: n.HostNetwork, - Hostname: n.Hostname, - } - - if n.DNSConfig != nil { - spec.DNSConfig = &v1.PodDNSConfig{ - Nameservers: n.DNSConfig.Nameservers, - Searches: n.DNSConfig.Searches, - Options: n.DNSConfig.Options, - } - } - - if n.DNSPolicy != nil { - policy := corev1.DNSPolicy(*n.DNSPolicy) - spec.DNSPolicy = &policy - } - - return spec -} diff --git a/pkg/apis/coherence/legacy/doc.go b/pkg/apis/coherence/legacy/doc.go deleted file mode 100644 index fde9a446b..000000000 --- a/pkg/apis/coherence/legacy/doc.go +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -// Package legacy contains API Schema definitions for the legacy Coherence Operator API -// to be used by the converter utility to convert legacy yaml to the current yaml. -// +kubebuilder:object:generate=false -package legacy diff --git a/pkg/apis/coherence/legacy/zz_generated.deepcopy.go b/pkg/apis/coherence/legacy/zz_generated.deepcopy.go deleted file mode 100644 index 3fe9419c1..000000000 --- a/pkg/apis/coherence/legacy/zz_generated.deepcopy.go +++ /dev/null @@ -1,1335 +0,0 @@ -// +build !ignore_autogenerated - -/* - * Copyright (c) 2020, Oracle and/or its affiliates. - * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. - */ - -// Code generated by controller-gen. DO NOT EDIT. - -package legacy - -import ( - "k8s.io/api/core/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) { - *out = *in - if in.Type != nil { - in, out := &in.Type, &out.Type - *out = new(string) - **out = **in - } - if in.Main != nil { - in, out := &in.Main, &out.Main - *out = new(string) - **out = **in - } - if in.Args != nil { - in, out := &in.Args, &out.Args - *out = make([]string, len(*in)) - copy(*out, *in) - } - in.ImageSpec.DeepCopyInto(&out.ImageSpec) - if in.AppDir != nil { - in, out := &in.AppDir, &out.AppDir - *out = new(string) - **out = **in - } - if in.LibDir != nil { - in, out := &in.LibDir, &out.LibDir - *out = new(string) - **out = **in - } - if in.ConfigDir != nil { - in, out := &in.ConfigDir, &out.ConfigDir - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec. -func (in *ApplicationSpec) DeepCopy() *ApplicationSpec { - if in == nil { - return nil - } - out := new(ApplicationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterRoleStatus) DeepCopyInto(out *ClusterRoleStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]ClusterRoleStatusCondition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRoleStatus. -func (in *ClusterRoleStatus) DeepCopy() *ClusterRoleStatus { - if in == nil { - return nil - } - out := new(ClusterRoleStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterRoleStatusCondition) DeepCopyInto(out *ClusterRoleStatusCondition) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRoleStatusCondition. -func (in *ClusterRoleStatusCondition) DeepCopy() *ClusterRoleStatusCondition { - if in == nil { - return nil - } - out := new(ClusterRoleStatusCondition) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceCluster) DeepCopyInto(out *CoherenceCluster) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceCluster. -func (in *CoherenceCluster) DeepCopy() *CoherenceCluster { - if in == nil { - return nil - } - out := new(CoherenceCluster) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CoherenceCluster) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceClusterList) DeepCopyInto(out *CoherenceClusterList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CoherenceCluster, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceClusterList. -func (in *CoherenceClusterList) DeepCopy() *CoherenceClusterList { - if in == nil { - return nil - } - out := new(CoherenceClusterList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CoherenceClusterList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceClusterSpec) DeepCopyInto(out *CoherenceClusterSpec) { - *out = *in - if in.ImagePullSecrets != nil { - in, out := &in.ImagePullSecrets, &out.ImagePullSecrets - *out = make([]LocalObjectReference, len(*in)) - copy(*out, *in) - } - if in.AutomountServiceAccountToken != nil { - in, out := &in.AutomountServiceAccountToken, &out.AutomountServiceAccountToken - *out = new(bool) - **out = **in - } - if in.OperatorRequestTimeout != nil { - in, out := &in.OperatorRequestTimeout, &out.OperatorRequestTimeout - *out = new(int32) - **out = **in - } - in.CoherenceRoleSpec.DeepCopyInto(&out.CoherenceRoleSpec) - if in.Roles != nil { - in, out := &in.Roles, &out.Roles - *out = make([]CoherenceRoleSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceClusterSpec. -func (in *CoherenceClusterSpec) DeepCopy() *CoherenceClusterSpec { - if in == nil { - return nil - } - out := new(CoherenceClusterSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceClusterStatus) DeepCopyInto(out *CoherenceClusterStatus) { - *out = *in - if in.RoleStatus != nil { - in, out := &in.RoleStatus, &out.RoleStatus - *out = make([]ClusterRoleStatus, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceClusterStatus. -func (in *CoherenceClusterStatus) DeepCopy() *CoherenceClusterStatus { - if in == nil { - return nil - } - out := new(CoherenceClusterStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceRole) DeepCopyInto(out *CoherenceRole) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceRole. -func (in *CoherenceRole) DeepCopy() *CoherenceRole { - if in == nil { - return nil - } - out := new(CoherenceRole) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CoherenceRole) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceRoleList) DeepCopyInto(out *CoherenceRoleList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]CoherenceRole, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceRoleList. -func (in *CoherenceRoleList) DeepCopy() *CoherenceRoleList { - if in == nil { - return nil - } - out := new(CoherenceRoleList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CoherenceRoleList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceRoleSpec) DeepCopyInto(out *CoherenceRoleSpec) { - *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas - *out = new(int32) - **out = **in - } - if in.Application != nil { - in, out := &in.Application, &out.Application - *out = new(ApplicationSpec) - (*in).DeepCopyInto(*out) - } - if in.Coherence != nil { - in, out := &in.Coherence, &out.Coherence - *out = new(CoherenceSpec) - (*in).DeepCopyInto(*out) - } - if in.CoherenceUtils != nil { - in, out := &in.CoherenceUtils, &out.CoherenceUtils - *out = new(ImageSpec) - (*in).DeepCopyInto(*out) - } - if in.Logging != nil { - in, out := &in.Logging, &out.Logging - *out = new(LoggingSpec) - (*in).DeepCopyInto(*out) - } - if in.JVM != nil { - in, out := &in.JVM, &out.JVM - *out = new(JVMSpec) - (*in).DeepCopyInto(*out) - } - if in.Ports != nil { - in, out := &in.Ports, &out.Ports - *out = make([]NamedPortSpec, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Env != nil { - in, out := &in.Env, &out.Env - *out = make([]v1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.HealthPort != nil { - in, out := &in.HealthPort, &out.HealthPort - *out = new(int32) - **out = **in - } - if in.ReadinessProbe != nil { - in, out := &in.ReadinessProbe, &out.ReadinessProbe - *out = new(ReadinessProbeSpec) - (*in).DeepCopyInto(*out) - } - if in.LivenessProbe != nil { - in, out := &in.LivenessProbe, &out.LivenessProbe - *out = new(ReadinessProbeSpec) - (*in).DeepCopyInto(*out) - } - if in.Scaling != nil { - in, out := &in.Scaling, &out.Scaling - *out = new(ScalingSpec) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Labels != nil { - in, out := &in.Labels, &out.Labels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]v1.Volume, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.VolumeClaimTemplates != nil { - in, out := &in.VolumeClaimTemplates, &out.VolumeClaimTemplates - *out = make([]v1.PersistentVolumeClaim, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.VolumeMounts != nil { - in, out := &in.VolumeMounts, &out.VolumeMounts - *out = make([]v1.VolumeMount, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Affinity != nil { - in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) - (*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.ShareProcessNamespace != nil { - in, out := &in.ShareProcessNamespace, &out.ShareProcessNamespace - *out = new(bool) - **out = **in - } - if in.HostIPC != nil { - in, out := &in.HostIPC, &out.HostIPC - *out = new(bool) - **out = **in - } - if in.Network != nil { - in, out := &in.Network, &out.Network - *out = new(NetworkSpec) - (*in).DeepCopyInto(*out) - } - if in.StartQuorum != nil { - in, out := &in.StartQuorum, &out.StartQuorum - *out = make([]StartQuorum, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceRoleSpec. -func (in *CoherenceRoleSpec) DeepCopy() *CoherenceRoleSpec { - if in == nil { - return nil - } - out := new(CoherenceRoleSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceRoleStatus) DeepCopyInto(out *CoherenceRoleStatus) { - *out = *in - if in.StartQuorum != nil { - in, out := &in.StartQuorum, &out.StartQuorum - *out = make([]StartQuorumStatus, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceRoleStatus. -func (in *CoherenceRoleStatus) DeepCopy() *CoherenceRoleStatus { - if in == nil { - return nil - } - out := new(CoherenceRoleStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CoherenceSpec) DeepCopyInto(out *CoherenceSpec) { - *out = *in - in.ImageSpec.DeepCopyInto(&out.ImageSpec) - if in.StorageEnabled != nil { - in, out := &in.StorageEnabled, &out.StorageEnabled - *out = new(bool) - **out = **in - } - if in.CacheConfig != nil { - in, out := &in.CacheConfig, &out.CacheConfig - *out = new(string) - **out = **in - } - if in.OverrideConfig != nil { - in, out := &in.OverrideConfig, &out.OverrideConfig - *out = new(string) - **out = **in - } - if in.LogLevel != nil { - in, out := &in.LogLevel, &out.LogLevel - *out = new(int32) - **out = **in - } - if in.Persistence != nil { - in, out := &in.Persistence, &out.Persistence - *out = new(PersistentStorageSpec) - (*in).DeepCopyInto(*out) - } - if in.Snapshot != nil { - in, out := &in.Snapshot, &out.Snapshot - *out = new(PersistentStorageSpec) - (*in).DeepCopyInto(*out) - } - if in.Management != nil { - in, out := &in.Management, &out.Management - *out = new(PortSpecWithSSL) - (*in).DeepCopyInto(*out) - } - if in.Metrics != nil { - in, out := &in.Metrics, &out.Metrics - *out = new(PortSpecWithSSL) - (*in).DeepCopyInto(*out) - } - if in.ExcludeFromWKA != nil { - in, out := &in.ExcludeFromWKA, &out.ExcludeFromWKA - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CoherenceSpec. -func (in *CoherenceSpec) DeepCopy() *CoherenceSpec { - if in == nil { - return nil - } - out := new(CoherenceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FluentdSpec) DeepCopyInto(out *FluentdSpec) { - *out = *in - in.ImageSpec.DeepCopyInto(&out.ImageSpec) - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.ConfigFile != nil { - in, out := &in.ConfigFile, &out.ConfigFile - *out = new(string) - **out = **in - } - if in.Tag != nil { - in, out := &in.Tag, &out.Tag - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FluentdSpec. -func (in *FluentdSpec) DeepCopy() *FluentdSpec { - if in == nil { - return nil - } - out := new(FluentdSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { - *out = *in - if in.Image != nil { - in, out := &in.Image, &out.Image - *out = new(string) - **out = **in - } - if in.ImagePullPolicy != nil { - in, out := &in.ImagePullPolicy, &out.ImagePullPolicy - *out = new(v1.PullPolicy) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec. -func (in *ImageSpec) DeepCopy() *ImageSpec { - if in == nil { - return nil - } - out := new(ImageSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JVMSpec) DeepCopyInto(out *JVMSpec) { - *out = *in - if in.Args != nil { - in, out := &in.Args, &out.Args - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Debug != nil { - in, out := &in.Debug, &out.Debug - *out = new(JvmDebugSpec) - (*in).DeepCopyInto(*out) - } - if in.UseContainerLimits != nil { - in, out := &in.UseContainerLimits, &out.UseContainerLimits - *out = new(bool) - **out = **in - } - if in.FlightRecorder != nil { - in, out := &in.FlightRecorder, &out.FlightRecorder - *out = new(bool) - **out = **in - } - if in.Gc != nil { - in, out := &in.Gc, &out.Gc - *out = new(JvmGarbageCollectorSpec) - (*in).DeepCopyInto(*out) - } - if in.DiagnosticsVolume != nil { - in, out := &in.DiagnosticsVolume, &out.DiagnosticsVolume - *out = new(v1.VolumeSource) - (*in).DeepCopyInto(*out) - } - if in.Memory != nil { - in, out := &in.Memory, &out.Memory - *out = new(JvmMemorySpec) - (*in).DeepCopyInto(*out) - } - if in.Jmxmp != nil { - in, out := &in.Jmxmp, &out.Jmxmp - *out = new(JvmJmxmpSpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JVMSpec. -func (in *JVMSpec) DeepCopy() *JVMSpec { - if in == nil { - return nil - } - out := new(JVMSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JvmDebugSpec) DeepCopyInto(out *JvmDebugSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.Suspend != nil { - in, out := &in.Suspend, &out.Suspend - *out = new(bool) - **out = **in - } - if in.Attach != nil { - in, out := &in.Attach, &out.Attach - *out = new(string) - **out = **in - } - if in.Port != nil { - in, out := &in.Port, &out.Port - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JvmDebugSpec. -func (in *JvmDebugSpec) DeepCopy() *JvmDebugSpec { - if in == nil { - return nil - } - out := new(JvmDebugSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JvmGarbageCollectorSpec) DeepCopyInto(out *JvmGarbageCollectorSpec) { - *out = *in - if in.Collector != nil { - in, out := &in.Collector, &out.Collector - *out = new(string) - **out = **in - } - if in.Args != nil { - in, out := &in.Args, &out.Args - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Logging != nil { - in, out := &in.Logging, &out.Logging - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JvmGarbageCollectorSpec. -func (in *JvmGarbageCollectorSpec) DeepCopy() *JvmGarbageCollectorSpec { - if in == nil { - return nil - } - out := new(JvmGarbageCollectorSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JvmJmxmpSpec) DeepCopyInto(out *JvmJmxmpSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.Port != nil { - in, out := &in.Port, &out.Port - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JvmJmxmpSpec. -func (in *JvmJmxmpSpec) DeepCopy() *JvmJmxmpSpec { - if in == nil { - return nil - } - out := new(JvmJmxmpSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JvmMemorySpec) DeepCopyInto(out *JvmMemorySpec) { - *out = *in - if in.HeapSize != nil { - in, out := &in.HeapSize, &out.HeapSize - *out = new(string) - **out = **in - } - if in.StackSize != nil { - in, out := &in.StackSize, &out.StackSize - *out = new(string) - **out = **in - } - if in.MetaspaceSize != nil { - in, out := &in.MetaspaceSize, &out.MetaspaceSize - *out = new(string) - **out = **in - } - if in.DirectMemorySize != nil { - in, out := &in.DirectMemorySize, &out.DirectMemorySize - *out = new(string) - **out = **in - } - if in.NativeMemoryTracking != nil { - in, out := &in.NativeMemoryTracking, &out.NativeMemoryTracking - *out = new(string) - **out = **in - } - if in.OnOutOfMemory != nil { - in, out := &in.OnOutOfMemory, &out.OnOutOfMemory - *out = new(JvmOutOfMemorySpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JvmMemorySpec. -func (in *JvmMemorySpec) DeepCopy() *JvmMemorySpec { - if in == nil { - return nil - } - out := new(JvmMemorySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JvmOutOfMemorySpec) DeepCopyInto(out *JvmOutOfMemorySpec) { - *out = *in - if in.Exit != nil { - in, out := &in.Exit, &out.Exit - *out = new(bool) - **out = **in - } - if in.HeapDump != nil { - in, out := &in.HeapDump, &out.HeapDump - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JvmOutOfMemorySpec. -func (in *JvmOutOfMemorySpec) DeepCopy() *JvmOutOfMemorySpec { - if in == nil { - return nil - } - out := new(JvmOutOfMemorySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LocalObjectReference) DeepCopyInto(out *LocalObjectReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalObjectReference. -func (in *LocalObjectReference) DeepCopy() *LocalObjectReference { - if in == nil { - return nil - } - out := new(LocalObjectReference) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LoggingSpec) DeepCopyInto(out *LoggingSpec) { - *out = *in - if in.ConfigFile != nil { - in, out := &in.ConfigFile, &out.ConfigFile - *out = new(string) - **out = **in - } - if in.ConfigMapName != nil { - in, out := &in.ConfigMapName, &out.ConfigMapName - *out = new(string) - **out = **in - } - if in.Fluentd != nil { - in, out := &in.Fluentd, &out.Fluentd - *out = new(FluentdSpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoggingSpec. -func (in *LoggingSpec) DeepCopy() *LoggingSpec { - if in == nil { - return nil - } - out := new(LoggingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NamedPortSpec) DeepCopyInto(out *NamedPortSpec) { - *out = *in - in.PortSpec.DeepCopyInto(&out.PortSpec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamedPortSpec. -func (in *NamedPortSpec) DeepCopy() *NamedPortSpec { - if in == nil { - return nil - } - out := new(NamedPortSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkSpec) DeepCopyInto(out *NetworkSpec) { - *out = *in - if in.DNSConfig != nil { - in, out := &in.DNSConfig, &out.DNSConfig - *out = new(PodDNSConfig) - (*in).DeepCopyInto(*out) - } - if in.DNSPolicy != nil { - in, out := &in.DNSPolicy, &out.DNSPolicy - *out = new(string) - **out = **in - } - if in.HostAliases != nil { - in, out := &in.HostAliases, &out.HostAliases - *out = make([]v1.HostAlias, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.HostNetwork != nil { - in, out := &in.HostNetwork, &out.HostNetwork - *out = new(bool) - **out = **in - } - if in.Hostname != nil { - in, out := &in.Hostname, &out.Hostname - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. -func (in *NetworkSpec) DeepCopy() *NetworkSpec { - if in == nil { - return nil - } - out := new(NetworkSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistentStorageSpec) DeepCopyInto(out *PersistentStorageSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.PersistentVolumeClaim != nil { - in, out := &in.PersistentVolumeClaim, &out.PersistentVolumeClaim - *out = new(v1.PersistentVolumeClaimSpec) - (*in).DeepCopyInto(*out) - } - if in.Volume != nil { - in, out := &in.Volume, &out.Volume - *out = new(v1.VolumeSource) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistentStorageSpec. -func (in *PersistentStorageSpec) DeepCopy() *PersistentStorageSpec { - if in == nil { - return nil - } - out := new(PersistentStorageSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodDNSConfig) DeepCopyInto(out *PodDNSConfig) { - *out = *in - if in.Nameservers != nil { - in, out := &in.Nameservers, &out.Nameservers - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Searches != nil { - in, out := &in.Searches, &out.Searches - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Options != nil { - in, out := &in.Options, &out.Options - *out = make([]v1.PodDNSConfigOption, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDNSConfig. -func (in *PodDNSConfig) DeepCopy() *PodDNSConfig { - if in == nil { - return nil - } - out := new(PodDNSConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PortSpec) DeepCopyInto(out *PortSpec) { - *out = *in - if in.Protocol != nil { - in, out := &in.Protocol, &out.Protocol - *out = new(string) - **out = **in - } - if in.Service != nil { - in, out := &in.Service, &out.Service - *out = new(ServiceSpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortSpec. -func (in *PortSpec) DeepCopy() *PortSpec { - if in == nil { - return nil - } - out := new(PortSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PortSpecWithSSL) DeepCopyInto(out *PortSpecWithSSL) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.Port != nil { - in, out := &in.Port, &out.Port - *out = new(int32) - **out = **in - } - if in.SSL != nil { - in, out := &in.SSL, &out.SSL - *out = new(SSLSpec) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortSpecWithSSL. -func (in *PortSpecWithSSL) DeepCopy() *PortSpecWithSSL { - if in == nil { - return nil - } - out := new(PortSpecWithSSL) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ProbeHandler) DeepCopyInto(out *ProbeHandler) { - *out = *in - if in.Exec != nil { - in, out := &in.Exec, &out.Exec - *out = new(v1.ExecAction) - (*in).DeepCopyInto(*out) - } - if in.HTTPGet != nil { - in, out := &in.HTTPGet, &out.HTTPGet - *out = new(v1.HTTPGetAction) - (*in).DeepCopyInto(*out) - } - if in.TCPSocket != nil { - in, out := &in.TCPSocket, &out.TCPSocket - *out = new(v1.TCPSocketAction) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProbeHandler. -func (in *ProbeHandler) DeepCopy() *ProbeHandler { - if in == nil { - return nil - } - out := new(ProbeHandler) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReadinessProbeSpec) DeepCopyInto(out *ReadinessProbeSpec) { - *out = *in - in.ProbeHandler.DeepCopyInto(&out.ProbeHandler) - if in.InitialDelaySeconds != nil { - in, out := &in.InitialDelaySeconds, &out.InitialDelaySeconds - *out = new(int32) - **out = **in - } - if in.TimeoutSeconds != nil { - in, out := &in.TimeoutSeconds, &out.TimeoutSeconds - *out = new(int32) - **out = **in - } - if in.PeriodSeconds != nil { - in, out := &in.PeriodSeconds, &out.PeriodSeconds - *out = new(int32) - **out = **in - } - if in.SuccessThreshold != nil { - in, out := &in.SuccessThreshold, &out.SuccessThreshold - *out = new(int32) - **out = **in - } - if in.FailureThreshold != nil { - in, out := &in.FailureThreshold, &out.FailureThreshold - *out = new(int32) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReadinessProbeSpec. -func (in *ReadinessProbeSpec) DeepCopy() *ReadinessProbeSpec { - if in == nil { - return nil - } - out := new(ReadinessProbeSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SSLSpec) DeepCopyInto(out *SSLSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.Secrets != nil { - in, out := &in.Secrets, &out.Secrets - *out = new(string) - **out = **in - } - if in.KeyStore != nil { - in, out := &in.KeyStore, &out.KeyStore - *out = new(string) - **out = **in - } - if in.KeyStorePasswordFile != nil { - in, out := &in.KeyStorePasswordFile, &out.KeyStorePasswordFile - *out = new(string) - **out = **in - } - if in.KeyPasswordFile != nil { - in, out := &in.KeyPasswordFile, &out.KeyPasswordFile - *out = new(string) - **out = **in - } - if in.KeyStoreAlgorithm != nil { - in, out := &in.KeyStoreAlgorithm, &out.KeyStoreAlgorithm - *out = new(string) - **out = **in - } - if in.KeyStoreProvider != nil { - in, out := &in.KeyStoreProvider, &out.KeyStoreProvider - *out = new(string) - **out = **in - } - if in.KeyStoreType != nil { - in, out := &in.KeyStoreType, &out.KeyStoreType - *out = new(string) - **out = **in - } - if in.TrustStore != nil { - in, out := &in.TrustStore, &out.TrustStore - *out = new(string) - **out = **in - } - if in.TrustStorePasswordFile != nil { - in, out := &in.TrustStorePasswordFile, &out.TrustStorePasswordFile - *out = new(string) - **out = **in - } - if in.TrustStoreAlgorithm != nil { - in, out := &in.TrustStoreAlgorithm, &out.TrustStoreAlgorithm - *out = new(string) - **out = **in - } - if in.TrustStoreProvider != nil { - in, out := &in.TrustStoreProvider, &out.TrustStoreProvider - *out = new(string) - **out = **in - } - if in.TrustStoreType != nil { - in, out := &in.TrustStoreType, &out.TrustStoreType - *out = new(string) - **out = **in - } - if in.RequireClientCert != nil { - in, out := &in.RequireClientCert, &out.RequireClientCert - *out = new(bool) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SSLSpec. -func (in *SSLSpec) DeepCopy() *SSLSpec { - if in == nil { - return nil - } - out := new(SSLSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ScalingProbe) DeepCopyInto(out *ScalingProbe) { - *out = *in - in.Handler.DeepCopyInto(&out.Handler) - if in.TimeoutSeconds != nil { - in, out := &in.TimeoutSeconds, &out.TimeoutSeconds - *out = new(int) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalingProbe. -func (in *ScalingProbe) DeepCopy() *ScalingProbe { - if in == nil { - return nil - } - out := new(ScalingProbe) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ScalingSpec) DeepCopyInto(out *ScalingSpec) { - *out = *in - if in.Policy != nil { - in, out := &in.Policy, &out.Policy - *out = new(ScalingPolicy) - **out = **in - } - if in.Probe != nil { - in, out := &in.Probe, &out.Probe - *out = new(ScalingProbe) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalingSpec. -func (in *ScalingSpec) DeepCopy() *ScalingSpec { - if in == nil { - return nil - } - out := new(ScalingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - if in.Name != nil { - in, out := &in.Name, &out.Name - *out = new(string) - **out = **in - } - if in.Port != nil { - in, out := &in.Port, &out.Port - *out = new(int32) - **out = **in - } - if in.Type != nil { - in, out := &in.Type, &out.Type - *out = new(v1.ServiceType) - **out = **in - } - if in.LoadBalancerIP != nil { - in, out := &in.LoadBalancerIP, &out.LoadBalancerIP - *out = new(string) - **out = **in - } - if in.Labels != nil { - in, out := &in.Labels, &out.Labels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.SessionAffinity != nil { - in, out := &in.SessionAffinity, &out.SessionAffinity - *out = new(v1.ServiceAffinity) - **out = **in - } - if in.LoadBalancerSourceRanges != nil { - in, out := &in.LoadBalancerSourceRanges, &out.LoadBalancerSourceRanges - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.ExternalName != nil { - in, out := &in.ExternalName, &out.ExternalName - *out = new(string) - **out = **in - } - if in.ExternalTrafficPolicy != nil { - in, out := &in.ExternalTrafficPolicy, &out.ExternalTrafficPolicy - *out = new(v1.ServiceExternalTrafficPolicyType) - **out = **in - } - if in.HealthCheckNodePort != nil { - in, out := &in.HealthCheckNodePort, &out.HealthCheckNodePort - *out = new(int32) - **out = **in - } - if in.PublishNotReadyAddresses != nil { - in, out := &in.PublishNotReadyAddresses, &out.PublishNotReadyAddresses - *out = new(bool) - **out = **in - } - if in.SessionAffinityConfig != nil { - in, out := &in.SessionAffinityConfig, &out.SessionAffinityConfig - *out = new(v1.SessionAffinityConfig) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. -func (in *ServiceSpec) DeepCopy() *ServiceSpec { - if in == nil { - return nil - } - out := new(ServiceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StartQuorum) DeepCopyInto(out *StartQuorum) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StartQuorum. -func (in *StartQuorum) DeepCopy() *StartQuorum { - if in == nil { - return nil - } - out := new(StartQuorum) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StartQuorumStatus) DeepCopyInto(out *StartQuorumStatus) { - *out = *in - out.StartQuorum = in.StartQuorum -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StartQuorumStatus. -func (in *StartQuorumStatus) DeepCopy() *StartQuorumStatus { - if in == nil { - return nil - } - out := new(StartQuorumStatus) - in.DeepCopyInto(out) - return out -} diff --git a/test/e2e/local/pvc.yaml b/test/e2e/local/pvc.yaml new file mode 100644 index 000000000..9f28e4d4d --- /dev/null +++ b/test/e2e/local/pvc.yaml @@ -0,0 +1,24 @@ +apiVersion: coherence.oracle.com/v1 +kind: Coherence +metadata: + name: storage-with-pvc +spec: + replicas: 1 + volumeClaimTemplates: + - metadata: + name: data-volume + labels: + coherence.oracle.com/test1: "pvc-test-1" + coherence.oracle.com/test2: "pvc-test-2" + annotations: + test-key1: test-value-1 + test-key2: test-value-2 + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 10Gi + volumeMounts: + - name: data-volume + mountPath: /opt/data + diff --git a/test/e2e/local/pvc_test.go b/test/e2e/local/pvc_test.go new file mode 100644 index 000000000..51983f311 --- /dev/null +++ b/test/e2e/local/pvc_test.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +package local + +import ( + . "github.com/onsi/gomega" + "github.com/oracle/coherence-operator/test/e2e/helper" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "testing" +) + +func TestAdditionalVolumeClaimTemplates(t *testing.T) { + g := NewGomegaWithT(t) + testContext.CleanupAfterTest(t) + + ns := helper.GetTestNamespace() + pvcName := "data-volume-storage-with-pvc-0" + + defer deletePVC(ns, pvcName) + + helper.AssertDeployments(testContext, t, "pvc.yaml") + + g.Expect(ns).NotTo(BeEmpty()) + pvc, err := testContext.KubeClient.CoreV1().PersistentVolumeClaims(ns). + Get(testContext.Context, pvcName, metav1.GetOptions{}) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(pvc).NotTo(BeNil()) + g.Expect(pvc.Status.Phase).To(Equal(corev1.ClaimBound)) + + labels := pvc.GetLabels() + g.Expect(labels["coherence.oracle.com/test1"]).To(Equal("pvc-test-1")) + g.Expect(labels["coherence.oracle.com/test2"]).To(Equal("pvc-test-2")) + + annotations := pvc.GetAnnotations() + g.Expect(annotations["test-key1"]).To(Equal("test-value-1")) + g.Expect(annotations["test-key2"]).To(Equal("test-value-2")) +} + +func deletePVC(namespace, name string) { + _ = testContext.KubeClient.CoreV1().PersistentVolumeClaims(namespace). + Delete(testContext.Context, name, metav1.DeleteOptions{}) +}