Skip to content

Commit

Permalink
Rename API to ResourceSet
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Jan 5, 2025
1 parent 9195fb3 commit e14febf
Show file tree
Hide file tree
Showing 26 changed files with 255 additions and 246 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ resources:
kind: FluxReport
path: github.com/controlplaneio-fluxcd/flux-operator/api/v1
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: controlplane.io
group: fluxcd
kind: ResourceSet
path: github.com/controlplaneio-fluxcd/flux-operator/api/v1
version: v1
version: "3"
48 changes: 24 additions & 24 deletions api/v1/resourcegroup_types.go → api/v1/resourceset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
)

const (
ResourceGroupKind = "ResourceGroup"
ResourceSetKind = "ResourceSet"
)

// ResourceGroupSpec defines the desired state of ResourceGroup
type ResourceGroupSpec struct {
// ResourceSetSpec defines the desired state of ResourceSet
type ResourceSetSpec struct {
// CommonMetadata specifies the common labels and annotations that are
// applied to all resources. Any existing label or annotation will be
// overridden if its key matches a common one.
Expand All @@ -27,7 +27,7 @@ type ResourceGroupSpec struct {

// Inputs contains the list of resource group inputs.
// +optional
Inputs []ResourceGroupInput `json:"inputs,omitempty"`
Inputs []ResourceSetInput `json:"inputs,omitempty"`

// Resources contains the list of Kubernetes resources to reconcile.
// +optional
Expand All @@ -50,7 +50,7 @@ type ResourceGroupSpec struct {
Wait bool `json:"wait,omitempty"`
}

// Dependency defines a ResourceGroup dependency on a Kubernetes resource.
// Dependency defines a ResourceSet dependency on a Kubernetes resource.
type Dependency struct {
// APIVersion of the resource to depend on.
// +required
Expand All @@ -77,11 +77,11 @@ type Dependency struct {
ReadyExpr string `json:"readyExpr,omitempty"`
}

// ResourceGroupInput defines the key-value pairs of the resource group input.
type ResourceGroupInput map[string]string
// ResourceSetInput defines the key-value pairs of the resource group input.
type ResourceSetInput map[string]string

// ResourceGroupStatus defines the observed state of ResourceGroup
type ResourceGroupStatus struct {
// ResourceSetStatus defines the observed state of ResourceSet
type ResourceSetStatus struct {
meta.ReconcileRequestStatus `json:",inline"`

// Conditions contains the readiness conditions of the object.
Expand All @@ -100,24 +100,24 @@ type ResourceGroupStatus struct {
}

// GetConditions returns the status conditions of the object.
func (in *ResourceGroup) GetConditions() []metav1.Condition {
func (in *ResourceSet) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the status conditions on the object.
func (in *ResourceGroup) SetConditions(conditions []metav1.Condition) {
func (in *ResourceSet) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// IsDisabled returns true if the object has the reconcile annotation set to 'disabled'.
func (in *ResourceGroup) IsDisabled() bool {
func (in *ResourceSet) IsDisabled() bool {
val, ok := in.GetAnnotations()[ReconcileAnnotation]
return ok && strings.ToLower(val) == DisabledValue
}

// GetInterval returns the interval at which the object should be reconciled.
// If no interval is set, the default is 60 minutes.
func (in *ResourceGroup) GetInterval() time.Duration {
func (in *ResourceSet) GetInterval() time.Duration {
val, ok := in.GetAnnotations()[ReconcileAnnotation]
if ok && strings.ToLower(val) == DisabledValue {
return 0
Expand All @@ -136,7 +136,7 @@ func (in *ResourceGroup) GetInterval() time.Duration {

// GetTimeout returns the timeout for the reconciliation process.
// If no timeout is set, the default is 5 minutes.
func (in *ResourceGroup) GetTimeout() time.Duration {
func (in *ResourceSet) GetTimeout() time.Duration {
defaultTimeout := 5 * time.Minute
val, ok := in.GetAnnotations()[ReconcileTimeoutAnnotation]
if !ok {
Expand All @@ -150,7 +150,7 @@ func (in *ResourceGroup) GetTimeout() time.Duration {
}

// GetInputs returns the resource group inputs.
func (in *ResourceGroup) GetInputs() []map[string]string {
func (in *ResourceSet) GetInputs() []map[string]string {
var inputs = make([]map[string]string, len(in.Spec.Inputs))
for i, input := range in.Spec.Inputs {
inputs[i] = make(map[string]string)
Expand All @@ -164,29 +164,29 @@ func (in *ResourceGroup) GetInputs() []map[string]string {
// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=rg
// +kubebuilder:resource:shortName=rset
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description=""
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""

// ResourceGroup is the Schema for the ResourceGroups API
type ResourceGroup struct {
// ResourceSet is the Schema for the ResourceSets API
type ResourceSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ResourceGroupSpec `json:"spec,omitempty"`
Status ResourceGroupStatus `json:"status,omitempty"`
Spec ResourceSetSpec `json:"spec,omitempty"`
Status ResourceSetStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&ResourceGroup{}, &ResourceGroupList{})
SchemeBuilder.Register(&ResourceSet{}, &ResourceSetList{})
}
122 changes: 61 additions & 61 deletions api/v1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func main() {
os.Exit(1)
}

if err = (&controller.ResourceGroupReconciler{
if err = (&controller.ResourceSetReconciler{
Client: mgr.GetClient(),
APIReader: mgr.GetAPIReader(),
Scheme: mgr.GetScheme(),
Expand All @@ -200,10 +200,10 @@ func main() {
EventRecorder: mgr.GetEventRecorderFor(controllerName),
DefaultServiceAccount: defaultServiceAccount,
}).SetupWithManager(mgr,
controller.ResourceGroupReconcilerOptions{
controller.ResourceSetReconcilerOptions{
RateLimiter: runtimeCtrl.GetRateLimiter(rateLimiterOptions),
}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", fluxcdv1.ResourceGroupKind)
setupLog.Error(err, "unable to create controller", "controller", fluxcdv1.ResourceSetKind)
os.Exit(1)
}
// +kubebuilder:scaffold:builder
Expand Down
Loading

0 comments on commit e14febf

Please sign in to comment.