Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Add a "version" command #22

Merged
merged 1 commit into from
May 11, 2021

Conversation

uablrek
Copy link
Contributor

@uablrek uablrek commented May 11, 2021

Adds;

kpng version

The main.version string is defined at compile time using -X main.version=(something). Example;

CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags '-static' -X main.version=$(git rev-parse --short HEAD)" -o kpng ./cmd/kpng

Now the git commit is printed;

$ ./kpng version
95df644

When developing when the commit is not updated a date may be more useful;

CGO_ENABLED=0 GOOS=linux go build -ldflags "-extldflags '-static' -X main.version=$(date +%F:%T)" -o kpng ./cmd/kpng
./kpng version
2021-05-11:11:20:36

NOTE; I have deliberately made the printout clean. No "Kpng version:" prefix or something. The version will most likely be interpreted by some script or test-report tool and unnecessary decorations are just annoying. And humans understand it just as good.

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 11, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @uablrek!

It looks like this is your first PR to kubernetes-sigs/kpng 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kpng has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 11, 2021
@uablrek
Copy link
Contributor Author

uablrek commented May 11, 2021

And IMO the "version" command and variable belongs in main.go. That's where you would expect to find it. To have it in a separate file or dir would be to over-structure things.

@mcluseau
Copy link
Contributor

thanks :)

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 11, 2021
Signed-off-by: Lars Ekman <lars.g.ekman@est.tech>
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels May 11, 2021
@uablrek
Copy link
Contributor Author

uablrek commented May 11, 2021

@mcluseau PTAL. I had to amend the commit message.
The commit is the same.

@mcluseau
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 11, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mcluseau, uablrek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit d88c59a into kubernetes-retired:master May 11, 2021
@uablrek uablrek deleted the version-cmd branch May 11, 2021 13:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants