@@ -36,7 +36,6 @@ import (
3636 "regexp"
3737 "strings"
3838 "sync"
39- "time"
4039)
4140
4241type ScopedVariableService interface {
@@ -45,6 +44,8 @@ type ScopedVariableService interface {
4544 GetJsonForVariables () (* models.Payload , error )
4645 CheckForSensitiveVariables (variableNames []string ) (map [string ]bool , error )
4746 GetFormattedVariableForName (name string ) string
47+ GetMatchedScopedVariables (varScope []* resourceQualifiers.QualifierMapping ) map [int ][]* resourceQualifiers.QualifierMapping
48+ GetScopeWithPriority (variableIdToVariableScopes map [int ][]* resourceQualifiers.QualifierMapping ) map [int ]int
4849}
4950
5051type ScopedVariableServiceImpl struct {
@@ -151,7 +152,7 @@ func (impl *ScopedVariableServiceImpl) CreateVariables(payload models.Payload) e
151152 return err
152153 }
153154
154- auditLog := getAuditLog (payload )
155+ auditLog := resourceQualifiers . GetAuditLog (payload . UserId )
155156 // Begin Transaction
156157 tx , err := impl .scopedVariableRepository .StartTx ()
157158 if err != nil {
@@ -281,7 +282,7 @@ func (impl *ScopedVariableServiceImpl) createVariableScopes(payload models.Paylo
281282 return scopeIdToVarData , nil
282283}
283284
284- func (impl * ScopedVariableServiceImpl ) getMatchedScopedVariables (varScope []* resourceQualifiers.QualifierMapping ) map [int ][]* resourceQualifiers.QualifierMapping {
285+ func (impl * ScopedVariableServiceImpl ) GetMatchedScopedVariables (varScope []* resourceQualifiers.QualifierMapping ) map [int ][]* resourceQualifiers.QualifierMapping {
285286 variableIdToVariableScopes := make (map [int ][]* resourceQualifiers.QualifierMapping )
286287 for _ , vScope := range varScope {
287288 variableId := vScope .ResourceId
@@ -315,7 +316,7 @@ func (impl *ScopedVariableServiceImpl) getMatchedScopedVariables(varScope []*res
315316
316317}
317318
318- func (impl * ScopedVariableServiceImpl ) getScopeWithPriority (variableIdToVariableScopes map [int ][]* resourceQualifiers.QualifierMapping ) map [int ]int {
319+ func (impl * ScopedVariableServiceImpl ) GetScopeWithPriority (variableIdToVariableScopes map [int ][]* resourceQualifiers.QualifierMapping ) map [int ]int {
319320 variableIdToSelectedScopeId := make (map [int ]int )
320321 var minScope * resourceQualifiers.QualifierMapping
321322 for variableId , scopes := range variableIdToVariableScopes {
@@ -337,7 +338,7 @@ func (impl *ScopedVariableServiceImpl) selectScopeForCompoundQualifier(scopes []
337338 if scope .ParentIdentifier > 0 {
338339 parentIdToChildScopes [scope .ParentIdentifier ] = append (parentIdToChildScopes [scope .ParentIdentifier ], scope )
339340 } else {
340- //is parent so collect IDs and put it in a map for easy retrieval
341+ // is parent so collect IDs and put it in a map for easy retrieval
341342 parentScopeIds = append (parentScopeIds , scope .Id )
342343 parentScopeIdToScope [scope .Id ] = scope
343344 }
@@ -419,8 +420,8 @@ func (impl *ScopedVariableServiceImpl) GetScopedVariables(scope resourceQualifie
419420 return nil , err
420421 }
421422
422- matchedScopes := impl .getMatchedScopedVariables (varScope )
423- variableIdToSelectedScopeId := impl .getScopeWithPriority (matchedScopes )
423+ matchedScopes := impl .GetMatchedScopedVariables (varScope )
424+ variableIdToSelectedScopeId := impl .GetScopeWithPriority (matchedScopes )
424425
425426 scopeIds := make ([]int , 0 )
426427 foundVarIds := make ([]int , 0 ) // the variable IDs which have data
@@ -684,13 +685,3 @@ func (impl *ScopedVariableServiceImpl) getVariableScopeData(scopeIds []int) (map
684685 }
685686 return scopeIdVsVarDataMap , nil
686687}
687-
688- func getAuditLog (payload models.Payload ) sql.AuditLog {
689- auditLog := sql.AuditLog {
690- CreatedOn : time .Now (),
691- CreatedBy : payload .UserId ,
692- UpdatedOn : time .Now (),
693- UpdatedBy : payload .UserId ,
694- }
695- return auditLog
696- }
0 commit comments