Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update product image tag and bump operator-go to 0.9.0 #68

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 13 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,25 @@ jobs:


golang-lint:
name: Golang Lint
runs-on: ubuntu-22.04
name: golang-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.54

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
args: --timeout=30m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.23'
cache: false
- name: golangci-lint
run: |
make lint


golang-test:
name: Golang Test
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: ['1.22']
go-version: ['1.23']
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -94,12 +64,12 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
k8s-version: ['1.26.14', '1.27.11']
k8s-version: ['1.26.15', '1.27.16']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22'
go-version: '1.23'
cache: false
- name: Create KinD clustet pur
env:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.22 as builder
FROM golang:1.23 as builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
49 changes: 42 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,30 @@ fmt: ## Run go fmt against code.
vet: ## Run go vet against code.
go vet ./...

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.60.3
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) $(GOLANGCI_LINT_VERSION) ;\
}

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
$(GOLANGCI_LINT) run --timeout 5m

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --fix

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out

##@ Build

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
build: manifests generate fmt vet lint ## Build manager binary.
go build -o bin/manager cmd/main.go

.PHONY: run
Expand Down Expand Up @@ -200,7 +216,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.4.2
CONTROLLER_TOOLS_VERSION ?= v0.15.0
CONTROLLER_TOOLS_VERSION ?= v0.16.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
Expand Down Expand Up @@ -367,14 +383,33 @@ kind-delete: kind ## Delete a kind cluster.

# chainsaw

CHAINSAW_VERSION ?= v0.2.6
CHAINSAW = $(LOCALBIN)/chainsaw
CHAINSAW_VERSION ?= v0.2.8
CHAINSAW ?= $(LOCALBIN)/chainsaw

# Use `grep 0.2.6 > /dev/null` instead of `grep -q 0.2.6`. It will not be able to determine the version number,
# although the execution in the shell is normal, but in the makefile does fail to understand the mechanism in the makefile
# The operation ends by using `touch` to change the time of the file so that its timestamp is further back than the directory,
# so that no subsequent logic is performed after the `chainsaw` check is successful in relying on the `$(CHAINSAW)` target.
.PHONY: chainsaw
chainsaw: $(CHAINSAW) ## Download chainsaw locally if necessary.
$(CHAINSAW): $(LOCALBIN)
test -s $(LOCALBIN)/chainsaw && $(LOCALBIN)/chainsaw version | grep -q $(CHAINSAW_VERSION) || \
GOBIN=$(LOCALBIN) go install github.com/kyverno/chainsaw@$(CHAINSAW_VERSION)
@{ \
set -xe ;\
if test -x $(LOCALBIN)/chainsaw && ! $(LOCALBIN)/chainsaw version | grep $(CHAINSAW_VERSION:v%=%) > /dev/null; then \
echo "$(LOCALBIN)/chainsaw version is not expected $(CHAINSAW_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/chainsaw; \
fi; \
if test ! -s $(LOCALBIN)/chainsaw; then \
mkdir -p $(dir $(CHAINSAW)) ;\
TMP=$(shell mktemp -d) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSL https://github.com/kyverno/chainsaw/releases/download/$(CHAINSAW_VERSION)/chainsaw_$${OS}_$${ARCH}.tar.gz | tar -xz -C $$TMP ;\
mv $$TMP/chainsaw $(CHAINSAW) ;\
rm -rf $$TMP ;\
chmod +x $(CHAINSAW) ;\
touch $(CHAINSAW) ;\
fi; \
}

.PHONY: chainsaw-setup
chainsaw-setup: manifests kustomize ## Run the chainsaw setup
Expand All @@ -385,7 +420,7 @@ chainsaw-setup: manifests kustomize ## Run the chainsaw setup

.PHONY: chainsaw-test
chainsaw-test: chainsaw ## Run the chainsaw test
KUBECONFIG=$(KIND_KUBECONFIG) $(CHAINSAW) test --cluster cluster-1=$(KIND_KUBECONFIG) --test-dir ./test/e2e/
KUBECONFIG=$(KIND_KUBECONFIG) $(CHAINSAW) test --cluster cluster-1=$(KIND_KUBECONFIG) --test-dir ./test/e2e/default

.PHONY: chainsaw-cleanup
chainsaw-cleanup: manifests kustomize ## Run the chainsaw cleanup
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/hbasecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type HbaseClusterSpec struct {
// +kubebuilder:validation:Required
ClusterConfigSpec *ClusterConfigSpec `json:"clusterConfig,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
ClusterOperationSpec *commonsv1alpha1.ClusterOperationSpec `json:"clusterOperation,omitempty"`

// +kubebuilder:validation:Optional
Expand Down
10 changes: 7 additions & 3 deletions api/v1alpha1/image_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
)

const (
DefaultRepository = "quay.io/zncdatadev"
DefaultProductVersion = "2.4.17"
DefaultRepository = "quay.io/zncdatadev"
DefaultProductVersion = "2.4.17"
DefaultPlatformVersion = "0.0.0-dev"
DefaultProductName = "hbase"
)

type ImageSpec struct {
Expand All @@ -18,7 +20,8 @@ type ImageSpec struct {
Repository string `json:"repository,omitempty"`

// +kubebuilder:validation:Optional
StackVersion string `json:"stackVersion,omitempty"`
// +kubebuilder:default="0.0.0-dev"
PlatformVersion string `json:"platformVersion,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default="2.4.17"
Expand All @@ -29,5 +32,6 @@ type ImageSpec struct {
PullPolicy *corev1.PullPolicy `json:"pullPolicy,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default="hbase"
PullSecretName string `json:"pullSecretName,omitempty"`
}
2 changes: 1 addition & 1 deletion api/v1alpha1/master_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type MasterSpec struct {
// +kubebuilder:validation:Required
RoleGroups map[string]MasterRoleGroupSpec `json:"roleGroups,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
PodDisruptionBudget *commonsv1alpha1.PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`

// +kubebuilder:validation:Optional
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/regionserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type RegionServerSpec struct {
// +kubebuilder:validation:Optional
Config *RegionConfigSpec `json:"config,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
RoleGroups map[string]RegionServerRoleGroupSpec `json:"roleGroups,omitempty"`

PodDisruptionBudget *commonsv1alpha1.PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`
Expand Down Expand Up @@ -58,7 +58,7 @@ type RegionServerRoleGroupSpec struct {
// +kubebuilder:validation:Optional
Config *RegionConfigSpec `json:"config,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
PodDisruptionBudget *commonsv1alpha1.PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`

// +kubebuilder:validation:Optional
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/restserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type RestServerSpec struct {
// +kubebuilder:validation:Required
RoleGroups map[string]RestServerRoleGroupSpec `json:"roleGroups,omitempty"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Optional
PodDisruptionBudget *commonsv1alpha1.PodDisruptionBudgetSpec `json:"podDisruptionBudget,omitempty"`

// +kubebuilder:validation:Optional
Expand Down
Loading
Loading