Skip to content

Commit

Permalink
clean up ineffectual assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
lfarnell committed Aug 7, 2017
1 parent c96c154 commit d9a5b69
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion builder/azure/pkcs12/bmp-string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestBMPString(t *testing.T) {

// some character outside the BMP should error
tst = "\U0001f000 East wind (Mahjong)"
str, err = bmpString(tst)
_, err = bmpString(tst)
if err == nil {
t.Errorf("expected '%s' to throw error because the first character is not in the BMP", tst)
}
Expand Down
2 changes: 0 additions & 2 deletions builder/azure/pkcs12/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func pbDecrypterFor(algorithm pkix.AlgorithmIdentifier, password []byte) (cipher

k := deriveKeyByAlg[algorithmName](params.Salt, password, params.Iterations)
iv := deriveIVByAlg[algorithmName](params.Salt, password, params.Iterations)
password = nil

code, err := blockcodeByAlg[algorithmName](k)
if err != nil {
Expand All @@ -34,7 +33,6 @@ func pbDecrypterFor(algorithm pkix.AlgorithmIdentifier, password []byte) (cipher

func pbDecrypt(info decryptable, password []byte) (decrypted []byte, err error) {
cbc, err := pbDecrypterFor(info.GetAlgorithm(), password)
password = nil
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion builder/azure/pkcs12/pbkdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func pbkdf(hash func([]byte) []byte, u, v int, salt, password []byte, r int, ID
for len(P) < times*v {
P = append(P, password...)
}
password = nil
P = P[:times*v]
}

Expand Down
5 changes: 3 additions & 2 deletions packer/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package plugin

import (
"fmt"
"github.com/hashicorp/packer/packer"
"log"
"os"
"os/exec"
"testing"
"time"

"github.com/hashicorp/packer/packer"
)

func helperProcess(s ...string) *exec.Cmd {
Expand Down Expand Up @@ -48,7 +49,7 @@ func TestHelperProcess(*testing.T) {
os.Exit(2)
}

cmd, args := args[0], args[1:]
cmd, _ := args[0], args[1:]
switch cmd {
case "bad-version":
fmt.Printf("%s1|tcp|:1234\n", APIVersion)
Expand Down
5 changes: 3 additions & 2 deletions post-processor/vagrant-cloud/step_release_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package vagrantcloud

import (
"fmt"
"strings"

"github.com/hashicorp/packer/packer"
"github.com/mitchellh/multistep"
"strings"
)

type stepReleaseVersion struct {
Expand All @@ -30,7 +31,7 @@ func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction

if err != nil || (resp.StatusCode != 200) {
cloudErrors := &VagrantCloudErrors{}
err = decodeBody(resp, cloudErrors)
_ = decodeBody(resp, cloudErrors)
if strings.Contains(cloudErrors.FormatErrors(), "already been released") {
ui.Message("Not releasing version, already released")
return multistep.ActionContinue
Expand Down
3 changes: 3 additions & 0 deletions provisioner/powershell/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func TestProvisionerPrepare_extractScript(t *testing.T) {
// File contents should contain 2 lines concatenated by newlines: foo\nbar
readFile, err := ioutil.ReadFile(file)
expectedContents := "foo\nbar\n"
if err != nil {
t.Fatalf("Should not be error: %s", err)
}
s := string(readFile[:])
if s != expectedContents {
t.Fatalf("Expected generated inlineScript to equal '%s', got '%s'", expectedContents, s)
Expand Down
3 changes: 3 additions & 0 deletions provisioner/puppet-masterless/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
delete(config, "facter")
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.Facter == nil {
t.Fatalf("err: Default facts are not set in the Puppet provisioner!")
}
Expand Down
6 changes: 5 additions & 1 deletion provisioner/puppet-server/provisioner_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package puppetserver

import (
"github.com/hashicorp/packer/packer"
"io/ioutil"
"os"
"testing"

"github.com/hashicorp/packer/packer"
)

func testConfig() map[string]interface{} {
Expand Down Expand Up @@ -167,6 +168,9 @@ func TestProvisionerPrepare_facterFacts(t *testing.T) {
delete(config, "facter")
p = new(Provisioner)
err = p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
if p.config.Facter == nil {
t.Fatalf("err: Default facts are not set in the Puppet provisioner!")
}
Expand Down
6 changes: 5 additions & 1 deletion provisioner/windows-shell/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"bytes"
"errors"
"fmt"
"github.com/hashicorp/packer/packer"
"io/ioutil"
"log"
"os"
"strings"
"testing"
"time"

"github.com/hashicorp/packer/packer"
)

func testConfig() map[string]interface{} {
Expand All @@ -34,6 +35,9 @@ func TestProvisionerPrepare_extractScript(t *testing.T) {

// File contents should contain 2 lines concatenated by newlines: foo\nbar
readFile, err := ioutil.ReadFile(file)
if err != nil {
t.Fatalf("Should not be error: %s", err)
}
expectedContents := "foo\nbar\n"
s := string(readFile[:])
if s != expectedContents {
Expand Down

0 comments on commit d9a5b69

Please sign in to comment.