From 2543ab7004feadfa5b16840840733e54957ddee1 Mon Sep 17 00:00:00 2001 From: Harshjosh361 Date: Mon, 14 Oct 2024 11:06:39 +0530 Subject: [PATCH] working --- notification-service/go.mod | 1 - notification-service/go.sum | 2 - .../internal/service/service.go | 27 +++++--- notification-service/keploy.yml | 61 +++++++++++++++++++ 4 files changed, 78 insertions(+), 13 deletions(-) create mode 100755 notification-service/keploy.yml diff --git a/notification-service/go.mod b/notification-service/go.mod index fa65023..3035f63 100644 --- a/notification-service/go.mod +++ b/notification-service/go.mod @@ -19,7 +19,6 @@ require ( github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang/mock v1.6.0 // indirect - github.com/joho/godotenv v1.5.1 github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect diff --git a/notification-service/go.sum b/notification-service/go.sum index ea68c69..5d457ed 100644 --- a/notification-service/go.sum +++ b/notification-service/go.sum @@ -33,8 +33,6 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= diff --git a/notification-service/internal/service/service.go b/notification-service/internal/service/service.go index 750fabd..c0fd7e9 100644 --- a/notification-service/internal/service/service.go +++ b/notification-service/internal/service/service.go @@ -5,27 +5,33 @@ import ( "log" "os" - "github.com/joho/godotenv" "github.com/twilio/twilio-go" twilioApi "github.com/twilio/twilio-go/rest/api/v2010" ) // load env variables -func init() { - err := godotenv.Load() - if err != nil { - log.Fatal("Error loading .env file") - } -} +// func init() { +// err := godotenv.Load() +// if err != nil { +// log.Fatal("Error loading .env file") +// } +// } type NotificationService struct { twilioClient *twilio.RestClient } func NewNotificationService() *NotificationService { + accountSid := os.Getenv("Account_SID") + authToken := os.Getenv("Auth_Token") + + if accountSid == "" || authToken == "" { + log.Fatal("Twilio credentials are missing") + } + client := twilio.NewRestClientWithParams(twilio.ClientParams{ - Username: os.Getenv("Account_SID"), - Password: os.Getenv("Auth_Token"), + Username: accountSid, + Password: authToken, }) return &NotificationService{ @@ -34,8 +40,9 @@ func NewNotificationService() *NotificationService { } func (ns *NotificationService) SendSMS(to string, body string) error { + phoneNumber := os.Getenv("PhoneNumber") params := &twilioApi.CreateMessageParams{} - params.SetFrom(os.Getenv("PhoneNumber")) + params.SetFrom(phoneNumber) params.SetBody(body) params.SetTo(to) diff --git a/notification-service/keploy.yml b/notification-service/keploy.yml new file mode 100755 index 0000000..6e838e1 --- /dev/null +++ b/notification-service/keploy.yml @@ -0,0 +1,61 @@ +path: "" +appId: 0 +appName: notification-service +command: docker run -e Account_SID=AC9465c2cf339aa21ed06284dc8bcaf5aa -e Auth_Token=6a1e9ef25b72d52b3fde6e4052d8f0d6 -e PhoneNumber=+16202061107 -p 8084:8084 notification +templatize: + testSets: [] +port: 0 +dnsPort: 26789 +proxyPort: 16789 +debug: false +disableTele: false +disableANSI: false +containerName: "" +networkName: "" +buildDelay: 30 +test: + selectedTests: {} + globalNoise: + global: {} + test-sets: {} + delay: 5 + host: "" + port: 0 + apiTimeout: 5 + skipCoverage: false + coverageReportPath: "" + ignoreOrdering: true + mongoPassword: default@123 + language: "" + removeUnusedMocks: false + fallBackOnMiss: false + jacocoAgentPath: "" + basePath: "" + mocking: true + ignoredTests: {} + disableLineCoverage: false + disableMockUpload: true + useLocalMock: false + updateTemplate: false +record: + filters: [] + recordTimer: 0s +configPath: "" +bypassRules: [] +generateGithubActions: false +keployContainer: keploy-v2 +keployNetwork: keploy-network +cmdType: native +contract: + services: [] + tests: [] + path: "" + download: false + generate: false + driven: consumer + mappings: + servicesMapping: {} + self: "" +inCi: false + +# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file.