Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions fleetconfig-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ helm-doc-gen: helmdoc ## Generate helm chart README.md
readme-generator -v charts/fleetconfig-controller/values.yaml -r charts/fleetconfig-controller/README.md

.PHONY: manifests
manifests: kustomize controller-gen ## Generate CustomResourceDefinition and WebhookConfiguration objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(KUSTOMIZE) build config/crd -o charts/fleetconfig-controller/crds/fleetconfig.open-cluster-management.io-crds.yaml
manifests: controller-gen ## Generate CustomResourceDefinition and WebhookConfiguration objects.
$(CONTROLLER_GEN) webhook crd paths="./..." output:crd:artifacts:config=charts/fleetconfig-controller/crds
./hack/install_crds.sh

##@ Testing Targets
Expand Down Expand Up @@ -142,9 +141,9 @@ ifndef ignore-not-found
endif

.PHONY: install-crds
install-crds: manifests kustomize ## Install CRDs.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
install-crds: manifests ## Install CRDs.
find charts/fleetconfig-controller/crds/ -name "fleetconfig.open-cluster-management.*.yaml" -exec $(KUBECTL) apply -f {} \;

.PHONY: uninstall-crds
uninstall-crds: manifests kustomize ## Uninstall CRDs. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
uninstall-crds: manifests ## Uninstall CRDs. Call with ignore-not-found=true to ignore resource not found errors during deletion.
find charts/fleetconfig-controller/crds/ -name "fleetconfig.open-cluster-management.*.yaml" -exec $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f {} \;
42 changes: 42 additions & 0 deletions fleetconfig-controller/PROJECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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
cliVersion: v4.7.1
layout:
- go.kubebuilder.io/v4
projectName: fleetconfig-controller
repo: github.com/open-cluster-management-io/lab/fleetconfig-controller
resources:
- api:
crdVersion: v1
namespaced: true
group: fleetconfig.open-cluster-management.io
kind: FleetConfig
path: github.com/open-cluster-management-io/lab/fleetconfig-controller/api/v1alpha1
version: v1alpha1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
group: fleetconfig.open-cluster-management.io
kind: Hub
path: github.com/open-cluster-management-io/lab/fleetconfig-controller/api/v1beta1
version: v1beta1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
group: fleetconfig.open-cluster-management.io
kind: Spoke
path: github.com/open-cluster-management-io/lab/fleetconfig-controller/api/v1beta1
version: v1beta1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
version: "3"
6 changes: 6 additions & 0 deletions fleetconfig-controller/api/v1alpha1/fleetconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ func (c Condition) Equal(other Condition) bool {
c.Reason == other.Reason && c.Message == other.Message
}

// +kubebuilder:object:root=false
// +kubebuilder:skipversion

// Hub provides specifications for an OCM hub cluster.
type Hub struct {
// APIServer is the API server URL for the Hub cluster. If provided, spokes clusters will
Expand Down Expand Up @@ -339,6 +342,9 @@ type ISpoke interface {
var _ ISpoke = &Spoke{}
var _ ISpoke = &JoinedSpoke{}

// +kubebuilder:object:root=false
// +kubebuilder:skipversion

// Spoke provides specifications for joining and potentially upgrading spokes.
type Spoke struct {
// The name of the spoke cluster.
Expand Down
5 changes: 4 additions & 1 deletion fleetconfig-controller/api/v1alpha1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ var _ = BeforeSuite(func() {
err = AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

root, err := test.GetProjectDir()
Expect(err).NotTo(HaveOccurred())

By("bootstrapping test environment")
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join(root, "charts", "fleetconfig-controller", "crds")},
ErrorIfCRDPathMissing: false,
WebhookInstallOptions: envtest.WebhookInstallOptions{
Paths: []string{filepath.Join("..", "..", "config", "webhook")},
Expand Down
36 changes: 36 additions & 0 deletions fleetconfig-controller/api/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2024.

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 contains API Schema definitions for the v1beta1 API group.
// +kubebuilder:object:generate=true
// +groupName=fleetconfig.open-cluster-management.io
package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "fleetconfig.open-cluster-management.io", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
76 changes: 76 additions & 0 deletions fleetconfig-controller/api/v1beta1/hub_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2024.
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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// HubSpec defines the desired state of Hub
type HubSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The following markers will use OpenAPI v3 schema to validate the value
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html

// foo is an example field of Hub. Edit hub_types.go to remove/update
// +optional
Foo *string `json:"foo,omitempty"`
}

// HubStatus defines the observed state of Hub.
type HubStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// Hub is the Schema for the hubs API
type Hub struct {
metav1.TypeMeta `json:",inline"`

// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the desired state of Hub
// +required
Spec HubSpec `json:"spec"`

// status defines the observed state of Hub
// +optional
Status HubStatus `json:"status,omitempty,omitzero"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Hub{}, &HubList{})
}
76 changes: 76 additions & 0 deletions fleetconfig-controller/api/v1beta1/spoke_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2024.

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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// SpokeSpec defines the desired state of Spoke
type SpokeSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// The following markers will use OpenAPI v3 schema to validate the value
// More info: https://book.kubebuilder.io/reference/markers/crd-validation.html

// foo is an example field of Spoke. Edit spoke_types.go to remove/update
// +optional
Foo *string `json:"foo,omitempty"`
}

// SpokeStatus defines the observed state of Spoke.
type SpokeStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

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

// Spoke is the Schema for the spokes API
type Spoke struct {
metav1.TypeMeta `json:",inline"`

// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`

// spec defines the desired state of Spoke
// +required
Spec SpokeSpec `json:"spec"`

// status defines the observed state of Spoke
// +optional
Status SpokeStatus `json:"status,omitempty,omitzero"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&Spoke{}, &SpokeList{})
}
Loading
Loading