func (v *versionCmd) run() error { // Regardless of whether we can talk to server or not, just print the client // version. cv := version.GetVersionProto() fmt.Fprintf(v.out, "Client: %#v\n", cv) resp, err := v.client.GetVersion() if err != nil { if grpc.Code(err) == codes.Unimplemented { return errors.New("server is too old to know its version") } return err } fmt.Fprintf(v.out, "Server: %#v\n", resp.Version) return nil }
func (v *versionCmd) run() error { if v.showClient { cv := version.GetVersionProto() fmt.Fprintf(v.out, "Client: %#v\n", cv) } if !v.showServer { return nil } resp, err := v.client.GetVersion() if err != nil { if grpc.Code(err) == codes.Unimplemented { return errors.New("server is too old to know its version") } return err } fmt.Fprintf(v.out, "Server: %#v\n", resp.Version) return nil }
func TestVersion(t *testing.T) { lver := version.GetVersionProto().SemVer sver := "1.2.3-fakeclient+testonly" tests := []struct { name string client, server bool args []string fail bool }{ {"default", true, true, []string{}, false}, {"client", true, false, []string{"-c"}, false}, {"server", false, true, []string{"-s"}, false}, } for _, tt := range tests { b := new(bytes.Buffer) c := &fakeReleaseClient{} cmd := newVersionCmd(c, b) cmd.ParseFlags(tt.args) if err := cmd.RunE(cmd, tt.args); err != nil { if tt.fail { continue } t.Fatal(err) } if tt.client && !strings.Contains(b.String(), lver) { t.Errorf("Expected %q to contain %q", b.String(), lver) } if tt.server && !strings.Contains(b.String(), sver) { t.Errorf("Expected %q to contain %q", b.String(), sver) } } }
func (v *versionCmd) run() error { if v.showClient { cv := version.GetVersionProto() fmt.Fprintf(v.out, "Client: %s\n", formatVersion(cv, v.short)) } if !v.showServer { return nil } resp, err := v.client.GetVersion() if err != nil { if grpc.Code(err) == codes.Unimplemented { return errors.New("server is too old to know its version") } if flagDebug { fmt.Fprintln(os.Stderr, err) } return errors.New("cannot connect to Tiller") } fmt.Fprintf(v.out, "Server: %s\n", formatVersion(resp.Version, v.short)) return nil }
func (s *releaseServer) GetVersion(c ctx.Context, req *services.GetVersionRequest) (*services.GetVersionResponse, error) { v := version.GetVersionProto() return &services.GetVersionResponse{Version: v}, nil }