Skip to content

Commit

Permalink
Create the MedusaConfiguration API (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski authored Jan 23, 2024
1 parent ff37de8 commit 6dc5d42
Show file tree
Hide file tree
Showing 25 changed files with 1,053 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/kind_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ jobs:
- PerNodeConfig/UserDefined
- RemoveLocalDcFromCluster
- AddDcToClusterSameDataplane
- CreateMedusaConfiguration
fail-fast: false
name: ${{ matrix.e2e_test }}
env:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG/CHANGELOG-1.12.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Changelog for the K8ssandra Operator, new PRs should update the `unreleased` sec
When cutting a new release, update the `unreleased` heading to the tag being generated and date, like `## vX.Y.Z - YYYY-MM-DD` and create a new placeholder section for `unreleased` entries.

## unreleased

* [CHANGE] [#1050](https://github.com/k8ssandra/k8ssandra-operator/issues/1050) Remove unnecessary requeues in the Medusa controllers
* [CHANGE] [#1165](https://github.com/k8ssandra/k8ssandra-operator/issues/1165) Upgrade to Medusa v0.17.1
* [FEATURE] [#1157](https://github.com/k8ssandra/k8ssandra-operator/issues/1157) Add the MedusaConfiguration API
* [FEATURE] [#1165](https://github.com/k8ssandra/k8ssandra-operator/issues/1165) Expose Medusa ssl_verify option to allow disabling cert verification for some on prem S3 compatible systems
* [ENHANCEMENT] [#1094](https://github.com/k8ssandra/k8ssandra-operator/issues/1094) Expose AdditionalAnnotations field for cassDC.
* [ENHANCEMENT] [#1160](https://github.com/k8ssandra/k8ssandra-operator/issues/1160) Allow disabling Reaper front-end auth.
Expand Down
13 changes: 13 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: k8ssandra.io
layout:
- go.kubebuilder.io/v3
Expand Down Expand Up @@ -130,4 +134,13 @@ resources:
kind: K8ssandraTask
path: github.com/k8ssandra/k8ssandra-operator/apis/control/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: k8ssandra.io
group: medusa
kind: MedusaConfiguration
path: github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1
version: v1alpha1
version: "3"
118 changes: 118 additions & 0 deletions apis/medusa/v1alpha1/medusaconfiguration_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
Copyright 2022.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

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

// MedusaConfigurationSpec defines the desired state of MedusaConfiguration
type MedusaConfigurationSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// StorageProperties defines the storage backend settings to use for the backups.
StorageProperties Storage `json:"storageProperties,omitempty"`
}

type MedusaConfigurationConditionType string

const (
ControlStatusSecretAvailable MedusaConfigurationConditionType = "SecretAvailable"
ControlStatusReady MedusaConfigurationConditionType = "Ready"
)

// MedusaConfigurationStatus defines the observed state of MedusaConfiguration
type MedusaConfigurationStatus struct {
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// SetCondition sets the condition with the given type to the given status.
// Returns true if the condition was changed.
func (m *MedusaConfigurationStatus) SetCondition(msg MedusaConfigurationConditionType, status metav1.ConditionStatus) bool {
condition := metav1.Condition{
Type: string(msg),
Status: status,
Reason: string(msg),
Message: string(msg),
LastTransitionTime: metav1.Now(),
}
found := false
updated := false
for i, c := range m.Conditions {
if c.Type == string(msg) {
found = true
if c.Status == status {
continue
}
m.Conditions[i] = condition
updated = true
}
}
if !found {
m.Conditions = append(m.Conditions, condition)
updated = true
}
return updated
}

func (m *MedusaConfigurationStatus) SetConditionMessage(msg MedusaConfigurationConditionType, message string) {
for i, c := range m.Conditions {
if c.Type == string(msg) {
m.Conditions[i].Message = message
return
}
}
}

func (m *MedusaConfigurationStatus) GetCondition(msg MedusaConfigurationConditionType) *metav1.Condition {
for _, c := range m.Conditions {
if c.Type == string(msg) {
return &c
}
}
return nil
}

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

// MedusaConfiguration is the Schema for the medusaconfigurations API
type MedusaConfiguration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MedusaConfigurationSpec `json:"spec,omitempty"`
Status MedusaConfigurationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&MedusaConfiguration{}, &MedusaConfigurationList{})
}
98 changes: 98 additions & 0 deletions apis/medusa/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 6dc5d42

Please sign in to comment.