From ef55ddc31197e3a16cedc9b55cd40cc5e9bd1505 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 29 Apr 2024 18:37:02 -0700 Subject: [PATCH 01/42] Remove deprecated ioutil (#73) Signed-off-by: Luca Comellini --- main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 8ab8f92..f21721b 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "fmt" "html/template" "io" - "io/ioutil" "net/http" "os" "os/exec" @@ -98,7 +97,6 @@ func init() { if err := resolveTemplateDir(*flTemplateDir); err != nil { panic(err) } - } func resolveTemplateDir(dir string) error { @@ -156,14 +154,14 @@ func main() { if *flOutFile != "" { dir := filepath.Dir(*flOutFile) - if err := os.MkdirAll(dir, 0755); err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { klog.Fatalf("failed to create dir %s: %v", dir, err) } s, err := mkOutput() if err != nil { klog.Fatalf("failed: %+v", err) } - if err := ioutil.WriteFile(*flOutFile, []byte(s), 0644); err != nil { + if err := os.WriteFile(*flOutFile, []byte(s), 0o644); err != nil { klog.Fatalf("failed to write to out file: %v", err) } klog.Infof("written to %s", *flOutFile) @@ -404,7 +402,7 @@ func linkForType(t *types.Type, c generatorConfig, typePkgMap map[*types.Type]*a return "#" + anchorIDForLocalType(t, typePkgMap), nil } - var arrIndex = func(a []string, i int) string { + arrIndex := func(a []string, i int) string { return a[(len(a)+i)%len(a)] } @@ -663,7 +661,7 @@ func render(w io.Writer, pkgs []*apiPackage, config generatorConfig) error { "apiGroup": func(t *types.Type) string { return apiGroupForType(t, typePkgMap) }, "packageAnchorID": func(p *apiPackage) string { // TODO(ahmetb): currently this is the same as packageDisplayName - // func, and it's fine since it retuns valid DOM id strings like + // func, and it's fine since it returns valid DOM id strings like // 'serving.knative.dev/v1alpha1' which is valid per HTML5, except // spaces, so just trim those. return strings.Replace(p.identifier(), " ", "", -1) From 1a29344d1b9d6a1aa3bec1fe91c1e07a7a262768 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 29 Apr 2024 19:15:03 -0700 Subject: [PATCH 02/42] Switch to GitHub Actions (#72) Removes Travis in favor of GitHub Actions. Adds binaries for arm64. Signs artifacts and generates SBOMs for them. Signed-off-by: Luca Comellini --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ .goreleaser.yml | 39 ++++++++++++++++++++------------ .travis.yml | 32 --------------------------- 3 files changed, 73 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..c2f2d7f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: + - master + tags: + - "v[0-9]+.[0-9]+.[0-9]+*" + pull_request: + branches: + - master + +permissions: + contents: read + +jobs: + build: + name: Build + runs-on: ubuntu-22.04 + permissions: + contents: write + id-token: write + steps: + - name: Checkout Repository + uses: actions/checkout@v4.1.4 + with: + fetch-depth: 0 + + - name: Setup Golang Environment + uses: actions/setup-go@0v5.0.0 + with: + go-version: stable + + - name: Download Syft + uses: anchore/sbom-action/download-syft@v0.15.11 + if: github.ref_type == 'tag' + + - name: Install Cosign + uses: sigstore/cosign-installer@v3.5.0 + if: github.ref_type == 'tag' + + - name: Build binary + uses: goreleaser/goreleaser-action@v5.0.0 + with: + version: latest + args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index f1cacca..3e25e6a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,24 +1,35 @@ builds: - env: - CGO_ENABLED=0 - # travis ci currently sets GOPATH even with go1.11. - # force-setting GO111MODULE=on to use vgo - - GO111MODULE=on goos: - linux - darwin goarch: - amd64 -archive: - name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" - files: - - LICENSE - - template/** - - example-config.json + - arm64 + +archives: + - files: + - LICENSE + - template/** + - example-config.json + checksum: name_template: "checksums.txt" -changelog: - skip: true -release: - # releases are uploaded to github by .travis.yml - disable: true + +sboms: + - artifacts: archive + documents: + - "${artifact}.spdx.json" + +signs: + - cmd: cosign + artifacts: checksum + output: true + certificate: "${artifact}.pem" + args: + - sign-blob + - "--output-signature=${signature}" + - "--output-certificate=${certificate}" + - "${artifact}" + - "--yes" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d6845ba..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: go -go: - - 1.11.x -install: - - echo noop -before_script: - # travis ci currently sets GOPATH even with go1.11. - # force-setting GO111MODULE=on to use vgo - - env GO111MODULE=on go mod download -script: - # travis ci currently sets GOPATH even with go1.11. - # force-setting GO111MODULE=on to use vgo - - env GO111MODULE=on go build -v -o /dev/null -deploy: - # use goreleaser to prepare dist/ - - provider: script - skip_cleanup: true - on: - tags: true - script: curl -sL https://git.io/goreleaser | bash - # use github release feature to upload dist/ - - provider: releases - skip_cleanup: true - on: - tags: true - file_glob: true - file: - - dist/*.tar.gz - - dist/*.zip - - dist/checksums.txt - api_key: - secure: r1GMgbVDnZTUcny/PbIATW9dXGOTpm2U9iEGaWvpprMO2AGo7ju7SWEJWtjcap3pc0YasyR2/eon9LC0scWY0Xlpeb+g0pRCQ39FABk1Vo3DpmIPRUCFFkaescWmrWDj3ImzjJgZjCewwK6Fo8s8ngnqIlZnE1Hq6ls2xDp6jNVf+Pn7LyqxkK4axFFSPQM9zFX3N1PVUH5RT03bIJfojJZguqnhNfyTvKvHJidoeWU/Ie+fXc4AdPHyP85xrmGHYl68O0HziU6JCLXira8r1FjUgVeYFYC5nnNuylszO6JWqWh1nXYDxs5FGPnZd9N8bEi/2ahiqms8eV7S+/DGzhSoEdHikcBxTgJpZP2VOmvRSITyv3RleJzCeMULTGFQodoxRgA/Q8qZySvInNjstiBjV2Pyucrnn990XQbN8rIV4RmNggJvbAwJNCGjCwS2eB42EKNCODTuzHPbIV0ap4EjvfBBo0cZ2J9M2Q6VzdpNErdntpM1hZl9yymv3MNN4hOiLQKkofoo/QI3cffB8Y0PBPAL8Cs9Mx1bbx+Dr8iitTHBUAt4a5DHFen4MS8znrZ+Cr4kLDD9QPJ8G0oh4tDKq8CJ73Gt+xqkLZEuka0W1awz9essqE7MH20kRJbKa5woTIs0v9njHMpbeqd7KrNV+1e5F5aPRQyiCzaom7c= From 91414af7ae7f1f08a5b8462598b48129ac0d5aa9 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 29 Apr 2024 19:15:15 -0700 Subject: [PATCH 03/42] Bump Go to 1.21 (#70) --- go.mod | 9 +++++---- go.sum | 13 ++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 65fac81..7e61b12 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module github.com/ahmetb/gen-crd-api-reference-docs -go 1.15 +go 1.21.0 require ( - github.com/go-logr/logr v1.2.4 // indirect github.com/russross/blackfriday/v2 v2.1.0 - k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4 - k8s.io/klog/v2 v2.90.1 + k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 + k8s.io/klog/v2 v2.120.1 ) + +require github.com/go-logr/logr v1.4.1 // indirect diff --git a/go.sum b/go.sum index 6d4a228..2397af6 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -37,9 +36,9 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4 h1:aClvVG6GbX10ISHcc24J+tqbr0S7fEe1MWkFJ7cWWCI= -k8s.io/gengo v0.0.0-20230306165830-ab3349d207d4/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 h1:wBIDZID8ju9pwOiLlV22YYKjFGtiNSWgHf5CnKLRUuM= +k8s.io/gengo v0.0.0-20240404160639-a0386bf69313/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= From 4a797a98d81880e4c6ccb518623446a8182e072e Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 29 Apr 2024 19:15:33 -0700 Subject: [PATCH 04/42] Add dependabot (#71) Signed-off-by: Luca Comellini --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..9aa5f33 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly From 89e5ed0440c40d960b574af9a004250844a8c0f1 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 29 Apr 2024 23:23:53 -0700 Subject: [PATCH 05/42] Fix typo in workflow (#74) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2f2d7f..1a2984d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@0v5.0.0 + uses: actions/setup-go@v5.0.0 with: go-version: stable From 5020c8c8819e0a5202039504a9a24bccf6b5541f Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 30 Apr 2024 07:41:31 -0700 Subject: [PATCH 06/42] Add GitHub Actions to depedndabot (#75) Signed-off-by: Luca Comellini --- .github/dependabot.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9aa5f33..d163711 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,8 @@ updates: directory: / schedule: interval: weekly + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly From 5e940503db38dca617fd666ee4fb911a0acf8eb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 19:23:23 -0700 Subject: [PATCH 07/42] Bump goreleaser/goreleaser-action from 5.0.0 to 5.1.0 (#79) Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](https://github.com/goreleaser/goreleaser-action/compare/v5.0.0...v5.1.0) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a2984d..5b5a603 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: if: github.ref_type == 'tag' - name: Build binary - uses: goreleaser/goreleaser-action@v5.0.0 + uses: goreleaser/goreleaser-action@v5.1.0 with: version: latest args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean From 04ee257ff0d1624d22d5a3dee61f749ac523e243 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:54:56 -0700 Subject: [PATCH 08/42] Bump goreleaser/goreleaser-action from 5.1.0 to 6.0.0 (#82) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b5a603..96c6830 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: if: github.ref_type == 'tag' - name: Build binary - uses: goreleaser/goreleaser-action@v5.1.0 + uses: goreleaser/goreleaser-action@v6.0.0 with: version: latest args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean From 9b789fe6820a44e9cfcedbbefde06eadfd079ab5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:55:06 -0700 Subject: [PATCH 09/42] Bump actions/setup-go from 5.0.0 to 5.0.1 (#77) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96c6830..73a06d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.0.0 + uses: actions/setup-go@v5.0.1 with: go-version: stable From f3a5c7724f388192add9c1111213340be515c3fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:55:26 -0700 Subject: [PATCH 10/42] Bump anchore/sbom-action from 0.15.11 to 0.16.0 (#80) Bumps [anchore/sbom-action](https://github.com/anchore/sbom-action) from 0.15.11 to 0.16.0. - [Release notes](https://github.com/anchore/sbom-action/releases) - [Commits](https://github.com/anchore/sbom-action/compare/v0.15.11...v0.16.0) --- updated-dependencies: - dependency-name: anchore/sbom-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73a06d2..219b9e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.15.11 + uses: anchore/sbom-action/download-syft@v0.16.0 if: github.ref_type == 'tag' - name: Install Cosign From ed46227d55a12eaa2f18841ec634a0f6ea4a7978 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 11:55:35 -0700 Subject: [PATCH 11/42] Bump actions/checkout from 4.1.4 to 4.1.6 (#81) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.4 to 4.1.6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.4...v4.1.6) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 219b9e2..6394764 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: id-token: write steps: - name: Checkout Repository - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4.1.6 with: fetch-depth: 0 From a78f09148642adbd247ecd56c205b0ed9facb111 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:23:06 -0700 Subject: [PATCH 12/42] Bump k8s.io/klog/v2 from 2.120.1 to 2.130.0 (#83) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7e61b12..a545add 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21.0 require ( github.com/russross/blackfriday/v2 v2.1.0 k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 - k8s.io/klog/v2 v2.120.1 + k8s.io/klog/v2 v2.130.0 ) require github.com/go-logr/logr v1.4.1 // indirect diff --git a/go.sum b/go.sum index 2397af6..7ad2c42 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,6 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 h1:wBIDZID8ju9pwOiLlV22YYKjFGtiNSWgHf5CnKLRUuM= k8s.io/gengo v0.0.0-20240404160639-a0386bf69313/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM= +k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= From 4b21651229c56a8a172a0057d0514741e6a07e38 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Mon, 8 Jul 2024 20:14:17 -0700 Subject: [PATCH 13/42] Update README.md (#86) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e1c6632..98793b9 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ CRD API Reference via https://doc.crds.dev/ without much effort. - [**Antrea** API reference docs](https://antrea.io/docs/v1.3.0/docs/api-reference/) - [**kube-green** API reference docs](https://kube-green.dev/docs/apireference_v1alpha1/) - [**Azure Service Operator** supported resources](https://azure.github.io/azure-service-operator/reference/) +- [**NGINX Gateway Fabric** API reference docs](https://docs.nginx.com/nginx-gateway-fabric/reference/api/) - _[[ADD YOUR PROJECT HERE]]_ Also some **forks**: From 2b5b05f03c8e2b1264a0ea0804f4a8321b6df837 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Thu, 11 Jul 2024 13:52:23 -0700 Subject: [PATCH 14/42] Bump GoReleaser config to v2 (#87) GorReleaser released version 2 which requires a bump in the config --- .goreleaser.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 3e25e6a..40ecfa4 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,4 @@ +version: 2 builds: - env: - CGO_ENABLED=0 From fb5ea333646ff594cd8ad4073303dbd359d43241 Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Fri, 26 Jul 2024 18:23:50 -0700 Subject: [PATCH 15/42] Switch to k8s.io/gengo/v2 (#90) --- go.mod | 10 +++++++--- go.sum | 50 ++++++++++---------------------------------------- main.go | 49 +++++++++++++++++++++++++++---------------------- 3 files changed, 44 insertions(+), 65 deletions(-) diff --git a/go.mod b/go.mod index a545add..8307543 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,12 @@ go 1.21.0 require ( github.com/russross/blackfriday/v2 v2.1.0 - k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 - k8s.io/klog/v2 v2.130.0 + k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 + k8s.io/klog/v2 v2.130.1 ) -require github.com/go-logr/logr v1.4.1 // indirect +require ( + github.com/go-logr/logr v1.4.1 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/tools v0.16.1 // indirect +) diff --git a/go.sum b/go.sum index 7ad2c42..4c38fcc 100644 --- a/go.sum +++ b/go.sum @@ -1,44 +1,14 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -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/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8 h1:BMFHd4OFnFtWX46Xj4DN6vvT1btiBxyq+s0orYBqcQY= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/gengo v0.0.0-20240404160639-a0386bf69313 h1:wBIDZID8ju9pwOiLlV22YYKjFGtiNSWgHf5CnKLRUuM= -k8s.io/gengo v0.0.0-20240404160639-a0386bf69313/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.130.0 h1:5nB3+3HpqKqXJIXNtJdtxcDCfaa9KL8StJgMzGJkUkM= -k8s.io/klog/v2 v2.130.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 h1:bKcdZJOPICVmIIuaM9+MXmapE94dn5AYv5ODs1jA43o= +k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= diff --git a/main.go b/main.go index f21721b..762df37 100644 --- a/main.go +++ b/main.go @@ -21,8 +21,9 @@ import ( "unicode" "github.com/russross/blackfriday/v2" - "k8s.io/gengo/parser" - "k8s.io/gengo/types" + "k8s.io/gengo/v2" + "k8s.io/gengo/v2/parser" + "k8s.io/gengo/v2/types" "k8s.io/klog/v2" ) @@ -189,7 +190,7 @@ func main() { // groupName extracts the "//+groupName" meta-comment from the specified // package's comments, or returns empty string if it cannot be found. func groupName(pkg *types.Package) string { - m := types.ExtractCommentTags("+", pkg.Comments) + m := gengo.ExtractCommentTags("+", pkg.Comments) v := m["groupName"] if len(v) == 1 { return v[0] @@ -198,39 +199,43 @@ func groupName(pkg *types.Package) string { } func parseAPIPackages(dir string) ([]*types.Package, error) { - b := parser.New() - // the following will silently fail (turn on -v=4 to see logs) - if err := b.AddDirRecursive(*flAPIDir); err != nil { - return nil, err + p := parser.New() + + pkgsFound, errFind := p.FindPackages(dir + "/...") + if errFind != nil { + return nil, fmt.Errorf("failed to find packages in %s: %w", dir, errFind) + } + klog.Infof("found %d packages", len(pkgsFound)) + + errLoad := p.LoadPackages(pkgsFound...) + if errLoad != nil { + return nil, fmt.Errorf("failed to load packages: %w", errLoad) } - scan, err := b.FindTypes() + + scan, err := p.NewUniverse() if err != nil { return nil, fmt.Errorf("failed to parse pkgs and types: %w", err) } - var pkgNames []string - for p := range scan { - pkg := scan[p] + + var pkgs []*types.Package + for _, pkg := range scan { + klog.V(3).Infof("trying package=%v groupName=%s", p, groupName(pkg)) // Do not pick up packages that are in vendor/ as API packages. (This // happened in knative/eventing-sources/vendor/..., where a package // matched the pattern, but it didn't have a compatible import path). if isVendorPackage(pkg) { - klog.V(3).Infof("package=%v coming from vendor/, ignoring.", p) + klog.V(3).Infof("package=%v coming from vendor/, ignoring.", pkg.Name) continue } if groupName(pkg) != "" && len(pkg.Types) > 0 || containsString(pkg.DocComments, docCommentForceIncludes) { - klog.V(3).Infof("package=%v has groupName and has types", p) - pkgNames = append(pkgNames, p) + klog.V(3).Infof("package=%v has groupName and has types", pkg.Name) + klog.Info("using package=", pkg.Name) + pkgs = append(pkgs, pkg) } } - sort.Strings(pkgNames) - var pkgs []*types.Package - for _, p := range pkgNames { - klog.Infof("using package=%s", p) - pkgs = append(pkgs, scan[p]) - } return pkgs, nil } @@ -300,7 +305,7 @@ func combineAPIPackages(pkgs []*types.Package) ([]*apiPackage, error) { // isVendorPackage determines if package is coming from vendor/ dir. func isVendorPackage(pkg *types.Package) bool { vendorPattern := string(os.PathSeparator) + "vendor" + string(os.PathSeparator) - return strings.Contains(pkg.SourcePath, vendorPattern) + return strings.Contains(pkg.Dir, vendorPattern) } func findTypeReferences(pkgs []*apiPackage) map[*types.Type][]*types.Type { @@ -589,7 +594,7 @@ func filterCommentTags(comments []string) []string { } func isOptionalMember(m types.Member) bool { - tags := types.ExtractCommentTags("+", m.CommentLines) + tags := gengo.ExtractCommentTags("+", m.CommentLines) _, ok := tags["optional"] return ok } From 91fdeba3e825affa8f2f2cb37750a797e207be6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 07:34:15 -0700 Subject: [PATCH 16/42] Bump anchore/sbom-action from 0.16.0 to 0.17.0 (#88) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6394764..d5464fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.16.0 + uses: anchore/sbom-action/download-syft@v0.17.0 if: github.ref_type == 'tag' - name: Install Cosign From 0b5266a60447f80d181116f049157565f2f067e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 07:34:22 -0700 Subject: [PATCH 17/42] Bump actions/setup-go from 5.0.1 to 5.0.2 (#89) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5464fe..a900005 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.0.1 + uses: actions/setup-go@v5.0.2 with: go-version: stable From 58b75366a89c13e212fa5bc5ad01c7e589ac08bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 27 Jul 2024 07:34:28 -0700 Subject: [PATCH 18/42] Bump actions/checkout from 4.1.6 to 4.1.7 (#84) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a900005..23945b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: id-token: write steps: - name: Checkout Repository - uses: actions/checkout@v4.1.6 + uses: actions/checkout@v4.1.7 with: fetch-depth: 0 From 819de227e5fe85ee70022e71191d7838847e075a Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Sat, 27 Jul 2024 07:34:55 -0700 Subject: [PATCH 19/42] Add version flag (#76) --- .github/workflows/ci.yml | 4 ++++ .gitignore | 2 ++ .goreleaser.yml | 4 ++++ main.go | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23945b1..36aeea7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,3 +46,7 @@ jobs: args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Print version + run: ./dist/gen-crd-api-reference-docs_linux_amd64_v1/gen-crd-api-reference-docs -version + continue-on-error: true diff --git a/.gitignore b/.gitignore index a4d184e..dcea91a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ refdocs # goreleaser output dist + +gen-crd-api-reference-docs diff --git a/.goreleaser.yml b/.goreleaser.yml index 40ecfa4..ac18240 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,6 +8,10 @@ builds: goarch: - amd64 - arm64 + flags: + - -trimpath + ldflags: + - -s -w -X main.version={{.Version}} archives: - files: diff --git a/main.go b/main.go index 762df37..d3f8d40 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,8 @@ import ( "path/filepath" "reflect" "regexp" + "runtime" + "runtime/debug" "sort" "strconv" "strings" @@ -31,9 +33,13 @@ var ( flConfig = flag.String("config", "", "path to config file") flAPIDir = flag.String("api-dir", "", "api directory (or import path), point this to pkg/apis") flTemplateDir = flag.String("template-dir", "template", "path to template/ dir") + flVersion = flag.Bool("version", false, "print version and exit") flHTTPAddr = flag.String("http-addr", "", "start an HTTP server on specified addr to view the result (e.g. :8080)") flOutFile = flag.String("out-file", "", "path to output file to save the result") + + // set by go build + version string ) const ( @@ -83,6 +89,14 @@ func init() { flag.Set("alsologtostderr", "true") // for klog flag.Parse() + commitHash, commitTime, dirtyBuild := getBuildInfo() + arch := fmt.Sprintf("%v/%v", runtime.GOOS, runtime.GOARCH) + + if *flVersion { + fmt.Printf("gen-crd-api-reference-docs version=%s commit=%s date=%s dirty=%v arch=%s go=%v\n", version, commitHash, commitTime, dirtyBuild, arch, runtime.Version()) + os.Exit(0) + } + if *flConfig == "" { panic("-config not specified") } @@ -707,3 +721,23 @@ func render(w io.Writer, pkgs []*apiPackage, config generatorConfig) error { return nil } + +func getBuildInfo() (string, string, bool) { + var commitHash, commitTime string + var dirtyBuild bool + info, ok := debug.ReadBuildInfo() + if !ok { + return "", "", false + } + for _, kv := range info.Settings { + switch kv.Key { + case "vcs.revision": + commitHash = kv.Value + case "vcs.time": + commitTime = kv.Value + case "vcs.modified": + dirtyBuild = kv.Value == "true" + } + } + return commitHash, commitTime, dirtyBuild +} From 642c3aa7441d324f54f5a9a6a1841ffffacf5aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:00:07 -0700 Subject: [PATCH 20/42] Bump anchore/sbom-action from 0.17.0 to 0.17.1 (#92) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36aeea7..62383db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.0 + uses: anchore/sbom-action/download-syft@v0.17.1 if: github.ref_type == 'tag' - name: Install Cosign From 3c180408bdcea50621e0999c0a3d5740e7a42630 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:02:12 -0700 Subject: [PATCH 21/42] Bump anchore/sbom-action from 0.17.1 to 0.17.2 (#93) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62383db..0f53885 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.1 + uses: anchore/sbom-action/download-syft@v0.17.2 if: github.ref_type == 'tag' - name: Install Cosign From 8575eb152c3afff13086542efe957bb6c4cecf44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 08:02:21 -0700 Subject: [PATCH 22/42] Bump sigstore/cosign-installer from 3.5.0 to 3.6.0 (#91) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f53885..58e0113 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: if: github.ref_type == 'tag' - name: Install Cosign - uses: sigstore/cosign-installer@v3.5.0 + uses: sigstore/cosign-installer@v3.6.0 if: github.ref_type == 'tag' - name: Build binary From 6f15f4857a32f500a9c6796e79f5f1aa1a1f46fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:53:04 -0700 Subject: [PATCH 23/42] Bump sigstore/cosign-installer from 3.6.0 to 3.7.0 (#96) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58e0113..119a099 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: if: github.ref_type == 'tag' - name: Install Cosign - uses: sigstore/cosign-installer@v3.6.0 + uses: sigstore/cosign-installer@v3.7.0 if: github.ref_type == 'tag' - name: Build binary From a253e3bb7a5acef3bccff0752b31fb296ca2f73f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:53:40 -0700 Subject: [PATCH 24/42] Bump actions/checkout from 4.1.7 to 4.2.1 (#95) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 119a099..c826286 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: id-token: write steps: - name: Checkout Repository - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.1 with: fetch-depth: 0 From ffc4efda75d4484fb8942c41d80fa4427b5f7cd7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:46:17 -0700 Subject: [PATCH 25/42] Bump anchore/sbom-action from 0.17.2 to 0.17.3 (#97) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c826286..9b187b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.2 + uses: anchore/sbom-action/download-syft@v0.17.3 if: github.ref_type == 'tag' - name: Install Cosign From 89e979a21afc181fa3d9884012c641cc048fe2bf Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Fri, 25 Oct 2024 19:22:19 -0700 Subject: [PATCH 26/42] Update Ubuntu runner to 24.04 (#99) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b187b6..26fd579 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ permissions: jobs: build: name: Build - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 permissions: contents: write id-token: write From d381d6ec0b6b3f692c52969a6941e0456d60d5ab Mon Sep 17 00:00:00 2001 From: Bevan Arps Date: Tue, 29 Oct 2024 07:19:48 +1300 Subject: [PATCH 27/42] Fix display of maps (#66) --- main.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index d3f8d40..0eaba72 100644 --- a/main.go +++ b/main.go @@ -490,21 +490,28 @@ func typeDisplayName(t *types.Type, c generatorConfig, typePkgMap map[*types.Typ s = tryDereference(t).Name.Name } - if t.Kind == types.Pointer { - s = strings.TrimLeft(s, "*") - } - switch t.Kind { case types.Struct, types.Interface, types.Alias, - types.Pointer, - types.Slice, types.Builtin: // noop + + case types.Pointer: + // Use the display name of the element of the pointer as the display name of the pointer. + return typeDisplayName(t.Elem, c, typePkgMap) + + case types.Slice: + // Use the display name of the element of the slice to build the display name of the slice. + elemName := typeDisplayName(t.Elem, c, typePkgMap) + return fmt.Sprintf("[]%s", elemName) + case types.Map: - // return original name - return t.Name.Name + // Use the display names of the key and element types of the map to build the display name of the map. + keyName := typeDisplayName(t.Key, c, typePkgMap) + elemName := typeDisplayName(t.Elem, c, typePkgMap) + return fmt.Sprintf("map[%s]%s", keyName, elemName) + case types.DeclarationOf: // For constants, we want to display the value // rather than the name of the constant, since the @@ -519,7 +526,9 @@ func typeDisplayName(t *types.Type, c generatorConfig, typePkgMap map[*types.Typ return *t.ConstValue } + klog.Fatalf("type %s is a non-const declaration, which is unhandled", t.Name) + default: klog.Fatalf("type %s has kind=%v which is unhandled", t.Name, t.Kind) } @@ -531,10 +540,6 @@ func typeDisplayName(t *types.Type, c generatorConfig, typePkgMap map[*types.Typ } } - if t.Kind == types.Slice { - s = "[]" + s - } - return s } From 8c2a0deff4db026f9e034a859c0e0870cf853aa8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:19:57 -0700 Subject: [PATCH 28/42] Bump actions/setup-go from 5.0.2 to 5.1.0 (#100) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26fd579..7766c43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.0.2 + uses: actions/setup-go@v5.1.0 with: go-version: stable From 939ccace7bbc5b66d06e8220ef129ab732eb9c88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:20:04 -0700 Subject: [PATCH 29/42] Bump actions/checkout from 4.2.1 to 4.2.2 (#102) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7766c43..516c1fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: id-token: write steps: - name: Checkout Repository - uses: actions/checkout@v4.2.1 + uses: actions/checkout@v4.2.2 with: fetch-depth: 0 From 4e93af4f8cc5c2505d1eb0801a034b827b594754 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:20:37 -0700 Subject: [PATCH 30/42] Bump anchore/sbom-action from 0.17.3 to 0.17.5 (#101) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 516c1fa..90003da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.3 + uses: anchore/sbom-action/download-syft@v0.17.5 if: github.ref_type == 'tag' - name: Install Cosign From 71fefeed89106e8d2879b9797e5991d414336182 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:18:08 -0700 Subject: [PATCH 31/42] Bump anchore/sbom-action from 0.17.5 to 0.17.7 (#105) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90003da..c49e87e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.5 + uses: anchore/sbom-action/download-syft@v0.17.7 if: github.ref_type == 'tag' - name: Install Cosign From b86131bbe0d92eb5a1ebde25e0915cc6f978b47c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:14:52 -0800 Subject: [PATCH 32/42] Bump sigstore/cosign-installer from 3.7.0 to 3.8.0 (#112) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c49e87e..7382b14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: if: github.ref_type == 'tag' - name: Install Cosign - uses: sigstore/cosign-installer@v3.7.0 + uses: sigstore/cosign-installer@v3.8.0 if: github.ref_type == 'tag' - name: Build binary From 02d173197a64380c5963f7408d815df6af84f15e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:15:05 -0800 Subject: [PATCH 33/42] Bump anchore/sbom-action from 0.17.7 to 0.18.0 (#111) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7382b14..f04ed8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.17.7 + uses: anchore/sbom-action/download-syft@v0.18.0 if: github.ref_type == 'tag' - name: Install Cosign From a4e4190827ba18bd59dc24d89aa16fec96d27134 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:15:11 -0800 Subject: [PATCH 34/42] Bump actions/setup-go from 5.1.0 to 5.3.0 (#110) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f04ed8a..1266ae3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.1.0 + uses: actions/setup-go@v5.3.0 with: go-version: stable From b98e7d5962ff93b89bf3e1712b2cdbd8f9dd6ca7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 17:00:27 -0700 Subject: [PATCH 35/42] Bump actions/setup-go from 5.3.0 to 5.4.0 (#115) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1266ae3..d323eb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.3.0 + uses: actions/setup-go@v5.4.0 with: go-version: stable From d91c2fcd73736e5e2c8a2afd3b960207de4683db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 10:01:02 -0700 Subject: [PATCH 36/42] Bump anchore/sbom-action from 0.18.0 to 0.19.0 (#117) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d323eb0..d81f948 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.18.0 + uses: anchore/sbom-action/download-syft@v0.19.0 if: github.ref_type == 'tag' - name: Install Cosign From d24950cae654bc36b30d06229b33ccb67423dfdf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 10:01:07 -0700 Subject: [PATCH 37/42] Bump sigstore/cosign-installer from 3.8.0 to 3.8.2 (#118) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d81f948..0782e4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: if: github.ref_type == 'tag' - name: Install Cosign - uses: sigstore/cosign-installer@v3.8.0 + uses: sigstore/cosign-installer@v3.8.2 if: github.ref_type == 'tag' - name: Build binary From b72afbbef8d884f65f3b91a2cc118fb6b2eb4f89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 10:02:30 -0700 Subject: [PATCH 38/42] Bump goreleaser/goreleaser-action from 6.0.0 to 6.3.0 (#116) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0782e4f..7f575ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: if: github.ref_type == 'tag' - name: Build binary - uses: goreleaser/goreleaser-action@v6.0.0 + uses: goreleaser/goreleaser-action@v6.3.0 with: version: latest args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean From f866bd5c9e996c5a0ce0df15c6adaa337452715a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 13:15:52 -0700 Subject: [PATCH 39/42] Bump actions/setup-go from 5.4.0 to 5.5.0 (#119) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f575ff..8f0fc1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Setup Golang Environment - uses: actions/setup-go@v5.4.0 + uses: actions/setup-go@v5.5.0 with: go-version: stable From c2e9cae110cd76f0bed32f9b3472658979ba7258 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 17:35:39 -0700 Subject: [PATCH 40/42] Bump anchore/sbom-action from 0.19.0 to 0.20.0 (#121) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f0fc1d..62f2b1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: go-version: stable - name: Download Syft - uses: anchore/sbom-action/download-syft@v0.19.0 + uses: anchore/sbom-action/download-syft@v0.20.0 if: github.ref_type == 'tag' - name: Install Cosign From 3d2cdab35f73193f16d81a80580157e5c743c349 Mon Sep 17 00:00:00 2001 From: dongjiang Date: Wed, 29 Oct 2025 23:38:12 +0800 Subject: [PATCH 41/42] fix unsupported type (#109) --- go.mod | 2 +- go.sum | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8307543..3afa56c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.0 require ( github.com/russross/blackfriday/v2 v2.1.0 - k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 + k8s.io/gengo/v2 v2.0.0-20250106234829-0359904fc2a6 k8s.io/klog/v2 v2.130.1 ) diff --git a/go.sum b/go.sum index 4c38fcc..942f510 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= @@ -8,7 +10,7 @@ golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= -k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313 h1:bKcdZJOPICVmIIuaM9+MXmapE94dn5AYv5ODs1jA43o= -k8s.io/gengo/v2 v2.0.0-20240404160639-a0386bf69313/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8= +k8s.io/gengo/v2 v2.0.0-20250106234829-0359904fc2a6 h1:SdzkGIk4b5LFkVO36PuO0Bx4tpBDJDpNN0F1/v8JM5c= +k8s.io/gengo/v2 v2.0.0-20250106234829-0359904fc2a6/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= From b591789745738f89109d61a4fb7a7fdeff361bf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 08:55:27 -0700 Subject: [PATCH 42/42] Bump actions/checkout from 4.2.2 to 5.0.0 (#128) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62f2b1b..399b5cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: id-token: write steps: - name: Checkout Repository - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v5.0.0 with: fetch-depth: 0