Embed the Authorino version info into the binary#345
Merged
didierofrivia merged 1 commit intomainfrom Aug 24, 2022
Merged
Conversation
The Authorino version info can be specified as a build argument (`VERSION`) of the `docker build` command, which is then set as an ldflag in the `go build` command. When using the Makefile: 1. If `VERSION` is not specified, it defaults to the Git ref (SHA-1) of HEAD; 2. The image tag (`IMAGE_TAG`) is inferred from the value of `VERSION` (user-defined or set to default): - When it matches `^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$` (e.g. '0.10.0-pre'), the tag is set to `v$VERSION` (e.g. 'v0.10.0-pre'); - otherwise, the tag is set to fixed value 'local'. Additionally, a new parameter `IMAGE_REPO` was introduced to the Makefile (default: 'authorino'), and the existing parameter `AUTHORINO_IMAGE` now defaults to `$(IMAGE_REPO):$(IMAGE_TAG)`. In CI, `VERSION` is inferred based on `GITHUB_REF_NAME`: - When the Git ref (branch/tag name) matches `^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$`, `VERSION` is set to `GITHUB_REF_NAME` (with all slashes replaced with dashes); - otherwise, `VERSION` is set to the actual Git ref (i.e. `github.sha`) Also in this chnage: - New make target `docker-build` - Rename the binary to 'authorino' (previously: 'manager')
didierofrivia
approved these changes
Aug 24, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Authorino version info can be specified as a build argument (
VERSION) of thedocker buildcommand, which is then set as an ldflag in thego buildcommand.When using the Makefile:
VERSIONis not specified, it defaults to the Git ref (SHA-1) of HEAD;IMAGE_TAG) is inferred from the value ofVERSION(user-defined or set to default):^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$(e.g. '0.10.0-pre'), the tag is set tov$VERSION(e.g. 'v0.10.0-pre');Additionally, a new parameter
IMAGE_REPOwas introduced to the Makefile (default: 'authorino'), and the existing parameterAUTHORINO_IMAGEnow defaults to$(IMAGE_REPO):$(IMAGE_TAG).In CI,
VERSIONis inferred based onGITHUB_REF_NAME:^v[0-9]+\.[0-9]+\.[0-9]+(-.+)?$,VERSIONis set toGITHUB_REF_NAME(with all slashes replaced with dashes);VERSIONis set to the actual Git ref (i.e.github.sha)Also in this chnage:
docker-buildVerification steps
In all the scenarios below, you should be able to spot in the Auhtorino logs a message 'booting up authorino', with a label
version, set to the value of the version build argument.Scenario: Build and run the binary locally
Setup a cluster to target the service to:
Build and run the binary locally:
make build KUBECONFIG=$HOME/.kube/config ./bin/authorinoTry with a version number:
make build VERSION=0.10.0-pre KUBECONFIG=$HOME/.kube/config ./bin/authorinoCleanup:
Scenario: Build and run container image in docker
Setup a cluster to target the service to:
Build and run container image in docker:
make docker-build docker run \ -v $HOME/.kube/config:/home/.kube/config \ --env KUBECONFIG=/home/.kube/config \ --network=host \ authorino:localTry with a version number:
make docker-build VERSION=0.10.0-pre docker run \ -v $HOME/.kube/config:/home/.kube/config \ --env KUBECONFIG=/home/.kube/config \ --network=host \ authorino:v0.10.0-preCleanup:
Scenario: Build and run container image in kubernetes
Cleanup: