Skip to content

Commit

Permalink
Merge pull request #81 from csi-addons/main
Browse files Browse the repository at this point in the history
sync downstream main with upstream main
  • Loading branch information
openshift-merge-robot authored Jul 6, 2023
2 parents 1585d76 + bed9c6e commit a08b342
Show file tree
Hide file tree
Showing 8,626 changed files with 1,308,940 additions and 55,001 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ updates:
prefix: "vendor"
labels:
- vendor
- package-ecosystem: "gomod"
directory: "/tools"
schedule:
interval: "weekly"
rebase-strategy: "disabled"
commit-message:
prefix: "vendor"
labels:
- vendor
- package-ecosystem: "github-actions"
# ODF only: disable PR creation, synced from upstream
open-pull-requests-limit: 0
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.20 as builder

# Copy the contents of the repository
ADD . /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons

ENV GOPATH=/workspace/go
ENV GOPATH=/workspace/go CGO_ENABLED=0
WORKDIR /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -a -o /workspace/manager cmd/manager/main.go
RUN make build

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/go/src/github.com/csi-addons/kubernetes-csi-addons/bin/csi-addons-manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/csi-addons-manager"]
33 changes: 23 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ ifneq ($(TAG),latest)
BUNDLE_VERSION ?= --version=$(shell sed s/^v// <<< $(TAG))
endif

# To get the GIT commit id
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)

# Fetch the git tag
GIT_TAG ?= $(shell git describe --tags HEAD 2>/dev/null || echo $(GIT_COMMIT))

GO_PROJECT=github.com/csi-addons/kubernetes-csi-addons

LDFLAGS ?=
LDFLAGS += -X $(GO_PROJECT)/internal/version.GitCommit=$(GIT_COMMIT)
LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(GIT_TAG)

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23

Expand Down Expand Up @@ -158,9 +170,9 @@ bundle-validate: container-cmd operator-sdk

.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
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons-manager cmd/manager/main.go
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons-sidecar sidecar/main.go
go build -ldflags '$(LDFLAGS)' -a -o bin/csi-addons ./cmd/csi-addons

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
Expand Down Expand Up @@ -192,7 +204,7 @@ docker-push-bundle: container-cmd

