Skip to content

Commit

Permalink
Fix staticcheck issues value of XXX is never used
Browse files Browse the repository at this point in the history
See,
$ $ golangci-lint run --skip-dirs '^vim25/xml/*' --disable-all --enable=staticcheck
  • Loading branch information
mjtrangoni committed Mar 14, 2019
1 parent 88f294e commit 499a882
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions govc/library/item/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func (cmd *upload) Run(ctx context.Context, f *flag.FlagSet) error {
defer file.Close()

fileInfo, err := file.Stat()
if err != nil {
return err
}
size := fileInfo.Size()

hash := md5.New()
Expand Down
14 changes: 14 additions & 0 deletions govc/library/ova.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ func (of *OVAFile) Close() error {
// getOVAFileInfo opens an OVA, finds the file entry, and returns both the size and md5 checksum
func getOVAFileInfo(ovafile string, filename string) (int64, string, error) {
of, err := NewOVAFile(ovafile)
if err != nil {
return 0, "", err
}

hdr, err := of.Find(filename)
if err != nil {
return 0, "", err
}

hash := md5.New()
_, err = io.Copy(hash, of)
Expand Down Expand Up @@ -169,6 +176,9 @@ func uploadFile(ctx context.Context, m *library.Manager, sessionID string, ovafi

// Setup to point to the OVA file to be transferred
_, err = of.Find(filename)
if err != nil {
return err
}

req, err := http.NewRequest("PUT", addFileInfo.UploadEndpoint.URI, of)
if err != nil {
Expand Down Expand Up @@ -201,7 +211,11 @@ func (cmd *ova) Run(ctx context.Context, f *flag.FlagSet) error {
if err != nil {
return err
}

hdr, err := o.Next()
if err != nil {
return err
}

// Per the OVA spec, the first file must be the .ovf file.
if !strings.HasSuffix(hdr.Name, ".ovf") {
Expand Down
8 changes: 8 additions & 0 deletions govc/vcenter/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func getOVFItemID(ctx context.Context, c *rest.Client, libname string, ovfname s
if err != nil {
return "", err
}

res, err := m.GetLibraryItems(ctx, library.ID)
if err != nil {
return "", err
}

for _, r := range res {
if r.Name == ovfname || r.ID == ovfname {
Expand Down Expand Up @@ -134,6 +138,10 @@ func (cmd *deploy) Run(ctx context.Context, f *flag.FlagSet) error {
}

filterResponse, err := m.FilterLibraryItem(ctx, ovfItemID, filter)
if err != nil {
return err
}

fmt.Printf("Found OVA for deployment: %s\n", filterResponse.Name)

deploy := vcenter.Deploy{
Expand Down
4 changes: 2 additions & 2 deletions object/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...str
p := property.DefaultCollector(v.c)

// Wait for all NICs to have a MacAddress, which may not be generated yet.
err := property.Wait(ctx, p, v.Reference(), []string{"config.hardware.device"}, func(pc []types.PropertyChange) bool {
_ = property.Wait(ctx, p, v.Reference(), []string{"config.hardware.device"}, func(pc []types.PropertyChange) bool {
for _, c := range pc {
if c.Op != types.PropertyChangeOpAssign {
continue
Expand Down Expand Up @@ -296,7 +296,7 @@ func (v VirtualMachine) WaitForNetIP(ctx context.Context, v4 bool, device ...str
}
}

err = property.Wait(ctx, p, v.Reference(), []string{"guest.net"}, func(pc []types.PropertyChange) bool {
err := property.Wait(ctx, p, v.Reference(), []string{"guest.net"}, func(pc []types.PropertyChange) bool {
for _, c := range pc {
if c.Op != types.PropertyChangeOpAssign {
continue
Expand Down
3 changes: 1 addition & 2 deletions toolbox/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func TestVixRelayedCommandHandler(t *testing.T) {
// header.UserCredentialType not set
header.OpCode = vix.CommandStartProgram
request := new(vix.StartProgramRequest)
buf := marshal(request)
reply, _ = cmd.Dispatch(marshal())
rc = vixRC(reply)
if rc != vix.AuthenticationFail {
Expand All @@ -181,7 +180,7 @@ func TestVixRelayedCommandHandler(t *testing.T) {
header.CredentialLength = uint32(len(creds))

// ProgramPath not set
buf = append(marshal(request), creds...)
buf := append(marshal(request), creds...)
reply, _ = cmd.Dispatch(buf)
rc = vixRC(reply)
if rc != vix.FileNotFound {
Expand Down

0 comments on commit 499a882

Please sign in to comment.