From f76b4c3aa28f54a75d94e47c0bbceeed8a8b4ccb Mon Sep 17 00:00:00 2001 From: Matt Schuchard Date: Wed, 26 Jun 2024 17:19:26 -0400 Subject: [PATCH] modify verbose from bool to int for level of verbose --- provisioner/testinfra.go | 6 +++--- provisioner/testinfra.hcl2spec.go | 4 ++-- provisioner/testinfra_test.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/provisioner/testinfra.go b/provisioner/testinfra.go index 18abbbe..103d72c 100644 --- a/provisioner/testinfra.go +++ b/provisioner/testinfra.go @@ -28,7 +28,7 @@ type Config struct { Sudo bool `mapstructure:"sudo" required:"false"` SudoUser string `mapstructure:"sudo_user" required:"false"` TestFiles []string `mapstructure:"test_files" required:"false"` - Verbose bool `mapstructure:"verbose" required:"false"` + Verbose int `mapstructure:"verbose" required:"false"` ctx interpolate.Context } @@ -175,8 +175,8 @@ func (provisioner *Provisioner) Prepare(raws ...interface{}) error { } // verbose parameter - if provisioner.config.Verbose { - log.Print("pytest will execute with verbosity enabled") + if provisioner.config.Verbose > 0 { + log.Print("pytest will execute with verbose enabled at level %d", provisioner.config.Verbose) } // check if testinfra files are specified as inputs diff --git a/provisioner/testinfra.hcl2spec.go b/provisioner/testinfra.hcl2spec.go index 8920f05..5e1fb16 100644 --- a/provisioner/testinfra.hcl2spec.go +++ b/provisioner/testinfra.hcl2spec.go @@ -20,7 +20,7 @@ type FlatConfig struct { Sudo *bool `mapstructure:"sudo" required:"false" cty:"sudo" hcl:"sudo"` SudoUser *string `mapstructure:"sudo_user" required:"false" cty:"sudo_user" hcl:"sudo_user"` TestFiles []string `mapstructure:"test_files" required:"false" cty:"test_files" hcl:"test_files"` - Verbose *bool `mapstructure:"verbose" required:"false" cty:"verbose" hcl:"verbose"` + Verbose *int `mapstructure:"verbose" required:"false" cty:"verbose" hcl:"verbose"` } // FlatMapstructure returns a new FlatConfig. @@ -45,7 +45,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec { "sudo": &hcldec.AttrSpec{Name: "sudo", Type: cty.Bool, Required: false}, "sudo_user": &hcldec.AttrSpec{Name: "sudo_user", Type: cty.String, Required: false}, "test_files": &hcldec.AttrSpec{Name: "test_files", Type: cty.List(cty.String), Required: false}, - "verbose": &hcldec.AttrSpec{Name: "verbose", Type: cty.Bool, Required: false}, + "verbose": &hcldec.AttrSpec{Name: "verbose", Type: cty.Number, Required: false}, } return s } diff --git a/provisioner/testinfra_test.go b/provisioner/testinfra_test.go index 798bb30..05dc1c1 100644 --- a/provisioner/testinfra_test.go +++ b/provisioner/testinfra_test.go @@ -23,7 +23,7 @@ var basicConfig = &Config{ Sudo: true, SudoUser: "fooman", TestFiles: []string{"fixtures/test.py"}, - Verbose: true, + Verbose: 1, } // test basic config for packer template/config data @@ -98,8 +98,8 @@ func TestProvisionerPrepareMinimal(test *testing.T) { test.Errorf("default empty setting for SudoUser is incorrect: %s", provisioner.config.SudoUser) } - if provisioner.config.Verbose == true { - test.Errorf("default false setting for Verbose is incorrect: %t", provisioner.config.Verbose) + if provisioner.config.Verbose != 0 { + test.Errorf("default empty setting for Verbose is incorrect: %d", provisioner.config.Verbose) } if provisioner.config.PytestPath != "py.test" {