Skip to content

Commit 99c77d2

Browse files
authored
Merge pull request #41 from dchudik/idn_domains
Added supporting IDN domains
2 parents aa31911 + 443ebe0 commit 99c77d2

File tree

15 files changed

+127
-58
lines changed

15 files changed

+127
-58
lines changed

.github/workflows/pr-ci-chart.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v2
2424
with:
25-
python-version: 3.7
25+
python-version: 3.13.3
2626

2727
- name: Set up chart-testing
2828
uses: helm/[email protected]
@@ -47,9 +47,10 @@ jobs:
4747
strategy:
4848
matrix:
4949
k8s:
50-
- v1.17.14
51-
- v1.19.4
52-
- v1.21.6
50+
- v1.30.10
51+
- v1.31.6
52+
- v1.32.2
53+
5354
steps:
5455
- name: Checkout
5556
uses: actions/checkout@v1

.golangci.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1+
version: "2"
12
linters:
2-
fast: false
3-
enable-all: true
3+
default: all
44
disable:
55
- bodyclose
6+
- depguard
67
- dupl
8+
- exhaustruct
9+
- funcorder
710
- gochecknoglobals
811
- gosec
912
- lll
10-
- wsl
11-
- depguard
12-
- testpackage
13-
- exhaustruct
1413
- tagliatelle
15-
# Disbale deprecated linters
16-
- interfacer
17-
- ifshort
18-
- structcheck
19-
- maligned
20-
- scopelint
21-
- deadcode
22-
- nosnakecase
23-
- golint
24-
- varcheck
25-
- exhaustivestruct
14+
- testpackage
15+
- wsl
16+
exclusions:
17+
generated: lax
18+
presets:
19+
- comments
20+
- common-false-positives
21+
- legacy
22+
- std-error-handling
23+
paths:
24+
- third_party$
25+
- builtin$
26+
- examples$
27+
formatters:
28+
enable:
29+
- gci
30+
- gofmt
31+
- gofumpt
32+
- goimports
33+
exclusions:
34+
generated: lax
35+
paths:
36+
- third_party$
37+
- builtin$
38+
- examples$

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
sudo: false
22
language: go
33
install:
4-
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
4+
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.1
55
go:
6-
- "1.17"
6+
- "1.24.2"
77
script:
88
- make golangci-lint
99
- make unit-tests

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20.3-alpine AS build
1+
FROM golang:1.24.2-alpine3.21 AS build
22
RUN apk add --no-cache git
33
WORKDIR /workspace
44
ENV GO111MODULE=on
@@ -7,7 +7,7 @@ RUN go mod download
77
RUN CGO_ENABLED=0 go build -o webhook -ldflags '-w -extldflags "-static"' .
88

