TP-5555 | account provision

This commit is contained in:
varnit goyal
2024-11-29 16:20:01 +05:30
parent 09b2c9a88f
commit c04e0a9157
12 changed files with 115 additions and 39 deletions

View File

@@ -49,6 +49,7 @@ type ExceptionValue struct {
Extra interface{} `json:"extra,omitempty"`
Request interface{} `json:"request,omitempty"`
Contexts interface{} `json:"contexts,omitempty"`
AwsAccount string `json:"aws_account,omitempty"`
}
type Exception struct {
@@ -86,14 +87,17 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) {
secret := c.Query("sentry_key")
var secretFromDb, found = exceptionService.inPodCacheClient.Get(projectID)
var awsAccountFromDb, awsAccountFound = exceptionService.inPodCacheClient.Get(projectID + "_account")
//validate project id and secret is valid
if !found {
if !found || !awsAccountFound {
var projectData db.Project
exceptionService.dbClient.First(&projectData, "project_reference_id = ?", projectID)
secretFromDb = projectData.Secret
awsAccountFromDb = projectData.Account
exceptionService.inPodCacheClient.Set(projectID, secretFromDb)
exceptionService.inPodCacheClient.Set(projectID+"_account", awsAccountFromDb)
}
@@ -130,6 +134,7 @@ func (exceptionService *ExceptionService) CatchErrors(c *gin.Context) {
errorItem.Extra = jsonData.Extra
errorItem.Request = jsonData.Request
errorItem.Contexts = jsonData.Contexts
errorItem.AwsAccount = awsAccountFromDb.(string)
err := exceptionService.kafkaProducer.PublishEvent(errorItem, exceptionService.kafkaConfig.Topic, "", nil, encoder.JsonEncoderInstance)
if err != nil {