-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add IAM Auth Policy dummy controller #443
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1" | ||
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" | ||
|
||
k8serr "k8s.io/apimachinery/pkg/api/errors" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type IAMAuthPolicyController struct { | ||
log gwlog.Logger | ||
client client.Client | ||
} | ||
|
||
func RegisterIAMAuthPolicyController(log gwlog.Logger, mgr ctrl.Manager) error { | ||
controller := &IAMAuthPolicyController{ | ||
log: log, | ||
client: mgr.GetClient(), | ||
} | ||
err := ctrl.NewControllerManagedBy(mgr). | ||
For(&anv1alpha1.IAMAuthPolicy{}). | ||
Complete(controller) | ||
return err | ||
} | ||
|
||
func (c *IAMAuthPolicyController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
c.log.Infow("reconcile", "req", req) | ||
|
||
policy := &anv1alpha1.IAMAuthPolicy{} | ||
err := c.client.Get(ctx, req.NamespacedName, policy) | ||
if !k8serr.IsNotFound(err) { | ||
return ctrl.Result{}, err | ||
} | ||
|
||
switch policy.Spec.TargetRef.Kind { | ||
case "Gateway": | ||
err = c.reconcileGateway(ctx, policy) | ||
break | ||
case "HTTPRoute": | ||
case "GRPCRoute": | ||
err = c.reconcileRoute(ctx, policy) | ||
break | ||
default: | ||
err = fmt.Errorf("unsupported targetRef type, req=%s, kind=%s", | ||
req, policy.Spec.TargetRef.Kind) | ||
} | ||
if err != nil { | ||
return ctrl.Result{}, err | ||
} | ||
|
||
c.log.Infow("successfully reconciled", "req", req) | ||
return ctrl.Result{}, nil | ||
} | ||
|
||
func (c *IAMAuthPolicyController) reconcileGateway(ctx context.Context, policy *anv1alpha1.IAMAuthPolicy) error { | ||
c.log.Debugw("reconcile gateway iam policy", "policy", policy) | ||
return nil | ||
} | ||
|
||
func (c IAMAuthPolicyController) reconcileRoute(ctx context.Context, policy *anv1alpha1.IAMAuthPolicy) error { | ||
c.log.Debugw("reconcile route iam policy", "policy", policy) | ||
return nil | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add the
pkg_builder.WithPredicates(predicate.GenerationChangedPredicate{})
in the later PRsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerationChangedPredicate description is a bit vague to me. Especially "Caveats" section. Why do we use this?