Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 1 | // Copyright 2017 The kubecfg authors |
| 2 | // |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | package cmd |
| 17 | |
| 18 | import ( |
| 19 | "fmt" |
| 20 | |
| 21 | jsonnet "github.com/google/go-jsonnet" |
| 22 | "github.com/spf13/cobra" |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 23 | ) |
| 24 | |
| 25 | func init() { |
| 26 | RootCmd.AddCommand(versionCmd) |
| 27 | } |
| 28 | |
| 29 | // Version is overridden by main |
Serge Bazanski | 6403361 | 2020-11-12 00:36:50 +0100 | [diff] [blame] | 30 | var Version = "unknown (external)" |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 31 | |
| 32 | var versionCmd = &cobra.Command{ |
| 33 | Use: "version", |
| 34 | Short: "Print version information", |
| 35 | Args: cobra.NoArgs, |
| 36 | Run: func(cmd *cobra.Command, args []string) { |
| 37 | out := cmd.OutOrStdout() |
Serge Bazanski | 6403361 | 2020-11-12 00:36:50 +0100 | [diff] [blame] | 38 | fmt.Fprintln(out, "kartongips, a fork of github.com/bitnami/kubecfg") |
| 39 | fmt.Fprintln(out, "hscloud version:", Version) |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 40 | fmt.Fprintln(out, "jsonnet version:", jsonnet.Version()) |
Serge Bazanski | be538db | 2020-11-12 00:22:42 +0100 | [diff] [blame] | 41 | }, |
| 42 | } |