mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
ci: initial pipeline (#3)
Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
This commit is contained in:
parent
3f4759c47b
commit
8c2bf2e6b7
44
.github/workflows/ci.yml
vendored
Normal file
44
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
# We need the full history for the commitlint task
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
- name: Install Dagger
|
||||||
|
env:
|
||||||
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
|
DAGGER_VERSION: 0.13.3
|
||||||
|
run: |
|
||||||
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
|
- name: Run CI task
|
||||||
|
run: |
|
||||||
|
task ci
|
||||||
|
- name: Write manifest
|
||||||
|
run: |
|
||||||
|
task manifest
|
||||||
|
- name: Publish images
|
||||||
|
if: |
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
github.event.pull_request.head.repo.full_name == github.repository
|
||||||
|
env:
|
||||||
|
REGISTRY_USER: ${{ github.actor }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
task publish
|
||||||
|
- name: Attach manifest to workflow run
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: manifest.yaml
|
||||||
|
path: ./manifest.yaml
|
||||||
57
.github/workflows/release-please.yml
vendored
Normal file
57
.github/workflows/release-please.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: release-please
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-please:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# TODO: googleapis/release-please-action cannot sign commits yet.
|
||||||
|
# We'll use the cli until there's a fix for
|
||||||
|
# https://github.com/googleapis/release-please/issues/2280.
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
- name: Install Dagger
|
||||||
|
env:
|
||||||
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
|
DAGGER_VERSION: 0.13.3
|
||||||
|
run: |
|
||||||
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
|
- name: Create image and manifest
|
||||||
|
env:
|
||||||
|
REGISTRY_USER: ${{ github.actor }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
task publish
|
||||||
|
task manifest
|
||||||
|
- name: Attach manifest to workflow run
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: manifest.yaml
|
||||||
|
path: ./manifest.yaml
|
||||||
|
# TODO: remove bump-minor-pre-major when in production. It prevents
|
||||||
|
# release-please from bumping the major version on breaking changes.
|
||||||
|
# TODO: remove release-as after first release. Used to set the first
|
||||||
|
# release version, which would default to 1.0.0. Set the version
|
||||||
|
# manually also for 1.0.0.
|
||||||
|
# We use a GitHub token with write permissions to create the release,
|
||||||
|
# otherwise we won't be able to trigger a new run when pushing on main.
|
||||||
|
- name: Run release-please
|
||||||
|
run: |
|
||||||
|
npx release-please release-pr \
|
||||||
|
--token="${{ secrets.REPO_PAT }}" \
|
||||||
|
--repo-url="${{ github.repository }}" \
|
||||||
|
--bump-minor-pre-major=true \
|
||||||
|
--release-as=0.1.0 \
|
||||||
|
--signoff "Peggie <info@cloudnative-pg.io>";
|
||||||
|
npx release-please github-release \
|
||||||
|
--token="${{ secrets.REPO_PAT }}" \
|
||||||
|
--repo-url="${{ github.repository }}"
|
||||||
31
.github/workflows/release-publish.yml
vendored
Normal file
31
.github/workflows/release-publish.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: Release Publish Artifacts
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-publish-artifacts:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v2
|
||||||
|
- name: Install Dagger
|
||||||
|
env:
|
||||||
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
|
DAGGER_VERSION: 0.13.3
|
||||||
|
run: |
|
||||||
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
|
- name: Create image and manifest
|
||||||
|
env:
|
||||||
|
REGISTRY_USER: ${{ github.actor }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
task publish
|
||||||
|
task manifest
|
||||||
|
- name: Attach manifest to release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
task upload-manifest-to-release
|
||||||
8
.gitignore
vendored
8
.gitignore
vendored
@ -26,5 +26,11 @@ go.work
|
|||||||
*.swo
|
*.swo
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# Temporary files
|
# Dependency directories (remove the comment below to include it)
|
||||||
vendor/
|
vendor/
|
||||||
|
|
||||||
|
# Go workspace file
|
||||||
|
go.work
|
||||||
|
|
||||||
|
# Taskfile cache
|
||||||
|
.task
|
||||||
|
|||||||
@ -1,47 +1,50 @@
|
|||||||
run:
|
linters-settings:
|
||||||
timeout: 5m
|
lll:
|
||||||
allow-parallel-runners: true
|
line-length: 120
|
||||||
|
gci:
|
||||||
|
sections:
|
||||||
|
- standard
|
||||||
|
- default
|
||||||
|
- prefix(github.com/cloudnative-pg/plugin-barman-cloud)
|
||||||
|
- blank
|
||||||
|
- dot
|
||||||
|
nlreturn:
|
||||||
|
# Size of the block (including return statement that is still "OK")
|
||||||
|
# so no return split required.
|
||||||
|
# Default: 1
|
||||||
|
block-size: 3
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# don't skip warning about doc comments
|
|
||||||
# don't exclude the default set of lint
|
|
||||||
exclude-use-default: false
|
|
||||||
# restore some of the defaults
|
|
||||||
# (fill in the rest as needed)
|
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: "api/*"
|
# Allow dot imports for ginkgo and gomega
|
||||||
|
- source: ginkgo|gomega
|
||||||
linters:
|
linters:
|
||||||
- lll
|
- revive
|
||||||
- path: "internal/*"
|
text: "should not use dot imports"
|
||||||
linters:
|
- linters:
|
||||||
- dupl
|
- stylecheck
|
||||||
- lll
|
text: "should not use dot imports"
|
||||||
linters:
|
exclude-dirs:
|
||||||
disable-all: true
|
- vendor
|
||||||
enable:
|
|
||||||
- dupl
|
|
||||||
- errcheck
|
|
||||||
- exportloopref
|
|
||||||
- ginkgolinter
|
|
||||||
- goconst
|
|
||||||
- gocyclo
|
|
||||||
- gofmt
|
|
||||||
- goimports
|
|
||||||
- gosimple
|
|
||||||
- govet
|
|
||||||
- ineffassign
|
|
||||||
- lll
|
|
||||||
- misspell
|
|
||||||
- nakedret
|
|
||||||
- prealloc
|
|
||||||
- revive
|
|
||||||
- staticcheck
|
|
||||||
- typecheck
|
|
||||||
- unconvert
|
|
||||||
- unparam
|
|
||||||
- unused
|
|
||||||
|
|
||||||
linters-settings:
|
linters:
|
||||||
revive:
|
enable-all: true
|
||||||
rules:
|
disable:
|
||||||
- name: comment-spacings
|
- depguard
|
||||||
|
- err113
|
||||||
|
- exhaustruct
|
||||||
|
- execinquery
|
||||||
|
- exportloopref
|
||||||
|
- funlen
|
||||||
|
- gochecknoglobals
|
||||||
|
- gochecknoinits
|
||||||
|
- godox
|
||||||
|
- gomnd
|
||||||
|
- paralleltest
|
||||||
|
- testpackage
|
||||||
|
- varnamelen
|
||||||
|
- wsl
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 10m
|
||||||
|
allow-parallel-runners: true
|
||||||
|
|||||||
3
.release-please-manifest.json
Normal file
3
.release-please-manifest.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
".": "0.0.0"
|
||||||
|
}
|
||||||
18
.spellcheck.yaml
Normal file
18
.spellcheck.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
matrix:
|
||||||
|
- name: Markdown
|
||||||
|
sources:
|
||||||
|
# Ignore the CHANGELOG.md file, it is autogenerated
|
||||||
|
- ./**/*.md|!./CHANGELOG.md
|
||||||
|
dictionary:
|
||||||
|
wordlists:
|
||||||
|
- .wordlist.txt
|
||||||
|
aspell:
|
||||||
|
lang: en
|
||||||
|
d: en_US
|
||||||
|
pipeline:
|
||||||
|
- pyspelling.filters.markdown:
|
||||||
|
- pyspelling.filters.html:
|
||||||
|
ignores:
|
||||||
|
- ':matches(code, pre)'
|
||||||
|
- 'code'
|
||||||
|
- 'pre'
|
||||||
3
.wordlist.txt
Normal file
3
.wordlist.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cnpg
|
||||||
|
CloudNativePG
|
||||||
|
TODO
|
||||||
@ -14,7 +14,7 @@ RUN go mod download
|
|||||||
# Copy the go source
|
# Copy the go source
|
||||||
COPY cmd/main.go cmd/main.go
|
COPY cmd/main.go cmd/main.go
|
||||||
COPY api/ api/
|
COPY api/ api/
|
||||||
COPY internal/controller/ internal/controller/
|
COPY internal/ internal/
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
# the GOARCH has not a default value to allow the binary be built according to the host where the command
|
# the GOARCH has not a default value to allow the binary be built according to the host where the command
|
||||||
|
|||||||
170
Taskfile.yml
Normal file
170
Taskfile.yml
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
version: 3
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
lint:
|
||||||
|
desc: Run golangci-lint
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=golangci-lint lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
|
||||||
|
DAGGER_GOLANGCI_LINT_SHA: b2bd806a2c43a5a58459aa7969d0e3740e66ec43
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
GITHUB_REF= dagger -s call -m github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA}
|
||||||
|
run --source . --config .golangci.yml stdout
|
||||||
|
sources:
|
||||||
|
- ./**/*.go
|
||||||
|
|
||||||
|
spellcheck:
|
||||||
|
desc: Run spellcheck
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=spellcheck lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
|
DAGGER_SPELLCHECK_SHA: 5f99d3a96134f1a4cca9384b7367f0c8c23abd63
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/spellcheck@${DAGGER_SPELLCHECK_SHA}
|
||||||
|
spellcheck --source . with-exec --use-entrypoint --args="" stdout
|
||||||
|
sources:
|
||||||
|
- ./**/*.md
|
||||||
|
- .spellcheck.yaml
|
||||||
|
- .wordlist.txt
|
||||||
|
|
||||||
|
commitlint:
|
||||||
|
desc: Check for conventional commits
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=commitlint lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
|
DAGGER_COMMITLINT_SHA: 5f99d3a96134f1a4cca9384b7367f0c8c23abd63
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/commitlint@${DAGGER_COMMITLINT_SHA}
|
||||||
|
lint --source . --args "--from=origin/main" stdout
|
||||||
|
|
||||||
|
uncommitted:
|
||||||
|
desc: Check for uncommitted changes
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=uncommitted lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
|
DAGGER_UNCOMMITTED_SHA: 5f99d3a96134f1a4cca9384b7367f0c8c23abd63
|
||||||
|
cmds:
|
||||||
|
- GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/uncommitted@${DAGGER_UNCOMMITTED_SHA} check-uncommitted --source . stdout
|
||||||
|
sources:
|
||||||
|
- ./**
|
||||||
|
|
||||||
|
go-test:
|
||||||
|
desc: Run go test
|
||||||
|
env:
|
||||||
|
# renovate: datasource=docker depName=golang versioning=semver
|
||||||
|
GOLANG_IMAGE_VERSION: 1.23.1
|
||||||
|
# renovate: datasource=git-refs depname=kubernetes packageName=https://github.com/kubernetes/kubernetes versioning=semver
|
||||||
|
K8S_VERSION: 1.31.0
|
||||||
|
# renovate: datasource=git-refs depName=controller-runtime packageName=https://github.com/kubernetes-sigs/controller-runtime versioning=semver
|
||||||
|
SETUP_ENVTEST_VERSION: 0.19.0
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
GITHUB_REF= dagger -s call -m ./dagger/gotest
|
||||||
|
--go-version ${GOLANG_IMAGE_VERSION}
|
||||||
|
--kube-version ${K8S_VERSION}
|
||||||
|
--setup-envtest-version ${SETUP_ENVTEST_VERSION}
|
||||||
|
unit-test --src .
|
||||||
|
sources:
|
||||||
|
- ./**/*.go
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
desc: Build a container image for the plugin
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
|
||||||
|
DAGGER_DOCKER_SHA: dcf4cc7865ada8433f601f728e4a019b68d1fe4e
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
GITHUB_REF= dagger -s call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
|
||||||
|
build --dir . --platform linux/amd64 image > /dev/null
|
||||||
|
|
||||||
|
ci:
|
||||||
|
desc: Run the CI pipeline
|
||||||
|
deps:
|
||||||
|
- spellcheck
|
||||||
|
- commitlint
|
||||||
|
- uncommitted
|
||||||
|
- lint
|
||||||
|
- go-test
|
||||||
|
- build-image
|
||||||
|
|
||||||
|
publish:
|
||||||
|
desc: Build and publish a container image for the plugin
|
||||||
|
requires:
|
||||||
|
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
|
||||||
|
# to prevent running this task locally by accident.
|
||||||
|
vars:
|
||||||
|
- CI
|
||||||
|
- GITHUB_REPOSITORY
|
||||||
|
- GITHUB_REF
|
||||||
|
- GITHUB_REF_NAME
|
||||||
|
- REGISTRY_USER
|
||||||
|
- REGISTRY_PASSWORD
|
||||||
|
vars:
|
||||||
|
IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
|
||||||
|
# remove /merge suffix from the branch name. This is a workaround for the GitHub workflow on PRs,
|
||||||
|
# where the branch name is suffixed with /merge. Prepend pr- to the branch name on PRs.
|
||||||
|
IMAGE_VERSION: '{{regexReplaceAll "(\\d+)/merge" .GITHUB_REF_NAME "pr-${1}"}}'
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
|
||||||
|
DAGGER_DOCKER_SHA: dcf4cc7865ada8433f601f728e4a019b68d1fe4e
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
dagger -s call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
|
||||||
|
--registry ghcr.io --username $REGISTRY_USER --password env:REGISTRY_PASSWORD
|
||||||
|
build --dir . --platform linux/amd64
|
||||||
|
publish --ref {{.IMAGE_NAME}} --tags {{.IMAGE_VERSION}}
|
||||||
|
|
||||||
|
manifest:
|
||||||
|
desc: Update the image in the Kustomization
|
||||||
|
requires:
|
||||||
|
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
|
||||||
|
# to prevent running this task locally by accident.
|
||||||
|
vars:
|
||||||
|
- CI
|
||||||
|
- GITHUB_REPOSITORY
|
||||||
|
- GITHUB_REF
|
||||||
|
- GITHUB_REF_NAME
|
||||||
|
vars:
|
||||||
|
IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}{{if not (hasPrefix "refs/tags/v" .GITHUB_REF)}}-testing{{end}}
|
||||||
|
# remove /merge suffix from the branch name. This is a workaround for the GitHub workflow on PRs,
|
||||||
|
# where the branch name is suffixed with /merge. Prepend pr- to the branch name on PRs.
|
||||||
|
IMAGE_VERSION: '{{regexReplaceAll "(\\d+)/merge" .GITHUB_REF_NAME "pr-${1}"}}'
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=kustomize lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main
|
||||||
|
DAGGER_KUSTOMIZE_SHA: d814d0d7c421348f51cdda96870a05ca2aa8e96a
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
dagger -s call -m github.com/sagikazarmark/daggerverse/kustomize@${DAGGER_KUSTOMIZE_SHA}
|
||||||
|
edit --source config --dir default set image --image controller={{.IMAGE_NAME}}:{{.IMAGE_VERSION}}
|
||||||
|
directory export --path manifest-build
|
||||||
|
- >
|
||||||
|
dagger -s call -m github.com/sagikazarmark/daggerverse/kustomize@${DAGGER_KUSTOMIZE_SHA}
|
||||||
|
build --source manifest-build --dir default export --path manifest.yaml
|
||||||
|
|
||||||
|
upload-manifest-to-release:
|
||||||
|
desc: Upload the manifest to the release
|
||||||
|
requires:
|
||||||
|
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
|
||||||
|
# to prevent running this task locally by accident.
|
||||||
|
vars:
|
||||||
|
- CI
|
||||||
|
- GITHUB_REPOSITORY
|
||||||
|
- GITHUB_REF
|
||||||
|
- GITHUB_REF_NAME
|
||||||
|
- GITHUB_TOKEN
|
||||||
|
env:
|
||||||
|
# renovate: datasource=git-refs depName=gh lookupName=https://github.com/sagikazarmark/daggerverse
|
||||||
|
DAGGER_GH_SHA: 8f444e2c2b8e8162cea76d702086034ed3edc4f1
|
||||||
|
preconditions:
|
||||||
|
- sh: "[[ {{.GITHUB_REF}} =~ 'refs/tags/v.*' ]]"
|
||||||
|
msg: not a tag, failing
|
||||||
|
cmds:
|
||||||
|
- >
|
||||||
|
dagger -s call -m github.com/sagikazarmark/daggerverse/gh@${DAGGER_GH_SHA}
|
||||||
|
with-source --source .
|
||||||
|
run --repo {{.GITHUB_REPOSITORY}} --token env:GITHUB_TOKEN
|
||||||
|
--cmd "release upload {{.GITHUB_REF_NAME}} manifest.yaml"
|
||||||
|
|
||||||
|
clean:
|
||||||
|
desc: Remove autogenerated artifacts
|
||||||
|
cmds:
|
||||||
|
- rm -rf .task/
|
||||||
@ -25,10 +25,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// GroupVersion is group version used to register these objects
|
// GroupVersion is group version used to register these objects.
|
||||||
GroupVersion = schema.GroupVersion{Group: "barmancloud.cnpg.io", Version: "v1"}
|
GroupVersion = schema.GroupVersion{Group: "barmancloud.cnpg.io", Version: "v1"}
|
||||||
|
|
||||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
|
||||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||||
|
|
||||||
// AddToScheme adds the types in this group-version to the given scheme.
|
// AddToScheme adds the types in this group-version to the given scheme.
|
||||||
|
|||||||
@ -17,22 +17,21 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
|
|
||||||
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||||
|
|
||||||
// ObjectStoreSpec defines the desired state of ObjectStore
|
// ObjectStoreSpec defines the desired state of ObjectStore.
|
||||||
type ObjectStoreSpec struct {
|
type ObjectStoreSpec struct {
|
||||||
Configuration barmanapi.BarmanObjectStoreConfiguration `json:"configuration"`
|
Configuration barmanapi.BarmanObjectStoreConfiguration `json:"configuration"`
|
||||||
|
|
||||||
// TODO: we add here any exclusive fields for our plugin CRD
|
// TODO: we add here any exclusive fields for our plugin CRD
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectStoreStatus defines the observed state of ObjectStore
|
// ObjectStoreStatus defines the observed state of ObjectStore.
|
||||||
type ObjectStoreStatus struct {
|
type ObjectStoreStatus struct {
|
||||||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||||
// Important: Run "make" to regenerate code after modifying this file
|
// Important: Run "make" to regenerate code after modifying this file
|
||||||
@ -41,7 +40,7 @@ type ObjectStoreStatus struct {
|
|||||||
// +kubebuilder:object:root=true
|
// +kubebuilder:object:root=true
|
||||||
// +kubebuilder:subresource:status
|
// +kubebuilder:subresource:status
|
||||||
|
|
||||||
// ObjectStore is the Schema for the objectstores API
|
// ObjectStore is the Schema for the objectstores API.
|
||||||
type ObjectStore struct {
|
type ObjectStore struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
@ -52,7 +51,7 @@ type ObjectStore struct {
|
|||||||
|
|
||||||
// +kubebuilder:object:root=true
|
// +kubebuilder:object:root=true
|
||||||
|
|
||||||
// ObjectStoreList contains a list of ObjectStore
|
// ObjectStoreList contains a list of ObjectStore.
|
||||||
type ObjectStoreList struct {
|
type ObjectStoreList struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
|||||||
13
cmd/main.go
13
cmd/main.go
@ -21,12 +21,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator"
|
// +kubebuilder:scaffold:imports
|
||||||
|
|
||||||
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
|
|
||||||
// to ensure that exec-entrypoint and run can make use of them.
|
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
@ -38,8 +33,12 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/controller"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/controller"
|
||||||
// +kubebuilder:scaffold:imports
|
|
||||||
|
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
|
||||||
|
// to ensure that exec-entrypoint and run can make use of them.
|
||||||
|
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
12
commitlint.config.js
Normal file
12
commitlint.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const Configuration= {
|
||||||
|
extends: ['@commitlint/config-conventional'],
|
||||||
|
formatter: '@commitlint/format',
|
||||||
|
rules: {
|
||||||
|
'body-empty': [1, 'never'],
|
||||||
|
'body-case': [2, 'always', 'sentence-case'],
|
||||||
|
'references-empty': [1, 'never'],
|
||||||
|
'signed-off-by': [2, 'always', 'Signed-off-by:'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Configuration;
|
||||||
4
dagger/gotest/.gitattributes
vendored
Normal file
4
dagger/gotest/.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/dagger.gen.go linguist-generated
|
||||||
|
/internal/dagger/** linguist-generated
|
||||||
|
/internal/querybuilder/** linguist-generated
|
||||||
|
/internal/telemetry/** linguist-generated
|
||||||
4
dagger/gotest/.gitignore
vendored
Normal file
4
dagger/gotest/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/dagger.gen.go
|
||||||
|
/internal/dagger
|
||||||
|
/internal/querybuilder
|
||||||
|
/internal/telemetry
|
||||||
5
dagger/gotest/dagger.json
Normal file
5
dagger/gotest/dagger.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name": "gotest",
|
||||||
|
"sdk": "go",
|
||||||
|
"engineVersion": "v0.13.3"
|
||||||
|
}
|
||||||
47
dagger/gotest/go.mod
Normal file
47
dagger/gotest/go.mod
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
module dagger/gotest
|
||||||
|
|
||||||
|
go 1.23.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/99designs/gqlgen v0.17.49
|
||||||
|
github.com/Khan/genqlient v0.7.0
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.16
|
||||||
|
go.opentelemetry.io/otel v1.27.0
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
|
||||||
|
go.opentelemetry.io/otel/log v0.3.0
|
||||||
|
go.opentelemetry.io/otel/sdk v1.27.0
|
||||||
|
go.opentelemetry.io/otel/sdk/log v0.3.0
|
||||||
|
go.opentelemetry.io/otel/trace v1.27.0
|
||||||
|
go.opentelemetry.io/proto/otlp v1.3.1
|
||||||
|
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
|
||||||
|
golang.org/x/sync v0.8.0
|
||||||
|
google.golang.org/grpc v1.65.0
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
|
||||||
|
github.com/sosodev/duration v1.3.1 // indirect
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/metric v1.27.0 // indirect
|
||||||
|
golang.org/x/net v0.29.0 // indirect
|
||||||
|
golang.org/x/sys v0.25.0 // indirect
|
||||||
|
golang.org/x/text v0.18.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
|
google.golang.org/protobuf v1.34.2 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
|
||||||
|
|
||||||
|
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
|
||||||
|
|
||||||
|
replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0
|
||||||
|
|
||||||
|
replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0
|
||||||
77
dagger/gotest/go.sum
Normal file
77
dagger/gotest/go.sum
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ=
|
||||||
|
github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0=
|
||||||
|
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
|
||||||
|
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
|
||||||
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||||
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
|
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
|
||||||
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||||
|
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||||
|
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
|
||||||
|
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8=
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
|
||||||
|
go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg=
|
||||||
|
go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s=
|
||||||
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY=
|
||||||
|
go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs=
|
||||||
|
go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys=
|
||||||
|
go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik=
|
||||||
|
go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A=
|
||||||
|
go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U=
|
||||||
|
go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g=
|
||||||
|
go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw=
|
||||||
|
go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||||
|
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||||
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
|
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
|
||||||
|
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
|
||||||
|
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||||
|
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||||
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||||
|
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||||
|
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||||
|
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||||
|
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||||
|
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||||
|
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
97
dagger/gotest/main.go
Normal file
97
dagger/gotest/main.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// A generated module for Gotest functions
|
||||||
|
//
|
||||||
|
// This module has been generated via dagger init and serves as a reference to
|
||||||
|
// basic module structure as you get started with Dagger.
|
||||||
|
//
|
||||||
|
// Two functions have been pre-created. You can modify, delete, or add to them,
|
||||||
|
// as needed. They demonstrate usage of arguments and return types using simple
|
||||||
|
// echo and grep commands. The functions can be called from the dagger CLI or
|
||||||
|
// from one of the SDKs.
|
||||||
|
//
|
||||||
|
// The first line in this comment block is a short description line and the
|
||||||
|
// rest is a long description with more detail on the module's purpose or usage,
|
||||||
|
// if appropriate. All modules should have a short description.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"dagger/gotest/internal/dagger"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Gotest struct {
|
||||||
|
// +private
|
||||||
|
Ctr *dagger.Container
|
||||||
|
// +private
|
||||||
|
KubeVersion string
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(
|
||||||
|
// Go version
|
||||||
|
//
|
||||||
|
// +optional
|
||||||
|
// +default="latest"
|
||||||
|
goVersion string,
|
||||||
|
// setup-envtest version
|
||||||
|
// +optional
|
||||||
|
// +default="0.19.0"
|
||||||
|
setupEnvtestVersion string,
|
||||||
|
// Kubernetes version
|
||||||
|
// +optional
|
||||||
|
// +default="1.31.0"
|
||||||
|
kubeVersion string,
|
||||||
|
// Container to run the tests
|
||||||
|
// +optional
|
||||||
|
ctr *dagger.Container,
|
||||||
|
) *Gotest {
|
||||||
|
if ctr != nil {
|
||||||
|
return &Gotest{Ctr: ctr}
|
||||||
|
}
|
||||||
|
|
||||||
|
user := "noroot"
|
||||||
|
modCachePath := fmt.Sprintf("/home/%s/go/pkg/mod", user)
|
||||||
|
goCachePath := fmt.Sprintf("/home/%s/.cache/go-build", user)
|
||||||
|
ctr = dag.Container().From("golang:"+goVersion).
|
||||||
|
WithExec([]string{"curl", "-L",
|
||||||
|
fmt.Sprintf("https://dl.k8s.io/release/v%v/bin/linux/amd64/kubectl", kubeVersion),
|
||||||
|
"-o", "/usr/local/bin/kubectl"}).
|
||||||
|
WithExec([]string{"chmod", "+x", "/usr/local/bin/kubectl"}).
|
||||||
|
WithExec([]string{"curl", "-L",
|
||||||
|
fmt.Sprintf(
|
||||||
|
"https://github.com/kubernetes-sigs/controller-runtime/releases/download/v%v/setup-envtest-linux-amd64",
|
||||||
|
setupEnvtestVersion),
|
||||||
|
"-o", "/usr/local/bin/setup-envtest"}).
|
||||||
|
WithExec([]string{"chmod", "+x", "/usr/local/bin/setup-envtest"}).
|
||||||
|
WithExec([]string{"useradd", "-m", user}).
|
||||||
|
WithUser(user).
|
||||||
|
WithEnvVariable("CGO_ENABLED", "0").
|
||||||
|
WithEnvVariable("GOMODCACHE", modCachePath).
|
||||||
|
WithEnvVariable("GOCACHE", goCachePath).
|
||||||
|
WithMountedCache(modCachePath, dag.CacheVolume("go-mod"),
|
||||||
|
dagger.ContainerWithMountedCacheOpts{Owner: user}).
|
||||||
|
WithMountedCache(goCachePath, dag.CacheVolume("go-build"),
|
||||||
|
dagger.ContainerWithMountedCacheOpts{Owner: user})
|
||||||
|
|
||||||
|
return &Gotest{Ctr: ctr, KubeVersion: kubeVersion}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Gotest) UnitTest(
|
||||||
|
ctx context.Context,
|
||||||
|
// Source directory
|
||||||
|
// +required
|
||||||
|
src *dagger.Directory,
|
||||||
|
) (string, error) {
|
||||||
|
envtestCmd := []string{"setup-envtest", "use", "-p", "path", m.KubeVersion}
|
||||||
|
return m.Ctr.WithDirectory("/src", src).
|
||||||
|
// Setup envtest. There is no proper way to install it from a git release, so we use the go install command
|
||||||
|
WithExec(envtestCmd).
|
||||||
|
WithEnvVariable("KUBEBUILDER_ASSETS",
|
||||||
|
fmt.Sprintf("/home/noroot/.local/share/kubebuilder-envtest/k8s/%v-linux-amd64", m.KubeVersion),
|
||||||
|
).
|
||||||
|
WithWorkdir("/src").
|
||||||
|
// Exclude the e2e tests, we don't want to run them here
|
||||||
|
WithoutDirectory("/src/test/e2e").
|
||||||
|
WithExec([]string{"go", "test", "./..."}).Stdout(ctx)
|
||||||
|
}
|
||||||
@ -10,7 +10,9 @@ type BackupServiceImplementation struct {
|
|||||||
backup.UnimplementedBackupServer
|
backup.UnimplementedBackupServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BackupServiceImplementation) GetCapabilities(ctx context.Context, request *backup.BackupCapabilitiesRequest) (*backup.BackupCapabilitiesResult, error) {
|
func (b BackupServiceImplementation) GetCapabilities(
|
||||||
|
_ context.Context, _ *backup.BackupCapabilitiesRequest,
|
||||||
|
) (*backup.BackupCapabilitiesResult, error) {
|
||||||
return &backup.BackupCapabilitiesResult{
|
return &backup.BackupCapabilitiesResult{
|
||||||
Capabilities: []*backup.BackupCapability{
|
Capabilities: []*backup.BackupCapability{
|
||||||
{
|
{
|
||||||
@ -24,7 +26,7 @@ func (b BackupServiceImplementation) GetCapabilities(ctx context.Context, reques
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BackupServiceImplementation) Backup(ctx context.Context, request *backup.BackupRequest) (*backup.BackupResult, error) {
|
func (b BackupServiceImplementation) Backup(_ context.Context, _ *backup.BackupRequest) (*backup.BackupResult, error) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
package instance
|
package instance
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
"github.com/cloudnative-pg/cnpg-i/pkg/wal"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,5 +17,6 @@ func NewCMD() *cobra.Command {
|
|||||||
})
|
})
|
||||||
|
|
||||||
cmd.Use = "plugin-instance"
|
cmd.Use = "plugin-instance"
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
|||||||
|
|
||||||
const PluginName = "instance.barman-cloud.cloudnative-pg.io"
|
const PluginName = "instance.barman-cloud.cloudnative-pg.io"
|
||||||
|
|
||||||
// Data is the metadata of this plugin
|
// Data is the metadata of this plugin.
|
||||||
var Data = identity.GetPluginMetadataResponse{
|
var Data = identity.GetPluginMetadataResponse{
|
||||||
Name: PluginName,
|
Name: PluginName,
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
|
|||||||
@ -11,15 +11,15 @@ type IdentityImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
) (*identity.GetPluginMetadataResponse, error) {
|
) (*identity.GetPluginMetadataResponse, error) {
|
||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
) (*identity.GetPluginCapabilitiesResponse, error) {
|
) (*identity.GetPluginCapabilitiesResponse, error) {
|
||||||
return &identity.GetPluginCapabilitiesResponse{
|
return &identity.GetPluginCapabilitiesResponse{
|
||||||
Capabilities: []*identity.PluginCapability{
|
Capabilities: []*identity.PluginCapability{
|
||||||
@ -42,8 +42,8 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
) (*identity.ProbeResponse, error) {
|
) (*identity.ProbeResponse, error) {
|
||||||
return &identity.ProbeResponse{
|
return &identity.ProbeResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
|
|||||||
@ -10,7 +10,9 @@ type WALServiceImplementation struct {
|
|||||||
wal.UnimplementedWALServer
|
wal.UnimplementedWALServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) GetCapabilities(ctx context.Context, request *wal.WALCapabilitiesRequest) (*wal.WALCapabilitiesResult, error) {
|
func (w WALServiceImplementation) GetCapabilities(
|
||||||
|
_ context.Context, _ *wal.WALCapabilitiesRequest,
|
||||||
|
) (*wal.WALCapabilitiesResult, error) {
|
||||||
return &wal.WALCapabilitiesResult{
|
return &wal.WALCapabilitiesResult{
|
||||||
Capabilities: []*wal.WALCapability{
|
Capabilities: []*wal.WALCapability{
|
||||||
{
|
{
|
||||||
@ -31,22 +33,30 @@ func (W WALServiceImplementation) GetCapabilities(ctx context.Context, request *
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Archive(ctx context.Context, request *wal.WALArchiveRequest) (*wal.WALArchiveResult, error) {
|
func (w WALServiceImplementation) Archive(_ context.Context, _ *wal.WALArchiveRequest) (*wal.WALArchiveResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Restore(ctx context.Context, request *wal.WALRestoreRequest) (*wal.WALRestoreResult, error) {
|
func (w WALServiceImplementation) Restore(_ context.Context, _ *wal.WALRestoreRequest) (*wal.WALRestoreResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) Status(ctx context.Context, request *wal.WALStatusRequest) (*wal.WALStatusResult, error) {
|
func (w WALServiceImplementation) Status(_ context.Context, _ *wal.WALStatusRequest) (*wal.WALStatusResult,
|
||||||
|
error,
|
||||||
|
) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W WALServiceImplementation) SetFirstRequired(ctx context.Context, request *wal.SetFirstRequiredRequest) (*wal.SetFirstRequiredResult, error) {
|
func (w WALServiceImplementation) SetFirstRequired(
|
||||||
|
_ context.Context, _ *wal.SetFirstRequiredRequest,
|
||||||
|
) (*wal.SetFirstRequiredResult, error) {
|
||||||
// TODO implement me
|
// TODO implement me
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import "github.com/cloudnative-pg/cnpg-i/pkg/identity"
|
|||||||
|
|
||||||
const PluginName = "operator.barman-cloud.cloudnative-pg.io"
|
const PluginName = "operator.barman-cloud.cloudnative-pg.io"
|
||||||
|
|
||||||
// Data is the metadata of this plugin
|
// Data is the metadata of this plugin.
|
||||||
var Data = identity.GetPluginMetadataResponse{
|
var Data = identity.GetPluginMetadataResponse{
|
||||||
Name: PluginName,
|
Name: PluginName,
|
||||||
Version: "0.0.1",
|
Version: "0.0.1",
|
||||||
|
|||||||
@ -11,15 +11,15 @@ type IdentityImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginMetadata(
|
func (i IdentityImplementation) GetPluginMetadata(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginMetadataRequest,
|
_ *identity.GetPluginMetadataRequest,
|
||||||
) (*identity.GetPluginMetadataResponse, error) {
|
) (*identity.GetPluginMetadataResponse, error) {
|
||||||
return &Data, nil
|
return &Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) GetPluginCapabilities(
|
func (i IdentityImplementation) GetPluginCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.GetPluginCapabilitiesRequest,
|
_ *identity.GetPluginCapabilitiesRequest,
|
||||||
) (*identity.GetPluginCapabilitiesResponse, error) {
|
) (*identity.GetPluginCapabilitiesResponse, error) {
|
||||||
return &identity.GetPluginCapabilitiesResponse{
|
return &identity.GetPluginCapabilitiesResponse{
|
||||||
Capabilities: []*identity.PluginCapability{
|
Capabilities: []*identity.PluginCapability{
|
||||||
@ -42,8 +42,8 @@ func (i IdentityImplementation) GetPluginCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i IdentityImplementation) Probe(
|
func (i IdentityImplementation) Probe(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *identity.ProbeRequest,
|
_ *identity.ProbeRequest,
|
||||||
) (*identity.ProbeResponse, error) {
|
) (*identity.ProbeResponse, error) {
|
||||||
return &identity.ProbeResponse{
|
return &identity.ProbeResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
|
|||||||
@ -11,8 +11,8 @@ type ReconcilerImplementation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) GetCapabilities(
|
func (r ReconcilerImplementation) GetCapabilities(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksCapabilitiesRequest,
|
_ *reconciler.ReconcilerHooksCapabilitiesRequest,
|
||||||
) (*reconciler.ReconcilerHooksCapabilitiesResult, error) {
|
) (*reconciler.ReconcilerHooksCapabilitiesResult, error) {
|
||||||
return &reconciler.ReconcilerHooksCapabilitiesResult{
|
return &reconciler.ReconcilerHooksCapabilitiesResult{
|
||||||
ReconcilerCapabilities: []*reconciler.ReconcilerHooksCapability{
|
ReconcilerCapabilities: []*reconciler.ReconcilerHooksCapability{
|
||||||
@ -27,8 +27,8 @@ func (r ReconcilerImplementation) GetCapabilities(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) Pre(
|
func (r ReconcilerImplementation) Pre(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
) (*reconciler.ReconcilerHooksResult, error) {
|
) (*reconciler.ReconcilerHooksResult, error) {
|
||||||
return &reconciler.ReconcilerHooksResult{
|
return &reconciler.ReconcilerHooksResult{
|
||||||
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
||||||
@ -36,8 +36,8 @@ func (r ReconcilerImplementation) Pre(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r ReconcilerImplementation) Post(
|
func (r ReconcilerImplementation) Post(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
request *reconciler.ReconcilerHooksRequest,
|
_ *reconciler.ReconcilerHooksRequest,
|
||||||
) (*reconciler.ReconcilerHooksResult, error) {
|
) (*reconciler.ReconcilerHooksResult, error) {
|
||||||
return &reconciler.ReconcilerHooksResult{
|
return &reconciler.ReconcilerHooksResult{
|
||||||
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
Behavior: reconciler.ReconcilerHooksResult_BEHAVIOR_CONTINUE,
|
||||||
|
|||||||
@ -20,5 +20,5 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
})
|
})
|
||||||
cmd.Use = "plugin-operator"
|
cmd.Use = "plugin-operator"
|
||||||
|
|
||||||
return cmd.ExecuteContext(ctx)
|
return cmd.ExecuteContext(ctx) //nolint:wrapcheck
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
@ -27,7 +28,7 @@ import (
|
|||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ObjectStoreReconciler reconciles a ObjectStore object
|
// ObjectStoreReconciler reconciles a ObjectStore object.
|
||||||
type ObjectStoreReconciler struct {
|
type ObjectStoreReconciler struct {
|
||||||
client.Client
|
client.Client
|
||||||
Scheme *runtime.Scheme
|
Scheme *runtime.Scheme
|
||||||
@ -46,7 +47,7 @@ type ObjectStoreReconciler struct {
|
|||||||
//
|
//
|
||||||
// For more details, check Reconcile and its Result here:
|
// For more details, check Reconcile and its Result here:
|
||||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile
|
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile
|
||||||
func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, _ ctrl.Request) (ctrl.Result, error) {
|
||||||
_ = log.FromContext(ctx)
|
_ = log.FromContext(ctx)
|
||||||
|
|
||||||
// TODO(user): your logic here
|
// TODO(user): your logic here
|
||||||
@ -56,7 +57,12 @@ func (r *ObjectStoreReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
|||||||
|
|
||||||
// SetupWithManager sets up the controller with the Manager.
|
// SetupWithManager sets up the controller with the Manager.
|
||||||
func (r *ObjectStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
func (r *ObjectStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||||
return ctrl.NewControllerManagedBy(mgr).
|
err := ctrl.NewControllerManagedBy(mgr).
|
||||||
For(&barmancloudv1.ObjectStore{}).
|
For(&barmancloudv1.ObjectStore{}).
|
||||||
Complete(r)
|
Complete(r)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to create controller: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,15 +19,16 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("ObjectStore Controller", func() {
|
var _ = Describe("ObjectStore Controller", func() {
|
||||||
@ -51,6 +52,9 @@ var _ = Describe("ObjectStore Controller", func() {
|
|||||||
Name: resourceName,
|
Name: resourceName,
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
},
|
},
|
||||||
|
Spec: barmancloudv1.ObjectStoreSpec{
|
||||||
|
Configuration: barmanapi.BarmanObjectStoreConfiguration{DestinationPath: "/tmp"},
|
||||||
|
},
|
||||||
// TODO(user): Specify other spec details if needed.
|
// TODO(user): Specify other spec details if needed.
|
||||||
}
|
}
|
||||||
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
// +kubebuilder:scaffold:imports
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
|
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
@ -34,17 +32,21 @@ import (
|
|||||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
// +kubebuilder:scaffold:imports
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
|
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
|
||||||
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
|
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
|
||||||
|
|
||||||
var cfg *rest.Config
|
var (
|
||||||
var k8sClient client.Client
|
cfg *rest.Config
|
||||||
var testEnv *envtest.Environment
|
k8sClient client.Client
|
||||||
var ctx context.Context
|
testEnv *envtest.Environment
|
||||||
var cancel context.CancelFunc
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
)
|
||||||
|
|
||||||
func TestControllers(t *testing.T) {
|
func TestControllers(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
@ -55,7 +57,7 @@ func TestControllers(t *testing.T) {
|
|||||||
var _ = BeforeSuite(func() {
|
var _ = BeforeSuite(func() {
|
||||||
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
|
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
|
||||||
|
|
||||||
ctx, cancel = context.WithCancel(context.TODO())
|
ctx, cancel = context.WithCancel(context.TODO()) //nolint: fatcontext
|
||||||
|
|
||||||
By("bootstrapping test environment")
|
By("bootstrapping test environment")
|
||||||
testEnv = &envtest.Environment{
|
testEnv = &envtest.Environment{
|
||||||
@ -85,7 +87,6 @@ var _ = BeforeSuite(func() {
|
|||||||
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
|
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(k8sClient).NotTo(BeNil())
|
Expect(k8sClient).NotTo(BeNil())
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = AfterSuite(func() {
|
var _ = AfterSuite(func() {
|
||||||
|
|||||||
12
release-please-config.json
Normal file
12
release-please-config.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"changelog-path": "CHANGELOG.md",
|
||||||
|
"release-type": "go",
|
||||||
|
"bump-minor-pre-major": false,
|
||||||
|
"bump-patch-for-minor-pre-major": false,
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false,
|
||||||
|
"packages": {
|
||||||
|
".": {}
|
||||||
|
},
|
||||||
|
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
||||||
|
}
|
||||||
@ -21,10 +21,10 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/test/utils"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/test/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const namespace = "plugin-barman-cloud-system"
|
const namespace = "plugin-barman-cloud-system"
|
||||||
@ -60,14 +60,15 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
// projectimage stores the name of the image used in the example
|
// projectimage stores the name of the image used in the example
|
||||||
var projectimage = "example.com/plugin-barman-cloud:v0.0.1"
|
projectimage := "example.com/plugin-barman-cloud:v0.0.1"
|
||||||
|
|
||||||
By("building the manager(Operator) image")
|
By("building the manager(Operator) image")
|
||||||
|
//nolint:gosec,perfsprint
|
||||||
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectimage))
|
cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectimage))
|
||||||
_, err = utils.Run(cmd)
|
_, err = utils.Run(cmd)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("loading the the manager(Operator) image on Kind")
|
By("loading the manager(Operator) image on Kind")
|
||||||
err = utils.LoadImageToKindClusterWithName(projectimage)
|
err = utils.LoadImageToKindClusterWithName(projectimage)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("deploying the controller-manager")
|
By("deploying the controller-manager")
|
||||||
|
//nolint:gosec,perfsprint
|
||||||
cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectimage))
|
cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectimage))
|
||||||
_, err = utils.Run(cmd)
|
_, err = utils.Run(cmd)
|
||||||
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
ExpectWithOffset(1, err).NotTo(HaveOccurred())
|
||||||
@ -113,10 +115,10 @@ var _ = Describe("controller", Ordered, func() {
|
|||||||
if string(status) != "Running" {
|
if string(status) != "Running" {
|
||||||
return fmt.Errorf("controller pod in %s status", status)
|
return fmt.Errorf("controller pod in %s status", status)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
|
EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed())
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2" //nolint:golint,revive
|
. "github.com/onsi/ginkgo/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -43,10 +43,11 @@ func InstallPrometheusOperator() error {
|
|||||||
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
||||||
cmd := exec.Command("kubectl", "create", "-f", url)
|
cmd := exec.Command("kubectl", "create", "-f", url)
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes the provided command within this context
|
// Run executes the provided command within this context.
|
||||||
func Run(cmd *exec.Cmd) ([]byte, error) {
|
func Run(cmd *exec.Cmd) ([]byte, error) {
|
||||||
dir, _ := GetProjectDir()
|
dir, _ := GetProjectDir()
|
||||||
cmd.Dir = dir
|
cmd.Dir = dir
|
||||||
@ -60,13 +61,13 @@ func Run(cmd *exec.Cmd) ([]byte, error) {
|
|||||||
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
|
_, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))
|
return output, fmt.Errorf("%s failed with error: (%w) %s", command, err, string(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninstallPrometheusOperator uninstalls the prometheus
|
// UninstallPrometheusOperator uninstalls the prometheus.
|
||||||
func UninstallPrometheusOperator() {
|
func UninstallPrometheusOperator() {
|
||||||
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion)
|
||||||
cmd := exec.Command("kubectl", "delete", "-f", url)
|
cmd := exec.Command("kubectl", "delete", "-f", url)
|
||||||
@ -75,7 +76,7 @@ func UninstallPrometheusOperator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// UninstallCertManager uninstalls the cert manager
|
// UninstallCertManager uninstalls the cert manager.
|
||||||
func UninstallCertManager() {
|
func UninstallCertManager() {
|
||||||
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
|
url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion)
|
||||||
cmd := exec.Command("kubectl", "delete", "-f", url)
|
cmd := exec.Command("kubectl", "delete", "-f", url)
|
||||||
@ -100,10 +101,11 @@ func InstallCertManager() error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster
|
// LoadImageToKindClusterWithName loads a local docker image to the kind cluster.
|
||||||
func LoadImageToKindClusterWithName(name string) error {
|
func LoadImageToKindClusterWithName(name string) error {
|
||||||
cluster := "kind"
|
cluster := "kind"
|
||||||
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
|
if v, ok := os.LookupEnv("KIND_CLUSTER"); ok {
|
||||||
@ -112,6 +114,7 @@ func LoadImageToKindClusterWithName(name string) error {
|
|||||||
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
|
kindOptions := []string{"load", "docker-image", name, "--name", cluster}
|
||||||
cmd := exec.Command("kind", kindOptions...)
|
cmd := exec.Command("kind", kindOptions...)
|
||||||
_, err := Run(cmd)
|
_, err := Run(cmd)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,12 +132,13 @@ func GetNonEmptyLines(output string) []string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetProjectDir will return the directory where the project is
|
// GetProjectDir will return the directory where the project is.
|
||||||
func GetProjectDir() (string, error) {
|
func GetProjectDir() (string, error) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return wd, err
|
return wd, fmt.Errorf("failed to get the current working directory: %w", err)
|
||||||
}
|
}
|
||||||
wd = strings.Replace(wd, "/test/e2e", "", -1)
|
wd = strings.ReplaceAll(wd, "/test/e2e", "")
|
||||||
|
|
||||||
return wd, nil
|
return wd, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user