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

add version flavour, print version command #229

Merged
merged 1 commit into from
May 24, 2024

Conversation

ph4r05
Copy link
Collaborator

@ph4r05 ph4r05 commented May 22, 2024

Changes from PS fork

@ph4r05 ph4r05 requested a review from rgooch May 22, 2024 19:16
Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 32.09%. Comparing base (9ce86fc) to head (69fd87f).

Files Patch % Lines
cmd/keymaster/main.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #229      +/-   ##
==========================================
- Coverage   32.35%   32.09%   -0.27%     
==========================================
  Files          75       75              
  Lines        9710     9713       +3     
==========================================
- Hits         3142     3117      -25     
- Misses       5930     5957      +27     
- Partials      638      639       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rgooch
rgooch previously requested changes May 22, 2024
Makefile Outdated
@@ -12,8 +12,10 @@ BINARY=keymaster
# These are the values we want to pass for Version and BuildTime
VERSION=1.15.3
DEFAULT_HOST?=
DEFAULT_LDFLAGS=-X main.Version=${VERSION}
CLIENT_LDFLAGS=${DEFAULT_LDFLAGS} -X main.defaultHost=${DEFAULT_HOST}
VERSION_FLAVOUR?=cf
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the "upstream" version should have a flavour. It's the default. This should be the empty string.

Copy link
Collaborator Author

@ph4r05 ph4r05 May 22, 2024

Choose a reason for hiding this comment

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

can it be main / upstream? Otherwise it prints "1.15.3-" as the version without further changes.

Copy link
Member

Choose a reason for hiding this comment

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

This can be solved by having the flavour string that's injected contain a leading -.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok changed

Copy link
Contributor

Choose a reason for hiding this comment

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

Why so many changes? I would have done this with a new conditional on the makefile and a new variable:

PRINTVERSION=version
ifeq ($(FLAVOR),)
PRINTVERTION = ${VERSION}-${FLAVOR}

And then use the printversion to the build instead of version.

Also I dont like using the useragent string for something else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thats doable as well :) so maybe lets close this PR and when you have it done I will merge it to the PS fork.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or modify this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

modify this PR :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done @cviecco

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, I still believe that useragent is better for debugging than the plain version as it contains also OS and Arch. If somebody pastes this in the report, it saves time / roundtrips for questions which OS do you use.

@ph4r05 ph4r05 requested a review from rgooch May 22, 2024 19:30
Copy link
Member

@rgooch rgooch left a comment

Choose a reason for hiding this comment

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

OK, thanks. @cviecco: any concerns?

@rgooch rgooch requested review from rgooch and cviecco May 22, 2024 19:33
@rgooch rgooch dismissed their stale review May 22, 2024 19:34

My issues are resolved.

@ph4r05 ph4r05 force-pushed the pr branch 2 times, most recently from 6180709 to 6c3868f Compare May 23, 2024 07:33
@ph4r05
Copy link
Collaborator Author

ph4r05 commented May 23, 2024

I've also added Makefile as a single source of truth for version. keymaster.spec is then generated in the makefile with sed. It is technically not needed for Windows but I am doing it anyway - tested on our windows builders.

Copy link
Contributor

@cviecco cviecco left a comment

Choose a reason for hiding this comment

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

@rgooch any other issues?

@@ -496,6 +497,10 @@ func main() {
flag.Usage = Usage
flag.Parse()
logger := cmdlogger.New()
if *printVersion {
fmt.Println(Version)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use the logger instead of directly using fmt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the thing is that logger prints it out to stderr, it made more sense to me to print it to stdout

Comment on lines 283 to 284
main()
close(done)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not really a good test as you are not even checking for the output of the call or its side-effects. Testing main IS complicated. And I think the way that is needed is to make a new : mainWithError(logger log.Logger) error. That basically does everything except that it no longer calls fatal, but returns and error. And the main will just call this mainWithError with the initialized logger. Now we can start testing mainWithError. And check for the return types and the sideEffects.

Not for today (unless you want too).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cviecco I added the test, pls check

- make makefile single source of truth for version
- trigger the flow in the tests
@cviecco cviecco merged commit f35df8b into Cloud-Foundations:master May 24, 2024
7 of 9 checks passed
@ph4r05 ph4r05 deleted the pr branch May 24, 2024 15:00
ph4r05 added a commit to ph4r05/keymaster that referenced this pull request May 28, 2024
* add flavour, version command, fix version source (Cloud-Foundations#229)

- make makefile single source of truth for version
- trigger the flow in the tests

* minor tests enhancements (Cloud-Foundations#232)

---------

Co-authored-by: Dušan Klinec <[email protected]>
Co-authored-by: cviecco <[email protected]>
ph4r05 added a commit to ph4r05/keymaster that referenced this pull request Jun 12, 2024
* add flavour, version command, fix version source (Cloud-Foundations#229)

- make makefile single source of truth for version
- trigger the flow in the tests

* minor tests enhancements (Cloud-Foundations#232)

* Docker cleanup (Cloud-Foundations#233)

* Removed unnecessary `start.sh`
* Updated Dockerfile to newer OS
* Cleaned up Dockerfile dirty hack for RSA keys

Co-authored-by: Espinoza, Erik <[email protected]>

* enable to specify agent connection to insert cert to (Cloud-Foundations#231)

* enable to specify agent connection to insert cert to

* add api

* bump version

---------

Co-authored-by: Dušan Klinec <[email protected]>

---------

Co-authored-by: Dušan Klinec <[email protected]>
Co-authored-by: cviecco <[email protected]>
Co-authored-by: Erik Espinoza <[email protected]>
Co-authored-by: Espinoza, Erik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants