Skip to content

Commit

Permalink
Merge pull request #80 from csi-addons/main
Browse files Browse the repository at this point in the history
Sync the upstream changes from csi-addons/kubernetes-csi-addons:main into the main branch
  • Loading branch information
openshift-merge-robot authored Jun 21, 2023
2 parents 36ebccb + 4932221 commit 1585d76
Show file tree
Hide file tree
Showing 384 changed files with 13,519 additions and 6,461 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Publish container images in quay.io

# yamllint disable-line rule:truthy
on:
push:
branches:
Expand All @@ -15,10 +16,10 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Go 1.19
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Generate the bundle contents
run: make bundle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
skip: .git,go.mod,go.sum,vendor
# kubebuilder latest release has a label with name kuberentes
# TODO: remove this in next kubebuilder update as this is fixed
# in kubebuilder master
# in kubebuilder master
# https://github.com/kubernetes-sigs/kubebuilder/pull/2964
ignore_words_list: kuberentes
check_filenames: true
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: golangci-lint
# yamllint disable-line rule:truthy
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --verbose --timeout=15m
24 changes: 19 additions & 5 deletions .github/workflows/kind-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Test deploying controller

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand All @@ -14,15 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.5.0
uses: helm/kind-action@v1.7.0

- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Build container container image
uses: docker/build-push-action@v4
Expand All @@ -33,14 +34,27 @@ jobs:
tags: quay.io/csiaddons/k8s-controller:${{ env.TAG }}

- name: push image to kind cluster
run: kind load docker-image quay.io/csiaddons/k8s-controller:${{ env.TAG }} --name=chart-testing
run: >
kind
load docker-image quay.io/csiaddons/k8s-controller:${{ env.TAG }}
--name=chart-testing
- name: Deploy the controller and CRDs
run: make deploy TAG=${{ env.TAG }}

- name: Wait for running controller pod
run: kubectl -n csi-addons-system wait pods -l app.kubernetes.io/name=csi-addons --for=condition=Ready=True
run: >
kubectl
-n csi-addons-system
wait pods
-l app.kubernetes.io/name=csi-addons
--for=condition=Ready=True
- name: Log the status of the failed controller pod
if: ${{ failure() }}
run: kubectl -n csi-addons-system describe pods -l app.kubernetes.io/name=csi-addons ; false
run: >
kubectl
-n csi-addons-system
describe pods
-l app.kubernetes.io/name=csi-addons
; false
29 changes: 21 additions & 8 deletions .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
---
name: Build and release versioned container images

# yamllint disable-line rule:truthy
on:
create

jobs:
tag_bundle:
name: Build and release the bundle container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Go 1.19
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Generate the bundle contents
run: make bundle TAG=${{ github.ref_name }}
Expand All @@ -41,7 +45,10 @@ jobs:

tag_controller:
name: Build and release the controller container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down Expand Up @@ -71,7 +78,10 @@ jobs:

tag_sidecar:
name: Build and release the sidecar container-image
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down Expand Up @@ -101,18 +111,21 @@ jobs:

