Skip to content

Commit 26a1887

Browse files
Merge pull request #4 from eyenx/fix/access-token
fix(semantic-release.yaml): switch to default GITHUB_TOKEN
2 parents eef9f5b + 2635f2a commit 26a1887

9 files changed

Lines changed: 159 additions & 63 deletions

File tree

.github/workflows/lint-and-test.yaml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,49 @@ jobs:
2626
with:
2727
go-version: 1.17.x
2828

29-
- name: Run GolangCI-Lint
30-
uses: golangci/golangci-lint-action@v3
31-
with:
32-
args: --timeout 3m
29+
# - name: Run GolangCI-Lint
30+
# uses: golangci/golangci-lint-action@v3
31+
# with:
32+
# args: --timeout 3m
3333

3434
test:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- name: Checkout
3838
uses: actions/checkout@v3
39-
- name: Set up Go
40-
uses: actions/setup-go@v3
41-
with:
42-
go-version: 1.17.x
43-
- name: Build App
44-
run: go build -v ./...
45-
- name: Test App
46-
run: go test -v ./...
4739

48-
goreleaser:
49-
runs-on: ubuntu-latest
50-
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v3
53-
- name: Set up Go
54-
uses: actions/setup-go@v3
55-
with:
56-
go-version: 1.17.x
57-
- name: Run GoReleaser
58-
uses: goreleaser/goreleaser-action@v2.9.1
59-
with:
60-
version: latest
61-
args: --snapshot --skip-publish --rm-dist
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Set up QEMU
41+
uses: docker/setup-qemu-action@v1
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v1
45+
46+
- name: Test build
47+
id: docker_build
48+
uses: docker/build-push-action@v2
49+
50+
# - name: Set up Go
51+
# uses: actions/setup-go@v3
52+
# with:
53+
# go-version: 1.17.x
54+
# - name: Build App
55+
# run: go build -v ./...
56+
# - name: Test App
57+
# run: go test -v ./...
58+
59+
# goreleaser:
60+
# runs-on: ubuntu-latest
61+
# steps:
62+
# - name: Checkout
63+
# uses: actions/checkout@v3
64+
# - name: Set up Go
65+
# uses: actions/setup-go@v3
66+
# with:
67+
# go-version: 1.17.x
68+
# - name: Run GoReleaser
69+
# uses: goreleaser/goreleaser-action@v2.9.1
70+
# with:
71+
# version: latest
72+
# args: --snapshot --skip-publish --rm-dist
73+
# env:
74+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 86 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,99 @@
22
name: Release App
33

44
on:
5-
release:
6-
types:
7-
- created
5+
push:
6+
branches: master
7+
tags:
8+
- 'v*.*.*'
89

