-
Notifications
You must be signed in to change notification settings - Fork 731
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
chore: Adding version info for gk, opa, and frameworks in gator cmd #2338
Conversation
@JaydipGabani looks like tests are failing |
@sozercan we are good to go for reviews! |
go.mod
Outdated
@@ -27,6 +27,7 @@ require ( | |||
github.com/onsi/gomega v1.19.0 | |||
github.com/open-policy-agent/cert-controller v0.4.0 | |||
github.com/open-policy-agent/frameworks/constraint v0.0.0-20221006234738-a3d297b3152f | |||
github.com/open-policy-agent/opa v0.44.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to add opa version here but get the dependency through frameworks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So fetch the version from mod file similar to frameworks/constraint
?
gator.Dockerfile
Outdated
@@ -22,7 +22,7 @@ COPY . /tmp/gatekeeper | |||
|
|||
WORKDIR /tmp/gatekeeper/cmd/gator | |||
|
|||
RUN go build -mod vendor -a -ldflags "${LDFLAGS:--X github.com/open-policy-agent/gatekeeper/pkg/version.Version=latest}" -o /gator | |||
RUN go build -mod vendor -a -ldflags "${LDFLAGS}" -o /gator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's keep the default if LDFLAGS is not passed
Makefile
Outdated
@@ -22,6 +22,7 @@ BATS_TESTS_FILE ?= test/bats/test.bats | |||
HELM_VERSION ?= 3.7.2 | |||
NODE_VERSION ?= 16-bullseye-slim | |||
YQ_VERSION ?= 4.2.0 | |||
FRAMEWORK_VERSION ?= $(shell go list -f '{{ .Version }}' -m github.com/open-policy-agent/frameworks/constraint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FRAMEWORK_VERSION ?= $(shell go list -f '{{ .Version }}' -m github.com/open-policy-agent/frameworks/constraint) | |
FRAMEWORKS_VERSION ?= $(shell go list -f '{{ .Version }}' -m github.com/open-policy-agent/frameworks/constraint) |
Makefile
Outdated
@@ -45,6 +46,8 @@ LDFLAGS := "-X github.com/open-policy-agent/gatekeeper/pkg/version.Version=$(VER | |||
-X github.com/open-policy-agent/gatekeeper/pkg/version.Timestamp=$(BUILD_TIMESTAMP) \ | |||
-X github.com/open-policy-agent/gatekeeper/pkg/version.Hostname=$(BUILD_HOSTNAME)" | |||
|
|||
GTRFLAGS := ${LDFLAGS} "-X main.frameworkVersion=$(FRAMEWORK_VERSION)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can add frameworksVersion
to LDFLAGS as it applies there too
cmd/gator/gator.go
Outdated
"github.com/spf13/cobra" | ||
) | ||
|
||
const version = "alpha" | ||
var frameworkVersion = "v0.0.0-20221006234738-a3d297b3152f" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this get set? can we skip hardcoding this?
Codecov ReportBase: 53.45% // Head: 53.50% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2338 +/- ##
==========================================
+ Coverage 53.45% 53.50% +0.04%
==========================================
Files 116 116
Lines 10174 10174
==========================================
+ Hits 5439 5444 +5
+ Misses 4317 4313 -4
+ Partials 418 417 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
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. |
Makefile
Outdated
-t ${GATOR_REPOSITORY}:${DEV_TAG} \ | ||
-t ${GATOR_REPOSITORY}:dev \ | ||
-f gator.Dockerfile . --push | ||
-f gator.Dockerfile . --load |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to revert this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!! I missed this
Makefile
Outdated
@@ -367,10 +371,10 @@ docker-buildx-crds-release: build-crds docker-buildx-builder | |||
|
|||
# Build gator image | |||
docker-buildx-gator-dev: docker-buildx-builder | |||
docker buildx build --build-arg LDFLAGS=${LDFLAGS} --platform "linux/amd64,linux/arm64,linux/arm/v6"\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were these platform versions removed for local testing? If so should we add this back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!! I missed this
cmd/gator/gator.go
Outdated
@@ -24,7 +28,7 @@ func init() { | |||
var rootCmd = &cobra.Command{ | |||
Use: "gator subcommand", | |||
Short: "gator is a suite of authorship tools for Gatekeeper", | |||
Version: version, | |||
Version: fmt.Sprintf("\nGator & Gatekeeper version: %s, OPA version: %s, Framework version: %s", version.Version, opaVersion, frameworksVersion), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version: fmt.Sprintf("\nGator & Gatekeeper version: %s, OPA version: %s, Framework version: %s", version.Version, opaVersion, frameworksVersion), | |
Version: fmt.Sprintf("\nGator version: %s (Feature State: %s), OPA version: %s, Framework version: %s", version.Version, state, opaVersion, frameworksVersion), |
state is alpha
cmd/gator/gator.go
Outdated
var frameworksVersion string | ||
|
||
var opaVersion string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var frameworksVersion string | |
var opaVersion string | |
var ( | |
frameworksVersion string | |
opaVersion string | |
) |
Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for the PR!
Signed-off-by: Jaydip Gabani gabanijaydip@gmail.com
What this PR does / why we need it:
Adds more information in output of
gator --version
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when the PR gets merged):Fixes #1643
Special notes for your reviewer:
Result: