Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
5315b198
Commit
5315b198
authored
Oct 11, 2013
by
Matthew Hooker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/config: config filter function [GH-521]
Fixes #521
parent
94487871
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
9 deletions
+32
-9
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+1
-1
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+1
-1
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+1
-1
builder/digitalocean/builder.go
builder/digitalocean/builder.go
+1
-5
builder/openstack/builder.go
builder/openstack/builder.go
+1
-1
common/config.go
common/config.go
+10
-0
common/config_test.go
common/config_test.go
+17
-0
No files found.
builder/amazon/chroot/builder.go
View file @
5315b198
...
@@ -143,7 +143,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
...
@@ -143,7 +143,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
errs
return
errs
}
}
log
.
Print
f
(
"Config: %+v"
,
b
.
config
)
log
.
Print
ln
(
common
.
ScrubConfig
(
b
.
config
),
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
)
return
nil
return
nil
}
}
...
...
builder/amazon/ebs/builder.go
View file @
5315b198
...
@@ -56,7 +56,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
...
@@ -56,7 +56,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
errs
return
errs
}
}
log
.
Print
f
(
"Config: %+v"
,
b
.
config
)
log
.
Print
ln
(
common
.
ScrubConfig
(
b
.
config
),
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
)
return
nil
return
nil
}
}
...
...
builder/amazon/instance/builder.go
View file @
5315b198
...
@@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
...
@@ -159,7 +159,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
errs
return
errs
}
}
log
.
Print
f
(
"Config: %+v"
,
b
.
config
)
log
.
Print
ln
(
common
.
ScrubConfig
(
b
.
config
),
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
)
return
nil
return
nil
}
}
...
...
builder/digitalocean/builder.go
View file @
5315b198
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"log"
"log"
"os"
"os"
"strings"
"time"
"time"
)
)
...
@@ -165,10 +164,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
...
@@ -165,10 +164,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
errs
return
errs
}
}
configRepr
:=
fmt
.
Sprintf
(
"Config: %+v"
,
b
.
config
)
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
ClientID
,
b
.
config
.
APIKey
)
scrubbedConfig
:=
strings
.
Replace
(
configRepr
,
b
.
config
.
ClientID
,
"CLIENT_ID"
,
-
1
)
scrubbedConfig
=
strings
.
Replace
(
scrubbedConfig
,
b
.
config
.
APIKey
,
"API_KEY"
,
-
1
)
log
.
Println
(
scrubbedConfig
)
return
nil
return
nil
}
}
...
...
builder/openstack/builder.go
View file @
5315b198
...
@@ -51,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
...
@@ -51,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
errs
return
errs
}
}
log
.
Print
f
(
"Config: %+v"
,
b
.
config
)
log
.
Print
ln
(
common
.
ScrubConfig
(
b
.
config
),
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
)
return
nil
return
nil
}
}
...
...
common/config.go
View file @
5315b198
...
@@ -12,6 +12,16 @@ import (
...
@@ -12,6 +12,16 @@ import (
"strings"
"strings"
)
)
// ScrubConfig is a helper that returns a string representation of
// any struct with the given values stripped out.
func
ScrubConfig
(
target
interface
{},
values
...
string
)
string
{
conf
:=
fmt
.
Sprintf
(
"Config: %+v"
,
target
)
for
_
,
value
:=
range
values
{
conf
=
strings
.
Replace
(
conf
,
value
,
"<Filtered>"
,
-
1
)
}
return
conf
}
// CheckUnusedConfig is a helper that makes sure that the there are no
// CheckUnusedConfig is a helper that makes sure that the there are no
// unused configuration keys, properly ignoring keys that don't matter.
// unused configuration keys, properly ignoring keys that don't matter.
func
CheckUnusedConfig
(
md
*
mapstructure
.
Metadata
)
*
packer
.
MultiError
{
func
CheckUnusedConfig
(
md
*
mapstructure
.
Metadata
)
*
packer
.
MultiError
{
...
...
common/config_test.go
View file @
5315b198
...
@@ -159,3 +159,20 @@ func TestDownloadableURL_FilePaths(t *testing.T) {
...
@@ -159,3 +159,20 @@ func TestDownloadableURL_FilePaths(t *testing.T) {
}
}
}
}
}
}
func
TestScrubConfig
(
t
*
testing
.
T
)
{
type
Inner
struct
{
Baz
string
}
type
Local
struct
{
Foo
string
Bar
string
Inner
}
c
:=
Local
{
"foo"
,
"bar"
,
Inner
{
"bar"
}}
expect
:=
"Config: {Foo:foo Bar:<Filtered> Inner:{Baz:<Filtered>}}"
conf
:=
ScrubConfig
(
c
,
c
.
Bar
)
if
conf
!=
expect
{
t
.
Fatalf
(
"got %s, expected %s"
,
conf
,
expect
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment