Skip to content

Commit

Permalink
Fix kustomize paths in tests, remove manual old kustomize install to …
Browse files Browse the repository at this point in the history
…prevent old versions from being in the path, change vector-test back to Makefile entirely for GHA
  • Loading branch information
burmanm committed Oct 4, 2024
1 parent 3bd6eb1 commit fc7cb39
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 60 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/kind_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@ jobs:
with:
go-version-file: 'go.mod'
cache: true
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: 4.x
- name: Log kustomize version
run: kustomize version
- name: Install Kind
run: go get sigs.k8s.io/kind
- name: Set up Docker Buildx
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/kind_multicluster_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ jobs:
with:
go-version-file: 'go.mod'
cache: true
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: 4.x
- name: Log kustomize version
run: kustomize version
- name: Install Kind
run: go get sigs.k8s.io/kind
- name: Set up Docker Buildx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ jobs:
with:
go-version-file: 'go.mod'
cache: true
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: 4.x
- name: Log kustomize version
run: kustomize version
- name: Install Kind
run: go get sigs.k8s.io/kind
- name: Set up Docker Buildx
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/kuttl_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ jobs:
- name: Load Docker images
run: |
docker load --input /tmp/k8ssandra-k8ssandra-operator.tar
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: 4.x
- name: Log kustomize version
run: kustomize version
- name: Install kuttl
run: |
make install-kuttl
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test_and_build_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ jobs:
fi
- name: Run Vector tests
run: |
sudo apt-get install --yes curl bc
curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev | bash -s -- -y
make $VECTOR=~/.vector/bin/vector vector-test
make vector-install vector-test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
build_image:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/version_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ jobs:
- name: Load Docker images
run: |
docker load --input /tmp/k8ssandra-k8ssandra-operator.tar
- name: Install kustomize
uses: imranismail/setup-kustomize@v2
with:
kustomize-version: 4.x
- name: Log kustomize version
run: kustomize version
- name: Install kuttl
run: |
make install-kuttl
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen

* [CHANGE] Bump default Medusa version to 0.22.3
* [BUGFIX] [#1409](https://github.com/k8ssandra/k8ssandra-operator/issues/1409) Vector would crash in the Cassandra log parsing if empty lines were present. Add automated tests for Vector parsing rules.
* [BUGFIX] [#1425](https://github.com/k8ssandra/k8ssandra-operator/issues/1425) prepare-helm-release.sh requires kustomize to be in the path and that makes make manifests fail.
* [DOCS] [#1469](https://github.com/riptano/mission-control/issues/1469) Add docs for Reaper's Control Plane deployment mode
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ help: ## Display this help.
##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
manifests: controller-gen kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=k8ssandra-operator webhook paths="./..." output:crd:artifacts:config=config/crd/bases
./scripts/prepare-helm-release.sh
KUSTOMIZE=$(KUSTOMIZE) ./scripts/prepare-helm-release.sh

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand All @@ -151,7 +151,7 @@ lint: golangci-lint ## Run golangci-lint against code.
$(GOLANGCI_LINT) run ./...

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate fmt vet lint envtest kustomize ## Run tests.
test: manifests generate fmt vet lint envtest ## Run tests.
ifdef TEST
@echo Running test $(TEST)
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(GO_FLAGS) ./apis/... ./pkg/... ./test/yq/... ./controllers/... -run="$(TEST)" -covermode=atomic -coverprofile coverage.out
Expand Down Expand Up @@ -335,7 +335,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint # TODO Add linting to the GHA also
VECTOR ?= $(LOCALBIN)/vector
VECTOR ?= $(LOCALBIN)/bin/vector

## Tool Versions
CERT_MANAGER_VERSION ?= v1.12.2
Expand Down
8 changes: 6 additions & 2 deletions scripts/prepare-helm-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@

set -e

if [ -z "$KUSTOMIZE" ]; then
KUSTOMIZE=$(command -v kustomize)
fi

mkdir -p build/helm
# Generate the CRDs
kustomize build config/crd > charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
$KUSTOMIZE build config/crd > charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
# Generate the role.yaml and clusterrole.yaml files using the RBAC generated manifests
kustomize build config/rbac > build/helm/k8ssandra-operator-rbac.yaml
$KUSTOMIZE build config/rbac > build/helm/k8ssandra-operator-rbac.yaml
cat charts/templates/role.tmpl.yaml | tee build/helm/role.yaml > /dev/null
cat build/helm/k8ssandra-operator-rbac.yaml | yq 'select(di == 1).rules' | tee -a build/helm/role.yaml > /dev/null
echo "{{- end }}" >> build/helm/role.yaml
Expand Down
32 changes: 11 additions & 21 deletions test/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ func LogOutput(enabled bool) {
logOutput = enabled
}

func BuildDir(dir string) (*bytes.Buffer, error) {
func kustomizePath() string {
binDir := os.Getenv("LOCALBIN")
kustomizeLocation := ""
if binDir == "" {
fmt.Println("warning: LOCALBIN environment variable not set, attempting to use system kustomize")
kustomizeLocation = "kustomize"
} else {
fmt.Println("LOCALBIN: " + binDir)
kustomizeLocation = binDir + "/kustomize"
return "kustomize"
}
cmd := exec.Command(kustomizeLocation, "build")
cmd.Dir = dir
return binDir + "/kustomize"
}

fmt.Println(cmd)
func BuildDir(dir string) (*bytes.Buffer, error) {
cmd := exec.Command(kustomizePath(), "build")
cmd.Dir = dir

output, err := cmd.CombinedOutput()
buffer := bytes.NewBuffer(output)
Expand All @@ -39,9 +37,7 @@ func BuildDir(dir string) (*bytes.Buffer, error) {
}

func BuildUrl(url string) (*bytes.Buffer, error) {
cmd := exec.Command("kustomize", "build", url)

fmt.Println(cmd)
cmd := exec.Command(kustomizePath(), "build", url)

output, err := cmd.CombinedOutput()
buffer := bytes.NewBuffer(output)
Expand All @@ -54,11 +50,9 @@ func BuildUrl(url string) (*bytes.Buffer, error) {
}

func SetNamespace(dir, namespace string) error {
cmd := exec.Command("kustomize", "edit", "set", "namespace", namespace)
cmd := exec.Command(kustomizePath(), "edit", "set", "namespace", namespace)
cmd.Dir = dir

fmt.Println(cmd)

output, err := cmd.CombinedOutput()

if logOutput {
Expand All @@ -69,11 +63,9 @@ func SetNamespace(dir, namespace string) error {
}

func AddResource(path string) error {
cmd := exec.Command("kustomize", "edit", "add", "resource", path)
cmd := exec.Command(kustomizePath(), "edit", "add", "resource", path)
cmd.Dir = "../testdata/k8ssandra-operator"

fmt.Println(cmd)

output, err := cmd.CombinedOutput()

if logOutput {
Expand All @@ -84,11 +76,9 @@ func AddResource(path string) error {
}

func RemoveResource(path string) error {
cmd := exec.Command("kustomize", "edit", "remove", "resource", path)
cmd := exec.Command(kustomizePath(), "edit", "remove", "resource", path)
cmd.Dir = "../testdata/k8ssandra-operator"

fmt.Println(cmd)

output, err := cmd.CombinedOutput()

if logOutput {
Expand Down

0 comments on commit fc7cb39

Please sign in to comment.