Skip to content

Commit

Permalink
move logsecretfilter into packer sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
SwampDragons committed Nov 30, 2020
1 parent 14bdb95 commit a6fdeca
Show file tree
Hide file tree
Showing 45 changed files with 74 additions and 96 deletions.
2 changes: 1 addition & 1 deletion builder/alicloud/ecs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}

packer.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey)
packersdk.LogSecretFilter.Set(b.config.AlicloudAccessKey, b.config.AlicloudSecretKey)
return nil, nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion builder/amazon/chroot/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
generatedData := awscommon.GetGeneratedDataList()
generatedData = append(generatedData, "Device", "MountPath")

Expand Down
3 changes: 1 addition & 2 deletions builder/amazon/common/step_get_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/retry"
Expand Down Expand Up @@ -92,7 +91,7 @@ WaitLoop:
}
// store so that we can access this later during provisioning
state.Put("winrm_password", s.Comm.WinRMPassword)
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)

return multistep.ActionContinue
}
Expand Down
2 changes: 1 addition & 1 deletion builder/amazon/ebs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)

generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil
Expand Down
2 changes: 1 addition & 1 deletion builder/amazon/ebssurrogate/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)

generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil
Expand Down
2 changes: 1 addition & 1 deletion builder/amazon/ebsvolume/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)

generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil
Expand Down
2 changes: 1 addition & 1 deletion builder/amazon/instance/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, warns, errs
}
packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)

generatedData := awscommon.GetGeneratedDataList()
return generatedData, warns, nil
Expand Down
3 changes: 1 addition & 2 deletions builder/azure/arm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/hashicorp/packer/builder/azure/common/constants"
"github.com/hashicorp/packer/builder/azure/pkcs12"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -690,7 +689,7 @@ func setRuntimeValues(c *Config) {

c.tmpAdminPassword = tempName.AdminPassword
// store so that we can access this later during provisioning
packer.LogSecretFilter.Set(c.tmpAdminPassword)
packersdk.LogSecretFilter.Set(c.tmpAdminPassword)

c.tmpCertificatePassword = tempName.CertificatePassword
if c.TempComputeName == "" {
Expand Down
2 changes: 1 addition & 1 deletion builder/azure/chroot/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT)
packersdk.LogSecretFilter.Set(b.config.ClientConfig.ClientSecret, b.config.ClientConfig.ClientJWT)
return nil, warns, nil
}

Expand Down
3 changes: 1 addition & 2 deletions builder/azure/dtl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/hashicorp/packer/builder/azure/pkcs12"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -492,7 +491,7 @@ func setRuntimeValues(c *Config) {
var tempName = NewTempName(c)

c.tmpAdminPassword = tempName.AdminPassword
packer.LogSecretFilter.Set(c.tmpAdminPassword)
packersdk.LogSecretFilter.Set(c.tmpAdminPassword)

c.tmpCertificatePassword = tempName.CertificatePassword
c.tmpComputeName = tempName.ComputeName
Expand Down
4 changes: 2 additions & 2 deletions builder/azure/dtl/step_save_winrm_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dtl
import (
"context"

"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)

type StepSaveWinRMPassword struct {
Expand All @@ -15,7 +15,7 @@ type StepSaveWinRMPassword struct {
func (s *StepSaveWinRMPassword) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
// store so that we can access this later during provisioning
state.Put("winrm_password", s.Password)
packer.LogSecretFilter.Set(s.Password)
packersdk.LogSecretFilter.Set(s.Password)
return multistep.ActionContinue
}

Expand Down
3 changes: 1 addition & 2 deletions builder/digitalocean/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -214,6 +213,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}

packer.LogSecretFilter.Set(c.APIToken)
packersdk.LogSecretFilter.Set(c.APIToken)
return nil, nil
}
5 changes: 2 additions & 3 deletions builder/googlecompute/step_create_windows_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"os"
"time"

"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
Expand All @@ -33,7 +32,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta

if c.Comm.WinRMPassword != "" {
state.Put("winrm_password", c.Comm.WinRMPassword)
packer.LogSecretFilter.Set(c.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(c.Comm.WinRMPassword)
return multistep.ActionContinue
}

Expand Down Expand Up @@ -119,7 +118,7 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta
}

state.Put("winrm_password", data.password)
packer.LogSecretFilter.Set(data.password)
packersdk.LogSecretFilter.Set(data.password)

