Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CN-539] Add MultiMap CR #367

Merged
merged 5 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -152,7 +152,7 @@ test-it-focus: manifests generate fmt vet ## Run tests.
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); PHONE_HOME_ENABLED=$(PHONE_HOME_ENABLED) DEVELOPER_MODE_ENABLED=$(DEVELOPER_MODE_ENABLED) go test -tags $(GO_BUILD_TAGS) -v ./test/integration/... -coverprofile cover.out $(GO_TEST_FLAGS) -timeout 5m

E2E_TEST_SUITE ?= hz || mc || hz_persistence || hz_expose_externally || map || map_persistence || hz_wan || custom_class
E2E_TEST_SUITE ?= hz || mc || hz_persistence || hz_expose_externally || map || map_persistence || hz_wan || custom_class || multimap
ifeq (,$(E2E_TEST_SUITE))
E2E_TEST_LABELS =
else
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Expand Up @@ -39,4 +39,12 @@ resources:
kind: WanReplication
path: github.com/hazelcast/hazelcast-platform-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: hazelcast.com
kind: MultiMap
path: github.com/hazelcast/hazelcast-platform-operator/api/v1alpha1
version: v1alpha1
version: "3"
2 changes: 1 addition & 1 deletion Tiltfile
Expand Up @@ -57,7 +57,7 @@ cmd_button('Undeploy operator',
)

cmd_button('Delete CRs and PVCs',
argv=['sh', '-c', '(kubectl delete $(kubectl get wanreplication,hotbackup,map,hazelcast,managementcenter -o name) 2> /dev/null || echo "No CRs" ) && kubectl delete pvc -l "app.kubernetes.io/managed-by=hazelcast-platform-operator"'],
argv=['sh', '-c', '(kubectl delete $(kubectl get wanreplication,hotbackup,map,multimap,hazelcast,managementcenter -o name) 2> /dev/null || echo "No CRs" ) && kubectl delete pvc -l "app.kubernetes.io/managed-by=hazelcast-platform-operator"'],
resource='hazelcast-platform-controller-manager',
location=location.RESOURCE,
icon_name='delete',
Expand Down
95 changes: 95 additions & 0 deletions api/v1alpha1/multimap_types.go
@@ -0,0 +1,95 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// MultiMapSpec defines the desired state of MultiMap
type MultiMapSpec struct {
// Name of the multiMap config to be created. If empty, CR name will be used.
// +optional
Name string `json:"name,omitempty"`

// Count of synchronous backups.
// +kubebuilder:default:=1
// +optional
BackupCount *int32 `json:"backupCount,omitempty"`

// Specifies in which format data will be stored in your multiMap.
// false: OBJECT true: BINARY
// +kubebuilder:default:=false
// +optional
Binary bool `json:"binary"`

// Type of the value collection
// +kubebuilder:default:=SET
// +optional
CollectionType CollectionType `json:"collectionType,omitempty"`

// HazelcastResourceName defines the name of the Hazelcast resource.
// +kubebuilder:validation:MinLength:=1
HazelcastResourceName string `json:"hazelcastResourceName"`
}

// CollectionType represents the value collection options for storing the data in the multiMap.
// +kubebuilder:validation:Enum=SET;LIST
type CollectionType string

const (
CollectionTypeSet CollectionType = "SET"

CollectionTypeList CollectionType = "LIST"
)

// MultiMapStatus defines the observed state of MultiMap
type MultiMapStatus struct {
State MultiMapConfigState `json:"state,omitempty"`
Message string `json:"message,omitempty"`
MemberStatuses map[string]MultiMapConfigState `json:"memberStatuses,omitempty"`
}

// +kubebuilder:validation:Enum=Success;Failed;Pending;Persisting;Terminating
type MultiMapConfigState string

const (
MultiMapFailed MultiMapConfigState = "Failed"
MultiMapSuccess MultiMapConfigState = "Success"
MultiMapPending MultiMapConfigState = "Pending"
// MultiMap config is added into all members but waiting for multiMap to be persisten into ConfigMap
MultiMapPersisting MultiMapConfigState = "Persisting"
MultiMapTerminating MultiMapConfigState = "Terminating"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// MultiMap is the Schema for the multimaps API
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state",description="Current state of the MultiMap Config"
// +kubebuilder:printcolumn:name="Message",type="string",priority=1,JSONPath=".status.message",description="Message for the current MultiMap Config"
type MultiMap struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MultiMapSpec `json:"spec,omitempty"`
Status MultiMapStatus `json:"status,omitempty"`
}

func (mm *MultiMap) MultiMapName() string {
if mm.Spec.Name != "" {
return mm.Spec.Name
}
return mm.Name
}

//+kubebuilder:object:root=true

// MultiMapList contains a list of MultiMap
type MultiMapList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MultiMap `json:"items"`
}

func init() {
SchemeBuilder.Register(&MultiMap{}, &MultiMapList{})
}
101 changes: 101 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 137 additions & 0 deletions bundle.yaml
Expand Up @@ -2581,6 +2581,117 @@ status:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: multimaps.hazelcast.com
spec:
group: hazelcast.com
names:
kind: MultiMap
listKind: MultiMapList
plural: multimaps
singular: multimap
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Current state of the MultiMap Config
jsonPath: .status.state
name: Status
type: string
- description: Message for the current MultiMap Config
jsonPath: .status.message
name: Message
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: MultiMap is the Schema for the multimaps API
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:
type: object
spec:
description: MultiMapSpec defines the desired state of MultiMap
properties:
backupCount:
default: 1
description: Count of synchronous backups.
format: int32
type: integer
binary:
default: false
description: 'Specifies in which format data will be stored in your
multiMap. false: OBJECT true: BINARY'
type: boolean
collectionType:
default: SET
description: Type of the value collection
enum:
- SET
- LIST
type: string
hazelcastResourceName:
description: HazelcastResourceName defines the name of the Hazelcast
resource.
minLength: 1
type: string
name:
description: Name of the multiMap config to be created. If empty,
CR name will be used.
type: string
required:
- hazelcastResourceName
type: object
status:
description: MultiMapStatus defines the observed state of MultiMap
properties:
memberStatuses:
additionalProperties:
enum:
- Success
- Failed
- Pending
- Persisting
- Terminating
type: string
type: object
message:
type: string
state:
enum:
- Success
- Failed
- Pending
- Persisting
- Terminating
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
Expand Down Expand Up @@ -2928,6 +3039,32 @@ rules:
- get
- patch
- update
- apiGroups:
- hazelcast.com
resources:
- multimaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- hazelcast.com
resources:
- multimaps/finalizers
verbs:
- update
- apiGroups:
- hazelcast.com
resources:
- multimaps/status
verbs:
- get
- patch
- update
- apiGroups:
- hazelcast.com
resources:
Expand Down