Skip to content

Commit

Permalink
chore: fix crdgen issue after upgrading (#1361)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
whynowy authored Sep 24, 2021
1 parent 89019dc commit 5b5b145
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 29 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
- name: Install protoc
run: |
set -eux -o pipefail
PROTOC_ZIP=protoc-3.11.1-linux-x86_64.zip
PROTOC_VERSION=3.11.1
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.11.1/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
Expand All @@ -42,11 +43,12 @@ jobs:
- name: Install pandoc
run: |
set -eux -o pipefail
PANDOC_ZIP=pandoc-2.11.1-linux-amd64.tar.gz
curl -OL https://github.com/jgm/pandoc/releases/download/2.11.1/$PANDOC_ZIP
PANDOC_VERSION=2.14.2
PANDOC_ZIP=pandoc-$PANDOC_VERSION-linux-amd64.tar.gz
curl -OL https://github.com/jgm/pandoc/releases/download/$PANDOC_VERSION/$PANDOC_ZIP
sudo tar xvzf $PANDOC_ZIP --strip-components 1 -C /usr/local
rm -f $PANDOC_ZIP
echo /usr/local/pandoc-2.11.1/bin >> $GITHUB_PATH
echo /usr/local/pandoc-$PANDOC_VERSION/bin >> $GITHUB_PATH
- name: Get dependencies
run: go mod download
- name: Make codegen
Expand Down
6 changes: 3 additions & 3 deletions api/event-bus.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions api/event-source.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions api/sensor.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions hack/crdgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ fi
header "Generating CRDs"
controller-gen crd:crdVersions=v1,trivialVersions=true,maxDescLen=0 paths=./pkg/apis/... output:dir=manifests/base/crds

mv manifests/base/crds/argoproj.io_eventbuses.yaml manifests/base/crds/argoproj.io_eventbus.yaml

find manifests/base/crds -name 'argoproj.io*.yaml' | while read -r file; do
echo "Patching ${file}"
# remove junk fields
Expand Down
7 changes: 7 additions & 0 deletions hack/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ func cleanCRD(filename string) {
}
delete(crd, "status")
metadata := crd["metadata"].(obj)
if metadata["name"] == "eventbuses.argoproj.io" {
metadata["name"] = "eventbus.argoproj.io"
}
delete(metadata, "annotations")
delete(metadata, "creationTimestamp")
spec := crd["spec"].(obj)
delete(spec, "validation")
names := spec["names"].(obj)
if names["plural"] == "eventbuses" {
names["plural"] = "eventbus"
}
versions := spec["versions"].([]interface{})
version := versions[0].(obj)
properties := version["schema"].(obj)["openAPIV3Schema"].(obj)["properties"].(obj)
Expand Down
1 change: 1 addition & 0 deletions hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -o pipefail
source $(dirname $0)/library.sh
header "generating proto files"

ensure_protobuf
ensure_vendor

if [ "`command -v protoc-gen-gogo`" = "" ]; then
Expand Down
7 changes: 7 additions & 0 deletions hack/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ ensure_pandoc() {
fi
}

ensure_protobuf() {
if [ "`command -v protoc`" = "" ]; then
warning "Please install protobuf with - brew install protobuf"
exit 1
fi
}

ensure_mockery() {
if [ "`command -v mockery`" = "" ]; then
warning "Please install mockery with - brew install vektra/tap/mockery"
Expand Down

0 comments on commit 5b5b145

Please sign in to comment.