Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with debug printing of VaultConfig #1587

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ func Float64(f float64) *float64 {
return &f
}

// FloatGoString returns the value of the float for printing in a string.
func FloatGoString(f *float64) string {
if f == nil {
return "(*float64)(nil)"
}
return fmt.Sprintf("%f", *f)
}

// Int returns a pointer to the given int.
func Int(i int) *int {
return &i
Expand Down
4 changes: 2 additions & 2 deletions config/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (c *VaultConfig) GoString() string {
"Transport:%#v, "+
"UnwrapToken:%s, "+
"DefaultLeaseDuration:%s, "+
"LeaseRenewalThreshold:%f, "+
"LeaseRenewalThreshold:%s, "+
"K8SAuthRoleName:%s, "+
"K8SServiceAccountToken:%s, "+
"K8SServiceAccountTokenPath:%s, "+
Expand All @@ -425,7 +425,7 @@ func (c *VaultConfig) GoString() string {
c.Transport,
BoolGoString(c.UnwrapToken),
TimeDurationGoString(c.DefaultLeaseDuration),
*c.LeaseRenewalThreshold,
FloatGoString(c.LeaseRenewalThreshold),
StringGoString(c.K8SAuthRoleName),
StringGoString(c.K8SServiceAccountToken),
StringGoString(c.K8SServiceAccountTokenPath),
Expand Down
8 changes: 7 additions & 1 deletion config/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ func TestVaultConfig_Copy(t *testing.T) {
}
}

func TestVaultConfig_Merge(t *testing.T) {
// test simple nil rendering (there was a bug for this)
func TestVaultGoString(t *testing.T) {
v := &VaultConfig{}
v.GoString()
(*v).GoString()
}

func TestVaultConfig_Merge(t *testing.T) {
cases := []struct {
name string
a *VaultConfig
Expand Down