Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
policy
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaia-X
Trust Services API
policy
Commits
a7dbb4ab
Commit
a7dbb4ab
authored
2 years ago
by
Lyuben Penkovski
Browse files
Options
Downloads
Patches
Plain Diff
Fix storing of policy result in cache
parent
72fc4a8c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/service/policy/service.go
+11
-11
11 additions, 11 deletions
internal/service/policy/service.go
with
11 additions
and
11 deletions
internal/service/policy/service.go
+
11
−
11
View file @
a7dbb4ab
...
...
@@ -96,17 +96,6 @@ func (s *Service) Evaluate(ctx context.Context, req *policy.EvaluateRequest) (*p
return
nil
,
errors
.
New
(
"policy evaluation result expressions are empty"
)
}
jsonValue
,
err
:=
json
.
Marshal
(
resultSet
[
0
]
.
Expressions
[
0
]
.
Value
)
if
err
!=
nil
{
logger
.
Error
(
"error encoding result to json"
,
zap
.
Error
(
err
))
return
nil
,
errors
.
New
(
"error encoding result to json"
)
}
if
err
:=
s
.
cache
.
Set
(
ctx
,
evaluationID
,
""
,
""
,
jsonValue
);
err
!=
nil
{
logger
.
Error
(
"error storing policy result in cache"
,
zap
.
Error
(
err
))
return
nil
,
errors
.
New
(
"error storing policy result in cache"
)
}
// If there is only a single result from the policy evaluation and it was assigned to an empty
// variable, then we'll return a custom response containing only the value of the empty variable
// without any mapping.
...
...
@@ -121,6 +110,17 @@ func (s *Service) Evaluate(ctx context.Context, req *policy.EvaluateRequest) (*p
}
}
jsonValue
,
err
:=
json
.
Marshal
(
result
)
if
err
!=
nil
{
logger
.
Error
(
"error encoding result to json"
,
zap
.
Error
(
err
))
return
nil
,
errors
.
New
(
"error encoding result to json"
)
}
if
err
:=
s
.
cache
.
Set
(
ctx
,
evaluationID
,
""
,
""
,
jsonValue
);
err
!=
nil
{
logger
.
Error
(
"error storing policy result in cache"
,
zap
.
Error
(
err
))
return
nil
,
errors
.
New
(
"error storing policy result in cache"
)
}
return
&
policy
.
EvaluateResult
{
Result
:
result
,
ETag
:
evaluationID
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment