Skip to content

Commit

Permalink
Disable ConfigMap watcher (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz-Smelcerz-SAP authored and aeneasr committed Dec 11, 2019
1 parent 0601fb0 commit b25c29e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
13 changes: 0 additions & 13 deletions controllers/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand All @@ -23,9 +22,6 @@ type OperatorMode interface {
// oathkeeperRulesJSON - serialized JSON with an array of objects that conform to Oathkeeper Rule syntax
// triggeredBy - the recently created/update rule that triggered the operation
CreateOrUpdate(ctx context.Context, oathkeeperRulesJSON []byte, triggeredBy *oathkeeperv1alpha1.Rule) error

//Registers additional K8s types necessary for the specific mode to work
Owns(*builder.Builder) *builder.Builder
}

//ConfigMapOperator that maintains Oathkeeper rules as an json-formatted entry in a ConfigMap
Expand Down Expand Up @@ -118,10 +114,6 @@ func (cmo *ConfigMapOperator) CreateOrUpdate(ctx context.Context, oathkeeperRule
return cmo.updateOrCreateRulesConfigmap(ctx, configMapRef, string(oathkeeperRulesJSON))
}

func (cmo *ConfigMapOperator) Owns(bldr *builder.Builder) *builder.Builder {
return bldr.Owns(&apiv1.ConfigMap{})
}

func (fo *FilesOperator) updateOrCreateRulesFile(ctx context.Context, data string) error {
var f *os.File
f, err := os.Create(fo.RulesFilePath)
Expand All @@ -148,8 +140,3 @@ func (fo *FilesOperator) CreateOrUpdate(ctx context.Context, oathkeeperRulesJSON

return fo.updateOrCreateRulesFile(ctx, string(oathkeeperRulesJSON))
}

func (fo *FilesOperator) Owns(bldr *builder.Builder) *builder.Builder {
//NO-OP
return bldr
}
6 changes: 3 additions & 3 deletions controllers/rule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ func (r *RuleReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {

//SetupWithManager ??
func (r *RuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
bldr := ctrl.NewControllerManagedBy(mgr).
For(&oathkeeperv1alpha1.Rule{})
return r.OperatorMode.Owns(bldr).Complete(r)
return ctrl.NewControllerManagedBy(mgr).
For(&oathkeeperv1alpha1.Rule{}).
Complete(r)
}

func isObjectHasBeenModified(err error) bool {
Expand Down

0 comments on commit b25c29e

Please sign in to comment.