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

crd changes #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions api/v1alpha1/resourcemanager_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ type ResourceManagerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Active bool `json:"active,omitempty"`
DryRun bool `json:"dry-run,omitempty"`
Disabled bool `json:"active,omitempty"`
DryRun bool `json:"dry-run,omitempty"`

// TODO: add validation
Resources string `json:"resources"`
Selector *metav1.LabelSelector `json:"selector"`
ResourceKind string `json:"resourceKind"`
Selector *metav1.LabelSelector `json:"selector"`

// TODO: add validation + enum
Action string `json:"action"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: resourcemanagers.resource-management.tikalk.com
spec:
Expand Down Expand Up @@ -54,7 +55,7 @@ spec:
type: array
dry-run:
type: boolean
resources:
resourceKind:
description: 'TODO: add validation'
type: string
selector:
Expand Down Expand Up @@ -104,11 +105,10 @@ spec:
are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
required:
- action
- condition
- resources
- resourceKind
- selector
type: object
status:
Expand All @@ -119,3 +119,9 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
127 changes: 0 additions & 127 deletions config/crd/bases/resource-managment.tikalk.com_resourcemanagers.yaml

This file was deleted.

1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ kind: ResourceManager
metadata:
name: resource-manager-sample
spec:
active: true
disabled: false
dry-run: false
resources: "namespace"
resourceKind: "namespace"
selector:
matchLabels:
name: managed-namespace1
Expand Down
4 changes: 2 additions & 2 deletions controllers/resourcemanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (r *ResourceManagerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
" action: %s \n"+
" condition: %s \n"+
" type: %s \n",
h.Spec.Resources,
h.Spec.ResourceKind,
h.Spec.Selector.MatchLabels,
h.Spec.Action,
h.Spec.Condition[0].After,
Expand All @@ -114,7 +114,7 @@ func (r *ResourceManagerReconciler) Reconcile(ctx context.Context, req ctrl.Requ
delete(collection, h.Name)
}

switch h.Spec.Resources {
switch h.Spec.ResourceKind {
case "namespace":
// add the function and its stop-channel to collection
collection[h.Name] = FHandler{
Expand Down
8 changes: 4 additions & 4 deletions controllers/resourcemanager_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ var _ = Context("Inside of a ResourceManager", func() {
Namespace: "default",
},
Spec: resourcemanagmentv1alpha1.ResourceManagerSpec{
Active: true,
DryRun: false,
Resources: "namespace",
Disabled: false,
DryRun: false,
ResourceKind: "Namespace",
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"name": "managed-namespace",
Expand Down Expand Up @@ -65,7 +65,7 @@ var _ = Context("Inside of a ResourceManager", func() {
},
}
err = k8sClient.Create(ctx, myNamespaceObj)
Expect(err).NotTo(HaveOccurred(), "failed to create test 'namespace' resource")
Expect(err).NotTo(HaveOccurred(), "failed to create test 'Namespace' resource")

// validate creation
nsObj, _ := getResourceByName(ctx, myNamespaceObj.Name)
Expand Down