Skip to content

Commit 5e31112

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #64541 from mrogers950/additive-flag
Automatic merge from submit-queue (batch tested with PRs 63580, 63744, 64541, 64502, 64100). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add more kubectl auth reconcile flags ```release-note The --remove-extra-subjects and --remove-extra-permissions flags have been enabled for kubectl auth reconcile ``` /assign @deads2k cc @enj @juanvallejo
2 parents 65819a8 + 9f3b975 commit 5e31112

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/kubectl/cmd/auth/reconcile.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ import (
3737
// ReconcileOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
3838
// referencing the cmd.Flags()
3939
type ReconcileOptions struct {
40-
PrintFlags *genericclioptions.PrintFlags
41-
FilenameOptions *resource.FilenameOptions
42-
DryRun bool
40+
PrintFlags *genericclioptions.PrintFlags
41+
FilenameOptions *resource.FilenameOptions
42+
DryRun bool
43+
RemoveExtraPermissions bool
44+
RemoveExtraSubjects bool
4345

4446
Visitor resource.Visitor
4547
RBACClient rbacv1client.RbacV1Interface
@@ -89,6 +91,8 @@ func NewCmdReconcile(f cmdutil.Factory, streams genericclioptions.IOStreams) *co
8991

9092
cmdutil.AddFilenameOptionFlags(cmd, o.FilenameOptions, "identifying the resource to reconcile.")
9193
cmd.Flags().BoolVar(&o.DryRun, "dry-run", o.DryRun, "If true, display results but do not submit changes")
94+
cmd.Flags().BoolVar(&o.RemoveExtraPermissions, "remove-extra-permissions", o.RemoveExtraPermissions, "If true, removes extra permissions added to roles")
95+
cmd.Flags().BoolVar(&o.RemoveExtraSubjects, "remove-extra-subjects", o.RemoveExtraSubjects, "If true, removes extra subjects added to rolebindings")
9296
cmd.MarkFlagRequired("filename")
9397

9498
return cmd
@@ -174,7 +178,7 @@ func (o *ReconcileOptions) RunReconcile() error {
174178
case *rbacv1.Role:
175179
reconcileOptions := reconciliation.ReconcileRoleOptions{
176180
Confirm: !o.DryRun,
177-
RemoveExtraPermissions: false,
181+
RemoveExtraPermissions: o.RemoveExtraPermissions,
178182
Role: reconciliation.RoleRuleOwner{Role: t},
179183
Client: reconciliation.RoleModifier{
180184
NamespaceClient: o.NamespaceClient.Namespaces(),
@@ -190,7 +194,7 @@ func (o *ReconcileOptions) RunReconcile() error {
190194
case *rbacv1.ClusterRole:
191195
reconcileOptions := reconciliation.ReconcileRoleOptions{
192196
Confirm: !o.DryRun,
193-
RemoveExtraPermissions: false,
197+
RemoveExtraPermissions: o.RemoveExtraPermissions,
194198
Role: reconciliation.ClusterRoleRuleOwner{ClusterRole: t},
195199
Client: reconciliation.ClusterRoleModifier{
196200
Client: o.RBACClient.ClusterRoles(),
@@ -205,7 +209,7 @@ func (o *ReconcileOptions) RunReconcile() error {
205209
case *rbacv1.RoleBinding:
206210
reconcileOptions := reconciliation.ReconcileRoleBindingOptions{
207211
Confirm: !o.DryRun,
208-
RemoveExtraSubjects: false,
212+
RemoveExtraSubjects: o.RemoveExtraSubjects,
209213
RoleBinding: reconciliation.RoleBindingAdapter{RoleBinding: t},
210214
Client: reconciliation.RoleBindingClientAdapter{
211215
Client: o.RBACClient,
@@ -221,7 +225,7 @@ func (o *ReconcileOptions) RunReconcile() error {
221225
case *rbacv1.ClusterRoleBinding:
222226
reconcileOptions := reconciliation.ReconcileRoleBindingOptions{
223227
Confirm: !o.DryRun,
224-
RemoveExtraSubjects: false,
228+
RemoveExtraSubjects: o.RemoveExtraSubjects,
225229
RoleBinding: reconciliation.ClusterRoleBindingAdapter{ClusterRoleBinding: t},
226230
Client: reconciliation.ClusterRoleBindingClientAdapter{
227231
Client: o.RBACClient.ClusterRoleBindings(),

0 commit comments

Comments
 (0)