Merge pull request #11202 from hashicorp/jbardin/vet

vet all packages
This commit is contained in:
James Bardin 2017-01-13 17:56:16 -05:00 committed by GitHub
commit d2d2cfd1c5
10 changed files with 25 additions and 26 deletions

View File

@ -1,5 +1,4 @@
TEST?=$$(go list ./... | grep -v '/terraform/vendor/' | grep -v '/builtin/bins/') TEST?=$$(go list ./... | grep -v '/terraform/vendor/' | grep -v '/builtin/bins/')
VETARGS?=-all
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
default: test vet default: test vet
@ -74,8 +73,8 @@ cover:
# vet runs the Go source code static analysis tool `vet` to find # vet runs the Go source code static analysis tool `vet` to find
# any common errors. # any common errors.
vet: vet:
@echo "go tool vet $(VETARGS) ." @echo "go vet ."
@go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \ @go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \ echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \ echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \ echo "and fix them if necessary before submitting the code for review."; \

View File

@ -172,7 +172,7 @@ func testAccCheckAWSOpsworksCreateAppAttributes(
opsapp *opsworks.App) resource.TestCheckFunc { opsapp *opsworks.App) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
if *opsapp.EnableSsl { if *opsapp.EnableSsl {
return fmt.Errorf("Unexpected enable ssl: %s", *opsapp.EnableSsl) return fmt.Errorf("Unexpected enable ssl: %t", *opsapp.EnableSsl)
} }
if *opsapp.Attributes["DocumentRoot"] != "foo" { if *opsapp.Attributes["DocumentRoot"] != "foo" {
@ -215,7 +215,7 @@ func testAccCheckAWSOpsworksUpdateAppAttributes(
} }
if !*opsapp.EnableSsl { if !*opsapp.EnableSsl {
return fmt.Errorf("Unexpected enable ssl: %s", *opsapp.EnableSsl) return fmt.Errorf("Unexpected enable ssl: %t", *opsapp.EnableSsl)
} }
if *opsapp.SslConfiguration.Certificate != "-----BEGIN CERTIFICATE-----\nMIIBkDCB+gIJALoScFD0sJq3MA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNVBAYTAkRF\nMB4XDTE1MTIxOTIwMzU1MVoXDTE2MDExODIwMzU1MVowDTELMAkGA1UEBhMCREUw\ngZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKKQKbTTH/Julz16xY7ArYlzJYCP\nedTCx1bopuryCx/+d1gC94MtRdlPSpQl8mfc9iBdtXbJppp73Qh/DzLzO9Ns25xZ\n+kUQMhbIyLsaCBzuEGLgAaVdGpNvRBw++UoYtd0U7QczFAreTGLH8n8+FIzuI5Mc\n+MJ1TKbbt5gFfRSzAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEALARo96wCDmaHKCaX\nS0IGLGnZCfiIUfCmBxOXBSJxDBwter95QHR0dMGxYIujee5n4vvavpVsqZnfMC3I\nOZWPlwiUJbNIpK+04Bg2vd5m/NMMrvi75RfmyeMtSfq/NrIX2Q3+nyWI7DLq7yZI\nV/YEvOqdAiy5NEWBztHx8HvB9G4=\n-----END CERTIFICATE-----" { if *opsapp.SslConfiguration.Certificate != "-----BEGIN CERTIFICATE-----\nMIIBkDCB+gIJALoScFD0sJq3MA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNVBAYTAkRF\nMB4XDTE1MTIxOTIwMzU1MVoXDTE2MDExODIwMzU1MVowDTELMAkGA1UEBhMCREUw\ngZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKKQKbTTH/Julz16xY7ArYlzJYCP\nedTCx1bopuryCx/+d1gC94MtRdlPSpQl8mfc9iBdtXbJppp73Qh/DzLzO9Ns25xZ\n+kUQMhbIyLsaCBzuEGLgAaVdGpNvRBw++UoYtd0U7QczFAreTGLH8n8+FIzuI5Mc\n+MJ1TKbbt5gFfRSzAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEALARo96wCDmaHKCaX\nS0IGLGnZCfiIUfCmBxOXBSJxDBwter95QHR0dMGxYIujee5n4vvavpVsqZnfMC3I\nOZWPlwiUJbNIpK+04Bg2vd5m/NMMrvi75RfmyeMtSfq/NrIX2Q3+nyWI7DLq7yZI\nV/YEvOqdAiy5NEWBztHx8HvB9G4=\n-----END CERTIFICATE-----" {
@ -234,7 +234,7 @@ func testAccCheckAWSOpsworksUpdateAppAttributes(
} }
if !reflect.DeepEqual(expectedAttrs, opsapp.Attributes) { if !reflect.DeepEqual(expectedAttrs, opsapp.Attributes) {
return fmt.Errorf("Unnexpected Attributes: %s", opsapp.Attributes) return fmt.Errorf("Unnexpected Attributes: %v", aws.StringValueMap(opsapp.Attributes))
} }
expectedAppSource := &opsworks.Source{ expectedAppSource := &opsworks.Source{
@ -270,7 +270,7 @@ func testAccCheckAWSOpsworksUpdateAppAttributes(
} }
if !reflect.DeepEqual(expectedDomains, opsapp.Domains) { if !reflect.DeepEqual(expectedDomains, opsapp.Domains) {
return fmt.Errorf("Unnexpected Daomins : %s", opsapp.Domains) return fmt.Errorf("Unnexpected Daomins : %v", aws.StringValueSlice(opsapp.Domains))
} }
return nil return nil

View File

@ -185,23 +185,23 @@ func testAccCheckAWSOpsworksCreateLayerAttributes(
if *opslayer.AutoAssignElasticIps { if *opslayer.AutoAssignElasticIps {
return fmt.Errorf( return fmt.Errorf(
"Unexpected AutoAssignElasticIps: %s", *opslayer.AutoAssignElasticIps) "Unexpected AutoAssignElasticIps: %t", *opslayer.AutoAssignElasticIps)
} }
if !*opslayer.EnableAutoHealing { if !*opslayer.EnableAutoHealing {
return fmt.Errorf( return fmt.Errorf(
"Unexpected EnableAutoHealing: %s", *opslayer.EnableAutoHealing) "Unexpected EnableAutoHealing: %t", *opslayer.EnableAutoHealing)
} }
if !*opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained { if !*opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained {
return fmt.Errorf( return fmt.Errorf(
"Unexpected DelayUntilElbConnectionsDrained: %s", "Unexpected DelayUntilElbConnectionsDrained: %t",
*opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained) *opslayer.LifecycleEventConfiguration.Shutdown.DelayUntilElbConnectionsDrained)
} }
if *opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout != 300 { if *opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout != 300 {
return fmt.Errorf( return fmt.Errorf(
"Unexpected ExecutionTimeout: %s", "Unexpected ExecutionTimeout: %d",
*opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout) *opslayer.LifecycleEventConfiguration.Shutdown.ExecutionTimeout)
} }
@ -215,7 +215,7 @@ func testAccCheckAWSOpsworksCreateLayerAttributes(
} }
if !reflect.DeepEqual(expectedPackages, opslayer.Packages) { if !reflect.DeepEqual(expectedPackages, opslayer.Packages) {
return fmt.Errorf("Unexpected Packages: %s", opslayer.Packages) return fmt.Errorf("Unexpected Packages: %v", aws.StringValueSlice(opslayer.Packages))
} }
expectedEbsVolumes := []*opsworks.VolumeConfiguration{ expectedEbsVolumes := []*opsworks.VolumeConfiguration{

View File

@ -130,11 +130,11 @@ func testAccCheckAWSOpsworksCreatePermissionAttributes(
opsperm *opsworks.Permission, allowSsh bool, allowSudo bool, level string) resource.TestCheckFunc { opsperm *opsworks.Permission, allowSsh bool, allowSudo bool, level string) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
if *opsperm.AllowSsh != allowSsh { if *opsperm.AllowSsh != allowSsh {
return fmt.Errorf("Unnexpected allowSsh: %s", *opsperm.AllowSsh) return fmt.Errorf("Unnexpected allowSsh: %t", *opsperm.AllowSsh)
} }
if *opsperm.AllowSudo != allowSudo { if *opsperm.AllowSudo != allowSudo {
return fmt.Errorf("Unnexpected allowSudo: %s", *opsperm.AllowSudo) return fmt.Errorf("Unnexpected allowSudo: %t", *opsperm.AllowSudo)
} }
if *opsperm.Level != level { if *opsperm.Level != level {

View File

@ -257,7 +257,7 @@ func testAccCheckAWSOpsworksCreateStackAttributes(
} }
if *opsstack.UseOpsworksSecurityGroups { if *opsstack.UseOpsworksSecurityGroups {
return fmt.Errorf("Unnexpected UseOpsworksSecurityGroups: %s", *opsstack.UseOpsworksSecurityGroups) return fmt.Errorf("Unnexpected UseOpsworksSecurityGroups: %t", *opsstack.UseOpsworksSecurityGroups)
} }
return nil return nil
@ -292,11 +292,11 @@ func testAccCheckAWSOpsworksUpdateStackAttributes(
} }
if !*opsstack.UseCustomCookbooks { if !*opsstack.UseCustomCookbooks {
return fmt.Errorf("Unnexpected UseCustomCookbooks: %s", *opsstack.UseCustomCookbooks) return fmt.Errorf("Unnexpected UseCustomCookbooks: %t", *opsstack.UseCustomCookbooks)
} }
if !*opsstack.ChefConfiguration.ManageBerkshelf { if !*opsstack.ChefConfiguration.ManageBerkshelf {
return fmt.Errorf("Unnexpected ManageBerkshelf: %s", *opsstack.ChefConfiguration.ManageBerkshelf) return fmt.Errorf("Unnexpected ManageBerkshelf: %t", *opsstack.ChefConfiguration.ManageBerkshelf)
} }
if *opsstack.CustomCookbooksSource.Type != "git" { if *opsstack.CustomCookbooksSource.Type != "git" {

View File

@ -74,7 +74,7 @@ func testAccCheckAWSOpsworksUserProfileExists(
opsuserprofile := *resp.UserProfiles[0] opsuserprofile := *resp.UserProfiles[0]
if *opsuserprofile.AllowSelfManagement { if *opsuserprofile.AllowSelfManagement {
return fmt.Errorf("Unnexpected allowSelfManagement: %s", return fmt.Errorf("Unnexpected allowSelfManagement: %t",
*opsuserprofile.AllowSelfManagement) *opsuserprofile.AllowSelfManagement)
} }

View File

@ -71,7 +71,7 @@ func TestIngnitionFilesystem(t *testing.T) {
} }
if f.Mount.Create != nil { if f.Mount.Create != nil {
return fmt.Errorf("mount, create was found %q", f.Mount.Create) return fmt.Errorf("mount, create was found %#v", f.Mount.Create)
} }
f = c.Storage.Filesystems[2] f = c.Storage.Filesystems[2]
@ -88,7 +88,7 @@ func TestIngnitionFilesystem(t *testing.T) {
} }
if f.Mount.Create.Force != true { if f.Mount.Create.Force != true {
return fmt.Errorf("mount.0.force, found %q", f.Mount.Create.Force) return fmt.Errorf("mount.0.force, found %t", f.Mount.Create.Force)
} }
if len(f.Mount.Create.Options) != 1 || f.Mount.Create.Options[0] != "rw" { if len(f.Mount.Create.Options) != 1 || f.Mount.Create.Options[0] != "rw" {

View File

@ -32,7 +32,7 @@ func TestIngnitionRaid(t *testing.T) {
} }
if len(a.Devices) != 1 || a.Devices[0] != "/foo" { if len(a.Devices) != 1 || a.Devices[0] != "/foo" {
return fmt.Errorf("devices, found %d", a.Devices) return fmt.Errorf("devices, found %v", a.Devices)
} }
if a.Level != "raid10" { if a.Level != "raid10" {

View File

@ -42,11 +42,11 @@ func TestIngnitionSystemdUnit(t *testing.T) {
} }
if u.Mask != true { if u.Mask != true {
return fmt.Errorf("mask, found %q", u.Mask) return fmt.Errorf("mask, found %t", u.Mask)
} }
if u.Enable != false { if u.Enable != false {
return fmt.Errorf("enable, found %q", u.Enable) return fmt.Errorf("enable, found %t", u.Enable)
} }
if len(u.DropIns) != 1 { if len(u.DropIns) != 1 {

View File

@ -66,7 +66,7 @@ func TestIngnitionUser(t *testing.T) {
} }
if u.Create.NoCreateHome != true { if u.Create.NoCreateHome != true {
return fmt.Errorf("no_create_home, found %q", u.Create.NoCreateHome) return fmt.Errorf("no_create_home, found %t", u.Create.NoCreateHome)
} }
if u.Create.PrimaryGroup != "primary_group" { if u.Create.PrimaryGroup != "primary_group" {
@ -78,11 +78,11 @@ func TestIngnitionUser(t *testing.T) {
} }
if u.Create.NoUserGroup != true { if u.Create.NoUserGroup != true {
return fmt.Errorf("no_create_home, found %q", u.Create.NoCreateHome) return fmt.Errorf("no_create_home, found %t", u.Create.NoCreateHome)
} }
if u.Create.NoLogInit != true { if u.Create.NoLogInit != true {
return fmt.Errorf("no_log_init, found %q", u.Create.NoLogInit) return fmt.Errorf("no_log_init, found %t", u.Create.NoLogInit)
} }
if u.Create.Shell != "shell" { if u.Create.Shell != "shell" {