Skip to content

Commit 369fc80

Browse files
authored
Add support for defaultOverrides (#104)
1 parent a33dafd commit 369fc80

File tree

12 files changed

+1846
-177
lines changed

12 files changed

+1846
-177
lines changed

.github/workflows/push-pre-releases.yml

-40
This file was deleted.

.github/workflows/push.yml

+28-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
---
2+
name: build
3+
24
on:
3-
release:
4-
types:
5-
- released
5+
push:
6+
tags:
7+
- 'v*'
68

79
jobs:
8-
multi-arch-build:
10+
build:
911
runs-on: ubuntu-latest
1012
steps:
1113
- name: Checkout
1214
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Determine Go version from go.mod
18+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: ${{ env.GO_VERSION }}
1323
- name: Set up QEMU
1424
uses: docker/setup-qemu-action@v1
1525
- name: Set up Docker Buildx
1626
uses: docker/setup-buildx-action@v1
27+
- name: Cache Go modules
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/go/pkg/mod
31+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32+
restore-keys: |
33+
${{ runner.os }}-go-
1734
- name: Login to DockerHub
1835
uses: docker/login-action@v1
1936
with:
@@ -25,18 +42,11 @@ jobs:
2542
registry: ghcr.io
2643
username: ${{ github.actor }}
2744
password: ${{ secrets.GITHUB_TOKEN }}
28-
- name: Prepare release tag
29-
id: tag
30-
run: echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
31-
- name: Build and push
32-
uses: docker/build-push-action@v2
45+
- name: Run GoReleaser
46+
uses: goreleaser/goreleaser-action@v2
47+
if: success() && startsWith(github.ref, 'refs/tags/')
3348
with:
34-
context: .
35-
file: ./Dockerfile
36-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
37-
push: true
38-
tags: |
39-
containeroo/syncflaer:latest
40-
containeroo/syncflaer:${{ steps.tag.outputs.version }}
41-
ghcr.io/containeroo/syncflaer:latest
42-
ghcr.io/containeroo/syncflaer:${{ steps.tag.outputs.version }}
49+
version: latest
50+
args: release --rm-dist
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

-85
This file was deleted.

.goreleaser.yaml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
project_name: SyncFlaer
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- main: ./cmd/syncflaer
8+
env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- darwin
13+
- windows
14+
goarch:
15+
- amd64
16+
- arm64
17+
- arm
18+
dockers:
19+
- image_templates:
20+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-amd64
21+
- containeroo/syncflaer:{{ .Tag }}-amd64
22+
use: buildx
23+
dockerfile: Dockerfile
24+
extra_files:
25+
- go.mod
26+
- go.sum
27+
- cmd
28+
- internal
29+
build_flag_templates:
30+
- --pull
31+
- --platform=linux/amd64
32+
- --label=org.opencontainers.image.title={{ .ProjectName }}
33+
- --label=org.opencontainers.image.description={{ .ProjectName }}
34+
- --label=org.opencontainers.image.url=https://github.com/containeroo/syncflaer
35+
- --label=org.opencontainers.image.source=https://github.com/containeroo/syncflaer
36+
- --label=org.opencontainers.image.version={{ .Version }}
37+
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
38+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
39+
- --label=org.opencontainers.image.licenses="GNU General Public License v3.0"
40+
- image_templates:
41+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-arm64
42+
- containeroo/syncflaer:{{ .Tag }}-arm64
43+
use: buildx
44+
dockerfile: Dockerfile
45+
extra_files:
46+
- go.mod
47+
- go.sum
48+
- cmd
49+
- internal
50+
goarch: arm64
51+
build_flag_templates:
52+
- --pull
53+
- --platform=linux/arm64
54+
- --label=org.opencontainers.image.title={{ .ProjectName }}
55+
- --label=org.opencontainers.image.description={{ .ProjectName }}
56+
- --label=org.opencontainers.image.url=https://github.com/containeroo/syncflaer
57+
- --label=org.opencontainers.image.source=https://github.com/containeroo/syncflaer
58+
- --label=org.opencontainers.image.version={{ .Version }}
59+
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
60+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
61+
- --label=org.opencontainers.image.licenses="GNU General Public License v3.0"
62+
docker_manifests:
63+
- name_template: containeroo/syncflaer:{{ .Tag }}
64+
image_templates:
65+
- containeroo/syncflaer:{{ .Tag }}-amd64
66+
- containeroo/syncflaer:{{ .Tag }}-arm64
67+
- name_template: ghcr.io/containeroo/syncflaer:{{ .Tag }}
68+
image_templates:
69+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-amd64
70+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-arm64
71+
- name_template: containeroo/syncflaer:latest
72+
image_templates:
73+
- containeroo/syncflaer:{{ .Tag }}-amd64
74+
- containeroo/syncflaer:{{ .Tag }}-arm64
75+
- name_template: ghcr.io/containeroo/syncflaer:latest
76+
image_templates:
77+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-amd64
78+
- ghcr.io/containeroo/syncflaer:{{ .Tag }}-arm64
79+
brews:
80+
- tap:
81+
owner: containeroo
82+
name: homebrew-tap
83+
folder: Formula
84+
homepage: https://containeroo.ch
85+
description: Synchronize Traefik host rules and/or Kubernetes Ingresses with Cloudflare
86+
license: GNU General Public License v3.0
87+
test: |
88+
system "#{bin}/syncflaer --version"
89+
dependencies:
90+
- name: go
91+
type: optional
92+
install: |-
93+
bin.install "syncflaer"

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [v5.4.0](https://github.com/containeroo/SyncFlaer/tree/v5.4.0) (2022-02-15)
4+
5+
**New features:**
6+
7+
- Add support for overriding defaults in Traefik rules (#102)
8+
9+
**Bug fixes:**
10+
11+
- Improve Traefik rule parsing (#103)
12+
313
## [v5.3.0](https://github.com/containeroo/SyncFlaer/tree/v5.3.0) (2022-01-21)
414

515
[All Commits](https://github.com/containeroo/SyncFlaer/compare/v5.2.0...v5.3.0)

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Synchronize Traefik host rules and/or Kubernetes Ingresses with Cloudflare®.
2424
- [Overview](#overview)
2525
- [Config File](#config-file)
2626
- [Using Multiple Traefik Instances](#using-multiple-traefik-instances)
27+
- [Overriding Default Settings](#overriding-default-settings)
2728
- [Kubernetes Ingress Support](#kubernetes-ingress-support)
2829
- [Environment Variables](#environment-variables)
2930
- [Defaults](#defaults)
@@ -95,6 +96,35 @@ traefikInstances:
9596
9697
Every instance can be configured to use different HTTP basic auth, custom request headers and ignored rules.
9798
99+
#### Overriding Default Settings
100+
101+
Let's say you have the following Cloudflare defaults defined in config file:
102+
103+
```yaml
104+
cloudflare:
105+
defaults:
106+
type: CNAME
107+
ttl: 1
108+
proxied: true
109+
```
110+
111+
Usually, every DNS record created for a Traefik host rule will have those defaults.
112+
113+
If you want to override those defaults, you can do so by specifying them in the `defaultOverrides` section of the config file under `traefikInstances`:
114+
115+
```yaml
116+
traefikInstances:
117+
- name: main
118+
url: https://traefik.example.com
119+
defaultOverrides:
120+
- rule: app.example.com
121+
type: A
122+
ttl: 60
123+
proxied: false
124+
```
125+
126+
This will override the defaults for the `app.example.com` rule.
127+
98128
#### Kubernetes Ingress Support
99129

100130
SyncFlaer can be configured to support Kubernetes Ingresses. By default, SyncFlaer will sync all Ingresses.

cmd/syncflaer/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
log "github.com/sirupsen/logrus"
1313
)
1414

15-
const version string = "5.3.0"
15+
const version string = "5.4.0"
1616

1717
func main() {
1818
log.SetOutput(os.Stdout)

configs/config.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,20 @@ traefikInstances:
4040
ignoredRules:
4141
- local.example.com
4242
- dev.example.com
43-
# you can add a second instance
43+
# you can define overrides for the default settings for each Traefik rule
44+
# this can be useful, if you want to have some rules with different settings than the ones defined in cloudflare.defaults
45+
defaultOverrides:
46+
# host must match with the host of the Traefik rule
47+
- rule: my.example.com
48+
# specify the overrides (type, content, proxied, ttl)
49+
proxied: false
50+
ttl: 120
51+
- rule: other.example.com
52+
type: A
53+
content: 1.1.1.1
54+
proxied: false
55+
ttl: 300
56+
# you can add a second instance
4457
- name: secondary
4558
url: https://traefik-secondary.example.com
4659
username: admin
@@ -82,6 +95,8 @@ cloudflare:
8295
# every run of SyncFlaer counts as a skip
8396
deleteGrace: 5
8497
# define a set of defaults applied to all DNS records
98+
# they can be overridden by either specifying them in traefikInstances.defaultOverrides or by using Kubernetes Ingress annotations
99+
# check the README for more information
85100
defaults:
86101
type: CNAME
87102
proxied: true

0 commit comments

Comments
 (0)