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

feat(api): combine Cryostat and ClusterCryostat CRDs #721

Merged
merged 11 commits into from
Feb 13, 2024
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN go mod download
COPY internal/main.go internal/main.go
COPY api/ api/
COPY internal/controllers/ internal/controllers/
COPY internal/webhooks/ internal/webhooks/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
Expand Down
32 changes: 30 additions & 2 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: cryostat.io
layout:
- go.kubebuilder.io/v3
Expand All @@ -10,7 +14,6 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cryostat.io
group: operator
kind: Cryostat
Expand All @@ -19,10 +22,35 @@ resources:
- api:
crdVersion: v1
namespaced: false
controller: true
domain: cryostat.io
group: operator
kind: ClusterCryostat
path: github.com/cryostatio/cryostat-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cryostat.io
group: operator
kind: Cryostat
path: github.com/cryostatio/cryostat-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: cryostat.io
group: operator
kind: ClusterCryostat
path: github.com/cryostatio/cryostat-operator/api/v1beta2
version: v1beta2
webhooks:
conversion: true
webhookVersion: v1
version: "3"
62 changes: 62 additions & 0 deletions api/v1beta1/clustercryostat_conversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright The Cryostat Authors.
//
// 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 v1beta1

import (
operatorv1beta2 "github.com/cryostatio/cryostat-operator/api/v1beta2"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// TODO Remove this file with ClusterCryostat CRD

var _ conversion.Convertible = &ClusterCryostat{}

// ConvertTo converts this ClusterCryostat to the Hub version (v1beta2).
func (src *ClusterCryostat) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*operatorv1beta2.ClusterCryostat)

// Copy ObjectMeta as-is
dst.ObjectMeta = src.ObjectMeta

// Convert existing Spec fields
convertSpecTo(&src.Spec.CryostatSpec, &dst.Spec.CryostatSpec)
dst.Spec.InstallNamespace = src.Spec.InstallNamespace
dst.Spec.TargetNamespaces = src.Spec.TargetNamespaces

// Convert existing Status fields
convertStatusTo(&src.Status.CryostatStatus, &dst.Status.CryostatStatus)
dst.Status.TargetNamespaces = src.Spec.TargetNamespaces

return nil
}

// ConvertFrom converts from the Hub version (v1beta2) to this version.
func (dst *ClusterCryostat) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*operatorv1beta2.ClusterCryostat)

// Copy ObjectMeta as-is
dst.ObjectMeta = src.ObjectMeta

// Convert existing Spec fields
convertSpecFrom(&src.Spec.CryostatSpec, &dst.Spec.CryostatSpec)
dst.Spec.InstallNamespace = src.Spec.InstallNamespace
dst.Spec.TargetNamespaces = src.Spec.TargetNamespaces

// Convert existing Status fields
convertStatusFrom(&src.Status.CryostatStatus, &dst.Status.CryostatStatus)
dst.Status.TargetNamespaces = src.Spec.TargetNamespaces

return nil
}
1 change: 0 additions & 1 deletion api/v1beta1/clustercryostat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type ClusterCryostatStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=clustercryostats,scope=Cluster

// ClusterCryostat allows you to install Cryostat for multiple namespaces or cluster-wide.
Expand Down
Loading
Loading