From a76a1220de9f06f8ff0df9a1c54c98283e2f907d Mon Sep 17 00:00:00 2001 From: "Marcel S. Henselin" Date: Wed, 13 May 2026 09:51:04 +0200 Subject: [PATCH] feat: env file loading support fix: typo --- .gitignore | 1 + config/config.go | 2 +- go.mod | 1 + go.sum | 2 ++ main.go | 8 +++++++- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f597e4b..eb1440c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ go.work.sum # env file .env +action-secretsmanager diff --git a/config/config.go b/config/config.go index d01e51b..da300d6 100644 --- a/config/config.go +++ b/config/config.go @@ -67,7 +67,7 @@ func ValidateConfig( } if cfg.VaultPath == "" { - FatalLog("VAULT_SECRET cannot be empty, this is the key of your secret") + FatalLog("VAULT_PATH cannot be empty, this is the key of your secret") } InfoLog("Using Vault address: %s", cfg.VaultAddr) diff --git a/go.mod b/go.mod index 2e6e585..2e4229a 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.8 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/stretchr/testify v1.10.0 // indirect diff --git a/go.sum b/go.sum index a15b9fd..10fedd1 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9 github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= github.com/hashicorp/vault-client-go v0.4.3 h1:zG7STGVgn/VK6rnZc0k8PGbfv2x/sJExRKHSUg3ljWc= github.com/hashicorp/vault-client-go v0.4.3/go.mod h1:4tDw7Uhq5XOxS1fO+oMtotHL7j4sB9cp0T7U6m4FzDY= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= diff --git a/main.go b/main.go index 24b5f8e..522284f 100644 --- a/main.go +++ b/main.go @@ -8,11 +8,17 @@ import ( "secretsmanager/secretsmanager" "github.com/caarlos0/env/v11" + "github.com/joho/godotenv" ) func main() { + err := godotenv.Load() + if err != nil { + log.Println(".env file not found, using regular environment variables") + } + var cfg config.Config - err := env.Parse(&cfg) + err = env.Parse(&cfg) if err != nil { log.Fatalf("Error parsing environment variables %s", err) }