From 4a3889edf68054d85fa0eb5990d96a9170db0b2f Mon Sep 17 00:00:00 2001 From: Siddhesh Khandagale Date: Mon, 27 Nov 2023 11:19:41 +0530 Subject: [PATCH] env Update --- lib/init.go | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/init.go b/lib/init.go index 4f4ce11..8336cde 100644 --- a/lib/init.go +++ b/lib/init.go @@ -1,48 +1,50 @@ package lib import ( + "log" + "os" + + "github.com/joho/godotenv" "github.com/pangeacyber/pangea-go/pangea-sdk/v2/pangea" "github.com/pangeacyber/pangea-go/pangea-sdk/v2/service/authn" "github.com/pangeacyber/pangea-go/pangea-sdk/v2/service/vault" ) func Init() *authn.AuthN { - // err := godotenv.Load(".env") - // if err != nil { - // log.Fatal("\033[31m", "Error loading .env file", "\033[0m") - // } + err := godotenv.Load(".env") + if err != nil { + log.Fatal("\033[31m", "Error loading .env file", "\033[0m") + } // Get token - // token := os.Getenv("PANGEA_AUTHN_TOKEN") - // if token == "" { - // log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m") - // } - token := "pts_xajlrac4we4mufoebqgejbrh2ieq72c4" - domain := "aws.us.pangea.cloud" + token := os.Getenv("PANGEA_AUTHN_TOKEN") + if token == "" { + log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m") + } + // Create config and client client := authn.New(&pangea.Config{ Token: token, - Domain: domain, + Domain: os.Getenv("PANGEA_DOMAIN"), }) return client } func InitVault() vault.Client { - // err := godotenv.Load(".env") - // if err != nil { - // log.Fatal("\033[31m", "Error loading .env file", "\033[0m") - // } + err := godotenv.Load(".env") + if err != nil { + log.Fatal("\033[31m", "Error loading .env file", "\033[0m") + } // Get token - // token := os.Getenv("PANGEA_VAULT_TOKEN") - // if token == "" { - // log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m") - // } - token := "pts_xajlrac4we4mufoebqgejbrh2ieq72c4" - domain := "aws.us.pangea.cloud" + token := os.Getenv("PANGEA_VAULT_TOKEN") + if token == "" { + log.Fatal("\033[31m", "Unauthorized: No token present", "\033[0m") + } + // Create config and client client := vault.New(&pangea.Config{ Token: token, - Domain: domain, + Domain: os.Getenv("PANGEA_DOMAIN"), }) return client