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
22 changes: 20 additions & 2 deletions apis/placement/v1alpha1/override_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,32 @@ type OverrideRule struct {
// +optional
ClusterSelector *placementv1beta1.ClusterSelector `json:"clusterSelector,omitempty"`

// OverrideType defines the type of the override rules.
// +kubebuilder:validation:Enum=JSONPatch;Delete
// +kubebuilder:default:JSONPatch
// +optional
OverrideType OverrideType `json:"overrideType,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OverrideType OverrideType `json:"overrideType,omitempty"`
Type OverrideType `json:"type,omitempty"`


// JSONPatchOverrides defines a list of JSON patch override rules.
// This field is only allowed when OverrideType is JSONPatch.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=20
// +required
JSONPatchOverrides []JSONPatchOverride `json:"jsonPatchOverrides"`
// +optional
JSONPatchOverrides []JSONPatchOverride `json:"jsonPatchOverrides,omitempty"`
}

// OverrideType defines the type of Override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing period

type OverrideType string

const (
// JSONPatchOverrideType applies a JSON patch on the selected resources following [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).
JSONPatchOverrideType OverrideType = "JSONPatch"

// DeleteOverrideType deletes the selected resources on the target clusters.
DeleteOverrideType OverrideType = "Delete"
)

// +genclient
// +genclient:Namespaced
// +kubebuilder:object:root=true
Expand Down
5 changes: 3 additions & 2 deletions apis/placement/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions pkg/controllers/updaterun/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"fmt"
"time"

"go.goms.io/fleet/pkg/utils"
"go.goms.io/fleet/pkg/utils/controller"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
Expand All @@ -27,6 +25,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

placementv1alpha1 "go.goms.io/fleet/apis/placement/v1alpha1"
"go.goms.io/fleet/pkg/utils"
"go.goms.io/fleet/pkg/utils/controller"
)

// Reconciler reconciles a ClusterStagedUpdateRun object.
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/updaterun/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ package updaterun
import (
"testing"

placementv1alpha1 "go.goms.io/fleet/apis/placement/v1alpha1"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

placementv1alpha1 "go.goms.io/fleet/apis/placement/v1alpha1"
)

func TestHandleClusterApprovalRequest(t *testing.T) {
Expand Down
Loading