Skip to content

Commit

Permalink
Client gen refactor (#1159)
Browse files Browse the repository at this point in the history
* Move generated files to a common location under `/api/generated`
(Instead of duplicating cli and frontend).
* Update `k8s.io/code-generator` to v0.30.0
* Add generation of the above files to CI and ensure it is up to date.
* Update e2e-test for Java in verify.bats
  • Loading branch information
RonFed committed May 2, 2024
1 parent cd103b1 commit b6d25a0
Show file tree
Hide file tree
Showing 163 changed files with 4,811 additions and 1,842 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/e2e/bats/utilities.bash
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ assert_regex() {
}

assert_not_empty() {
EMPTY=(\"\")
if [[ "$1" == "${EMPTY}" ]]; then
if [[ -z "$1" ]]; then
{
echo
echo "-- 💥 value is empty 💥 --"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e/bats/verify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ JS_SCOPE="@opentelemetry/instrumentation-http"
}

@test "client, server :: spans have same trace ID" {
client_trace_id=$(server_spans_from_scope_named ${JAVA_CLIENT_SCOPE} | jq ".traceId")
client_trace_id=$(client_spans_from_scope_named ${JAVA_CLIENT_SCOPE} | jq ".traceId" | uniq)
assert_not_empty "$client_trace_id"
server_trace_id=$(client_spans_from_scope_named ${JAVA_SCOPE} | jq ".traceId")
server_trace_id=$(server_spans_from_scope_named ${JAVA_SCOPE} | jq ".traceId" | uniq)
assert_not_empty "$server_trace_id"
assert_equal "$server_trace_id" "$client_trace_id"
}
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/verify-api-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ jobs:
echo "api CRDs are not up to date. Please run 'make generate && make manifests' and commit the changes."
exit 1
fi
- name: Generate client files
run: make generate-client
- name: Verify Generate
run: |
if [[ $(git diff --exit-code) ]]; then
git diff
echo "client files are not up to date. Please run 'make generate-client' and commit the changes."
exit 1
fi
3 changes: 2 additions & 1 deletion api/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
1. Update the relevant CRD `go` file in the `api/odigos` directory.
2. Run `make generate` to update the auto generated `zz_generated.deepcopy.go` file.
3. Run `make manifests` to update the CRD yaml files in the `config/crd/bases` directory.
4. Update the code in `cli` module to reflect the changes in the CRD in the `cli/cmd/resources/crds` directory
4. Run `make generate-client` to update the auto generated files under `api/generated`.
5. Update the code in `cli` module to reflect the changes in the CRD in the `cli/cmd/resources/crds` directory

## CRD versioning

Expand Down
6 changes: 6 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: generate-client
generate-client:
GOWORK=off go mod vendor
./hack/update-codegen.sh
rm -rf ./vendor
File renamed without changes.

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

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

Loading

0 comments on commit b6d25a0

Please sign in to comment.