Skip to content

Commit

Permalink
feat(secrets-kubernetes): Support using credentials with the NATS con…
Browse files Browse the repository at this point in the history
…nection

Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
  • Loading branch information
joonas committed Aug 18, 2024
1 parent 4ffedf3 commit 69f0c25
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion secrets/secrets-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func kubeClientWithImpersonation(role string) (clientcorev1.CoreV1Interface, err
func main() {
var (
natsURL = flag.String("nats-url", nats.DefaultURL, "Nats URL")
natsCreds = flag.String("nats-creds", "", "NATS credentials file path.")
secretsBackendSeed = flag.String("backend-seed", "", "NKeys Curve Seed. Leave blank for ephemeral key, only recommended for development use")
)
flag.Parse()
Expand All @@ -107,7 +108,12 @@ func main() {

s := &kubeSecretsServer{}

nc, err := nats.Connect(*natsURL)
natsConnectOps := []nats.Option{}
if *natsCreds != "" {
natsConnectOps = append(natsConnectOps, nats.UserCredentials(*natsCreds))
}

nc, err := nats.Connect(*natsURL, natsConnectOps...)
if err != nil {
slog.Error("Couldn't setup nats client", slog.Any("error", err))
os.Exit(1)
Expand Down

0 comments on commit 69f0c25

Please sign in to comment.