Skip to content

Commit

Permalink
Addressing PR comments
Browse files Browse the repository at this point in the history
Missed some stuff
  • Loading branch information
UnstoppableMango committed Jan 19, 2024
1 parent 0a1ca52 commit 025da4a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 353 deletions.
4 changes: 4 additions & 0 deletions pkg/cloudflare-controller/tunnel-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func (t *TunnelClient) PutExposures(ctx context.Context, exposures []exposure.Ex
return nil
}

func (t *TunnelClient) TunnelDomain() string {
return tunnelDomain(t.tunnelId)
}

func (t *TunnelClient) updateTunnelIngressRules(ctx context.Context, exposures []exposure.Exposure) error {
var ingressRules []cloudflare.UnvalidatedIngressRule

Expand Down
17 changes: 15 additions & 2 deletions pkg/controller/ingress-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package controller
import (
"context"
"fmt"

cloudflarecontroller "github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/cloudflare-controller"
"github.com/STRRL/cloudflare-tunnel-ingress-controller/pkg/exposure"
"github.com/go-logr/logr"
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -99,6 +99,19 @@ func (i *IngressController) Reconcile(ctx context.Context, request reconcile.Req
}
}

origin.Status.LoadBalancer.Ingress = append(origin.Status.LoadBalancer.Ingress,
networkingv1.IngressLoadBalancerIngress{
Hostname: i.tunnelClient.TunnelDomain(),
Ports: []networkingv1.IngressPortStatus{{
Protocol: v1.ProtocolTCP,
Port: 443,
}},
},
)
if err = i.kubeClient.Status().Update(ctx, &origin); err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to update ingress status")
}

i.logger.V(3).Info("reconcile completed", "triggered-by", request.NamespacedName)
return reconcile.Result{}, nil
}
Expand Down Expand Up @@ -135,7 +148,7 @@ func (i *IngressController) listControlledIngressClasses(ctx context.Context) ([
if err != nil {
return nil, errors.Wrap(err, "list ingress classes")
}

filteredList := make([]networkingv1.IngressClass, 0, len(list.Items))
for _, ingress := range list.Items {
if ingress.Spec.Controller != i.controllerClassName {
Expand Down
13 changes: 0 additions & 13 deletions pkg/controller/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@ func FromIngressToExposure(ctx context.Context, logger logr.Logger, kubeClient c
IsDeleted: isDeleted,
ProxySSLVerifyEnabled: proxySSLVerifyEnabled,
})

if service.Status.LoadBalancer.Ingress == nil {
service.Status.LoadBalancer.Ingress = []v1.LoadBalancerIngress{{Hostname: hostname}}
} else {
service.Status.LoadBalancer.Ingress = append(service.Status.LoadBalancer.Ingress, v1.LoadBalancerIngress{
Hostname: hostname,
})
}

err = kubeClient.Status().Update(ctx, &service)
if err != nil {
return nil, errors.Wrapf(err, "update service %s", service.Name)
}
}
}

Expand Down
Loading

0 comments on commit 025da4a

Please sign in to comment.