Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version command #3379

Merged
merged 2 commits into from
Jan 13, 2023
Merged

feat: add version command #3379

merged 2 commits into from
Jan 13, 2023

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Jan 13, 2023

What this PR does / why we need it:

This is a bit more than the commit message would say it is but when I was going through the Makefile I discovered that the build target uses incorrect paths to set the ldflags, i.e.

$(REPO_URL)/v2/internal/metadata.Release=$(TAG)

should be

$(REPO_URL)/v2/internal/manager/metadata.Release=$(TAG)

Hence this PR also contains that change and propagates usage of unified Makefile targets for building in Dockerfile.

Additionally in order to actually test that the binary contains the desired version information that we'd like it to I added version command so that the binary can be run for the sole reason to check the version information and get it in the following form:

{"release":"v2.8.1-23-gde3af6e2","repo":"git@github.com:Kong/kubernetes-ingress-controller.git","commit":"de3af6e2"}

As a cleanup exercises this PR also reformats some of the flags descriptions so that they align properly when binary usage information is printed out.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@pmalek pmalek added this to the KIC v2.9.0 milestone Jan 13, 2023
@pmalek pmalek self-assigned this Jan 13, 2023
@pmalek pmalek added the area/feature New feature or request label Jan 13, 2023
@pmalek pmalek marked this pull request as ready for review January 13, 2023 18:06
@pmalek pmalek requested a review from a team as a code owner January 13, 2023 18:06
@pmalek pmalek enabled auto-merge (squash) January 13, 2023 19:08
@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Base: 74.1% // Head: 74.1% // Increases project coverage by +0.0% 🎉

Coverage data is based on head (6819381) compared to base (d31fb3d).
Patch coverage: 29.1% of modified lines in pull request are covered.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3379   +/-   ##
=====================================
  Coverage   74.1%   74.1%           
=====================================
  Files        110     110           
  Lines      13268   13285   +17     
=====================================
+ Hits        9837    9851   +14     
- Misses      2804    2813    +9     
+ Partials     627     621    -6     
Impacted Files Coverage Δ
internal/cmd/rootcmd/rootcmd.go 0.0% <0.0%> (ø)
internal/manager/config.go 91.8% <100.0%> (ø)
internal/dataplane/kongstate/service.go 66.0% <0.0%> (-1.3%) ⬇️
internal/controllers/gateway/gateway_utils.go 90.0% <0.0%> (-0.5%) ⬇️
internal/dataplane/parser/parser.go 92.1% <0.0%> (+0.8%) ⬆️
...nternal/controllers/gateway/tlsroute_controller.go 78.4% <0.0%> (+5.2%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the local smoke test to confirm new make functionality? Checking out and trying to build results in some error:

11:59:25-0800 esenin $ make build                     
make[1]: Entering directory '/tmp/kubernetes-ingress-controller'
(cd third_party && go mod tidy && \
	GOBIN=/tmp/kubernetes-ingress-controller/bin go generate -tags=third_party ./controller-gen.go )
make[1]: Leaving directory '/tmp/kubernetes-ingress-controller'
/tmp/kubernetes-ingress-controller/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go generate /tmp/kubernetes-ingress-controller/internal/cmd
make[1]: Entering directory '/tmp/kubernetes-ingress-controller'
(cd third_party && go mod tidy && \
	GOBIN=/tmp/kubernetes-ingress-controller/bin go generate -tags=third_party ./client-gen.go )
make[1]: Leaving directory '/tmp/kubernetes-ingress-controller'
/tmp/kubernetes-ingress-controller/bin/client-gen \
	--go-header-file ./hack/boilerplate.go.txt \
	--logtostderr \
	--clientset-name clientset \
	--input-base github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/  \
	--input configuration/v1,configuration/v1beta1,configuration/v1alpha1 \
	--input-dirs github.com/kong/kubernetes-ingress-controller/pkg/apis/configuration/v1alpha1/,github.com/kong/kubernetes-ingress-controller/pkg/apis/configuration/v1beta1/,github.com/kong/kubernetes-ingress-controller/pkg/apis/configuration/v1/ \
	--output-base pkg/ \
	--output-package github.com/kong/kubernetes-ingress-controller/v2/pkg/ \
	--trim-path-prefix pkg/github.com/kong/kubernetes-ingress-controller/v2/
CRDS_STANDARD_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' github.com/kubernetes-sigs/gateway-api/config/crd/?ref=v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller'\
	CRDS_EXPERIMENTAL_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller' \
	RAW_REPO_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller' \
	INPUT=/tmp/kubernetes-ingress-controller/test/internal/cmd/generate-gateway-api-urls/gateway_consts.tmpl \
	OUTPUT=/tmp/kubernetes-ingress-controller/test/consts/zz_generated_gateway.go \
	go generate -tags=generate_gateway_api_urls ./test/internal/cmd/generate-gateway-api-urls
/bin/sh: line 1: Entering: command not found
make: *** [Makefile:561: generate.gateway-api-urls] Error 127

line indications suggest something around some of the generator targets, but those seem fine when run independently:

12:02:11-0800 esenin $ make print-gateway-api-crds-url      
github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.1
12:02:22-0800 esenin $ make print-gateway-api-raw-repo-url
https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v0.5.

something is making sh unhappy though I have no idea what, and -x and shellcheck aren't properly screaming as to what exactly the problem is.

@pmalek
Copy link
Member Author

pmalek commented Jan 13, 2023

@rainest weird 🤔 Works on my machine ™️

How about make generate.gateway-api-urls?

@rainest
Copy link
Contributor

rainest commented Jan 13, 2023

some sort of make default that you have and I don't? added a commit that should make it consistent.

13:10:44-0800 esenin $ make generate.gateway-api-urls                             
+zsh:39> make generate.gateway-api-urls
CRDS_STANDARD_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' github.com/kubernetes-sigs/gateway-api/config/crd/?ref=v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller'\
	CRDS_EXPERIMENTAL_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller' \
	RAW_REPO_URL=make[1]: Entering directory '/tmp/kubernetes-ingress-controller' https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v0.5.1 make[1]: Leaving directory '/tmp/kubernetes-ingress-controller' \
	INPUT=/tmp/kubernetes-ingress-controller/test/internal/cmd/generate-gateway-api-urls/gateway_consts.tmpl \
	OUTPUT=/tmp/kubernetes-ingress-controller/test/consts/zz_generated_gateway.go \
	go generate -tags=generate_gateway_api_urls ./test/internal/cmd/generate-gateway-api-urls
/bin/sh: line 1: Entering: command not found
make: *** [Makefile:561: generate.gateway-api-urls] Error 127

13:10:48-0800 esenin $ make --no-print-directory generate.gateway-api-urls                             
+zsh:40> make --no-print-directory generate.gateway-api-urls              
CRDS_STANDARD_URL=github.com/kubernetes-sigs/gateway-api/config/crd/?ref=v0.5.1\
	CRDS_EXPERIMENTAL_URL=github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v0.5.1 \
	RAW_REPO_URL=https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/v0.5.1 \
	INPUT=/tmp/kubernetes-ingress-controller/test/internal/cmd/generate-gateway-api-urls/gateway_consts.tmpl \
	OUTPUT=/tmp/kubernetes-ingress-controller/test/consts/zz_generated_gateway.go \
	go generate -tags=generate_gateway_api_urls ./test/internal/cmd/generate-gateway-api-url

@pmalek pmalek merged commit d17356f into main Jan 13, 2023
@pmalek pmalek deleted the add-version-command branch January 13, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants