Skip to content

Commit d1ea083

Browse files
nitishtdvaldivia
andauthored
Add version command (minio#511)
Also remove additional flags from the proxy command. Fixes minio#502 Fixes minio#478 Co-authored-by: Daniel Valdivia <[email protected]>
1 parent c1d3307 commit d1ea083

File tree

3 files changed

+77
-5
lines changed

3 files changed

+77
-5
lines changed

kubectl-minio/cmd/kubectl-minio.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ func NewCmdMinIO(streams genericclioptions.IOStreams) *cobra.Command {
6666
rootCmd.AddCommand(newTenantCmd(rootCmd.OutOrStdout(), rootCmd.ErrOrStderr()))
6767
rootCmd.AddCommand(newDeleteCmd(rootCmd.OutOrStdout(), rootCmd.ErrOrStderr()))
6868
rootCmd.AddCommand(newProxyCmd(rootCmd.OutOrStdout(), rootCmd.ErrOrStderr()))
69+
rootCmd.AddCommand(newVersionCmd(rootCmd.OutOrStdout(), rootCmd.ErrOrStderr()))
6970
return rootCmd
7071
}

kubectl-minio/cmd/proxy.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ func newProxyCmd(out io.Writer, errOut io.Writer) *cobra.Command {
7676
}
7777
cmd = helpers.DisableHelp(cmd)
7878
f := cmd.Flags()
79-
f.StringVarP(&o.operatorOpts.Image, "image", "i", helpers.DefaultOperatorImage, "operator image")
8079
f.StringVarP(&o.operatorOpts.Namespace, "namespace", "n", helpers.DefaultNamespace, "namespace scope for this request")
81-
f.StringVarP(&o.operatorOpts.ClusterDomain, "cluster-domain", "d", helpers.DefaultClusterDomain, "cluster domain of the Kubernetes cluster")
82-
f.StringVar(&o.operatorOpts.NSToWatch, "namespace-to-watch", "", "namespace where operator looks for MinIO tenants, leave empty for all namespaces")
83-
f.StringVar(&o.operatorOpts.ImagePullSecret, "image-pull-secret", "", "image pull secret to be used for pulling operator image")
84-
f.BoolVarP(&o.output, "output", "o", false, "dry run this command and generate requisite yaml")
8580

8681
return cmd
8782
}

kubectl-minio/cmd/version.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* This file is part of MinIO Operator
3+
* Copyright (C) 2021, MinIO, Inc.
4+
*
5+
* This code is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License, version 3,
7+
* as published by the Free Software Foundation.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License, version 3,
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>
16+
*
17+
*/
18+
19+
package cmd
20+
21+
import (
22+
"errors"
23+
"fmt"
24+
"io"
25+
26+
"k8s.io/klog/v2"
27+
28+
"github.com/minio/kubectl-minio/cmd/helpers"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
// version provides the version of this plugin
33+
var version = "DEVELOPMENT.GOGET"
34+
35+
const (
36+
operatorVersionDesc = `
37+
'version' command displays the kubectl plugin version.`
38+
operatorVersionExample = ` kubectl minio version`
39+
)
40+
41+
type operatorVersionCmd struct {
42+
out io.Writer
43+
errOut io.Writer
44+
output bool
45+
}
46+
47+
func newVersionCmd(out io.Writer, errOut io.Writer) *cobra.Command {
48+
o := &operatorVersionCmd{out: out, errOut: errOut}
49+
50+
cmd := &cobra.Command{
51+
Use: "version",
52+
Short: "Display plugin version",
53+
Long: operatorVersionDesc,
54+
Example: operatorVersionExample,
55+
RunE: func(cmd *cobra.Command, args []string) error {
56+
if len(args) != 0 {
57+
return errors.New("this command does not accept arguments")
58+
}
59+
err := o.run()
60+
if err != nil {
61+
klog.Warning(err)
62+
return err
63+
}
64+
return nil
65+
},
66+
}
67+
cmd = helpers.DisableHelp(cmd)
68+
69+
return cmd
70+
}
71+
72+
// run initializes local config and installs MinIO Operator to Kubernetes cluster.
73+
func (o *operatorVersionCmd) run() error {
74+
fmt.Println(version)
75+
return nil
76+
}

0 commit comments

Comments
 (0)