Skip to content

Commit

Permalink
minor fix for multiple dns zones / fuzzy search of zones
Browse files Browse the repository at this point in the history
  • Loading branch information
canaykin committed Apr 19, 2024
1 parent 9949dd2 commit d95192c
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 33 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: lint, build, test

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
name: Lint the waf cert uploader source code
runs-on: ubuntu-22.04
steps:
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: ^1.20
- name: Checkout
uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
github-token: ${{ secrets.GITHUB_TOKEN }}
build:
needs: lint
name: Build the waf cert uploader
runs-on: ubuntu-latest
steps:
- name: Setup Go environment
uses: actions/setup-go@v3
with:
go-version: ^1.21
- name: Checkout
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v -o waf-cert-uploader
- name: Upload the built binary executable for testing
uses: actions/upload-artifact@v2
with:
name: build
path: waf-cert-uploader
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: go test -v ./...
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release docker and helm charts
on:
push:
tags:
- "*"
jobs:
docker-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
push: true
tags: |
ghcr.io/iits-consulting/waf-cert-uploader:latest
ghcr.io/iits-consulting/waf-cert-uploader:${{ env.RELEASE_VERSION }}
chart-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
26 changes: 0 additions & 26 deletions .github/workflows/releases.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ GO ?= $(shell which go)
OS ?= $(shell $(GO) env GOOS)
ARCH ?= $(shell $(GO) env GOARCH)

IMAGE_NAME := "akyriako78/cert-manager-webhook-opentelekomcloud"
IMAGE_TAG ?= "v0.1.2"
IMAGE_NAME := "iits-consulting/cert-manager-webhook-opentelekomcloud"
IMAGE_TAG ?= "v0.1.3"

OUT := $(shell pwd)/_out

Expand Down
2 changes: 1 addition & 1 deletion charts/cert-manager-webhook-opentelekomcloud/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "v0.1.2"
description: ACME DNS01 solver webhook for Open Telekom Cloud DNS
name: cert-manager-webhook-opentelekomcloud
version: 0.1.2
version: 0.1.3
4 changes: 2 additions & 2 deletions charts/cert-manager-webhook-opentelekomcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ certManager:
serviceAccountName: cert-manager

image:
repository: akyriako78/cert-manager-webhook-opentelekomcloud
tag: v0.1.2
repository: iits-consulting/cert-manager-webhook-opentelekomcloud
tag: v0.1.3
pullPolicy: IfNotPresent

replicaCount: 1
Expand Down
13 changes: 11 additions & 2 deletions pkg/dns/solver_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,20 @@ func (s *OpenTelekomCloudDnsProviderSolver) getResolvedZone(ch *v1alpha1.Challen
return nil, errors.Wrap(err, fmt.Sprintf("%s up failed", strings.ToLower(string(ch.Action))))
}

if len(allZones) != 1 {
if len(allZones) < 1 {
return nil, fmt.Errorf("%s failed: found %v while expecting 1 for zone %s", action, len(allZones), ch.ResolvedZone)
}

return &allZones[0], nil
minLen := 256
r := 0

for idx, zone := range allZones {
if len(zone.Name) < minLen {
minLen = len(zone.Name)
r = idx
}
}
return &allZones[r], nil
}

func (s *OpenTelekomCloudDnsProviderSolver) getTxtRecordSetsByZone(ch *v1alpha1.ChallengeRequest, zone *zones.Zone) ([]recordsets.RecordSet, error) {
Expand Down

0 comments on commit d95192c

Please sign in to comment.