From 6f8e1cf01f12fa839bdec2b6f7bd47d07cc792ac Mon Sep 17 00:00:00 2001 From: Alexander Krieg <128027135+akrieg-ionos@users.noreply.github.com> Date: Thu, 22 Jun 2023 11:11:46 +0200 Subject: [PATCH] fix(naming): rename "plugin" into "webhook" [DNS-861] (#18) This change is directly related to this [change in external-dns](https://github.com/kubernetes-sigs/external-dns/pull/3063/commits/dd170b9e0e67a0114a59ef0c8e3b40cd1fbff715). It affects all artifacts including the repository itself, which is renamed after the merge of this PR. --- .goreleaser.yaml | 12 +-- Dockerfile | 4 +- Makefile | 11 +-- README.md | 38 +++++----- .../init/configuration/configuration.go | 0 .../init/dnsprovider/dnsprovider.go | 14 ++-- .../init/dnsprovider/dnsprovider_test.go | 15 ++-- cmd/{plugin => webhook}/init/logging/log.go | 0 cmd/{plugin => webhook}/init/server/server.go | 8 +- .../init/server/server_test.go | 74 +++++++++---------- cmd/{plugin => webhook}/main.go | 14 ++-- deployments/helm/local-kind-values.yaml | 10 +-- go.mod | 20 ++--- go.sum | 41 +++++----- internal/ionoscloud/ionoscloud.go | 62 ---------------- internal/ionoscore/ionoscore.go | 8 +- internal/ionoscore/ionoscore_test.go | 6 +- localbuild.Dockerfile | 4 +- pkg/plan/changes.go | 2 +- pkg/provider/provider.go | 4 +- pkg/{plugin/plugin.go => webhook/webhook.go} | 34 ++++----- scripts/deploy_on_kind.sh | 14 ++-- 22 files changed, 165 insertions(+), 230 deletions(-) rename cmd/{plugin => webhook}/init/configuration/configuration.go (100%) rename cmd/{plugin => webhook}/init/dnsprovider/dnsprovider.go (86%) rename cmd/{plugin => webhook}/init/dnsprovider/dnsprovider_test.go (77%) rename cmd/{plugin => webhook}/init/logging/log.go (100%) rename cmd/{plugin => webhook}/init/server/server.go (86%) rename cmd/{plugin => webhook}/init/server/server_test.go (85%) rename cmd/{plugin => webhook}/main.go (52%) delete mode 100644 internal/ionoscloud/ionoscloud.go rename pkg/{plugin/plugin.go => webhook/webhook.go} (89%) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0369494..731863c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,11 +1,11 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com +project_name: external-dns-ionos-webhook + before: hooks: - scripts/release_precheck.sh builds: - - main: ./cmd/plugin + - main: ./cmd/webhook env: - CGO_ENABLED=0 goos: @@ -31,7 +31,7 @@ archives: - goos: windows format: zip dockers: - - id: external-dns-ionos-plugin + - id: external-dns-ionos-webhook use: buildx image_templates: - "{{ .Env.REGISTRY }}/{{ .Env.IMAGE_NAME }}:{{ .Tag }}" @@ -41,7 +41,7 @@ dockers: goarch: amd64 build_flag_templates: - --label=org.opencontainers.image.title={{ .ProjectName }} - - --label=org.opencontainers.image.description=ionos DNS plugin for external-dns + - --label=org.opencontainers.image.description=ionos DNS webhook for external-dns - --label=org.opencontainers.image.url=https://{{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY}} - --label=org.opencontainers.image.source=https://{{ .Env.GITHUB_SERVER_URL }}/{{ .Env.GITHUB_REPOSITORY}} - --label=org.opencontainers.image.version={{ .Version }} @@ -67,7 +67,7 @@ docker_signs: - --yes artifacts: images ids: - - external-dns-ionos-plugin + - external-dns-ionos-webhook output: true changelog: diff --git a/Dockerfile b/Dockerfile index 8cf607f..07b5cb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM gcr.io/distroless/static-debian11:nonroot USER 20000:20000 -ADD --chmod=555 external-dns-ionos-plugin /opt/external-dns-ionos-plugin/app +ADD --chmod=555 external-dns-ionos-webhook /opt/external-dns-ionos-webhook/app -ENTRYPOINT ["/opt/external-dns-ionos-plugin/app"] \ No newline at end of file +ENTRYPOINT ["/opt/external-dns-ionos-webhook/app"] \ No newline at end of file diff --git a/Makefile b/Makefile index 56a4099..b8061a5 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ifndef $(GOPATH) export GOPATH endif -ARTIFACT_NAME = external-dns-ionos-plugin +ARTIFACT_NAME = external-dns-ionos-webhook # logging LOG_LEVEL = debug @@ -16,7 +16,7 @@ LOG_FORMAT = auto REGISTRY ?= localhost:5001 -IMAGE_NAME ?= external-dns-ionos-plugin +IMAGE_NAME ?= external-dns-ionos-webhook IMAGE_TAG ?= latest IMAGE = $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) @@ -57,16 +57,17 @@ static-analysis: lint vet ## Run static analysis against code. .PHONY: clean clean: ## Clean the build directory + rm -rf ./dist rm -rf ./build rm -rf ./vendor .PHONY: build build: ## Build the binary - CGO_ENABLED=0 go build -o build/bin/$(ARTIFACT_NAME) ./cmd/plugin + CGO_ENABLED=0 go build -o build/bin/$(ARTIFACT_NAME) ./cmd/webhook .PHONY: run run:build ## Run the binary on local machine - LOG_LEVEL=$(LOG_LEVEL) LOG_ENVIRONMENT=$(LOG_ENVIRONMENT) LOG_FORMAT=$(LOG_FORMAT) build/bin/external-dns-ionos-plugin + LOG_LEVEL=$(LOG_LEVEL) LOG_ENVIRONMENT=$(LOG_ENVIRONMENT) LOG_FORMAT=$(LOG_FORMAT) build/bin/external-dns-ionos-webhook ##@ Docker @@ -90,7 +91,7 @@ unit-test: ## Run unit tests .PHONY: release-check release-check: ## Check if the release will work - GITHUB_SERVER_URL=github.com GITHUB_REPOSITORY=ionos-cloud/external-dns-ionos-plugin REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) goreleaser release --snapshot --clean --skip-publish + GITHUB_SERVER_URL=github.com GITHUB_REPOSITORY=ionos-cloud/external-dns-ionos-webhook REGISTRY=$(REGISTRY) IMAGE_NAME=$(IMAGE_NAME) goreleaser release --snapshot --clean --skip-publish ##@ License diff --git a/README.md b/README.md index db4b09b..c7a69b6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# ExternalDNS - IONOS Plugin +# ExternalDNS - IONOS Webhook -**⚠️ NOTE**: This Plugin is based on a not yet released version of +**⚠️ NOTE**: This Webhook is based on a not yet released version of [ExternalDNS](https://github.com/kubernetes-sigs/external-dns) - -especially the new integration approach by using plugins, discussed and implemented in +especially the new integration approach by using webhooks, discussed and implemented in [PR-3063](https://github.com/kubernetes-sigs/external-dns/pull/3063). ExternalDNS is a Kubernetes add-on for automatically managing @@ -10,18 +10,18 @@ Domain Name System (DNS) records for Kubernetes services by using different DNS By default, Kubernetes manages DNS records internally, but ExternalDNS takes this functionality a step further by delegating the management of DNS records to an external DNS provider such as IONOS. -Therefore, the IONOS plugin allows to manage your +Therefore, the IONOS webhook allows to manage your IONOS domains inside your kubernetes cluster with [ExternalDNS](https://github.com/kubernetes-sigs/external-dns). To use ExternalDNS with IONOS, you need your IONOS API key or token of the account managing your domains. -For detailed technical instructions on how the IONOS plugin is deployed using the Bitnami Helm charts for ExternalDNS, +For detailed technical instructions on how the IONOS webhook is deployed using the Bitnami Helm charts for ExternalDNS, see[deployment instructions](#kubernetes-deployment). ## Kubernetes Deployment -The IONOS plugin is provided as a regular Open Container Initiative (OCI) image released in -the [GitHub container registry](https://github.com/ionos-cloud/external-dns-ionos-plugin/pkgs/container/external-dns-ionos-plugin). +The IONOS webhook is provided as a regular Open Container Initiative (OCI) image released in +the [GitHub container registry](https://github.com/ionos-cloud/external-dns-ionos-webhook/pkgs/container/external-dns-ionos-webhook). The deployment can be performed in every way Kubernetes supports. The following example shows the deployment as a [sidecar container](https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods) in the @@ -36,17 +36,17 @@ kubectl create secret generic ionos-credentials --from-literal=api-key=' external-dns-ionos-values.yaml image: registry: ghcr.io - repository: ionos-cloud/external-dns-plugin-provider + repository: ionos-cloud/external-dns-webhook-provider tag: latest -provider: plugin +provider: webhook extraArgs: - plugin-provider-url: http://localhost:8888 + webhook-provider-url: http://localhost:8888 sidecars: - - name: ionos-plugin - image: ghcr.io/ionos-cloud/external-dns-ionos-plugin:$RELEASE_VERSION + - name: ionos-webhook + image: ghcr.io/ionos-cloud/external-dns-ionos-webhook:$RELEASE_VERSION ports: - containerPort: 8888 name: http @@ -81,15 +81,15 @@ helm install external-dns-ionos bitnami/external-dns -f external-dns-ionos-value ## Verify the image resource integrity -All official plugins provided by IONOS are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/). +All official webhooks provided by IONOS are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/). The Cosign public key can be found in the [cosign.pub](./cosign.pub) file. -Note: Due to the early development stage of the plugin, the image is not yet signed +Note: Due to the early development stage of the webhook, the image is not yet signed by [sigstores transparency log](https://github.com/sigstore/rekor). ```shell export RELEASE_VERSION=latest -cosign verify --insecure-ignore-tlog --key cosign.pub ghcr.io/ionos-cloud/external-dns-ionos-plugin:$RELEASE_VERSION +cosign verify --insecure-ignore-tlog --key cosign.pub ghcr.io/ionos-cloud/external-dns-ionos-webhook:$RELEASE_VERSION ``` ## Development @@ -98,7 +98,7 @@ The basic development tasks are provided by make. Run `make help` to see the ava ### Local deployment -The plugin can be deployed locally with a kind cluster. As a prerequisite, you need to install: +The webhook can be deployed locally with a kind cluster. As a prerequisite, you need to install: - [Docker](https://docs.docker.com/get-docker/), - [Helm](https://https://helm.sh/ ) with the repos: @@ -113,10 +113,10 @@ The plugin can be deployed locally with a kind cluster. As a prerequisite, you n - [kubectl](https://kubernetes.io/docs/tasks/tools/) ```shell -# setup the kind cluster and deploy external-dns with ionos plugin and a dns mockserver +# setup the kind cluster and deploy external-dns with ionos webhook and a dns mockserver ./scripts/deploy_on_kind.sh -# check if the plugin is running +# check if the webhook is running kubectl get pods -l app.kubernetes.io/name=external-dns -o wide # trigger a DNS change e.g. with annotating the ingress controller service @@ -128,7 +128,7 @@ kubectl -n ingress-nginx annotate service ingress-nginx-controller "external-dn ### Local acceptance tests -The acceptance tests are run against a kind cluster with ExternalDNS and the plugin deployed. +The acceptance tests are run against a kind cluster with ExternalDNS and the webhook deployed. The DNS mock server is used to verify the DNS changes. The following diagram shows the test setup: ```mermaid diff --git a/cmd/plugin/init/configuration/configuration.go b/cmd/webhook/init/configuration/configuration.go similarity index 100% rename from cmd/plugin/init/configuration/configuration.go rename to cmd/webhook/init/configuration/configuration.go diff --git a/cmd/plugin/init/dnsprovider/dnsprovider.go b/cmd/webhook/init/dnsprovider/dnsprovider.go similarity index 86% rename from cmd/plugin/init/dnsprovider/dnsprovider.go rename to cmd/webhook/init/dnsprovider/dnsprovider.go index abc8341..17b3464 100644 --- a/cmd/plugin/init/dnsprovider/dnsprovider.go +++ b/cmd/webhook/init/dnsprovider/dnsprovider.go @@ -9,12 +9,11 @@ import ( "github.com/caarlos0/env/v8" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionos" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscloud" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscore" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/provider" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration" + "github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionos" + "github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionoscore" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/provider" log "github.com/sirupsen/logrus" ) @@ -40,7 +39,8 @@ var IonosCoreProviderFactory = func(domainFilter endpoint.DomainFilter, ionosCon var IonosCloudProviderFactory = func(domainFilter endpoint.DomainFilter, ionosConfig *ionos.Configuration, dryRun bool) (provider.Provider, error) { setDefaults("https://dns.de-fra.ionos.com", "Bearer", ionosConfig) - return ionoscloud.NewProvider(domainFilter, ionosConfig, dryRun) + // return ionoscloud.NewProvider(domainFilter, ionosConfig, dryRun) + return nil, fmt.Errorf("ionos cloud DNS is not supported in this version") } func Init(config configuration.Config) (provider.Provider, error) { diff --git a/cmd/plugin/init/dnsprovider/dnsprovider_test.go b/cmd/webhook/init/dnsprovider/dnsprovider_test.go similarity index 77% rename from cmd/plugin/init/dnsprovider/dnsprovider_test.go rename to cmd/webhook/init/dnsprovider/dnsprovider_test.go index e9969a5..084f126 100644 --- a/cmd/plugin/init/dnsprovider/dnsprovider_test.go +++ b/cmd/webhook/init/dnsprovider/dnsprovider_test.go @@ -3,9 +3,8 @@ package dnsprovider import ( "testing" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscloud" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionoscore" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration" + "github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionoscore" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) @@ -32,7 +31,8 @@ func TestInit(t *testing.T) { env: map[string]string{ "IONOS_API_KEY": "algorithm.eyAiaXNzIiA6ICJpb25vc2Nsb3VkIiB9.signature", }, - providerType: "cloud", + providerType: "cloud", + expectedError: "failed to initialize IONOS provider: ionos cloud DNS is not supported in this version", }, { name: "without api key you are not able to create provider", @@ -56,10 +56,11 @@ func TestInit(t *testing.T) { if tc.providerType == "core" { _, ok := dnsProvider.(*ionoscore.Provider) assert.True(t, ok, "provider is not of type ionoscore.Provider") - } else if tc.providerType == "cloud" { - _, ok := dnsProvider.(*ionoscloud.Provider) - assert.True(t, ok, "provider is not of type ionoscloud.Provider") } + //} else if tc.providerType == "cloud" { + // _, ok := dnsProvider.(*ionoscloud.Provider) + // assert.True(t, ok, "provider is not of type ionoscloud.Provider") + //} }) } } diff --git a/cmd/plugin/init/logging/log.go b/cmd/webhook/init/logging/log.go similarity index 100% rename from cmd/plugin/init/logging/log.go rename to cmd/webhook/init/logging/log.go diff --git a/cmd/plugin/init/server/server.go b/cmd/webhook/init/server/server.go similarity index 86% rename from cmd/plugin/init/server/server.go rename to cmd/webhook/init/server/server.go index f763086..813a663 100644 --- a/cmd/plugin/init/server/server.go +++ b/cmd/webhook/init/server/server.go @@ -14,15 +14,15 @@ import ( log "github.com/sirupsen/logrus" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plugin" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/webhook" ) // Init server initialization function -func Init(config configuration.Config, p *plugin.Plugin) *http.Server { +func Init(config configuration.Config, p *webhook.Webhook) *http.Server { r := chi.NewRouter() - r.Use(plugin.Health) + r.Use(webhook.Health) r.Get("/records", p.Records) r.Post("/records", p.ApplyChanges) r.Post("/propertyvaluesequals", p.PropertyValuesEquals) diff --git a/cmd/plugin/init/server/server_test.go b/cmd/webhook/init/server/server_test.go similarity index 85% rename from cmd/plugin/init/server/server_test.go rename to cmd/webhook/init/server/server_test.go index 94b5626..9c17bff 100644 --- a/cmd/plugin/init/server/server_test.go +++ b/cmd/webhook/init/server/server_test.go @@ -12,11 +12,11 @@ import ( log "github.com/sirupsen/logrus" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/plan" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plugin" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/webhook" ) type testCase struct { @@ -42,7 +42,7 @@ var mockProvider *MockProvider func TestMain(m *testing.M) { mockProvider = &MockProvider{} - srv := Init(configuration.Init(), plugin.New(mockProvider)) + srv := Init(configuration.Init(), webhook.New(mockProvider)) go ShutdownGracefully(srv) time.Sleep(300 * time.Millisecond) m.Run() @@ -67,12 +67,12 @@ func TestRecords(t *testing.T) { }, }, method: http.MethodGet, - headers: map[string]string{"Accept": "application/external.dns.plugin+json;version=1"}, + headers: map[string]string{"Accept": "application/external.dns.webhook+json;version=1"}, path: "/records", body: "", expectedStatusCode: http.StatusOK, expectedResponseHeaders: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, expectedBody: "[{\"dnsName\":\"test.example.com\",\"targets\":[\"\"],\"recordType\":\"A\",\"recordTTL\":3600,\"labels\":{\"label1\":\"value1\"}}]", }, @@ -98,13 +98,13 @@ func TestRecords(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "backend error", hasError: fmt.Errorf("backend error"), method: http.MethodGet, - headers: map[string]string{"Accept": "application/external.dns.plugin+json;version=1"}, + headers: map[string]string{"Accept": "application/external.dns.webhook+json;version=1"}, path: "/records", body: "", expectedStatusCode: http.StatusInternalServerError, @@ -119,7 +119,7 @@ func TestApplyChanges(t *testing.T) { name: "happy case", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, path: "/records", body: ` @@ -178,14 +178,14 @@ func TestApplyChanges(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "invalid json", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/records", body: "invalid", @@ -200,8 +200,8 @@ func TestApplyChanges(t *testing.T) { hasError: fmt.Errorf("backend error"), method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/records", body: ` @@ -242,8 +242,8 @@ func TestAdjustEndpoints(t *testing.T) { }, method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/adjustendpoints", body: ` @@ -261,7 +261,7 @@ func TestAdjustEndpoints(t *testing.T) { ]`, expectedStatusCode: http.StatusOK, expectedResponseHeaders: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, expectedBody: "[{\"dnsName\":\"adjusted.example.com\",\"targets\":[\"\"],\"recordType\":\"A\",\"recordTTL\":3600,\"labels\":{\"label1\":\"value1\"}}]", expectedEndpointsToAdjust: []*endpoint.Endpoint{ @@ -281,7 +281,7 @@ func TestAdjustEndpoints(t *testing.T) { name: "no content type header", method: http.MethodPost, headers: map[string]string{ - "Accept": "application/external.dns.plugin+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/adjustendpoints", body: "", @@ -296,7 +296,7 @@ func TestAdjustEndpoints(t *testing.T) { method: http.MethodPost, headers: map[string]string{ "Content-Type": "invalid", - "Accept": "application/external.dns.plugin+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/adjustendpoints", body: "", @@ -304,13 +304,13 @@ func TestAdjustEndpoints(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "no accept header", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, path: "/adjustendpoints", body: "", @@ -324,7 +324,7 @@ func TestAdjustEndpoints(t *testing.T) { name: "wrong accept header", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", "Accept": "invalid", }, path: "/adjustendpoints", @@ -333,14 +333,14 @@ func TestAdjustEndpoints(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "invalid json", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/adjustendpoints", body: "invalid", @@ -360,8 +360,8 @@ func TestPropertyValuesEqual(t *testing.T) { name: "happy case", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/propertyvaluesequals", body: ` @@ -372,7 +372,7 @@ func TestPropertyValuesEqual(t *testing.T) { }`, expectedStatusCode: http.StatusOK, expectedResponseHeaders: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, expectedBody: "{\"equals\":false}", expectedPropertyValuesEqualName: "propertyname", @@ -383,7 +383,7 @@ func TestPropertyValuesEqual(t *testing.T) { name: "no content type header", method: http.MethodPost, headers: map[string]string{ - "Accept": "application/external.dns.plugin+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/propertyvaluesequals", body: "", @@ -398,7 +398,7 @@ func TestPropertyValuesEqual(t *testing.T) { method: http.MethodPost, headers: map[string]string{ "Content-Type": "invalid", - "Accept": "application/external.dns.plugin+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/propertyvaluesequals", body: "", @@ -406,13 +406,13 @@ func TestPropertyValuesEqual(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the content type: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "no accept header", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", }, path: "/propertyvaluesequals", body: "", @@ -426,7 +426,7 @@ func TestPropertyValuesEqual(t *testing.T) { name: "wrong accept header", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", "Accept": "invalid", }, path: "/propertyvaluesequals", @@ -435,14 +435,14 @@ func TestPropertyValuesEqual(t *testing.T) { expectedResponseHeaders: map[string]string{ "Content-Type": "text/plain", }, - expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.plugin+json;version=1'", + expectedBody: "client must provide a valid versioned media type in the accept header: unsupported media type version: 'invalid'. Supported media types are: 'application/external.dns.webhook+json;version=1'", }, { name: "invalid json", method: http.MethodPost, headers: map[string]string{ - "Content-Type": "application/external.dns.plugin+json;version=1", - "Accept": "application/external.dns.plugin+json;version=1", + "Content-Type": "application/external.dns.webhook+json;version=1", + "Accept": "application/external.dns.webhook+json;version=1", }, path: "/propertyvaluesequals", body: "invalid", diff --git a/cmd/plugin/main.go b/cmd/webhook/main.go similarity index 52% rename from cmd/plugin/main.go rename to cmd/webhook/main.go index 2851d4c..f2a3984 100644 --- a/cmd/plugin/main.go +++ b/cmd/webhook/main.go @@ -3,11 +3,11 @@ package main import ( "fmt" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/configuration" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/dnsprovider" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/logging" - "github.com/ionos-cloud/external-dns-ionos-plugin/cmd/plugin/init/server" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plugin" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/configuration" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/dnsprovider" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/logging" + "github.com/ionos-cloud/external-dns-ionos-webhook/cmd/webhook/init/server" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/webhook" log "github.com/sirupsen/logrus" ) @@ -16,7 +16,7 @@ const banner = ` |_ _/ _ \| \| |/ _ \/ __| | | (_) | . | (_) \__ \ |___\___/|_|\_|\___/|___/ - external-dns-ionos-plugin + external-dns-ionos-webhook version: %s (%s) ` @@ -34,6 +34,6 @@ func main() { if err != nil { log.Fatalf("Failed to initialize DNS provider: %v", err) } - srv := server.Init(config, plugin.New(provider)) + srv := server.Init(config, webhook.New(provider)) server.ShutdownGracefully(srv) } diff --git a/deployments/helm/local-kind-values.yaml b/deployments/helm/local-kind-values.yaml index c6b3fda..75c5582 100644 --- a/deployments/helm/local-kind-values.yaml +++ b/deployments/helm/local-kind-values.yaml @@ -1,10 +1,10 @@ image: registry: localhost:5001 - repository: external-dns-plugin-provider + repository: external-dns-webhook-provider tag: latest pullPolicy: Always -provider: plugin +provider: webhook sources: - service @@ -14,11 +14,11 @@ dryRun: true logLevel: debug extraArgs: - plugin-provider-url: http://localhost:8888 + webhook-provider-url: http://localhost:8888 sidecars: - - name: plugin - image: localhost:5001/external-dns-ionos-plugin:latest + - name: webhook + image: localhost:5001/external-dns-ionos-webhook:latest imagePullPolicy: Always ports: - containerPort: 8888 diff --git a/go.mod b/go.mod index 397cb66..33ddda2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ionos-cloud/external-dns-ionos-plugin +module github.com/ionos-cloud/external-dns-ionos-webhook go 1.20 @@ -6,7 +6,7 @@ require ( github.com/caarlos0/env/v8 v8.0.0 github.com/go-chi/chi/v5 v5.0.8 github.com/golang/mock v1.6.0 - github.com/golangci/golangci-lint v1.53.2 + github.com/golangci/golangci-lint v1.53.3 github.com/google/go-licenses v1.6.0 github.com/ionos-developer/dns-sdk-go v0.0.5 github.com/sirupsen/logrus v1.9.3 @@ -21,18 +21,18 @@ require ( github.com/Abirdcfly/dupword v0.0.11 // indirect github.com/Antonboom/errname v0.1.10 // indirect github.com/Antonboom/nilnil v0.1.5 // indirect - github.com/BurntSushi/toml v1.3.0 // indirect + github.com/BurntSushi/toml v1.3.2 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.1.0 // indirect - github.com/alexkohler/nakedret/v2 v2.0.1 // indirect + github.com/alexkohler/nakedret/v2 v2.0.2 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect - github.com/ashanbrown/forbidigo v1.5.1 // indirect + github.com/ashanbrown/forbidigo v1.5.3 // indirect github.com/ashanbrown/makezero v1.1.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bkielbasa/cyclop v1.2.0 // indirect + github.com/bkielbasa/cyclop v1.2.1 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v3 v3.4.0 // indirect github.com/breml/bidichk v0.2.4 // indirect @@ -81,7 +81,7 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/licenseclassifier v0.0.0-20210722185704-3043a050f148 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect + github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/comment v1.4.2 // indirect github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect @@ -123,9 +123,9 @@ require ( github.com/moricho/tparallel v0.3.1 // indirect github.com/nakabonne/nestif v0.3.1 // indirect github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect - github.com/nishanths/exhaustive v0.10.0 // indirect + github.com/nishanths/exhaustive v0.11.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.12.0 // indirect + github.com/nunnatsa/ginkgolinter v0.12.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/otiai10/copy v1.6.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect @@ -178,7 +178,7 @@ require ( github.com/xen0n/gosmopolitan v1.2.1 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect - github.com/ykadowak/zerologlint v0.1.1 // indirect + github.com/ykadowak/zerologlint v0.1.2 // indirect gitlab.com/bosi/decorder v0.2.3 // indirect go.opencensus.io v0.23.0 // indirect go.tmz.dev/musttag v0.7.0 // indirect diff --git a/go.sum b/go.sum index 53f9142..d138993 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,8 @@ github.com/Antonboom/errname v0.1.10/go.mod h1:xLeiCIrvVNpUtsN0wxAh05bNIZpqE22/q github.com/Antonboom/nilnil v0.1.5 h1:X2JAdEVcbPaOom2TUa1FxZ3uyuUlex0XMLGYMemu6l0= github.com/Antonboom/nilnil v0.1.5/go.mod h1:I24toVuBKhfP5teihGWctrRiPbRKHwZIFOvc6v3HZXk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.3.0 h1:Ws8e5YmnrGEHzZEzg0YvK/7COGYtTC5PbaH9oSSbgfA= -github.com/BurntSushi/toml v1.3.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= @@ -92,8 +92,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alexkohler/nakedret/v2 v2.0.1 h1:DLFVWaHbEntNHBYGhPX+AhCM1gCErTs35IFWPh6Bnn0= -github.com/alexkohler/nakedret/v2 v2.0.1/go.mod h1:2b8Gkk0GsOrqQv/gPWjNLDSKwG8I5moSXG1K4VIBcTQ= +github.com/alexkohler/nakedret/v2 v2.0.2 h1:qnXuZNvv3/AxkAb22q/sEsEpcA99YxLFACDtEw9TPxE= +github.com/alexkohler/nakedret/v2 v2.0.2/go.mod h1:2b8Gkk0GsOrqQv/gPWjNLDSKwG8I5moSXG1K4VIBcTQ= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= @@ -103,8 +103,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/ashanbrown/forbidigo v1.5.1 h1:WXhzLjOlnuDYPYQo/eFlcFMi8X/kLfvWLYu6CSoebis= -github.com/ashanbrown/forbidigo v1.5.1/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= +github.com/ashanbrown/forbidigo v1.5.3 h1:jfg+fkm/snMx+V9FBwsl1d340BV/99kZGv5jN9hBoXk= +github.com/ashanbrown/forbidigo v1.5.3/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= @@ -112,8 +112,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bkielbasa/cyclop v1.2.0 h1:7Jmnh0yL2DjKfw28p86YTd/B4lRGcNuu12sKE35sM7A= -github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= +github.com/bkielbasa/cyclop v1.2.1 h1:AeF71HZDob1P2/pRm1so9cd1alZnrpyc4q2uP2l0gJY= +github.com/bkielbasa/cyclop v1.2.1/go.mod h1:K/dT/M0FPAiYjBgQGau7tz+3TMh4FWAEqlMhzFWCrgM= github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bombsimon/wsl/v3 v3.4.0 h1:RkSxjT3tmlptwfgEgTgU+KYKLI35p/tviNXNXiL2aNU= @@ -282,8 +282,8 @@ github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe h1:6RGUuS7EGotKx6 github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe/go.mod h1:gjqyPShc/m8pEMpk0a3SeagVb0kaqvhscv+i9jI5ZhQ= github.com/golangci/gofmt v0.0.0-20220901101216-f2edd75033f2 h1:amWTbTGqOZ71ruzrdA+Nx5WA3tV1N0goTspwmKCQvBY= github.com/golangci/gofmt v0.0.0-20220901101216-f2edd75033f2/go.mod h1:9wOXstvyDRshQ9LggQuzBCGysxs3b6Uo/1MvYCR2NMs= -github.com/golangci/golangci-lint v1.53.2 h1:52pgJKXiAuyfcOa8HJPIrZk1oMgpyXeN8TUxpcteweM= -github.com/golangci/golangci-lint v1.53.2/go.mod h1:fz9DDC9UABJ7SFHTz0XnkiYzb4su7YpuB9ucsgdUfCk= +github.com/golangci/golangci-lint v1.53.3 h1:CUcRafczT4t1F+mvdkUm6KuOpxUZTl0yWN/rSU6sSMo= +github.com/golangci/golangci-lint v1.53.3/go.mod h1:W4Gg3ONq6p3Jl+0s/h9Gr0j7yEgHJWWZO2bHl2tBUXM= github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 h1:MfyDlzVjl1hoaPzPD4Gpb/QgoRfSBR0jdhwGyAWwMSA= github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA= @@ -359,8 +359,8 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 h1:9alfqbrhuD+9fLZ4iaAVwhlp5PEhmnBt7yvK2Oy5C1U= -github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= +github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 h1:mrEEilTAUmaAORhssPPkxj84TsHrPMLBGW2Z4SoTxm8= +github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk= github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= github.com/gostaticanalysis/comment v1.4.1/go.mod h1:ih6ZxzTHLdadaiSnF5WY3dxUoXfXAlTaRzuaNDlSado= @@ -492,12 +492,12 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6Fx github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nishanths/exhaustive v0.10.0 h1:BMznKAcVa9WOoLq/kTGp4NJOJSMwEpcpjFNAVRfPlSo= -github.com/nishanths/exhaustive v0.10.0/go.mod h1:IbwrGdVMizvDcIxPYGVdQn5BqWJaOwpCvg4RGb8r/TA= +github.com/nishanths/exhaustive v0.11.0 h1:T3I8nUGhl/Cwu5Z2hfc92l0e04D2GEW6e0l8pzda2l0= +github.com/nishanths/exhaustive v0.11.0/go.mod h1:RqwDsZ1xY0dNdqHho2z6X+bgzizwbLYOWnZbbl2wLB4= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.12.0 h1:seZo112n+lt0gdLJ/Jh70mzvrqbABWFpXd1bZTLTByM= -github.com/nunnatsa/ginkgolinter v0.12.0/go.mod h1:dJIGXYXbkBswqa/pIzG0QlVTTDSBMxDoCFwhsl4Uras= +github.com/nunnatsa/ginkgolinter v0.12.1 h1:vwOqb5Nu05OikTXqhvLdHCGcx5uthIYIl0t79UVrERQ= +github.com/nunnatsa/ginkgolinter v0.12.1/go.mod h1:AK8Ab1PypVrcGUusuKD8RDcl2KgsIwvNaaxAlyHSzso= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE= @@ -666,8 +666,8 @@ github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= github.com/yeya24/promlinter v0.2.0 h1:xFKDQ82orCU5jQujdaD8stOHiv8UN68BSdn2a8u8Y3o= github.com/yeya24/promlinter v0.2.0/go.mod h1:u54lkmBOZrpEbQQ6gox2zWKKLKu2SGe+2KOiextY+IA= -github.com/ykadowak/zerologlint v0.1.1 h1:CA1+RsGS1DbBn3jJP2jpWfiMJipWdeqJfSY0GpNgqaY= -github.com/ykadowak/zerologlint v0.1.1/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg= +github.com/ykadowak/zerologlint v0.1.2 h1:Um4P5RMmelfjQqQJKtE8ZW+dLZrXrENeIzWWKw800U4= +github.com/ykadowak/zerologlint v0.1.2/go.mod h1:KaUskqF3e/v59oPmdq1U1DnKcuHokl2/K1U4pmIELKg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -809,7 +809,6 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= @@ -937,7 +936,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -948,7 +946,6 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= @@ -963,7 +960,6 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= @@ -1041,7 +1037,6 @@ golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= diff --git a/internal/ionoscloud/ionoscloud.go b/internal/ionoscloud/ionoscloud.go deleted file mode 100644 index 2add0fe..0000000 --- a/internal/ionoscloud/ionoscloud.go +++ /dev/null @@ -1,62 +0,0 @@ -package ionoscloud - -import ( - "context" - - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionos" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/provider" -) - -// DNSService interface with needed zone and records method -type DNSService interface { - // TODO define neeeded methods: get zones, create record, delete record, update record(update record type) -} - -type DNSClient struct { - // client *sdk.APIClient -} - -// Provider extends base provider to work with paas dns rest API -type Provider struct { - provider.BaseProvider - // client DNSClient - - // domainFilter endpoint.DomainFilter - DryRun bool -} - -// NewProvider returns an instance of new provider -func NewProvider(domainFilter endpoint.DomainFilter, configuration *ionos.Configuration, dryRun bool) (*Provider, error) { - // TODO create client - // TODO create provider - - return &Provider{}, nil -} - -// TODO client methods interface and impelemtations -// get record -// create record -// update record/both versions -// delete record - -// TODO record to endpoint / endpoint to record conversion - -// TODO Records -// call get zones -// filter zones -// get records -func (p *Provider) Records(ctx context.Context) ([]*endpoint.Endpoint, error) { - return nil, nil -} - -// filter records -// convert records to endpoint - -// TODO Apply changes -// filter change slices -// call methods for changes -func (p *Provider) ApplyChanges(ctx context.Context, changes *plan.Changes) error { - return nil -} diff --git a/internal/ionoscore/ionoscore.go b/internal/ionoscore/ionoscore.go index eb20290..fe43c4a 100644 --- a/internal/ionoscore/ionoscore.go +++ b/internal/ionoscore/ionoscore.go @@ -7,13 +7,13 @@ import ( "strconv" "strings" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionos" + "github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionos" log "github.com/sirupsen/logrus" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/provider" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/plan" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/provider" sdk "github.com/ionos-developer/dns-sdk-go" ) diff --git a/internal/ionoscore/ionoscore_test.go b/internal/ionoscore/ionoscore_test.go index 777418b..d888512 100644 --- a/internal/ionoscore/ionoscore_test.go +++ b/internal/ionoscore/ionoscore_test.go @@ -6,12 +6,12 @@ import ( "sort" "testing" - "github.com/ionos-cloud/external-dns-ionos-plugin/internal/ionos" + "github.com/ionos-cloud/external-dns-ionos-webhook/internal/ionos" log "github.com/sirupsen/logrus" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/plan" sdk "github.com/ionos-developer/dns-sdk-go" "github.com/stretchr/testify/require" diff --git a/localbuild.Dockerfile b/localbuild.Dockerfile index 7cddd83..f87cb45 100644 --- a/localbuild.Dockerfile +++ b/localbuild.Dockerfile @@ -1,5 +1,5 @@ FROM gcr.io/distroless/static-debian11:nonroot USER 20000:20000 -ADD --chmod=555 build/bin/external-dns-ionos-plugin /opt/external-dns-ionos-plugin/app +ADD --chmod=555 build/bin/external-dns-ionos-webhook /opt/external-dns-ionos-webhook/app -ENTRYPOINT ["/opt/external-dns-ionos-plugin/app"] \ No newline at end of file +ENTRYPOINT ["/opt/external-dns-ionos-webhook/app"] \ No newline at end of file diff --git a/pkg/plan/changes.go b/pkg/plan/changes.go index e8c7e11..7548a96 100644 --- a/pkg/plan/changes.go +++ b/pkg/plan/changes.go @@ -17,7 +17,7 @@ limitations under the License. package plan import ( - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" ) // Changes holds lists of actions to be executed by dns providers diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 585f24d..d107127 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -19,8 +19,8 @@ package provider import ( "context" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/plan" ) // Provider defines the interface DNS providers should implement. diff --git a/pkg/plugin/plugin.go b/pkg/webhook/webhook.go similarity index 89% rename from pkg/plugin/plugin.go rename to pkg/webhook/webhook.go index 810aa90..7e1fd36 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/webhook/webhook.go @@ -1,4 +1,4 @@ -package plugin +package webhook import ( "encoding/json" @@ -6,14 +6,14 @@ import ( "net/http" "strings" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/endpoint" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/plan" - "github.com/ionos-cloud/external-dns-ionos-plugin/pkg/provider" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/endpoint" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/plan" + "github.com/ionos-cloud/external-dns-ionos-webhook/pkg/provider" log "github.com/sirupsen/logrus" ) const ( - mediaTypeFormat = "application/external.dns.plugin+json;" + mediaTypeFormat = "application/external.dns.webhook+json;" contentTypeHeader = "Content-Type" contentTypePlaintext = "text/plain" acceptHeader = "Accept" @@ -54,14 +54,14 @@ func checkAndGetMediaTypeHeaderValue(value string) (string, error) { return "", fmt.Errorf("unsupported media type version: '%s'. Supported media types are: '%s'", value, supportedMediaTypesString) } -// Plugin for external dns provider -type Plugin struct { +// Webhook for external dns provider +type Webhook struct { provider provider.Provider } -// New creates a new instance of the Plugin -func New(provider provider.Provider) *Plugin { - p := Plugin{provider: provider} +// New creates a new instance of the Webhook +func New(provider provider.Provider) *Webhook { + p := Webhook{provider: provider} return &p } @@ -75,15 +75,15 @@ func Health(next http.Handler) http.Handler { }) } -func (p *Plugin) contentTypeHeaderCheck(w http.ResponseWriter, r *http.Request) error { +func (p *Webhook) contentTypeHeaderCheck(w http.ResponseWriter, r *http.Request) error { return p.headerCheck(true, w, r) } -func (p *Plugin) acceptHeaderCheck(w http.ResponseWriter, r *http.Request) error { +func (p *Webhook) acceptHeaderCheck(w http.ResponseWriter, r *http.Request) error { return p.headerCheck(false, w, r) } -func (p *Plugin) headerCheck(isContentType bool, w http.ResponseWriter, r *http.Request) error { +func (p *Webhook) headerCheck(isContentType bool, w http.ResponseWriter, r *http.Request) error { var header string if isContentType { header = r.Header.Get(contentTypeHeader) @@ -127,7 +127,7 @@ func (p *Plugin) headerCheck(isContentType bool, w http.ResponseWriter, r *http. } // Records handles the get request for records -func (p *Plugin) Records(w http.ResponseWriter, r *http.Request) { +func (p *Webhook) Records(w http.ResponseWriter, r *http.Request) { if err := p.acceptHeaderCheck(w, r); err != nil { requestLog(r).WithField(logFieldError, err).Error("accept header check failed") return @@ -152,7 +152,7 @@ func (p *Plugin) Records(w http.ResponseWriter, r *http.Request) { } // ApplyChanges handles the post request for record changes -func (p *Plugin) ApplyChanges(w http.ResponseWriter, r *http.Request) { +func (p *Webhook) ApplyChanges(w http.ResponseWriter, r *http.Request) { if err := p.contentTypeHeaderCheck(w, r); err != nil { requestLog(r).WithField(logFieldError, err).Error("content type header check failed") return @@ -192,7 +192,7 @@ type PropertiesValuesEqualsResponse struct { } // PropertyValuesEquals handles the post request for property values equals -func (p *Plugin) PropertyValuesEquals(w http.ResponseWriter, r *http.Request) { +func (p *Webhook) PropertyValuesEquals(w http.ResponseWriter, r *http.Request) { if err := p.contentTypeHeaderCheck(w, r); err != nil { requestLog(r).WithField(logFieldError, err).Error("content type header check failed") return @@ -230,7 +230,7 @@ func (p *Plugin) PropertyValuesEquals(w http.ResponseWriter, r *http.Request) { } // AdjustEndpoints handles the post request for adjusting endpoints -func (p *Plugin) AdjustEndpoints(w http.ResponseWriter, r *http.Request) { +func (p *Webhook) AdjustEndpoints(w http.ResponseWriter, r *http.Request) { if err := p.contentTypeHeaderCheck(w, r); err != nil { log.Errorf("content type header check failed, request method: %s, request path: %s", r.Method, r.URL.Path) return diff --git a/scripts/deploy_on_kind.sh b/scripts/deploy_on_kind.sh index a11434e..d95fe16 100755 --- a/scripts/deploy_on_kind.sh +++ b/scripts/deploy_on_kind.sh @@ -8,10 +8,10 @@ LOCAL_REGISTRY_NAME=kind-registry LOCAL_REGISTRY_RUNNING=$(docker ps -a | grep -q $LOCAL_REGISTRY_NAME && echo "true" || echo "false") # docker -IMAGE_EXTERNAL_DNS_PLUGIN_PROVIDER=ghcr.io/ionos-cloud/external-dns-plugin-provider:latest +IMAGE_EXTERNAL_DNS_WEBHOOK_PROVIDER=ghcr.io/ionos-cloud/external-dns-webhook-provider:latest IMAGE_REGISTRY=localhost:$LOCAL_REGISTRY_PORT -IMAGE_NAME=external-dns-ionos-plugin +IMAGE_NAME=external-dns-ionos-webhook IMAGE=$IMAGE_REGISTRY/$IMAGE_NAME #kind @@ -56,11 +56,11 @@ printf "KIND_CLUSTER_RUNNING: %s\n" "$KIND_CLUSTER_RUNNING" if [ "$LOCAL_REGISTRY_RUNNING" = "false" ]; then printf "Starting local registry...\n" docker run -d --restart=always -p "127.0.0.1:$LOCAL_REGISTRY_PORT:5000" --name "$LOCAL_REGISTRY_NAME" registry:2 - # once there is an official release of external-dns with the provider plugin, we can remove this steps - printf "pushing external-dns-plugin-provider image to local registry...\n" - docker pull $IMAGE_EXTERNAL_DNS_PLUGIN_PROVIDER - docker tag $IMAGE_EXTERNAL_DNS_PLUGIN_PROVIDER localhost:$LOCAL_REGISTRY_PORT/external-dns-plugin-provider:latest - docker push localhost:$LOCAL_REGISTRY_PORT/external-dns-plugin-provider:latest + # once there is an official release of external-dns with the provider webhook, we can remove this steps + printf "pushing external-dns-webhook-provider image to local registry...\n" + docker pull $IMAGE_EXTERNAL_DNS_WEBHOOK_PROVIDER + docker tag $IMAGE_EXTERNAL_DNS_WEBHOOK_PROVIDER localhost:$LOCAL_REGISTRY_PORT/external-dns-webhook-provider:latest + docker push localhost:$LOCAL_REGISTRY_PORT/external-dns-webhook-provider:latest fi printf "Building binary...\n"