publish_release:
name: Publish a release based on the tag
if: github.repository == 'csi-addons/kubernetes-csi-addons' && github.ref_type == 'tag'
if: >
github.repository == 'csi-addons/kubernetes-csi-addons'
&&
github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Go 1.19
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Generate manifests for installation by kubectl
run: make manifests TAG=${{ github.ref_name }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Test building container images

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand All @@ -14,10 +15,10 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Go 1.19
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Generate the bundle contents
run: make bundle
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test-golang.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Run Golang tests

# yamllint disable-line rule:truthy
on:
pull_request:
branches:
Expand All @@ -17,7 +18,7 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Install Protoc
uses: arduino/setup-protoc@v1
Expand All @@ -44,7 +45,7 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Verify Go modules
run: go mod verify
Expand All @@ -59,7 +60,7 @@ jobs:
- name: Set up Golang
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: "1.20"

- name: Vendor all dependencies
run: go mod vendor
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: Yaml Lint
# yamllint disable-line rule:truthy
on:
push:
pull_request:

jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yaml
23 changes: 23 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
extends: default

ignore:
- .git/
# bundle/ contains generated contents
- bundle/
# vendor/ are maintained elsewhere
- vendor/

rules:
document-start:
ignore:
- config/manager/
- deploy/
indentation:
ignore:
- config/
- deploy/
line-length:
ignore:
- config/
- deploy/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ someone in the @csi-addons/kubernetes-csi-addons-reviewers team is required.
After a Pull-Request has been reviewed and approved, it will get merged
automatically by the Mergify bot (@mergifyio).

[github_pr]: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
[github_pr]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
51 changes: 36 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
CONTROLLER_IMG ?= quay.io/csiaddons/k8s-controller
SIDECAR_IMG ?= quay.io/csiaddons/k8s-sidecar
BUNDLE_IMG ?= quay.io/csiaddons/k8s-bundle
TOOLS_IMG ?= quay.io/csiaddons/tools

# set TAG to a release for consumption in the bundle
TAG ?= latest
Expand All @@ -23,6 +24,10 @@ ifneq (findstring $(BUNDLE_IMG),:)
BUNDLE_IMG := $(BUNDLE_IMG):$(TAG)
endif

ifneq (findstring $(TOOLS_IMG),:)
TOOLS_IMG := $(TOOLS_IMG):$(TAG)
endif

# the PACKAGE_NAME is included in the bundle/CSV and is used in catalogsources
# for operators (like OperatorHub.io). Products that include the CSI-Addons
# bundle should use a different PACKAGE_NAME to prevent conflicts.
Expand Down Expand Up @@ -67,6 +72,17 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

# detect container tools, prefer Podman over Docker
CONTAINER_CMD ?= $(shell podman version >/dev/null 2>&1 && echo podman)
ifeq ($(CONTAINER_CMD),)
CONTAINER_CMD = $(shell docker version >/dev/null 2>&1 && echo docker)
endif

# validation that CONTAINER_CMD is set, return an error if podman/docker is missing
.PHONY: container-cmd
container-cmd:
@[ -n "$(CONTAINER_CMD)" ] || { echo "podman or docker needs to be installed" ; exit 1; }

.PHONY: all
all: build

Expand Down Expand Up @@ -135,44 +151,49 @@ check-all-committed: ## Fail in case there are uncommitted changes
test -z "$(shell git status --short)" || (echo "files were modified: " ; git status --short ; false)

.PHONY: bundle-validate
bundle-validate: IMAGE_BUILDER ?= $(shell which podman docker | head -n1 | xargs basename)
bundle-validate: operator-sdk
$(OPERATOR_SDK) bundle validate --image-builder=$(IMAGE_BUILDER) ./bundle
bundle-validate: container-cmd operator-sdk
$(OPERATOR_SDK) bundle validate --image-builder=$(CONTAINER_CMD) ./bundle

##@ Build

.PHONY: build
build: generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/manager/main.go
go build -o bin/sidecar sidecar/main.go
go build -o bin/csi-addons ./cmd/csi-addons

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/manager/main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${CONTROLLER_IMG} .
docker-build: container-cmd test ## Build docker image with the manager.
$(CONTAINER_CMD) build -t ${CONTROLLER_IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${CONTROLLER_IMG}
docker-push: container-cmd ## Push docker image with the manager.
$(CONTAINER_CMD) push ${CONTROLLER_IMG}

.PHONY: docker-build-sidecar
docker-build-sidecar:
docker build -f ./build/Containerfile.sidecar -t ${SIDECAR_IMG} .
docker-build-sidecar: container-cmd
$(CONTAINER_CMD) build -f ./build/Containerfile.sidecar -t ${SIDECAR_IMG} .

.PHONY: docker-push-sidecar
docker-push-sidecar:
docker push ${SIDECAR_IMG}
docker-push-sidecar: container-cmd
$(CONTAINER_CMD) push ${SIDECAR_IMG}

.PHONY: docker-build-bundle
docker-build-bundle: bundle
docker build -f ./bundle.Dockerfile -t ${BUNDLE_IMG} .
docker-build-bundle: container-cmd bundle
$(CONTAINER_CMD) build -f ./bundle.Dockerfile -t ${BUNDLE_IMG} .

.PHONY: docker-push-bundle
docker-push-bundle:
docker push ${BUNDLE_IMG}
docker-push-bundle: container-cmd
$(CONTAINER_CMD) push ${BUNDLE_IMG}

.PHONY: docker-build-tools
docker-generate-protobuf: container-cmd ./build/Containerfile.tools
$(CONTAINER_CMD) build -f $^ -t ${TOOLS_IMG} .
$(CONTAINER_CMD) run --rm -ti --volume=${PWD}:/go/src/github.com/csi-addons/kubernetes-csi-addons:Z ${TOOLS_IMG} make generate-protobuf

##@ Deployment

Expand Down
Loading

0 comments on commit 1585d76

Please sign in to comment.