Skip to content

Commit

Permalink
feat: Add delete override option in the API (Azure#972)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanzhang-oss authored Nov 27, 2024
1 parent 299da87 commit 85a7531
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
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"`

// 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
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

0 comments on commit 85a7531

Please sign in to comment.