-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Oliver Bähler <[email protected]>
- Loading branch information
1 parent
05b6c36
commit e8c06de
Showing
7 changed files
with
82 additions
and
64 deletions.
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
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
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,38 @@ | ||
package controller | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
networkingv1 "k8s.io/api/networking/v1" | ||
) | ||
|
||
const IngressControllerFinalizer = "strrl.dev/cloudflare-tunnel-ingress-controller-controlled" | ||
|
||
func (i *IngressController) hasFinalizer(ctx context.Context, ingress networkingv1.Ingress) bool { | ||
return stringSliceContains(ingress.Finalizers, IngressControllerFinalizer) | ||
} | ||
|
||
func (i *IngressController) attachFinalizer(ctx context.Context, ingress networkingv1.Ingress) error { | ||
if stringSliceContains(ingress.Finalizers, IngressControllerFinalizer) { | ||
return nil | ||
} | ||
ingress.Finalizers = append(ingress.Finalizers, IngressControllerFinalizer) | ||
err := i.kubeClient.Update(ctx, &ingress) | ||
if err != nil { | ||
return errors.Wrapf(err, "attach finalizer for %s/%s", ingress.Namespace, ingress.Name) | ||
} | ||
return nil | ||
} | ||
|
||
func (i *IngressController) cleanFinalizer(ctx context.Context, ingress networkingv1.Ingress) error { | ||
if !stringSliceContains(ingress.Finalizers, IngressControllerFinalizer) { | ||
return nil | ||
} | ||
ingress.Finalizers = removeStringFromSlice(ingress.Finalizers, IngressControllerFinalizer) | ||
err := i.kubeClient.Update(ctx, &ingress) | ||
if err != nil { | ||
return errors.Wrapf(err, "clean finalizer for %s/%s", ingress.Namespace, ingress.Name) | ||
} | ||
return nil | ||
} |
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