2014-10-06 01:24:19 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2014-12-10 20:16:18 +00:00
|
|
|
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
|
2014-10-06 01:24:19 +00:00
|
|
|
)
|
|
|
|
|
2014-11-17 18:29:45 +00:00
|
|
|
func (f *Factory) NewCmdVersion(out io.Writer) *cobra.Command {
|
2014-10-06 01:24:19 +00:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "version",
|
|
|
|
Short: "Print version of client and server",
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2014-11-10 17:09:32 +00:00
|
|
|
if GetFlagBool(cmd, "client") {
|
2014-10-06 01:24:19 +00:00
|
|
|
kubectl.GetClientVersion(out)
|
|
|
|
} else {
|
2014-12-10 20:16:18 +00:00
|
|
|
config, err := f.ClientConfig.ClientConfig()
|
|
|
|
checkErr(err)
|
|
|
|
client, err := client.New(config)
|
2014-11-17 18:29:45 +00:00
|
|
|
checkErr(err)
|
|
|
|
|
|
|
|
kubectl.GetVersion(out, client)
|
2014-10-06 01:24:19 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cmd.Flags().BoolP("client", "c", false, "Client version only (no server required)")
|
|
|
|
return cmd
|
|
|
|
}
|