Skip to content

Commit

Permalink
make a few small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverMKing committed Nov 2, 2023
1 parent 220163f commit 8a95cdc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func NewManagerForRestConfig(conf *config.Config, rc *rest.Config) (ctrl.Manager
}

certsReady := make(chan struct{})
if err := webhookCfg.AddCertManager(context.Background(), m, certsReady); err != nil {
if err := webhookCfg.AddCertManager(context.Background(), m, certsReady, cl); err != nil {
return nil, fmt.Errorf("adding cert manager: %w", err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/webhook/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ type certManager struct {
Ready chan struct{}
}

func (c *certManager) addToManager(ctx context.Context, mgr manager.Manager, lgr logr.Logger) error {
func (c *certManager) addToManager(ctx context.Context, mgr manager.Manager, lgr logr.Logger, cl client.Client) error {
lgr.Info("ensuring webhook cert secret")
if err := c.ensureSecret(ctx, mgr.GetClient()); err != nil {
if err := c.ensureSecret(ctx, cl); err != nil {
return fmt.Errorf("ensuring secret: %w", err)
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/webhook/nginxingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ var sarAuthenticate = func(ctx context.Context, lgr logr.Logger, cl client.Clien
lgr := lgr.WithValues("sarResource", resource.Name, "sarGroup", resource.Group, "sarVersion", resource.Version)
lgr.Info("checking permissions for resource")
sar := authv1.SubjectAccessReview{
ObjectMeta: metav1.ObjectMeta{
Name: "nginx-ingress-controller-validation",
},
Spec: authv1.SubjectAccessReviewSpec{
ResourceAttributes: &authv1.ResourceAttributes{
// TODO: add namespace check, this is a bit harder because we need to check if resource is namespaced
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c *config) EnsureWebhookConfigurations(ctx context.Context, cl client.Clie

// AddCertManager adds cert-manager to the manager. The manager starting will result in the cert-manager
// starting and generating the certificates.
func (c *config) AddCertManager(ctx context.Context, mgr manager.Manager, certsReady chan struct{}) error {
func (c *config) AddCertManager(ctx context.Context, mgr manager.Manager, certsReady chan struct{}, cl client.Client) error {
lgr := log.FromContext(ctx).WithName("cert-manager")

lgr.Info("calculating webhooks for cert-manager")
Expand All @@ -162,7 +162,7 @@ func (c *config) AddCertManager(ctx context.Context, mgr manager.Manager, certsR
CAOrganization: "Microsoft",
Ready: certsReady,
}
if err := cm.addToManager(ctx, mgr, lgr); err != nil {
if err := cm.addToManager(ctx, mgr, lgr, cl); err != nil {
return fmt.Errorf("adding rotation: %w", err)
}

Expand Down

0 comments on commit 8a95cdc

Please sign in to comment.