return multistep.ActionContinue
}
Expand Down
3 changes: 1 addition & 2 deletions builder/hcloud/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
Expand Down Expand Up @@ -144,7 +143,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}

packer.LogSecretFilter.Set(c.HCloudToken)
packersdk.LogSecretFilter.Set(c.HCloudToken)
return nil, nil
}

Expand Down
3 changes: 1 addition & 2 deletions builder/hyperone/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/json"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
Expand Down Expand Up @@ -308,7 +307,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}

packer.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.Token)

return nil, nil
}
Expand Down
2 changes: 1 addition & 1 deletion builder/jdcloud/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey)

return nil, nil, nil
}
Expand Down
3 changes: 1 addition & 2 deletions builder/linode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -144,6 +143,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return nil, errs
}

packer.LogSecretFilter.Set(c.PersonalAccessToken)
packersdk.LogSecretFilter.Set(c.PersonalAccessToken)
return nil, nil
}
3 changes: 1 addition & 2 deletions builder/oneandone/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/1and1/oneandone-cloudserver-sdk-go"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -109,6 +108,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, errs
}
packer.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.Token)
return nil, nil
}
2 changes: 1 addition & 1 deletion builder/openstack/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
b.config.InstanceName = b.config.ImageName
}

packer.LogSecretFilter.Set(b.config.Password)
packersdk.LogSecretFilter.Set(b.config.Password)
return nil, nil, nil
}

Expand Down
3 changes: 1 addition & 2 deletions builder/openstack/step_get_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -78,7 +77,7 @@ func (s *StepGetPassword) Run(ctx context.Context, state multistep.StateBag) mul
"Password (since debug is enabled) \"%s\"", s.Comm.WinRMPassword))
}

packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)

return multistep.ActionContinue
}
Expand Down
3 changes: 1 addition & 2 deletions builder/oracle/oci/step_get_default_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
)
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s *stepGetDefaultCredentials) Run(ctx context.Context, state multistep.Sta

// store so that we can access this later during provisioning
state.Put("winrm_password", s.Comm.WinRMPassword)
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)
return multistep.ActionContinue
}

Expand Down
2 changes: 1 addition & 1 deletion builder/osc/bsu/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion builder/osc/bsusurrogate/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil

}
Expand Down
2 changes: 1 addition & 1 deletion builder/osc/bsuvolume/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, nil, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion builder/osc/chroot/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
return nil, warns, errs
}

packer.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
packersdk.LogSecretFilter.Set(b.config.AccessKey, b.config.SecretKey, b.config.Token)
return nil, warns, nil
}

Expand Down
3 changes: 1 addition & 2 deletions builder/osc/common/step_get_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/antihax/optional"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/outscale/osc-sdk-go/osc"
Expand Down Expand Up @@ -96,7 +95,7 @@ WaitLoop:
"Password (since debug is enabled): %s", s.Comm.WinRMPassword))
}
// store so that we can access this later during provisioning
packer.LogSecretFilter.Set(s.Comm.WinRMPassword)
packersdk.LogSecretFilter.Set(s.Comm.WinRMPassword)

return multistep.ActionContinue
}
Expand Down
3 changes: 1 addition & 2 deletions builder/profitbricks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -123,7 +122,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
if errs != nil && len(errs.Errors) > 0 {
return nil, errs
}
packer.LogSecretFilter.Set(c.PBUsername)
packersdk.LogSecretFilter.Set(c.PBUsername)

return nil, nil
}
3 changes: 1 addition & 2 deletions builder/proxmox/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/bootcommand"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps"
Expand Down Expand Up @@ -123,7 +122,7 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
var errs *packersdk.MultiError
var warnings []string

packer.LogSecretFilter.Set(c.Password)
packersdk.LogSecretFilter.Set(c.Password)

// Defaults
if c.ProxmoxURLRaw == "" {
Expand Down
5 changes: 2 additions & 3 deletions builder/scaleway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/hashicorp/packer/builder/scaleway/version"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/common"
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
Expand Down Expand Up @@ -260,7 +259,7 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
return warnings, errs
}

packer.LogSecretFilter.Set(c.Token)
packer.LogSecretFilter.Set(c.SecretKey)
packersdk.LogSecretFilter.Set(c.Token)
packersdk.LogSecretFilter.Set(c.SecretKey)
return warnings, nil
}
Loading

0 comments on commit a6fdeca

Please sign in to comment.