Skip to content

Commit

Permalink
use actions/deploy and add requisite permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenTobin committed Dec 16, 2024
1 parent d57191e commit 7a0feef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
11 changes: 6 additions & 5 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -858,17 +858,18 @@ rules:
- apiGroups:
- services.platform.opendatahub.io
resources:
- auths/status
- monitorings/status
- auths/finalizers
- monitorings/finalizers
verbs:
- get
- patch
- update
- apiGroups:
- services.platform.opendatahub.io
resources:
- monitorings/finalizers
- auths/status
- monitorings/status
verbs:
- get
- patch
- update
- apiGroups:
- serving.knative.dev
Expand Down
1 change: 1 addition & 0 deletions controllers/datasciencecluster/kubebuilder_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,4 @@ package datasciencecluster
// Auth
// +kubebuilder:rbac:groups=services.platform.opendatahub.io,resources=auths,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=services.platform.opendatahub.io,resources=auths/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=services.platform.opendatahub.io,resources=auths/finalizers,verbs=update
4 changes: 4 additions & 0 deletions controllers/services/auth/auth_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"

serviceApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/services/v1alpha1"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/render/template"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/reconciler"
)
Expand Down Expand Up @@ -54,6 +55,9 @@ func NewServiceReconciler(ctx context.Context, mgr ctrl.Manager) error {
)).
WithAction(copyGroups).
WithAction(managePermissions).
WithAction(deploy.NewAction(
deploy.WithCache(),
)).
WithAction(setStatus).
Build(ctx)

Expand Down
9 changes: 1 addition & 8 deletions controllers/services/auth/auth_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func bindRole(ctx context.Context, rr *odhtypes.ReconciliationRequest, groups []
Name: roleName,
},
}
err := rr.Client.Update(ctx, rb)
err := rr.AddResources(rb)
if err != nil {
return errors.New("error creating RoleBinding for group")
}
Expand Down Expand Up @@ -199,13 +199,6 @@ func managePermissions(ctx context.Context, rr *odhtypes.ReconciliationRequest)
return errors.New("instance is not of type *services.Auth")
}

for _, role := range rr.Resources {
err := rr.Client.Update(ctx, &role)
if err != nil {
return err
}
}

err := bindRole(ctx, rr, ai.Spec.AdminGroups, "admingroup-rolebinding", "admingroup-role")
if err != nil {
return err
Expand Down

0 comments on commit 7a0feef

Please sign in to comment.