Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit ce621bb

Browse files
authored
feat: initial import (#1)
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
1 parent d38cc68 commit ce621bb

36 files changed

Lines changed: 1922 additions & 0 deletions

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/go:1-bullseye",
3+
"features": {
4+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
5+
"ghcr.io/rio/features/k3d:1": {},
6+
"ghcr.io/mpriscella/features/kind:1": {},
7+
"ghcr.io/rjfmachado/devcontainer-features/cloud-native:1": {
8+
"kubectl": "latest",
9+
"helm": "latest",
10+
"kubelogin": "none",
11+
"azwi": "none",
12+
"flux": "none",
13+
"cilium": "none"
14+
},
15+
"ghcr.io/guiyomh/features/golangci-lint:0": {},
16+
"ghcr.io/devcontainers-contrib/features/kubectx-kubens:1": {},
17+
"ghcr.io/dhoeric/features/stern:1": {}
18+
},
19+
20+
// Needed by kind and k3s to enable kube-proxy's ipvs mode
21+
"mounts":["type=bind,source=/lib/modules,target=/lib/modules"],
22+
23+
// Enable kubectl short alias with completion
24+
"postCreateCommand": "echo 'alias k=kubectl; complete -F __start_kubectl k' >> ~/.bash_aliases; git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1; echo 'if [ -f \"$HOME/.bash-git-prompt/gitprompt.sh\" ]; then . \"$HOME/.bash-git-prompt/gitprompt.sh\"; fi' >> ~/.bashrc"
25+
}
26+

.github/workflows/build-image.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
workflow_dispatch:
6+
env:
7+
REGISTRY: ghcr.io
8+
IMAGE_NAME: ${{ github.repository }}
9+
name: build image
10+
jobs:
11+
build-image:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Log in to the Container registry
16+
uses: docker/login-action@v2
17+
with:
18+
registry: ${{ env.REGISTRY }}
19+
username: ${{ github.actor }}
20+
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Extract metadata (tags, labels) for Docker
22+
id: meta
23+
uses: docker/metadata-action@v4
24+
with:
25+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
26+
- name: Build and push Docker image
27+
uses: docker/build-push-action@v3
28+
with:
29+
context: .
30+
push: true
31+
tags: ${{ steps.meta.outputs.tags }}
32+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Plugin PVC Backup CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-go@v3
16+
with:
17+
go-version: '>=1.19.0'
18+
- run: make check
19+
name: "Linters"
20+
21+
unit-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-go@v3
26+
with:
27+
go-version: '>=1.19.0'
28+
- run: make test
29+
name: "Unit tests"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
env:
6+
REGISTRY: ghcr.io
7+
IMAGE_NAME: ${{ github.repository }}
8+
name: release-please
9+
jobs:
10+
release-please:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: google-github-actions/release-please-action@v3
14+
id: release
15+
with:
16+
release-type: go
17+
package-name: plugin_pvc_backup
18+
token: ${{secrets.REPO_PAT}}

.github/workflows/spellcheck.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: spellcheck
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
spellcheck:
8+
name: runner / spellcheck
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code.
12+
uses: actions/checkout@v2
13+
- name: Run PySpelling as a GitHub action
14+
uses: sbates130272/spellcheck-github-actions@v0.6.0

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin/
2+
dist/
3+
.env
4+
.vscode/

.golangci.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
linters-settings:
2+
lll:
3+
line-length: 120
4+
gci:
5+
sections:
6+
- standard
7+
- default
8+
- prefix(github.com/cloudnative-pg/plugin-pvc-backup)
9+
- blank
10+
- dot
11+
12+
linters:
13+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
14+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
15+
disable-all: true
16+
enable:
17+
- asciicheck
18+
- bodyclose
19+
- dogsled
20+
- dupl
21+
- durationcheck
22+
- errcheck
23+
- exportloopref
24+
- gci
25+
- gocognit
26+
- goconst
27+
- gocritic
28+
- gocyclo
29+
- gofmt
30+
- gofumpt
31+
- goheader
32+
- goimports
33+
- gomoddirectives
34+
- gomodguard
35+
- goprintffuncname
36+
- gosec
37+
- gosimple
38+
- govet
39+
- importas
40+
- ineffassign
41+
- lll
42+
- makezero
43+
- misspell
44+
- nakedret
45+
- nestif
46+
- prealloc
47+
- predeclared
48+
- revive
49+
- rowserrcheck
50+
- sqlclosecheck
51+
- staticcheck
52+
- stylecheck
53+
- thelper
54+
- tparallel
55+
- typecheck
56+
- unconvert
57+
- unparam
58+
- unused
59+
- wastedassign
60+
- whitespace
61+
62+
# to be checked:
63+
# - errorlint
64+
# - forbidigo
65+
# - forcetypeassert
66+
# - goerr113
67+
# - ifshort
68+
# - nilerr
69+
# - nlreturn
70+
# - noctx
71+
# - nolintlint
72+
# - paralleltest
73+
# - promlinter
74+
# - tagliatelle
75+
# - wrapcheck
76+
77+
# don't enable:
78+
# - cyclop
79+
# - depguard
80+
# - exhaustive
81+
# - exhaustivestruct
82+
# - funlen
83+
# - gochecknoglobals
84+
# - gochecknoinits
85+
# - godot
86+
# - godox
87+
# - gomnd
88+
# - testpackage
89+
# - wsl
90+
91+
# deprecated:
92+
# - deadcode
93+
# - golint
94+
# - interfacer
95+
# - maligned
96+
# - scopelint
97+
# - structcheck
98+
# - varcheck
99+
100+
run:
101+
skip-files: "zz_generated.*"
102+
103+
issues:
104+
exclude-rules:
105+
# Exclude lll issues for lines with long annotations
106+
- linters:
107+
- lll
108+
source: "//\\s*\\+"
109+
# We have no control of this in zz_generated files and it looks like that excluding those files is not enough
110+
# so we disable "ST1016: methods on the same type should have the same receiver name" in api directory
111+
- linters:
112+
- stylecheck
113+
text: "ST1016:"
114+
path: api/
115+
exclude-use-default: false

.spellcheck.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
matrix:
2+
- name: Python Source
3+
sources:
4+
- ./**/*.go
5+
- ./**/*.md
6+
dictionary:
7+
wordlists:
8+
- .wordlist.txt
9+
aspell:
10+
lang: en
11+
d: en_US
12+
pipeline:
13+
- pyspelling.filters.python:
14+
- pyspelling.filters.context:
15+
context_visible_first: true
16+
escapes: \\[\\`~]
17+
delimiters:
18+
# Ignore multiline content between fences (fences can have 3 or more back ticks)
19+
# ```
20+
# content
21+
# ```
22+
- open: '(?s)^(?P<open> *`{3,})$'
23+
close: '^(?P=open)$'
24+
# Ignore text between inline back ticks
25+
- open: '(?P<open>`+)'
26+
close: '(?P=open)'

.wordlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sidebarToggle
2+
pvc

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Step 1: build image
2+
FROM golang:1.21 AS builder
3+
4+
# Cache the dependencies
5+
WORKDIR /app
6+
COPY go.mod go.sum /app/
7+
RUN go mod download
8+
9+
# Compile the application
10+
COPY . /app
11+
RUN ./scripts/build.sh
12+
13+
# Step 2: build the image to be actually run
14+
FROM alpine:3.18.4
15+
USER 10001:10001
16+
COPY --from=builder /app/bin/plugin-pvc-backup /app/bin/plugin-pvc-backup
17+
ENTRYPOINT ["/app/bin/plugin-pvc-backup"]

0 commit comments

Comments
 (0)