|
| 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