Skip to content

Commit

Permalink
Fixing path of secret so that it actually works for gcp (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
i3149 authored Feb 12, 2024
1 parent 8ca4cfa commit 0638a8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/kt/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
)

var (
gSMClient *secretmanager.Client
gSMClient *secretmanager.Client
gcpProject = ""
)

const (
Expand All @@ -34,7 +35,17 @@ func loadViaGCPSecrets(key string) string {
gSMClient = client
}

// We need this project explicitly set for us also.
if gcpProject == "" {
gcpProject = LookupEnvString("GOOGLE_CLOUD_PROJECT", "")
if gcpProject == "" {
log.Printf("Missing env var GOOGLE_CLOUD_PROJECT")
return fmt.Sprintf("Missing env var GOOGLE_CLOUD_PROJECT")
}
}

// Build the request.
key = fmt.Sprintf("projects/%s/secrets/%s/versions/latest", gcpProject, key)
req := &secretmanagerpb.AccessSecretVersionRequest{
Name: key,
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/kt/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,11 @@ func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error {

type V3SNMP V3SNMPConfig // Need a 2nd type alias to avoid stack overflow on parsing.

func (a *V3SNMPConfig) String() string {
return fmt.Sprintf("UserName: %s, AuthenticationProtocol: %s, AuthenticationPassphrase: %s PrivacyProtocol: %s PrivacyPassphrase: %s ContextEngineID: %s ContextName: %s",
a.UserName, a.AuthenticationProtocol, a.AuthenticationPassphrase, a.PrivacyProtocol, a.PrivacyPassphrase, a.ContextEngineID, a.ContextName)
}

// Make sure that things serialize back to how they were.
func (a *V3SNMPConfig) MarshalYAML() (interface{}, error) {
if a.origStr != "" {
Expand Down

0 comments on commit 0638a8b

Please sign in to comment.