.PHONY: docker-build-tools
docker-generate-protobuf: container-cmd ./build/Containerfile.tools
$(CONTAINER_CMD) build -f $^ -t ${TOOLS_IMG} .
$(CONTAINER_CMD) build -f ./build/Containerfile.tools -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 Expand Up @@ -221,38 +233,39 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen:
go build -o $(CONTROLLER_GEN) ./vendor/$(shell grep controller-gen tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(CONTROLLER_GEN) ./vendor/$(shell grep controller-gen tools/tools.go | sed 's/.*_ "//;s/"//')

# kustomize gets installed from the vendor/ directory. The tools.go file is
# used to select the major version of kustomize.
KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize:
go build -o $(KUSTOMIZE) ./vendor/$(shell grep kustomize tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(KUSTOMIZE) ./vendor/$(shell grep kustomize tools/tools.go | sed 's/.*_ "//;s/"//')

# setup-envtest gets installed from the vendor/ directory.
ENVTEST = $(shell pwd)/bin/setup-envtest
.PHONY: envtest
envtest:
go build -o $(ENVTEST) ./vendor/$(shell grep setup-envtest tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(ENVTEST) ./vendor/$(shell grep setup-envtest tools/tools.go | sed 's/.*_ "//;s/"//')

# operator-sdk gets installed from the vendor/ directory.
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
.PHONY: operator-sdk
operator-sdk:
go build -o $(OPERATOR_SDK) ./vendor/$(shell grep operator-sdk tools.go | sed 's/.*_ "//;s/"//')
# FIXME: Remove `go mod tidy && go mod vendor` once we find the reason why ci workflow fails.
cd ./tools && go mod tidy && go mod vendor && go build -o $(OPERATOR_SDK) ./vendor/$(shell grep operator-sdk tools/tools.go | sed 's/.*_ "//;s/"//')

# protoc-gen-go gets installed from the vendor/ directory.
PROTOC_GEN_GO = $(shell pwd)/bin/protoc-gen-go
.PHONY: protoc-gen-go
protoc-gen-go:
go build -o $(PROTOC_GEN_GO) ./vendor/$(shell grep '/protoc-gen-go"' tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(PROTOC_GEN_GO) ./vendor/$(shell grep '/protoc-gen-go"' tools/tools.go | sed 's/.*_ "//;s/"//')

# protoc-gen-go-grpc gets installed from the vendor/ directory.
PROTOC_GEN_GO_GRPC = $(shell pwd)/bin/protoc-gen-go-grpc
.PHONY: protoc-gen-go-grpc
protoc-gen-go-grpc:
go build -o $(PROTOC_GEN_GO_GRPC) ./vendor/$(shell grep protoc-gen-go-grpc tools.go | sed 's/.*_ "//;s/"//')
cd ./tools && go build -o $(PROTOC_GEN_GO_GRPC) ./vendor/$(shell grep protoc-gen-go-grpc tools/tools.go | sed 's/.*_ "//;s/"//')

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/csiaddonsnode_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -42,17 +43,17 @@ func (c *CSIAddonsNode) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &CSIAddonsNode{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (c *CSIAddonsNode) ValidateCreate() error {
return nil
func (c *CSIAddonsNode) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (c *CSIAddonsNode) ValidateUpdate(old runtime.Object) error {
func (c *CSIAddonsNode) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
csnLog.Info("validate update", "name", c.Name)

oldCSIAddonsNode, ok := old.(*CSIAddonsNode)
if !ok {
return errors.New("error casting CSIAddonsNode object")
return nil, errors.New("error casting CSIAddonsNode object")
}

var allErrs field.ErrorList
Expand All @@ -66,15 +67,15 @@ func (c *CSIAddonsNode) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "CSIAddonsNode"},
c.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CSIAddonsNode) ValidateDelete() error {
return nil
func (r *CSIAddonsNode) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/networkfence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -43,17 +44,17 @@ func (n *NetworkFence) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &NetworkFence{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (n *NetworkFence) ValidateCreate() error {
return nil
func (n *NetworkFence) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (n *NetworkFence) ValidateUpdate(old runtime.Object) error {
func (n *NetworkFence) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
nfLog.Info("validate update", "name", n.Name)

oldNetworkFence, ok := old.(*NetworkFence)
if !ok {
return errors.New("error casting NetworkFence object")
return nil, errors.New("error casting NetworkFence object")
}

var allErrs field.ErrorList
Expand All @@ -74,15 +75,15 @@ func (n *NetworkFence) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "NetworkFence"},
n.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (n *NetworkFence) ValidateDelete() error {
return nil
func (n *NetworkFence) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/reclaimspacecronjob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -42,17 +43,17 @@ func (r *ReclaimSpaceCronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &ReclaimSpaceCronJob{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceCronJob) ValidateCreate() error {
return nil
func (r *ReclaimSpaceCronJob) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceCronJob) ValidateUpdate(old runtime.Object) error {
func (r *ReclaimSpaceCronJob) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
rscjLog.Info("validate update", "name", r.Name)

oldReclaimSpaceCronJob, ok := old.(*ReclaimSpaceCronJob)
if !ok {
return errors.New("error casting ReclaimSpaceCronJob object")
return nil, errors.New("error casting ReclaimSpaceCronJob object")
}

var allErrs field.ErrorList
Expand All @@ -62,14 +63,14 @@ func (r *ReclaimSpaceCronJob) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "ReclaimSpaceCronJob"},
r.Name, allErrs)
}
return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceCronJob) ValidateDelete() error {
return nil
func (r *ReclaimSpaceCronJob) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
17 changes: 9 additions & 8 deletions apis/csiaddons/v1alpha1/reclaimspacejob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -42,17 +43,17 @@ func (r *ReclaimSpaceJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &ReclaimSpaceJob{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceJob) ValidateCreate() error {
return nil
func (r *ReclaimSpaceJob) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceJob) ValidateUpdate(old runtime.Object) error {
func (r *ReclaimSpaceJob) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
rsjLog.Info("validate update", "name", r.Name)

oldReclaimSpaceJob, ok := old.(*ReclaimSpaceJob)
if !ok {
return errors.New("error casting ReclaimSpaceJob object")
return nil, errors.New("error casting ReclaimSpaceJob object")
}

var allErrs field.ErrorList
Expand All @@ -62,15 +63,15 @@ func (r *ReclaimSpaceJob) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "csiaddons.openshift.io", Kind: "ReclaimSpaceJob"},
r.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *ReclaimSpaceJob) ValidateDelete() error {
return nil
func (r *ReclaimSpaceJob) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
10 changes: 6 additions & 4 deletions apis/replication.storage/v1alpha1/volumereplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ type VolumeReplicationStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
// observedGeneration is the last generation change the operator has dealt with
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
LastSyncBytes *int64 `json:"lastSyncBytes,omitempty"`
LastSyncDuration *metav1.Duration `json:"lastSyncDuration,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
17 changes: 9 additions & 8 deletions apis/replication.storage/v1alpha1/volumereplication_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
Expand All @@ -43,17 +44,17 @@ func (v *VolumeReplication) SetupWebhookWithManager(mgr ctrl.Manager) error {
var _ webhook.Validator = &VolumeReplication{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (v *VolumeReplication) ValidateCreate() error {
return nil
func (v *VolumeReplication) ValidateCreate() (admission.Warnings, error) {
return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (v *VolumeReplication) ValidateUpdate(old runtime.Object) error {
func (v *VolumeReplication) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
vrLog.Info("validate update", "name", v.Name)

oldReplication, ok := old.(*VolumeReplication)
if !ok {
return errors.New("error casting old VolumeReplication object")
return nil, errors.New("error casting old VolumeReplication object")
}

var allErrs field.ErrorList
Expand All @@ -69,15 +70,15 @@ func (v *VolumeReplication) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) != 0 {
return apierrors.NewInvalid(
return nil, apierrors.NewInvalid(
schema.GroupKind{Group: "replication.storage.openshift.io", Kind: "VolumeReplication"},
v.Name, allErrs)
}

return nil
return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (v *VolumeReplication) ValidateDelete() error {
return nil
func (v *VolumeReplication) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
Loading

0 comments on commit a08b342

Please sign in to comment.