Skip to content

Commit

Permalink
use the upstream kubernetes version lib and ldflags (sigstore#1413)
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <n3wscott@chainguard.dev>
  • Loading branch information
n3wscott authored and mlieberman85 committed May 6, 2022
1 parent 6da9ec2 commit 51ae750
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 294 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ endif
PLATFORMS=darwin linux windows
ARCHITECTURES=amd64

PKG=github.com/sigstore/cosign/pkg/version
LDFLAGS=-X $(PKG).GitVersion=$(GIT_VERSION) -X $(PKG).gitCommit=$(GIT_HASH) -X $(PKG).gitTreeState=$(GIT_TREESTATE) -X $(PKG).buildDate=$(BUILD_DATE)
LDFLAGS=-X sigs.k8s.io/release-utils/version.gitVersion=$(GIT_VERSION) \
-X sigs.k8s.io/release-utils/version.gitCommit=$(GIT_HASH) \
-X sigs.k8s.io/release-utils/version.gitTreeState=$(GIT_TREESTATE) \
-X sigs.k8s.io/release-utils/version.buildDate=$(BUILD_DATE)

SRCS = $(shell find cmd -iname "*.go") $(shell find pkg -iname "*.go")

Expand Down
3 changes: 2 additions & 1 deletion cmd/cosign/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/google/go-containerregistry/pkg/logs"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/release-utils/version"

cranecmd "github.com/google/go-containerregistry/cmd/crane/cmd"
"github.com/sigstore/cosign/cmd/cosign/cli/options"
Expand Down Expand Up @@ -92,7 +93,7 @@ func New() *cobra.Command {
cmd.AddCommand(VerifyAttestation())
cmd.AddCommand(VerifyBlob())
cmd.AddCommand(Triangulate())
cmd.AddCommand(Version())
cmd.AddCommand(version.Version())

cmd.AddCommand(cranecmd.NewCmdAuthLogin("cosign"))
return cmd
Expand Down
4 changes: 2 additions & 2 deletions cmd/cosign/cli/options/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"fmt"
"runtime"

"github.com/sigstore/cosign/pkg/version"
"sigs.k8s.io/release-utils/version"
)

var (
// uaString is meant to resemble the User-Agent sent by browsers with requests.
// See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
uaString = fmt.Sprintf("cosign/%s (%s; %s)", version.GitVersion, runtime.GOOS, runtime.GOARCH)
uaString = fmt.Sprintf("cosign/%s (%s; %s)", version.GetVersionInfo().GitVersion, runtime.GOOS, runtime.GOARCH)
)

// UserAgent returns the User-Agent string which `cosign` should send with HTTP requests.ß
Expand Down
54 changes: 0 additions & 54 deletions cmd/cosign/cli/version.go

This file was deleted.

37 changes: 0 additions & 37 deletions cmd/cosign/cli/version_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/cosign/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (
"knative.dev/pkg/webhook/resourcesemantics"
"knative.dev/pkg/webhook/resourcesemantics/defaulting"
"knative.dev/pkg/webhook/resourcesemantics/validation"
"sigs.k8s.io/release-utils/version"

cwebhook "github.com/sigstore/cosign/pkg/cosign/kubernetes/webhook"
"github.com/sigstore/cosign/pkg/version"
)

var secretName = flag.String("secret-name", "", "The name of the secret in the webhook's namespace that holds the public key for verification.")
Expand Down
3 changes: 2 additions & 1 deletion cmd/sget/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/release-utils/version"

"github.com/sigstore/cosign/cmd/sget/cli/options"
"github.com/sigstore/cosign/pkg/sget"
Expand Down Expand Up @@ -54,7 +55,7 @@ func New() *cobra.Command {
ro.AddFlags(cmd)

// Add sub-commands.
cmd.AddCommand(Version())
cmd.AddCommand(version.Version())

return cmd
}
Expand Down
55 changes: 0 additions & 55 deletions cmd/sget/cli/version.go

This file was deleted.

37 changes: 0 additions & 37 deletions cmd/sget/cli/version_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion doc/cosign.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions doc/cosign_version.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ require (
k8s.io/client-go v0.22.5
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704
knative.dev/pkg v0.0.0-20220121092305-3ba5d72e310a
sigs.k8s.io/release-utils v0.4.1-0.20220207182343-6dadf2228617
)

require (
Expand Down
Loading

0 comments on commit 51ae750

Please sign in to comment.