Compare commits
2 commits
292cc4147d
...
e85d06d6cd
| Author | SHA1 | Date | |
|---|---|---|---|
| e85d06d6cd | |||
| a624a7bfd1 |
3 changed files with 224 additions and 8 deletions
22
.drone-manifest.yml
Normal file
22
.drone-manifest.yml
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
image: happydomain/checker-dangling:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
manifests:
|
||||||
|
- image: happydomain/checker-dangling:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||||
|
platform:
|
||||||
|
architecture: amd64
|
||||||
|
os: linux
|
||||||
|
- image: happydomain/checker-dangling:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||||
|
platform:
|
||||||
|
architecture: arm64
|
||||||
|
os: linux
|
||||||
|
variant: v8
|
||||||
|
- image: happydomain/checker-dangling:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||||
|
platform:
|
||||||
|
architecture: arm
|
||||||
|
os: linux
|
||||||
|
variant: v7
|
||||||
187
.drone.yml
Normal file
187
.drone.yml
Normal file
|
|
@ -0,0 +1,187 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-amd64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: checker build
|
||||||
|
image: golang:1-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git make
|
||||||
|
- make
|
||||||
|
environment:
|
||||||
|
CHECKER_VERSION: "${DRONE_BRANCH}-${DRONE_COMMIT}"
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: checker build tag
|
||||||
|
image: golang:1-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git make
|
||||||
|
- make
|
||||||
|
environment:
|
||||||
|
CHECKER_VERSION: "${DRONE_SEMVER}"
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: publish on Docker Hub
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: happydomain/checker-dangling
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_args:
|
||||||
|
- CHECKER_VERSION=${DRONE_BRANCH}-${DRONE_COMMIT}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: publish on Docker Hub (tag)
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: happydomain/checker-dangling
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_args:
|
||||||
|
- CHECKER_VERSION=${DRONE_SEMVER}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
exclude:
|
||||||
|
- renovate/*
|
||||||
|
event:
|
||||||
|
- cron
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build-arm64
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: checker build
|
||||||
|
image: golang:1-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git make
|
||||||
|
- make
|
||||||
|
environment:
|
||||||
|
CHECKER_VERSION: "${DRONE_BRANCH}-${DRONE_COMMIT}"
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: checker build tag
|
||||||
|
image: golang:1-alpine
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache git make
|
||||||
|
- make
|
||||||
|
environment:
|
||||||
|
CHECKER_VERSION: "${DRONE_SEMVER}"
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: publish on Docker Hub
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: happydomain/checker-dangling
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_args:
|
||||||
|
- CHECKER_VERSION=${DRONE_BRANCH}-${DRONE_COMMIT}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: publish on Docker Hub (tag)
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: happydomain/checker-dangling
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
build_args:
|
||||||
|
- CHECKER_VERSION=${DRONE_SEMVER}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- cron
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
name: docker-manifest
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: publish on Docker Hub
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
ignore_missing: true
|
||||||
|
spec: .drone-manifest.yml
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
exclude:
|
||||||
|
- renovate/*
|
||||||
|
event:
|
||||||
|
- cron
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build-amd64
|
||||||
|
- build-arm64
|
||||||
|
|
@ -159,7 +159,7 @@ func extractPointers(sub, apex string, svc rawService) ([]Pointer, error) {
|
||||||
if target == "" {
|
if target == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
ptOwner := preferRRName(b.Record.Hdr.Name, owner)
|
ptOwner := preferRRName(b.Record.Hdr.Name, owner, apex)
|
||||||
return []Pointer{{
|
return []Pointer{{
|
||||||
Owner: ptOwner,
|
Owner: ptOwner,
|
||||||
Subdomain: sub,
|
Subdomain: sub,
|
||||||
|
|
@ -180,7 +180,7 @@ func extractPointers(sub, apex string, svc rawService) ([]Pointer, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
out = append(out, Pointer{
|
out = append(out, Pointer{
|
||||||
Owner: preferRRName(r.Hdr.Name, owner),
|
Owner: preferRRName(r.Hdr.Name, owner, apex),
|
||||||
Subdomain: sub,
|
Subdomain: sub,
|
||||||
Rrtype: "MX",
|
Rrtype: "MX",
|
||||||
Target: target,
|
Target: target,
|
||||||
|
|
@ -201,7 +201,7 @@ func extractPointers(sub, apex string, svc rawService) ([]Pointer, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
out = append(out, Pointer{
|
out = append(out, Pointer{
|
||||||
Owner: preferRRName(r.Hdr.Name, owner),
|
Owner: preferRRName(r.Hdr.Name, owner, apex),
|
||||||
Subdomain: sub,
|
Subdomain: sub,
|
||||||
Rrtype: "SRV",
|
Rrtype: "SRV",
|
||||||
Target: target,
|
Target: target,
|
||||||
|
|
@ -215,7 +215,7 @@ func extractPointers(sub, apex string, svc rawService) ([]Pointer, error) {
|
||||||
if err := json.Unmarshal(svc.Service, &b); err != nil {
|
if err := json.Unmarshal(svc.Service, &b); err != nil {
|
||||||
return nil, fmt.Errorf("decode orphan body: %w", err)
|
return nil, fmt.Errorf("decode orphan body: %w", err)
|
||||||
}
|
}
|
||||||
ptOwner := preferRRName(b.Record.Hdr.Name, owner)
|
ptOwner := preferRRName(b.Record.Hdr.Name, owner, apex)
|
||||||
switch b.Record.Hdr.Rrtype {
|
switch b.Record.Hdr.Rrtype {
|
||||||
case dns.TypeNS:
|
case dns.TypeNS:
|
||||||
target := normaliseTarget(b.Record.Ns, ptOwner, apex)
|
target := normaliseTarget(b.Record.Ns, ptOwner, apex)
|
||||||
|
|
@ -330,13 +330,20 @@ func ownerFQDN(svcDomain, sub, apex string) string {
|
||||||
return sub + "." + apex
|
return sub + "." + apex
|
||||||
}
|
}
|
||||||
|
|
||||||
// preferRRName returns the RR header Name when present, as it is authoritative over the service-derived owner.
|
// preferRRName returns the RR header Name as an FQDN when present.
|
||||||
func preferRRName(rrName, fallback string) string {
|
// happyDomain encodes service-embedded record owners relative to the zone
|
||||||
|
// apex, so the rrName must be joined with apex unless it already contains
|
||||||
|
// the apex suffix (services published with absolute owners).
|
||||||
|
func preferRRName(rrName, fallback, apex string) string {
|
||||||
rrName = strings.TrimSuffix(rrName, ".")
|
rrName = strings.TrimSuffix(rrName, ".")
|
||||||
if rrName != "" {
|
if rrName == "" {
|
||||||
|
return fallback
|
||||||
|
}
|
||||||
|
apex = strings.TrimSuffix(apex, ".")
|
||||||
|
if apex == "" || rrName == apex || strings.HasSuffix(rrName, "."+apex) {
|
||||||
return rrName
|
return rrName
|
||||||
}
|
}
|
||||||
return fallback
|
return rrName + "." + apex
|
||||||
}
|
}
|
||||||
|
|
||||||
// normaliseTarget converts a target to FQDN form; happyDomain stores in-zone targets relative, external ones absolute.
|
// normaliseTarget converts a target to FQDN form; happyDomain stores in-zone targets relative, external ones absolute.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue