From 03f3f772388c08d88d3fd0fca32a27eb682e9495 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:05:07 -0400 Subject: [PATCH 01/16] bump to go 1.22 Signed-off-by: Alexandre Lamarre --- go.mod | 2 +- go.sum | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fbbf6c57..bff5b48c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/rancher/prometheus-federator -go 1.20 +go 1.22.3 replace ( k8s.io/api => k8s.io/api v0.25.4 diff --git a/go.sum b/go.sum index 986a7023..3e514a8c 100644 --- a/go.sum +++ b/go.sum @@ -40,6 +40,7 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= @@ -149,6 +150,7 @@ github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -271,6 +273,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -306,6 +309,7 @@ github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsO github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= +github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= @@ -336,7 +340,9 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= +github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= +github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -350,6 +356,7 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/poy/onpar v0.0.0-20190519213022-ee068f8ea4d1/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU= github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY= +github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= From 2b01a7cb1cebbe33beee29c90a05dd4ea8603a55 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:06:49 -0400 Subject: [PATCH 02/16] remove dependency on dapper Signed-off-by: Alexandre Lamarre --- Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index ca0f440a..7c472ef6 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,7 @@ TARGETS := $(shell ls scripts) -.dapper: - @echo Downloading dapper - @curl -sL https://releases.rancher.com/dapper/latest/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp - @@chmod +x .dapper.tmp - @./.dapper.tmp -v - @mv .dapper.tmp .dapper - -$(TARGETS): .dapper - ./.dapper $@ +$(TARGETS): + ./scripts/$@ .DEFAULT_GOAL := default From 0fd83e6773ba1fc4dafe666fd8214d7096d2b4b5 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:21:19 -0400 Subject: [PATCH 03/16] update docker build process Signed-off-by: Alexandre Lamarre --- package/Dockerfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/package/Dockerfile b/package/Dockerfile index b514a9cf..53ca8a69 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,8 +1,23 @@ +FROM registry.suse.com/bci/golang:1.22 AS helm +RUN zypper -n install git +RUN git -C / clone --branch release-v3.9.0 --depth=1 https://github.com/rancher/helm +RUN make -C /helm + +FROM registry.suse.com/bci/golang:1.22 as builder +WORKDIR /usr/src/app +COPY --from=helm ./helm/bin/helm /usr/local/bin/ +RUN zypper -n install git vim less file curl wget patch +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +RUN make build + FROM registry.suse.com/bci/bci-micro:15.4 RUN echo 'prometheus:x:1000:1000::/home/prometheus:/bin/bash' >> /etc/passwd && \ echo 'prometheus:x:1000:' >> /etc/group && \ mkdir /home/prometheus && \ chown -R prometheus:prometheus /home/prometheus -COPY bin/prometheus-federator /usr/bin/ +COPY --from=helm ./helm/bin/helm /usr/local/bin/ +COPY --from=builder /usr/src/app/bin/prometheus-federator /usr/bin/ USER prometheus CMD ["prometheus-federator"] From 0f2f8eb31b3b782ac65f1dd6ac6fa122f3c414f8 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:22:18 -0400 Subject: [PATCH 04/16] fix lint issues Signed-off-by: Alexandre Lamarre --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 712ff980..a17a0e21 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,7 @@ type PrometheusFederator struct { Kubeconfig string `usage:"Kubeconfig file"` } -func (f *PrometheusFederator) Run(cmd *cobra.Command, args []string) error { +func (f *PrometheusFederator) Run(cmd *cobra.Command, _ []string) error { go func() { // required to set up healthz and pprof handlers log.Println(http.ListenAndServe("localhost:80", nil)) From ac1caac6825b37caae9d1ef02c5c87b550654b39 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:24:05 -0400 Subject: [PATCH 05/16] update .gitignore Signed-off-by: Alexandre Lamarre --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 13fed769..90526974 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ /prometheus-federator /.charts-build-scripts *.DS_Store -/Dockerfile.dapper* \ No newline at end of file +/Dockerfile.dapper* +dev/ +kubeconfig.yaml \ No newline at end of file From 0fedca5e9cf6ecdd1be5a502838a5ba00e1d8ad2 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:29:25 -0400 Subject: [PATCH 06/16] remove deprecated stuff in scripts Signed-off-by: Alexandre Lamarre --- scripts/validate | 12 ------------ scripts/version | 7 +------ 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/scripts/validate b/scripts/validate index 7f98128b..35a87f00 100755 --- a/scripts/validate +++ b/scripts/validate @@ -4,18 +4,6 @@ set -e cd $(dirname $0)/.. echo Running validation - PACKAGES="$(go list ./...)" - -if ! command -v golangci-lint; then - echo Skipping validation: no golangci-lint available - exit -fi - -echo Running validation - -echo Running: golangci-lint -golangci-lint run - echo Running: go fmt test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)" diff --git a/scripts/version b/scripts/version index 1646092e..7d73eeb4 100755 --- a/scripts/version +++ b/scripts/version @@ -13,13 +13,8 @@ else VERSION="${COMMIT}${DIRTY}" fi -if [ -z "$ARCH" ]; then - ARCH=$(go env GOHOSTARCH) -fi - -SUFFIX="-${ARCH}" -TAG=${TAG:-${VERSION}${SUFFIX}} +TAG=${TAG:-${VERSION}} REPO=${REPO:-rancher} if echo $TAG | grep -q dirty; then From d1010e011e99f4d28738a4ae707a92eae0b40c61 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:33:23 -0400 Subject: [PATCH 07/16] remove MAINTAINERS.md Signed-off-by: Alexandre Lamarre --- MAINTAINERS.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 MAINTAINERS.md diff --git a/MAINTAINERS.md b/MAINTAINERS.md deleted file mode 100644 index 79f91eb3..00000000 --- a/MAINTAINERS.md +++ /dev/null @@ -1 +0,0 @@ -Arvind Iyengar (arvindiyengar@suse.com / @aiyengar2) \ No newline at end of file From 4c6e7f0be09da98cf75e79fe21eea30a06cc20f5 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:34:50 -0400 Subject: [PATCH 08/16] bump docker image base Signed-off-by: Alexandre Lamarre --- package/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/Dockerfile b/package/Dockerfile index 53ca8a69..d6997751 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -12,7 +12,7 @@ RUN go mod download COPY . . RUN make build -FROM registry.suse.com/bci/bci-micro:15.4 +FROM registry.suse.com/bci/bci-micro:15.5 RUN echo 'prometheus:x:1000:1000::/home/prometheus:/bin/bash' >> /etc/passwd && \ echo 'prometheus:x:1000:' >> /etc/group && \ mkdir /home/prometheus && \ From 0b200d345ccf33f60c44df0a0274ca54c991e947 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:38:45 -0400 Subject: [PATCH 09/16] update ci workflow Signed-off-by: Alexandre Lamarre --- .github/workflows/ci.yaml | 38 +++++++++++++++++++++++++++++ .github/workflows/pull-request.yaml | 23 ----------------- 2 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/pull-request.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..fcc3620e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: ci + +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'scripts/**' + - '*.md' + - '*.dapper' + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - 'Makefile' + +env: + YQ_VERSION : v4.25.1 + CGO_ENABLED : 0 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name : Set up Go + uses: actions/setup-go@v2 + with: + go-version: '1.22' + - name : Install YQ + run: | + wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH} -O /usr/bin/yq && chmod +x /usr/bin/yq; + - name : Install helm + run : | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + helm version + - name: Run CI + run: make ci diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml deleted file mode 100644 index 0006de77..00000000 --- a/.github/workflows/pull-request.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: CI-pullrequest - -on: - pull_request: - paths-ignore: - - 'docs/**' - - 'scripts/**' - - '*.md' - - '*.dapper' - - '.gitignore' - - 'CODEOWNERS' - - 'LICENSE' - - 'Makefile' - -jobs: - build: - runs-on: ubuntu-latest - container: - image: rancher/dapper:v0.5.4 - steps: - - uses: actions/checkout@v1 - - name: Run CI - run: dapper ci From 5c507782bb40ae2b943c9810a6de4c10b89e0842 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:40:15 -0400 Subject: [PATCH 10/16] add lint action Signed-off-by: Alexandre Lamarre --- .github/workflows/lint.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 00000000..15d3cfeb --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,31 @@ +name: golangci-lint +on: + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + 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.56 \ No newline at end of file From 81867ce61dec2c0eafb828d353fa5a6aa78ff6db Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:48:45 -0400 Subject: [PATCH 11/16] fix permissions Signed-off-by: Alexandre Lamarre --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fcc3620e..3e1ab517 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: go-version: '1.22' - name : Install YQ run: | - wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH} -O /usr/bin/yq && chmod +x /usr/bin/yq; + sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq; - name : Install helm run : | curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 From 73fd51ba6a2c3b20395f831fe2420ab03f123406 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 14:53:01 -0400 Subject: [PATCH 12/16] fix ci configs Signed-off-by: Alexandre Lamarre --- .github/workflows/ci.yaml | 2 +- .github/workflows/lint.yaml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e1ab517..3599d39a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: go-version: '1.22' - name : Install YQ run: | - sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq; + sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq; - name : Install helm run : | curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 15d3cfeb..8fdde95e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,6 +22,14 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22' + - name: Package helm chart + ./scripts/build-chart + - name : Install helm + run : | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + helm version - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: From 789c32d2cc37e621ba6197f2feec2d67ead87e2e Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 15:03:31 -0400 Subject: [PATCH 13/16] more changes Signed-off-by: Alexandre Lamarre --- .github/workflows/ci.yaml | 1 + .github/workflows/lint.yaml | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3599d39a..5eb39f75 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,7 @@ jobs: curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh + rm get_helm.sh helm version - name: Run CI run: make ci diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 8fdde95e..537a518a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,14 +22,15 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '1.22' - - name: Package helm chart - ./scripts/build-chart - name : Install helm run : | curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh helm version + rm get_helm.sh + - name: Package helm chart + run : ./scripts/build-chart - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: From 5325c172861d1b20680986f11df29fed3455a978 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 16:20:55 -0400 Subject: [PATCH 14/16] add IMAGE to versions & publish image workflows Signed-off-by: Alexandre Lamarre --- .github/workflows/publish.yaml | 43 ++++++++++++++++++++++++++++++++++ scripts/version | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..9d685e09 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,43 @@ +name : Publish images + +on: + push: + tags: + - "*" + +jobs: + push: + runs-on: ubuntu-latest + permissions: + contents : read + id-token: write + steps: + - name : "Read Secrets" + uses : rancher-eio/read-vault-secrets@main + with: + secrets: | + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + - name : Export image version + run : | + source ./scripts/version + echo IMAGE=$IMAGE >> $GITHUB_ENV + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Helm-Project-Operator image + uses: docker/build-push-action@v5 + with: + context: . + file: ./package/Dockerfile + push: true + tags: ${{ env.IMAGE }} + platforms: linux/amd64,linux/arm64 \ No newline at end of file diff --git a/scripts/version b/scripts/version index 7d73eeb4..48f4070a 100755 --- a/scripts/version +++ b/scripts/version @@ -13,10 +13,10 @@ else VERSION="${COMMIT}${DIRTY}" fi - TAG=${TAG:-${VERSION}} REPO=${REPO:-rancher} if echo $TAG | grep -q dirty; then TAG=dev fi +IMAGE=${IMAGE:-$REPO/prometheus-federator:${TAG}} \ No newline at end of file From 0a6d5aa7d19dc10a2f8d53290e242020034e42ee Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 16:22:49 -0400 Subject: [PATCH 15/16] remove dapper and drone Signed-off-by: Alexandre Lamarre --- .drone.yml | 158 ---------------------------------------------- Dockerfile.dapper | 31 --------- 2 files changed, 189 deletions(-) delete mode 100644 .drone.yml delete mode 100644 Dockerfile.dapper diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 07d36b2b..00000000 --- a/.drone.yml +++ /dev/null @@ -1,158 +0,0 @@ ---- -kind: pipeline -name: amd64 - -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: rancher/dapper:v0.5.4 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-amd64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -- name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "rancher/prometheus-federator" - tag: "${DRONE_TAG}-amd64" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: -- name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: arm64 - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: rancher/dapper:v0.5.4 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - -- name: github_binary_release - image: plugins/github-release - settings: - api_key: - from_secret: github_token - prerelease: true - checksum: - - sha256 - checksum_file: CHECKSUMsum-arm64.txt - checksum_flatten: true - files: - - "dist/artifacts/*" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -- name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "rancher/prometheus-federator" - tag: "${DRONE_TAG}-arm64" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: -- name: docker - host: - path: /var/run/docker.sock - ---- -kind: pipeline -name: manifest - -platform: - os: linux - arch: amd64 - -steps: -- name: manifest - image: plugins/manifest:1.0.2 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - platforms: - - linux/amd64 - - linux/arm64 - target: "rancher/prometheus-federator:${DRONE_TAG}" - template: "rancher/prometheus-federator:${DRONE_TAG}-ARCH" - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -depends_on: -- amd64 -- arm64 - diff --git a/Dockerfile.dapper b/Dockerfile.dapper deleted file mode 100644 index faae2fb8..00000000 --- a/Dockerfile.dapper +++ /dev/null @@ -1,31 +0,0 @@ -FROM registry.suse.com/bci/golang:1.20 AS helm -RUN zypper -n install git -RUN git -C / clone --branch release-v3.9.0 --depth=1 https://github.com/rancher/helm -RUN make -C /helm - -FROM registry.suse.com/bci/golang:1.20 - -ARG DAPPER_HOST_ARCH -ENV ARCH $DAPPER_HOST_ARCH - -RUN zypper -n install git docker vim less file curl wget patch -RUN go install golang.org/x/tools/cmd/goimports@latest -RUN if [ "${ARCH}" == "amd64" ]; then \ - curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.50.1; \ - fi - -ENV YQ_VERSION=v4.25.1 -RUN wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH} -O /usr/bin/yq && chmod +x /usr/bin/yq; - -COPY --from=helm ./helm/bin/helm /usr/local/bin/ - -ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS -ENV DAPPER_SOURCE /go/src/github.com/rancher/prometheus-federator/ -ENV DAPPER_OUTPUT ./bin ./dist -ENV DAPPER_DOCKER_SOCKET true -ENV GOPATH /go -ENV HOME ${DAPPER_SOURCE} -WORKDIR ${DAPPER_SOURCE} - -ENTRYPOINT ["./scripts/entry"] -CMD ["ci"] From f05d83d7baae834ec5d990ade1ffee2123cf5d12 Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Tue, 21 May 2024 16:38:23 -0400 Subject: [PATCH 16/16] tidy gitignore after dapper removal Signed-off-by: Alexandre Lamarre --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 90526974..650bf217 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -/.dapper /.cache /bin /dist @@ -7,6 +6,5 @@ /prometheus-federator /.charts-build-scripts *.DS_Store -/Dockerfile.dapper* dev/ kubeconfig.yaml \ No newline at end of file