Skip to content

Commit 2bc5b86

Browse files
authored
Merge pull request #2036 from rabbitmq/rewrite-kubectl-plugin
Rewrite kubectl plugin in Go
2 parents 84533a5 + f538313 commit 2bc5b86

File tree

19 files changed

+2171
-754
lines changed

19 files changed

+2171
-754
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@ updates:
3737
directory: "/"
3838
schedule:
3939
interval: "weekly"
40+
- package-ecosystem: "gomod"
41+
directory: "/bin/kubectl-rabbitmq-plugin/"
42+
groups:
43+
kubectl-rabbitmq-plugin:
44+
patterns:
45+
- '*'
46+
schedule:
47+
interval: "daily"
48+
ignore:
49+
- dependency-name: "github.com/rabbitmq/cluster-operator/v2"

.github/workflows/build-test-publish.yml

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,33 @@ jobs:
3333
- name: Install Go
3434
uses: actions/setup-go@v6
3535
with:
36-
go-version: ${{ env.GO_VERSION }}
37-
check-latest: true
36+
go-version-file: bin/kubectl-rabbitmq-plugin/go.mod
37+
cache-dependency-path: |
38+
bin/kubectl-rabbitmq-plugin/go.sum
3839
3940
- name: Install Carvel
4041
uses: carvel-dev/[email protected]
4142
with:
4243
token: ${{ secrets.GITHUB_TOKEN }}
4344
only: ytt
4445

45-
- name: Install Bats
46-
run: |
47-
git clone https://github.com/bats-core/bats-core.git "$HOME"/bats-core
48-
cd "$HOME"/bats-core
49-
sudo ./install.sh /usr/local
50-
5146
- name: Download Operator artifact
5247
uses: actions/download-artifact@v7
5348
with:
5449
name: operator_image
55-
path: /tmp
50+
path: ${{ runner.temp }}
5651

5752
- name: Create KinD
5853
uses: helm/kind-action@v1
5954
with:
6055
cluster_name: cluster-operator-testing
6156
node_image: ${{ env.KIND_NODE_IMAGE }}
6257

63-
- name: kubectl rabbitmq tests
58+
- name: Deploy dev Operator
6459
env:
6560
IMG: "rabbitmqoperator/cluster-operator:${{ needs.build_operator.outputs.image_tag }}"
6661
run: |
67-
kind load image-archive /tmp/operator.tar --name cluster-operator-testing
62+
kind load image-archive ${{ runner.temp }}/operator.tar --name cluster-operator-testing
6863
6964
make manifests deploy-namespace-rbac
7065
kubectl kustomize config/crd | kubectl apply -f-
@@ -74,7 +69,9 @@ jobs:
7469
-f config/ytt/never_pull.yaml \
7570
| kubectl apply -f-
7671
77-
make kubectl-plugin-tests
72+
- name: Test kubectl plugin
73+
working-directory: bin/kubectl-rabbitmq-plugin
74+
run: make tests TEST_TAGS=integration
7875

7976
- name: Notify Google Chat
8077
if: ${{ failure() && github.event_name != 'pull_request' }}
@@ -84,6 +81,40 @@ jobs:
8481
jobStatus: ${{ job.status }}
8582
title: Cluster Operator - RabbitMQ kubectl tests
8683

84+
build_kubectl_plugin:
85+
name: Build kubectl plugin
86+
runs-on: ubuntu-latest
87+
needs: kubectl_tests
88+
if: github.ref_type == 'tag'
89+
strategy:
90+
matrix:
91+
os: [darwin, linux]
92+
arch: [amd64, arm64]
93+
steps:
94+
- name: Check out code into the Go module directory
95+
uses: actions/checkout@v6
96+
97+
- name: Install Go
98+
uses: actions/setup-go@v6
99+
with:
100+
go-version-file: bin/kubectl-rabbitmq-plugin/go.mod
101+
cache-dependency-path: |
102+
bin/kubectl-rabbitmq-plugin/go.sum
103+
104+
- name: Build kubectl plugin
105+
working-directory: bin/kubectl-rabbitmq-plugin
106+
run: make build PLUGIN_VERSION=${{ github.ref_name }} GO_OS=${{ matrix.os }} GO_ARCH=${{ matrix.arch }}
107+
108+
- name: Compress kubectl plugin
109+
working-directory: bin/kubectl-rabbitmq-plugin
110+
run: tar -cvzf kubectl-rabbitmq-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz kubectl-rabbitmq-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}
111+
112+
- name: Upload kubectl plugin artifact
113+
uses: actions/upload-artifact@v6
114+
with:
115+
name: kubectl-rabbitmq-${{ matrix.os }}-${{ matrix.arch }}
116+
path: bin/kubectl-rabbitmq-plugin/kubectl-rabbitmq-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
117+
87118
unit_integration_tests:
88119
name: unit and integration tests
89120
runs-on: ubuntu-latest
@@ -517,30 +548,34 @@ jobs:
517548
release:
518549
name: Release to GitHub Releases
519550
runs-on: ubuntu-latest
520-
if: startsWith(github.ref, 'refs/tags/v')
521-
needs: [system_tests, test_doc_examples, test_upgrade]
551+
if: github.ref_type == 'tag'
552+
needs: [system_tests, test_doc_examples, test_upgrade, build_kubectl_plugin]
522553
steps:
523-
- name: Checkout
524-
uses: actions/checkout@v6
525-
526554
- name: Get operator manifest
527555
uses: actions/download-artifact@v7
528556
with:
529557
name: operator-manifests
530558

559+
- name: Get kubectl plugin artefacts
560+
uses: actions/download-artifact@v7
561+
with:
562+
pattern: kubectl-rabbitmq-*
563+
merge-multiple: true
564+
path: bin/
565+
531566
- name: Get release header
532567
uses: actions/download-artifact@v7
533568
with:
534569
name: release-header
535570

536571
- name: Release
537572
uses: softprops/action-gh-release@v2
538-
if: startsWith(github.ref, 'refs/tags/')
539573
with:
540574
files: |
541575
cluster-operator.yml
542576
cluster-operator-quay-io.yml
543577
cluster-operator-ghcr-io.yml
578+
bin/kubectl-rabbitmq-*
544579
generate_release_notes: true
545580
draft: true
546581
body_path: release-header.md

0 commit comments

Comments
 (0)