From fcd1cce5cc048fd19257653d670675efa7bc64cd Mon Sep 17 00:00:00 2001 From: Michel Loiseleur Date: Thu, 14 Nov 2024 08:58:10 +0100 Subject: [PATCH] update and fix last warning --- .github/workflows/lint.yaml | 6 +-- Makefile | 5 ++- api/webhook.yaml | 63 +++++++++++++++++++++++++++++--- provider/webhook/webhook_test.go | 1 - 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 53691a3af..f8e1c83d7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -35,12 +35,8 @@ jobs: args: --timeout=30m version: v1.60 - - name: Install Vacuum - # See: https://quobix.com/vacuum/installing/ - run: | - curl -fsSL https://quobix.com/scripts/install_vacuum.sh | sh > /dev/null shell: bash - name: Run Vacuum run: | - vacuum lint -d api/webhook.yaml + go run github.com/daveshanley/vacuum@latest lint -d api/webhook.yaml shell: bash diff --git a/Makefile b/Makefile index 5ffdfd0fc..0c22b0096 100644 --- a/Makefile +++ b/Makefile @@ -60,9 +60,12 @@ licensecheck: exit 1; \ fi +oas-lint: + go run github.com/daveshanley/vacuum@latest lint -d api/webhook.yaml + # Run all the linters .PHONY: lint -lint: licensecheck go-lint +lint: licensecheck go-lint oas-lint # generates CRD using controller-gen .PHONY: crd diff --git a/api/webhook.yaml b/api/webhook.yaml index 04e11b5d0..96f477c14 100644 --- a/api/webhook.yaml +++ b/api/webhook.yaml @@ -61,6 +61,12 @@ paths: application/external.dns.webhook+json;version=1: schema: $ref: '#/components/schemas/endpoints' + example: + - dnsName: "test.example.com" + recordTTL: 10 + recordType: 'A' + targets: + - "1.2.3.4" '500': description: | Failed to provide the list of DNS records. @@ -83,6 +89,11 @@ paths: application/external.dns.webhook+json;version=1: schema: $ref: '#/components/schemas/changes' + example: + create: + - dnsName: "test.example.com" + recordTTL: 10 + recordType: 'A' responses: '204': description: | @@ -106,6 +117,12 @@ paths: application/external.dns.webhook+json;version=1: schema: $ref: '#/components/schemas/endpoints' + example: + - dnsName: "test.example.com" + recordTTL: 10 + recordType: 'A' + targets: + - "1.2.3.4" responses: '200': description: | @@ -114,6 +131,12 @@ paths: application/external.dns.webhook+json;version=1: schema: $ref: '#/components/schemas/endpoints' + example: + - dnsName: "test.example.com" + recordTTL: 0 + recordType: 'A' + targets: + - "1.2.3.4" '500': description: | Adjustments were not accepted. @@ -122,16 +145,20 @@ components: schemas: filters: description: | - TODO: explain the filters object. + external-dns will only create DNS records for host names (specified in ingress objects and services with the external-dns annotation) related to zones that match filters. They can set in external-dns deployment manifest. type: object properties: filters: type: array items: type: string + example: "foo.example.com" + example: + - ".example.com" example: filters: - - foo.example.com + - ".example.com" + - ".example.org" endpoints: description: | @@ -139,6 +166,10 @@ components: type: array items: $ref: '#/components/schemas/endpoint' + example: + - dnsName: foo.example.com + recordType: A + recordTTL: 60 endpoint: description: | @@ -147,23 +178,33 @@ components: properties: dnsName: type: string + example: "foo.example.org" targets: $ref: '#/components/schemas/targets' recordType: type: string + example: "CNAME" setIdentifier: type: string + example: "v1" recordTTL: type: integer format: int64 + example: 60 labels: type: object additionalProperties: type: string + example: "foo" + example: + foo: bar providerSpecific: type: array items: $ref: '#/components/schemas/providerSpecificProperty' + example: + - name: foo + value: bar example: dnsName: foo.example.com recordType: A @@ -176,20 +217,22 @@ components: type: array items: type: string + example: "::1" example: - - 1.2.3.4 - - 1.2.3.5 + - "1.2.3.4" + - "test.example.org" providerSpecificProperty: description: | - TODO: explain the provider object. What might this be used for? - Examples? + Allows provider to pass property specific to their implementation. type: object properties: name: type: string + example: foo value: type: string + example: bar example: name: foo value: bar @@ -212,3 +255,11 @@ components: $ref: '#/components/schemas/endpoints' delete: $ref: '#/components/schemas/endpoints' + example: + create: + - dnsName: foo.example.com + recordType: A + recordTTL: 60 + delete: + - dnsName: foo.example.org + recordType: CNAME diff --git a/provider/webhook/webhook_test.go b/provider/webhook/webhook_test.go index 999cdc3bf..470c3caf5 100644 --- a/provider/webhook/webhook_test.go +++ b/provider/webhook/webhook_test.go @@ -162,7 +162,6 @@ func TestAdjustEndpoints(t *testing.T) { } j, _ := json.Marshal(endpoints) w.Write(j) - })) defer svr.Close()