910
jobs:
10-
goreleaser:
11+
container:
1112
runs-on: ubuntu-latest
1213
steps:
1314
- name: Checkout
14-
uses: actions/checkout@v3
15-
with:
16-
fetch-depth: 0
17-
- name: Set up Go
18-
uses: actions/setup-go@v3
19-
with:
20-
go-version: 1.17.x
21-
- name: Login to GitHub Container Registry
15+
uses: actions/checkout@v2
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v1
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v1
22+
23+
- name: Prepare Image Metadata
24+
id: prep
25+
run: |
26+
DOCKER_IMAGE=ghcr.io/linkyard/cloudscale-slb-controller
27+
VERSION=noop
28+
if [ "${{ github.event_name }}" = "schedule" ]; then
29+
VERSION=nightly
30+
elif [[ $GITHUB_REF == refs/tags/* ]]; then
31+
VERSION=${GITHUB_REF#refs/tags/}
32+
elif [[ $GITHUB_REF == refs/heads/* ]]; then
33+
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
34+
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
35+
VERSION=edge
36+
fi
37+
elif [[ $GITHUB_REF == refs/pull/* ]]; then
38+
VERSION=pr-${{ github.event.number }}
39+
fi
40+
TAGS="${DOCKER_IMAGE}:${VERSION}"
41+
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
42+
MINOR=${VERSION%.*}
43+
MAJOR=${MINOR%.*}
44+
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
45+
elif [ "${{ github.event_name }}" = "push" ]; then
46+
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
47+
fi
48+
echo ::set-output name=version::${VERSION}
49+
echo ::set-output name=tags::${TAGS}
50+
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
51+
- name: Login to GHCR
2252
uses: docker/login-action@v1
23-
if: github.event_name != 'pull_request'
2453
with:
2554
registry: ghcr.io
26-
username: ${{ github.actor }}
55+
username: ${{ github.repository_owner }}
2756
password: ${{ secrets.GITHUB_TOKEN }}
28-
- name: Run GoReleaser
29-
uses: goreleaser/goreleaser-action@v2.9.1
57+
58+
- name: Build and push
59+
id: docker_build
60+
uses: docker/build-push-action@v2
3061
with:
31-
version: latest
32-
args: release --rm-dist
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
context: ./src
63+
file: ./src/Dockerfile
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.prep.outputs.tags }}
66+
labels: |
67+
org.opencontainers.image.title=${{ github.event.repository.name }}
68+
org.opencontainers.image.description=${{ github.event.repository.description }}
69+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
70+
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
71+
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
72+
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
73+
org.opencontainers.image.revision=${{ github.sha }}
74+
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
75+
76+
# goreleaser:
77+
# runs-on: ubuntu-latest
78+
# steps:
79+
# - name: Checkout
80+
# uses: actions/checkout@v3
81+
# with:
82+
# fetch-depth: 0
83+
# - name: Set up Go
84+
# uses: actions/setup-go@v3
85+
# with:
86+
# go-version: 1.17.x
87+
# - name: Login to GitHub Container Registry
88+
# uses: docker/login-action@v1
89+
# if: github.event_name != 'pull_request'
90+
# with:
91+
# registry: ghcr.io
92+
# username: ${{ github.actor }}
93+
# password: ${{ secrets.GITHUB_TOKEN }}
94+
# - name: Run GoReleaser
95+
# uses: goreleaser/goreleaser-action@v2.9.1
96+
# with:
97+
# version: latest
98+
# args: release --rm-dist
99+
# env:
100+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/semantic-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
id: semrel
1919
uses: go-semantic-release/action@v1.17
2020
with:
21-
github-token: ${{ secrets.BOT_ACCESS_TOKEN }}
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
2222
allow-initial-development-versions: true

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/TekWizely/pre-commit-golang
3+
rev: v1.0.0-beta.5
4+
hooks:
5+
- id: go-fmt
6+
- id: go-vet-mod
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.1.0
9+
hooks:
10+
- id: trailing-whitespace
11+
- id: end-of-file-fixer
12+
- id: check-symlinks
13+
- id: check-merge-conflict
14+
- id: check-case-conflict
15+
- id: detect-aws-credentials
16+
args:
17+
- --allow-missing-credentials
18+
- id: detect-private-key
19+
- id: forbid-new-submodules

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ The following annotations on services of type `LoadBalancer` are supported:
1818

1919
The following configuration flags are supported:
2020

21-
- `-cloudscale-token`, `CLOUDSCALE_TOKEN`, no default, required: cloudscale.ch API token with
21+
- `-cloudscale-token`, `CLOUDSCALE_TOKEN`, no default, required: cloudscale.ch API token with
2222
write access
2323
- `-ip-limit`, `IP_LIMIT`, default `5`: maximum number of floating ips that are allowed to exist on
2424
the cloudscale.ch account; this is used as an additional guard in case this controller is out of
2525
control and would create an infinite amount of floating ips
2626
- `-controller-id`, `CONTROLLER_ID`, no default: if set, the controller will only process services
2727
with a `linkyard.ch/slb-controller-id` annotation set to this value
28-
- `-leader-election-configmap`, `LEADER_ELECTION_CONFIGMAP`, no default: name of the `ConfigMap`
28+
- `-leader-election-configmap`, `LEADER_ELECTION_CONFIGMAP`, no default: name of the `ConfigMap`
2929
to use for leader election
30-
- `-leader-election-namespace` `LEADER_ELECTION_NAMESPACE`, no default: name of the namespace where
30+
- `-leader-election-namespace` `LEADER_ELECTION_NAMESPACE`, no default: name of the namespace where
3131
the `ConfigMap` for leader election is located at
3232
- `-leader-election-node`, `LEADER_ELECTION_NODE`, no default: name of the pod
3333
- `-leader-election-ttl`, `LEADER_ELECTION_TTL`, default `10s`: TTL for leader election, e.g. `10s`;
@@ -36,7 +36,7 @@ The following configuration flags are supported:
3636
`Panic`, `Fatal`, `Error`, `Warn`, `Info`, `Debug`, `Trace`
3737
- `-kubeconfig`, `KUBECONFIG`, no default, not required: path to a kubernetes kubconfig file; this
3838
is not required when running inside a kubernetes cluster
39-
- `-fake-cloudscale-client`, `FAKE_CLOUDSCALE_CLIENT`: set to `true` to use a fake cloudscale.ch
39+
- `-fake-cloudscale-client`, `FAKE_CLOUDSCALE_CLIENT`: set to `true` to use a fake cloudscale.ch
4040
API client
41-
- `-chaos-chance`, `CHAOS_CHANCE`, default `0`: chance of a call to one of the fake components failing;
41+
- `-chaos-chance`, `CHAOS_CHANCE`, default `0`: chance of a call to one of the fake components failing;
4242
range `[0.0,1,0)`

cmd/cloudscale_slb_controller/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Flags:
2929
-cloudscale-token cloudscale.ch API token [CLOUDSCALE_TOKEN]
3030
3131
-ip-limit maximum number of floating ips that are allowed to exist on the
32-
cloudscale.ch account (default: 5); used to make sure we don't go
32+
cloudscale.ch account (default: 5); used to make sure we don't go
3333
bankrupt if this component runs amok [IP_LIMIT]
3434
3535
-kubeconfig path to a kubernetes kubeconfig [KUBECONFIG]

deploy/rbac.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ roleRef:
9292
name: cloudscale-slb-controller
9393
subjects:
9494
- kind: ServiceAccount
95-
name: cloudscale-slb-controller
95+
name: cloudscale-slb-controller

glide.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ import:
1313
- package: github.com/evanphx/json-patch
1414
- package: github.com/imdario/mergo
1515
- package: github.com/spf13/pflag
16-
- package: github.com/namsral/flag
16+
- package: github.com/namsral/flag

internal/event_processor.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ func (processor *EventProcessor) ReAttach(namespace string, name string) (*v1.Se
144144
svc, err := processor.k8sClient.CoreV1().Services(namespace).Get(name, metav1.GetOptions{})
145145
if err != nil {
146146
log.WithFields(log.Fields{
147-
"svc": getKeyFor(namespace, name),
148-
"action": "ReAttach",
149-
"error": err,
147+
"svc": getKeyFor(namespace, name),
148+
"action": "ReAttach",
149+
"error": err,
150150
}).Error("unable to re-attach ip")
151151
processor.emitEvent(
152152
"Warning",
@@ -165,10 +165,10 @@ func (processor *EventProcessor) VerifyIp(svc *v1.Service) error {
165165
ip, serverName, err := processor.verifyIp(svc)
166166
if err != nil {
167167
log.WithFields(log.Fields{
168-
"svc": getKey(svc),
169-
"action": "VerifyIp",
168+
"svc": getKey(svc),
169+
"action": "VerifyIp",
170170
"server_name": serverName,
171-
"error": err,
171+
"error": err,
172172
}).Error("unable to verify ip")
173173
processor.emitEvent(
174174
"Warning",

0 commit comments

Comments
 (0)