99
# ------------------------------
10-
FROM alpine:3.14.2
10+
FROM alpine:3.21.3
1111
RUN apk add --no-cache ca-certificates
1212
COPY --from=build /workspace/webhook /usr/local/bin/webhook
1313
ENTRYPOINT ["webhook"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
apiVersion: v1
33
name: cert-manager-webhook-selectel
4-
appVersion: "1.3.0"
4+
appVersion: "1.4.0"
55
description: Selectel DNS cert-manager ACME webhook
66
maintainers:
77
- name: andrsp
88
99
url: https://github.com/andrsp
10-
version: 1.3.0
10+
version: 1.4.0

deploy/cert-manager-webhook-selectel/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ replicaCount: 1
1616

1717
image:
1818
repository: ghcr.io/selectel/cert-manager-webhook-selectel
19-
tag: v1.3.0
19+
tag: v1.4.0
2020
pullPolicy: Always
2121

2222
nameOverride: ""

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module github.com/selectel/cert-manager-webhook-selectel
22

3-
go 1.20
3+
go 1.24
44

55
require (
66
github.com/cert-manager/cert-manager v1.14.1
77
github.com/go-playground/validator/v10 v10.17.0
88
github.com/selectel/domains-go v1.0.2
99
github.com/selectel/go-selvpcclient/v3 v3.1.1
1010
github.com/stretchr/testify v1.8.4
11+
golang.org/x/net v0.19.0
1112
k8s.io/api v0.29.1
1213
k8s.io/apiextensions-apiserver v0.29.0
1314
k8s.io/apimachinery v0.29.1
@@ -89,7 +90,6 @@ require (
8990
golang.org/x/crypto v0.17.0 // indirect
9091
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect
9192
golang.org/x/mod v0.14.0 // indirect
92-
golang.org/x/net v0.19.0 // indirect
9393
golang.org/x/oauth2 v0.15.0 // indirect
9494
golang.org/x/sync v0.5.0 // indirect
9595
golang.org/x/sys v0.16.0 // indirect

go.sum

Lines changed: 32 additions & 0 deletions
Large diffs are not rendered by default.

main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"os"
89

@@ -28,14 +29,14 @@ const (
2829
var (
2930
// use a single instance of Validate, it caches struct info.
3031
validate *validator.Validate = validator.New(validator.WithRequiredStructEnabled())
31-
errSecretNameNotSetup = fmt.Errorf("secret name not setup")
32-
errConvertToValidator = fmt.Errorf("convert to validator")
32+
errSecretNameNotSetup = errors.New("secret name not setup")
33+
errConvertToValidator = errors.New("convert to validator")
3334
)
3435

3536
func main() {
3637
groupName := os.Getenv("GROUP_NAME")
3738
if groupName == "" {
38-
panic(fmt.Sprintf("%s must be specified", groupNameEnvVar))
39+
panic(groupNameEnvVar + " must be specified")
3940
}
4041
// This will register our custom DNS provider with the webhook serving
4142
// library, making it available as an API under the provided groupName.

selectel/internal/rrset.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@ package internal
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"regexp"
78
"strconv"
89

910
domainsV2 "github.com/selectel/domains-go/pkg/v2"
11+
"golang.org/x/net/idna"
1012
)
1113

12-
var ErrRrsetNotFound = fmt.Errorf("rrset not found")
14+
var ErrRrsetNotFound = errors.New("rrset not found")
1315

1416
func GetRrsetByNameAndType(ctx context.Context, client domainsV2.DNSClient[domainsV2.Zone, domainsV2.RRSet], zoneID, rrsetName, rrsetType string) (*domainsV2.RRSet, error) {
17+
rrsetNameUnicode, err := idna.ToUnicode(rrsetName)
18+
if err != nil {
19+
return nil, fmt.Errorf("convert rrset name to unicode: %w", err)
20+
}
21+
1522
optsForSearchRrset := map[string]string{
16-
"name": rrsetName,
23+
"name": rrsetNameUnicode,
1724
"rrset_types": rrsetType,
1825
"limit": "100",
1926
"offset": "0",
2027
}
2128

22-
regexpRRSetWithDotOrNot, err := regexp.Compile(fmt.Sprintf("^%s.?", rrsetName))
29+
regexpRRSetWithDotOrNot, err := regexp.Compile(fmt.Sprintf("^%s.?", rrsetNameUnicode))
2330
if err != nil {
2431
return nil, fmt.Errorf("compile regexp: %w", err)
2532
}
@@ -29,11 +36,13 @@ func GetRrsetByNameAndType(ctx context.Context, client domainsV2.DNSClient[domai
2936
if err != nil {
3037
return nil, fmt.Errorf("list rrsets: %w", err)
3138
}
39+
3240
for _, rrset := range rrsets.GetItems() {
3341
if regexpRRSetWithDotOrNot.MatchString(rrset.Name) && string(rrset.Type) == rrsetType {
3442
return rrset, nil
3543
}
3644
}
45+
3746
optsForSearchRrset["offset"] = strconv.Itoa(rrsets.GetNextOffset())
3847
if rrsets.GetNextOffset() == 0 {
3948
break

0 commit comments

Comments
 (0)