本文整理汇总了Golang中k8s/io/kubernetes/pkg/version.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunVersion
func RunVersion(f cmdutil.Factory, out io.Writer, cmd *cobra.Command) error {
v := fmt.Sprintf("%#v", version.Get())
if cmdutil.GetFlagBool(cmd, "short") {
v = version.Get().GitVersion
}
fmt.Fprintf(out, "Client Version: %s\n", v)
if cmdutil.GetFlagBool(cmd, "client") {
return nil
}
clientset, err := f.ClientSet()
if err != nil {
return err
}
serverVersion, err := clientset.Discovery().ServerVersion()
if err != nil {
return err
}
v = fmt.Sprintf("%#v", *serverVersion)
if cmdutil.GetFlagBool(cmd, "short") {
v = serverVersion.GitVersion
}
fmt.Fprintf(out, "Server Version: %s\n", v)
return nil
}
示例2: PrintAndExitIfRequested
// PrintAndExitIfRequested will check if the -version flag was passed
// and, if so, print the version and exit.
func PrintAndExitIfRequested() {
if *versionFlag == VersionRaw {
fmt.Printf("%#v\n", version.Get())
os.Exit(0)
} else if *versionFlag == VersionTrue {
fmt.Printf("Kubernetes %s\n", version.Get())
os.Exit(0)
}
}
示例3: DefaultKubernetesUserAgent
// DefaultKubernetesUserAgent returns the default user agent that clients can use.
func DefaultKubernetesUserAgent() string {
commit := version.Get().GitCommit
if len(commit) > 7 {
commit = commit[:7]
}
if len(commit) == 0 {
commit = "unknown"
}
version := version.Get().GitVersion
seg := strings.SplitN(version, "-", 2)
version = seg[0]
return fmt.Sprintf("%s/%s (%s/%s) kubernetes/%s", path.Base(os.Args[0]), version, gruntime.GOOS, gruntime.GOARCH, commit)
}
示例4: NewVersionCommand
// NewVersionCommand creates a command for displaying the version of this binary
func NewVersionCommand(basename string, options Options) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Display version",
Run: func(c *cobra.Command, args []string) {
fmt.Printf("%s %v\n", basename, Get())
fmt.Printf("kubernetes %v\n", kubeversion.Get())
if options.PrintEtcdVersion {
fmt.Printf("etcd %v\n", etcdversion.Version)
}
if options.PrintClientFeatures {
features := []string{}
if tokencmd.BasicEnabled() {
features = append(features, "Basic-Auth")
}
if tokencmd.GSSAPIEnabled() {
features = append(features, "GSSAPI")
features = append(features, "Kerberos") // GSSAPI or SSPI
features = append(features, "SPNEGO") // GSSAPI or SSPI
}
fmt.Printf("features: %s\n", strings.Join(features, " "))
}
},
}
}
示例5: Complete
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
func (c *Config) Complete() completedConfig {
c.GenericConfig.Complete()
version := version.Get()
c.GenericConfig.Version = &version
return completedConfig{c}
}
示例6: ServerVersion
func (c *FakeDiscovery) ServerVersion() (*version.Info, error) {
action := core.ActionImpl{}
action.Verb = "get"
action.Resource = unversioned.GroupVersionResource{Resource: "version"}
c.Invokes(action, nil)
versionInfo := version.Get()
return &versionInfo, nil
}
示例7: ServerVersion
func (c *Fake) ServerVersion() (*version.Info, error) {
action := ActionImpl{}
action.Verb = "get"
action.Resource = "version"
c.Invokes(action, nil)
versionInfo := version.Get()
return &versionInfo, nil
}
示例8: NewVersionCommand
// NewVersionCommand creates a command for displaying the version of this binary
func NewVersionCommand(basename string) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Display version",
Run: func(c *cobra.Command, args []string) {
fmt.Printf("%s %v\n", basename, Get())
fmt.Printf("kubernetes %v\n", kubeversion.Get())
},
}
}
示例9: setNodeStatusVersionInfo
// Set versioninfo for the node.
func (kl *Kubelet) setNodeStatusVersionInfo(node *api.Node) {
verinfo, err := kl.cadvisor.VersionInfo()
if err != nil {
glog.Errorf("Error getting version info: %v", err)
} else {
node.Status.NodeInfo.KernelVersion = verinfo.KernelVersion
node.Status.NodeInfo.OSImage = verinfo.ContainerOsVersion
runtimeVersion := "Unknown"
if runtimeVer, err := kl.containerRuntime.Version(); err == nil {
runtimeVersion = runtimeVer.String()
}
node.Status.NodeInfo.ContainerRuntimeVersion = fmt.Sprintf("%s://%s", kl.containerRuntime.Type(), runtimeVersion)
node.Status.NodeInfo.KubeletVersion = version.Get().String()
// TODO: kube-proxy might be different version from kubelet in the future
node.Status.NodeInfo.KubeProxyVersion = version.Get().String()
}
}
示例10: Run
func (server *KubeDNSServer) Run() {
glog.Infof("%+v", version.Get())
pflag.VisitAll(func(flag *pflag.Flag) {
glog.Infof("FLAG: --%s=%q", flag.Name, flag.Value)
})
setupSignalHandlers()
server.startSkyDNSServer()
server.kd.Start()
server.setupHealthzHandlers()
glog.Infof("Setting up Healthz Handler(/readiness, /cache) on port :%d", server.healthzPort)
glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", server.healthzPort), nil))
}
示例11: TestVersion
// TestVersion tests /version
func TestVersion(t *testing.T) {
s, etcdserver, _, _ := newMaster(t)
defer etcdserver.Terminate(t)
req, _ := http.NewRequest("GET", "/version", nil)
resp := httptest.NewRecorder()
s.GenericAPIServer.InsecureHandler.ServeHTTP(resp, req)
if resp.Code != 200 {
t.Fatalf("expected http 200, got: %d", resp.Code)
}
var info version.Info
err := json.NewDecoder(resp.Body).Decode(&info)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(version.Get(), info) {
t.Errorf("Expected %#v, Got %#v", version.Get(), info)
}
}
示例12: NewVersionCommand
// NewVersionCommand creates a command for displaying the version of this binary
func NewVersionCommand(basename string, printEtcdVersion bool) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Display version",
Run: func(c *cobra.Command, args []string) {
fmt.Printf("%s %v\n", basename, Get())
fmt.Printf("kubernetes %v\n", kubeversion.Get())
if printEtcdVersion {
fmt.Printf("etcd %v\n", etcdversion.Version)
}
},
}
}
示例13: MatchesServerVersion
// MatchesServerVersion queries the server to compares the build version
// (git hash) of the client with the server's build version. It returns an error
// if it failed to contact the server or if the versions are not an exact match.
func MatchesServerVersion(client DiscoveryInterface) error {
cVer := version.Get()
sVer, err := client.ServerVersion()
if err != nil {
return fmt.Errorf("couldn't read version from server: %v\n", err)
}
// GitVersion includes GitCommit and GitTreeState, but best to be safe?
if cVer.GitVersion != sVer.GitVersion || cVer.GitCommit != sVer.GitCommit || cVer.GitTreeState != sVer.GitTreeState {
return fmt.Errorf("server version (%#v) differs from client version (%#v)!\n", sVer, cVer)
}
return nil
}
示例14: Run
// Run runs the CMServer. This should never exit.
func Run(s *options.CMServer) error {
glog.Infof("%+v", version.Get())
if c, err := configz.New("componentconfig"); err == nil {
c.Set(s.ControllerManagerConfiguration)
} else {
glog.Errorf("unable to register configz: %s", err)
}
// Create the config to talk to federation-apiserver.
kubeconfigGetter := util.KubeconfigGetterForSecret(KubeconfigSecretName)
restClientCfg, err := clientcmd.BuildConfigFromKubeconfigGetter(s.Master, kubeconfigGetter)
if err != nil || restClientCfg == nil {
// Retry with the deprecated name in 1.4.
// TODO(madhusudancs): Remove this in 1.5.
var depErr error
kubeconfigGetter := util.KubeconfigGetterForSecret(DeprecatedKubeconfigSecretName)
restClientCfg, depErr = clientcmd.BuildConfigFromKubeconfigGetter(s.Master, kubeconfigGetter)
if depErr != nil {
return fmt.Errorf("failed to find the secret containing Federation API server kubeconfig, tried the secret name %s and the deprecated name %s: %v, %v", KubeconfigSecretName, DeprecatedKubeconfigSecretName, err, depErr)
}
}
// Override restClientCfg qps/burst settings from flags
restClientCfg.QPS = s.APIServerQPS
restClientCfg.Burst = s.APIServerBurst
go func() {
mux := http.NewServeMux()
healthz.InstallHandler(mux)
if s.EnableProfiling {
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
}
mux.Handle("/metrics", prometheus.Handler())
server := &http.Server{
Addr: net.JoinHostPort(s.Address, strconv.Itoa(s.Port)),
Handler: mux,
}
glog.Fatal(server.ListenAndServe())
}()
run := func() {
err := StartControllers(s, restClientCfg)
glog.Fatalf("error running controllers: %v", err)
panic("unreachable")
}
run()
panic("unreachable")
}
示例15: main
func main() {
config := options.NewKubeDNSConfig()
config.AddFlags(pflag.CommandLine)
flag.InitFlags()
logs.InitLogs()
defer logs.FlushLogs()
verflag.PrintAndExitIfRequested()
glog.V(0).Infof("version: %+v", version.Get())
server := app.NewKubeDNSServerDefault(config)
server.Run()
}