Skip to content

Commit

Permalink
codegen
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Oct 6, 2023
1 parent a44ee22 commit ca0e0d1
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w
- -s -w -X github.com/kyverno/kyverno-json/pkg/version.BuildVersion={{ .Version }}

signs:
- cmd: cosign
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ CLI_DIR := $(CMD_DIR)/cli
CLI_BIN := kyverno-json
CGO_ENABLED ?= 0
GOOS ?= $(shell go env GOOS)
LD_FLAGS ?= "-s -w"
ifdef VERSION
LD_FLAGS := "-s -w -X $(PACKAGE)/pkg/version.BuildVersion=$(VERSION)"
else
LD_FLAGS := "-s -w"
endif

.PHONY: fmt
fmt: ## Run go fmt
Expand Down
1 change: 1 addition & 0 deletions docs/user/commands/kyverno-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ kyverno-json [flags]
* [kyverno-json docs](kyverno-json_docs.md) - Generates reference documentation.
* [kyverno-json jp](kyverno-json_jp.md) - Provides a command-line interface to JMESPath, enhanced with custom functions.
* [kyverno-json scan](kyverno-json_scan.md) - scan
* [kyverno-json version](kyverno-json_version.md) - Prints the version informations.

31 changes: 31 additions & 0 deletions docs/user/commands/kyverno-json_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## kyverno-json version

Prints the version informations.

### Synopsis

Prints the version informations.


```
kyverno-json version [flags]
```

### Examples

```
# Print version infos
kyverno-json version
```

### Options

```
-h, --help help for version
```

### SEE ALSO

* [kyverno-json](kyverno-json.md) - kyverno-json

2 changes: 1 addition & 1 deletion pkg/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestRootCommand(t *testing.T) {
cmd := RootCommand()
assert.NotNil(t, cmd)
assert.Len(t, cmd.Commands(), 3)
assert.Len(t, cmd.Commands(), 4)
err := cmd.Execute()
assert.NoError(t, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/kyverno/kyverno-json/pkg/command"
"github.com/kyverno/kyverno/pkg/version"
"github.com/kyverno/kyverno-json/pkg/version"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/version/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/kyverno/kyverno/pkg/version"
"github.com/kyverno/kyverno-json/pkg/version"
"github.com/stretchr/testify/assert"
)

Expand Down
43 changes: 43 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package version

import (
"runtime/debug"
)

// BuildVersion is provided by govvv at compile-time
var BuildVersion string

func Version() string {
if BuildVersion == "" {
bi, ok := debug.ReadBuildInfo()
if !ok {
return "---"
}
BuildVersion = bi.Main.Version
}
return BuildVersion
}

func Time() string {
bi, ok := debug.ReadBuildInfo()
if ok {
for _, setting := range bi.Settings {
if setting.Key == "vcs.time" {
return setting.Value
}
}
}
return "---"
}

func Hash() string {
bi, ok := debug.ReadBuildInfo()
if ok {
for _, setting := range bi.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return "---"
}
1 change: 1 addition & 0 deletions website/docs/commands/kyverno-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ kyverno-json [flags]
* [kyverno-json docs](kyverno-json_docs.md) - Generates reference documentation.
* [kyverno-json jp](kyverno-json_jp.md) - Provides a command-line interface to JMESPath, enhanced with custom functions.
* [kyverno-json scan](kyverno-json_scan.md) - scan
* [kyverno-json version](kyverno-json_version.md) - Prints the version informations.

31 changes: 31 additions & 0 deletions website/docs/commands/kyverno-json_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## kyverno-json version

Prints the version informations.

### Synopsis

Prints the version informations.


```
kyverno-json version [flags]
```

### Examples

```
# Print version infos
kyverno-json version
```

### Options

```
-h, --help help for version
```

### SEE ALSO

* [kyverno-json](kyverno-json.md) - kyverno-json

0 comments on commit ca0e0d1

Please sign in to comment.