Skip to content

Commit 8a3e6a7

Browse files
committed
Add soft delete flag to DNS Operator plan.
Signed-off-by: Phil Brookes <[email protected]>
1 parent 8fe0b96 commit 8a3e6a7

File tree

8 files changed

+1404
-375
lines changed

8 files changed

+1404
-375
lines changed

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ build: manifests generate fmt vet ## Build manager binary.
250250
.PHONY: run
251251
run: GIT_SHA=$(shell git rev-parse HEAD || echo "unknown")
252252
run: DIRTY=$(shell hack/check-git-dirty.sh || echo "unknown")
253+
run: MPORT=:8080
254+
run: PPORT=:8081
253255
run: manifests generate fmt vet ## Run a controller from your host.
254-
go run -ldflags "-X main.version=v${VERSION} -X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" --race ./cmd/main.go --zap-devel --provider inmemory,aws,google,azure
256+
go run -ldflags "-X main.version=v${VERSION} -X main.gitSHA=${GIT_SHA} -X main.dirty=${DIRTY}" --race ./cmd/main.go --zap-devel --provider inmemory,aws,google,azure --metrics-bind-address ${MPORT} --health-probe-bind-address ${PPORT}
255257

256258
.PHONY: run-with-probes
257259
run-with-probes: GIT_SHA=$(shell git rev-parse HEAD || echo "unknown")

internal/common/helper.go

+34
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package common
22

33
import (
4+
"fmt"
5+
"io"
46
"time"
57

68
"k8s.io/apimachinery/pkg/util/rand"
9+
externaldnsendpoint "sigs.k8s.io/external-dns/endpoint"
710
)
811

912
// RandomizeValidationDuration randomizes duration for a given variance with a min value of 1 sec
@@ -27,3 +30,34 @@ func RandomizeDuration(variance, duration float64) time.Duration {
2730
int64(lowerLimit),
2831
int64(upperLimit)))
2932
}
33+
34+
func WriteEndpoints(s io.Writer, endpoints []*externaldnsendpoint.Endpoint, title string) {
35+
fmt.Fprintf(s, "\n====== %s ======\n", title)
36+
for _, ep := range endpoints {
37+
fmt.Fprintf(s, " endpoint: %v > %+v with labels: %+v and flags: %+v\n", ep.DNSName, ep.Targets, ep.Labels, ep.ProviderSpecific)
38+
}
39+
fmt.Fprintf(s, "====== %s ======\n\n", title)
40+
}
41+
42+
func RemoveLabelFromEndpoint(label string, endpoint *externaldnsendpoint.Endpoint) *externaldnsendpoint.Endpoint {
43+
if endpoint.Labels == nil {
44+
return endpoint
45+
}
46+
47+
delete(endpoint.Labels, label)
48+
return endpoint
49+
}
50+
51+
func RemoveLabelFromEndpoints(label string, endpoints []*externaldnsendpoint.Endpoint) []*externaldnsendpoint.Endpoint {
52+
for _, e := range endpoints {
53+
RemoveLabelFromEndpoint(label, e)
54+
}
55+
return endpoints
56+
}
57+
func RemoveLabelsFromEndpoints(labels []string, endpoints []*externaldnsendpoint.Endpoint) []*externaldnsendpoint.Endpoint {
58+
for _, l := range labels {
59+
RemoveLabelFromEndpoints(l, endpoints)
60+
}
61+
62+
return endpoints
63+
}

0 commit comments

Comments
 (0)