Skip to content

Commit

Permalink
add version info
Browse files Browse the repository at this point in the history
  • Loading branch information
devorbitus committed Jun 12, 2023
1 parent 390b3a9 commit d31c8f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
# ignore:
# - goos: darwin
# goarch: arm64
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"cSpell.words": [
"akeylesslabs",
"asciicast",
"Homebrew",
"Auths",
"clientcmd",
"clientcmdapi",
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This Go CLI validates the configuration of the currently connected Kubernetes (k
It interacts with the Akeyless API Gateway and uses kubeconfig for Kubernetes interactions.

## Example

[![asciicast](https://asciinema.org/a/588498.svg)](https://asciinema.org/a/588498)

## Installation
Expand Down Expand Up @@ -43,7 +44,8 @@ The program takes the following command line arguments:
- `--token, -t`: Akeyless token, required for making authenticated requests to the Akeyless API Gateway.
- `--api-gateway-url, -u`: The URL of the Akeyless API Gateway. By default, it is set to "https://api.akeyless.io".
- `--gateway-name-filter, -g`: A filter for the name of the Akeyless Gateway.
- `--verbose, -v`: Enables verbose logging to provide detailed debug information.
- `--verbose, -V`: Enables verbose logging to provide detailed debug information.
- `--version, -v`: Prints the version of the program and exits.

#### Token

Expand Down
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type Options struct {
Token string `short:"t" long:"token" description:"Akeyless token" required:"true"`
ApiGatewayUrl string `short:"u" long:"api-gateway-url" description:"Akeyless API Gateway URL" required:"true" default:"https://api.akeyless.io"`
GatewayNameFilter string `short:"g" long:"gateway-name-filter" description:"Akeyless Gateway Name Filter" required:"false"`
Verbose bool `short:"v" long:"verbose" description:"Show verbose debug information"`
Verbose bool `short:"V" long:"verbose" description:"Show verbose debug information"`
Version bool `short:"v" long:"version" description:"Print the version number and exit" required:"false"`
}

type KubeAuthConfig struct {
Expand Down Expand Up @@ -101,6 +102,10 @@ type Status struct {
Audiences []string `json:"audiences,omitempty"`
}

// Declare a new variable that will be set during the build process.
var version string
var commit string
var date string
var token string
var timeout = 30000 * time.Millisecond
var listAllRunningGatewayKubeConfigs = make([]GatewayKubeAuthConfigs, 0)
Expand All @@ -120,6 +125,13 @@ func main() {
_, err := parser.Parse()
handleError(parser, err)

if options.Version {
fmt.Println("Version:", version)
fmt.Println("Commit:", commit)
fmt.Println("Date:", date)
os.Exit(0)
}

// Get kubeconfig path
kubeconfig, err := getKubeconfigPath()
if err != nil {
Expand Down

0 comments on commit d31c8f3

Please sign in to comment.