Skip to content

Commit 0ccb948

Browse files
authored
Use GetBaseVersion method from kutil (#316)
1 parent 8c5e6ff commit 0ccb948

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

run.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import (
88
"github.com/appscode/go/log"
99
stringz "github.com/appscode/go/strings"
1010
v "github.com/appscode/go/version"
11+
"github.com/appscode/kutil/discovery"
1112
"github.com/appscode/pat"
1213
api "github.com/appscode/stash/apis/stash"
1314
cs "github.com/appscode/stash/client/typed/stash/v1alpha1"
1415
"github.com/appscode/stash/pkg/controller"
1516
"github.com/appscode/stash/pkg/docker"
16-
"github.com/hashicorp/go-version"
1717
"github.com/prometheus/client_golang/prometheus/promhttp"
1818
"github.com/spf13/cobra"
1919
crd_cs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
@@ -49,15 +49,10 @@ func NewCmdRun() *cobra.Command {
4949
crdClient := crd_cs.NewForConfigOrDie(config)
5050

5151
// get kube api server version
52-
info, err := kubeClient.Discovery().ServerVersion()
52+
opts.KubectlImageTag, err = discovery.GetBaseVersion(kubeClient.Discovery())
5353
if err != nil {
54-
log.Fatalf("Error getting server version, reason: %s\n", err)
54+
log.Fatalf("Failed to detect server version, reason: %s\n", err)
5555
}
56-
gv, err := version.NewVersion(info.GitVersion)
57-
if err != nil {
58-
log.Fatalf("Failed to parse server version, reason: %s\n", err)
59-
}
60-
opts.KubectlImageTag = gv.ToMutator().ResetMetadata().ResetPrerelease().ResetPatch().String()
6156

6257
ctrl := controller.New(kubeClient, crdClient, stashClient, opts)
6358
err = ctrl.Setup()

0 commit comments

Comments
 (0)