Skip to content
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

[feature] Implement soft_delete and stop_soft_delete flags in the plan #384

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ build: manifests generate fmt vet ## Build manager binary.
.PHONY: run
run: GIT_SHA=$(shell git rev-parse HEAD || echo "unknown")
run: DIRTY=$(shell hack/check-git-dirty.sh || echo "unknown")
run: MPORT=:8080
run: PPORT=:8081
run: manifests generate fmt vet ## Run a controller from your host.
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
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}

.PHONY: run-with-probes
run-with-probes: GIT_SHA=$(shell git rev-parse HEAD || echo "unknown")
Expand Down
34 changes: 34 additions & 0 deletions internal/common/helper.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package common

import (
"fmt"
"io"
"time"

"k8s.io/apimachinery/pkg/util/rand"
externaldnsendpoint "sigs.k8s.io/external-dns/endpoint"
)

// RandomizeValidationDuration randomizes duration for a given variance with a min value of 1 sec
Expand All @@ -27,3 +30,34 @@ func RandomizeDuration(variance, duration float64) time.Duration {
int64(lowerLimit),
int64(upperLimit)))
}

func WriteEndpoints(s io.Writer, endpoints []*externaldnsendpoint.Endpoint, title string) {
fmt.Fprintf(s, "\n====== %s ======\n", title)
for _, ep := range endpoints {
fmt.Fprintf(s, " endpoint: %v > %+v with labels: %+v and flags: %+v\n", ep.DNSName, ep.Targets, ep.Labels, ep.ProviderSpecific)
}
fmt.Fprintf(s, "====== %s ======\n\n", title)
}

func RemoveLabelFromEndpoint(label string, endpoint *externaldnsendpoint.Endpoint) *externaldnsendpoint.Endpoint {
if endpoint.Labels == nil {
return endpoint
}

delete(endpoint.Labels, label)
return endpoint
}

func RemoveLabelFromEndpoints(label string, endpoints []*externaldnsendpoint.Endpoint) []*externaldnsendpoint.Endpoint {
for _, e := range endpoints {
RemoveLabelFromEndpoint(label, e)
}
return endpoints
}
func RemoveLabelsFromEndpoints(labels []string, endpoints []*externaldnsendpoint.Endpoint) []*externaldnsendpoint.Endpoint {
for _, l := range labels {
RemoveLabelFromEndpoints(l, endpoints)
}

return endpoints
}
Loading
Loading