diff --git a/docs/contributing/sources-and-providers.md b/docs/contributing/sources-and-providers.md index 83120af519..3f9222799f 100644 --- a/docs/contributing/sources-and-providers.md +++ b/docs/contributing/sources-and-providers.md @@ -50,6 +50,7 @@ When creating a new source, add the following annotations above the source struc // +externaldns:source:filters= // +externaldns:source:namespace=all,single // +externaldns:source:fqdn-template=false +// +externaldns:source:events=false|true type myNewSource struct { // ... fields } @@ -64,6 +65,7 @@ type myNewSource struct { * `+externaldns:source:filters` - Supported filter types (annotation, label) * `+externaldns:source:namespace` - Namespace support: comma-separated values (all, single, multiple) * `+externaldns:source:fqdn-template` - FQDN template support (true, false) +* `+externaldns:source:events` - Kubernetes [`events`](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_events/) support (true, false) After adding annotations, run `make generate-sources-documentation` to update sources file. diff --git a/docs/sources/index.md b/docs/sources/index.md index 0f0f2511e3..269edc9680 100644 --- a/docs/sources/index.md +++ b/docs/sources/index.md @@ -22,32 +22,32 @@ Sources are responsible for: ## Available Sources -| **Source Name** | Resources | Filters | Namespace | FQDN Template | Category | -|:----------------|:----------|:--------|:----------|:--------------|:---------| -| **ambassador-host** | Host.getambassador.io | annotation,label | all,single | false | ingress controllers | -| **connector** | Remote TCP Server | | | false | special | -| **contour-httpproxy** | HTTPProxy.projectcontour.io | annotation | all,single | true | ingress controllers | -| **crd** | DNSEndpoint.k8s.io | annotation,label | all,single | false | externaldns | -| **empty** | None | | | false | testing | -| **f5-transportserver** | TransportServer.cis.f5.com | annotation | all,single | false | load balancers | -| **f5-virtualserver** | VirtualServer.cis.f5.com | annotation | all,single | false | load balancers | -| **fake** | Fake Endpoints | | | true | testing | -| **gateway-grpcroute** | GRPCRoute.gateway.networking.k8s.io | annotation,label | all,single | false | gateway api | -| **gateway-httproute** | HTTPRoute.gateway.networking.k8s.io | annotation,label | all,single | false | gateway api | -| **gateway-tcproute** | TCPRoute.gateway.networking.k8s.io | annotation,label | all,single | false | gateway api | -| **gateway-tlsroute** | TLSRoute.gateway.networking.k8s.io | annotation,label | all,single | false | gateway api | -| **gateway-udproute** | UDPRoute.gateway.networking.k8s.io | annotation,label | all,single | true | gateway api | -| **gloo-proxy** | Proxy.gloo.solo.io | | all,single | false | service mesh | -| **ingress** | Ingress | annotation,label | all,single | true | kubernetes core | -| **istio-gateway** | Gateway.networking.istio.io | annotation | all,single | true | service mesh | -| **istio-virtualservice** | VirtualService.networking.istio.io | annotation | all,single | true | service mesh | -| **kong-tcpingress** | TCPIngress.configuration.konghq.com | annotation | all,single | false | ingress controllers | -| **node** | Node | annotation,label | all | true | kubernetes core | -| **openshift-route** | Route.route.openshift.io | annotation,label | all,single | true | openshift | -| **pod** | Pod | annotation,label | all,single | true | kubernetes core | -| **service** | Service | annotation,label | all,single | true | kubernetes core | -| **skipper-routegroup** | RouteGroup.zalando.org | annotation | all,single | true | ingress controllers | -| **traefik-proxy** | IngressRoute.traefik.io
IngressRouteTCP.traefik.io
IngressRouteUDP.traefik.io | annotation | all,single | false | ingress controllers | +| **Source Name** | Resources | Filters | Namespace | FQDN Template | Events | Category | +|:----------------|:----------|:--------|:----------|:--------------|:---------|:---------| +| **ambassador-host** | Host.getambassador.io | annotation,label | all,single | false | false | ingress controllers | +| **connector** | Remote TCP Server | | | false | false | special | +| **contour-httpproxy** | HTTPProxy.projectcontour.io | annotation | all,single | true | false | ingress controllers | +| **crd** | DNSEndpoint.externaldns.k8s.io | annotation,label | all,single | false | false | externaldns | +| **empty** | None | | | false | false | testing | +| **f5-transportserver** | TransportServer.cis.f5.com | annotation | all,single | false | false | load balancers | +| **f5-virtualserver** | VirtualServer.cis.f5.com | annotation | all,single | false | false | load balancers | +| **fake** | Fake Endpoints | | | true | true | testing | +| **gateway-grpcroute** | GRPCRoute.gateway.networking.k8s.io | annotation,label | all,single | false | false | gateway api | +| **gateway-httproute** | HTTPRoute.gateway.networking.k8s.io | annotation,label | all,single | false | false | gateway api | +| **gateway-tcproute** | TCPRoute.gateway.networking.k8s.io | annotation,label | all,single | false | false | gateway api | +| **gateway-tlsroute** | TLSRoute.gateway.networking.k8s.io | annotation,label | all,single | false | false | gateway api | +| **gateway-udproute** | UDPRoute.gateway.networking.k8s.io | annotation,label | all,single | true | false | gateway api | +| **gloo-proxy** | Proxy.gloo.solo.io | | all,single | false | false | service mesh | +| **ingress** | Ingress | annotation,label | all,single | true | false | kubernetes core | +| **istio-gateway** | Gateway.networking.istio.io | annotation | all,single | true | false | service mesh | +| **istio-virtualservice** | VirtualService.networking.istio.io | annotation | all,single | true | false | service mesh | +| **kong-tcpingress** | TCPIngress.configuration.konghq.com | annotation | all,single | false | false | ingress controllers | +| **node** | Node | annotation,label | all | true | false | kubernetes core | +| **openshift-route** | Route.route.openshift.io | annotation,label | all,single | true | false | openshift | +| **pod** | Pod | annotation,label | all,single | true | false | kubernetes core | +| **service** | Service | annotation,label | all,single | true | false | kubernetes core | +| **skipper-routegroup** | RouteGroup.zalando.org | annotation | all,single | true | false | ingress controllers | +| **traefik-proxy** | IngressRoute.traefik.io
IngressRouteTCP.traefik.io
IngressRouteUDP.traefik.io | annotation | all,single | false | false | ingress controllers | ## Usage diff --git a/internal/gen/docs/sources/main.go b/internal/gen/docs/sources/main.go index a1e6614bd4..13de9ad954 100644 --- a/internal/gen/docs/sources/main.go +++ b/internal/gen/docs/sources/main.go @@ -42,6 +42,7 @@ const ( annotationFilters = annotationPrefix + "filters=" annotationNamespace = annotationPrefix + "namespace=" annotationFQDNTemplate = annotationPrefix + "fqdn-template=" + annotationEvents = annotationPrefix + "events=" ) var ( @@ -62,6 +63,7 @@ type Source struct { Filters string // Supported filters, e.g., "annotation,label" Namespace string // Namespace support: "all", "single", "multiple" FQDNTemplate string // FQDN template support: "true", "false" + Events string // Events support: "true", "false" } type Sources []Source @@ -254,9 +256,10 @@ func extractSourcesFromComments(comments, typeName, filePath string) (Sources, e // Start new source currentSource = &Source{ - Type: typeName, - File: filePath, - Name: strings.TrimPrefix(line, annotationName), + Type: typeName, + File: filePath, + Name: strings.TrimPrefix(line, annotationName), + Events: "false", } case currentSource == nil: return nil, fmt.Errorf("found annotation line without preceding source name in type %s: %s", typeName, line) @@ -272,6 +275,8 @@ func extractSourcesFromComments(comments, typeName, filePath string) (Sources, e currentSource.Namespace = strings.TrimPrefix(line, annotationNamespace) case strings.HasPrefix(line, annotationFQDNTemplate): currentSource.FQDNTemplate = strings.TrimPrefix(line, annotationFQDNTemplate) + case strings.HasPrefix(line, annotationEvents): + currentSource.Events = strings.TrimPrefix(line, annotationEvents) } } diff --git a/internal/gen/docs/sources/main_test.go b/internal/gen/docs/sources/main_test.go index c24f6ee655..3e58c2e8de 100644 --- a/internal/gen/docs/sources/main_test.go +++ b/internal/gen/docs/sources/main_test.go @@ -128,6 +128,7 @@ type testSource struct { assert.Equal(t, "annotation,label", source.Filters) assert.Equal(t, "all,single", source.Namespace) assert.Equal(t, "true", source.FQDNTemplate) + assert.Equal(t, "false", source.Events) } func TestParseSourceAnnotations_SkipsTestFiles(t *testing.T) { @@ -168,6 +169,7 @@ type firstSource struct {} // +externaldns:source:name=second // +externaldns:source:category=Testing // +externaldns:source:description=Second source +// +externaldns:source:events=true type secondSource struct {} ` err := os.WriteFile(testFile, []byte(content), 0644) @@ -177,7 +179,9 @@ type secondSource struct {} require.NoError(t, err) assert.Len(t, sources, 2) assert.Equal(t, "first", sources[0].Name) + assert.Equal(t, "false", sources[0].Events) assert.Equal(t, "second", sources[1].Name) + assert.Equal(t, "true", sources[1].Events) } func TestParseFile_IgnoresNonSourceTypes(t *testing.T) { diff --git a/internal/gen/docs/sources/templates/sources.gotpl b/internal/gen/docs/sources/templates/sources.gotpl index ccd7934921..486c72c53c 100644 --- a/internal/gen/docs/sources/templates/sources.gotpl +++ b/internal/gen/docs/sources/templates/sources.gotpl @@ -22,10 +22,10 @@ Sources are responsible for: ## Available Sources -| **Source Name** | Resources | Filters | Namespace | FQDN Template | Category | -|:----------------|:----------|:--------|:----------|:--------------|:---------| +| **Source Name** | Resources | Filters | Namespace | FQDN Template | Events | Category | +|:----------------|:----------|:--------|:----------|:--------------|:---------|:---------| {{- range . }} -| **{{ .Name }}** | {{ replace .Resources "," "
" }} | {{ .Filters }} | {{ .Namespace }} | {{ .FQDNTemplate }} | {{ lower .Category }} | +| **{{ .Name }}** | {{ replace .Resources "," "
" }} | {{ .Filters }} | {{ .Namespace }} | {{ .FQDNTemplate }} | {{ .Events }} | {{ lower .Category }} | {{- end }} ## Usage diff --git a/source/ambassador_host.go b/source/ambassador_host.go index 730c05385f..11b401227d 100644 --- a/source/ambassador_host.go +++ b/source/ambassador_host.go @@ -65,6 +65,7 @@ var ( // +externaldns:source:filters=annotation,label // +externaldns:source:namespace=all,single // +externaldns:source:fqdn-template=false +// +externaldns:source:events=false type ambassadorHostSource struct { dynamicKubeClient dynamic.Interface kubeClient kubernetes.Interface diff --git a/source/crd.go b/source/crd.go index 2b2a172afb..4cee53c9c6 100644 --- a/source/crd.go +++ b/source/crd.go @@ -48,10 +48,11 @@ import ( // +externaldns:source:name=crd // +externaldns:source:category=ExternalDNS // +externaldns:source:description=Creates DNS entries from DNSEndpoint CRD resources -// +externaldns:source:resources=DNSEndpoint.k8s.io +// +externaldns:source:resources=DNSEndpoint.externaldns.k8s.io // +externaldns:source:filters=annotation,label // +externaldns:source:namespace=all,single // +externaldns:source:fqdn-template=false +// +externaldns:source:events=false type crdSource struct { crdClient rest.Interface namespace string diff --git a/source/fake.go b/source/fake.go index d1faaae195..bc1a58f431 100644 --- a/source/fake.go +++ b/source/fake.go @@ -44,6 +44,7 @@ import ( // +externaldns:source:filters= // +externaldns:source:namespace= // +externaldns:source:fqdn-template=true +// +externaldns:source:events=true type fakeSource struct { dnsName string }