build(deps): bump github.com/open-policy-agent/opa from 0.64.1 to 0.65.0
Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.64.1 to 0.65.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-policy-agent/opa/compare/v0.64.1...v0.65.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
340b75495b
commit
01867a22dc
+11
@@ -1139,6 +1139,17 @@ func (c *Compiler) compileBlock(block *ir.Block) ([]instruction.Instruction, err
|
||||
instrs = append(instrs, instruction.Br{Index: 0})
|
||||
break
|
||||
}
|
||||
case *ir.IsSetStmt:
|
||||
if loc, ok := stmt.Source.Value.(ir.Local); ok {
|
||||
instrs = append(instrs, instruction.GetLocal{Index: c.local(loc)})
|
||||
instrs = append(instrs, instruction.Call{Index: c.function(opaValueType)})
|
||||
instrs = append(instrs, instruction.I32Const{Value: opaTypeSet})
|
||||
instrs = append(instrs, instruction.I32Ne{})
|
||||
instrs = append(instrs, instruction.BrIf{Index: 0})
|
||||
} else {
|
||||
instrs = append(instrs, instruction.Br{Index: 0})
|
||||
break
|
||||
}
|
||||
case *ir.IsUndefinedStmt:
|
||||
instrs = append(instrs, instruction.GetLocal{Index: c.local(stmt.Source)})
|
||||
instrs = append(instrs, instruction.I32Const{Value: 0})
|
||||
|
||||
+34
@@ -893,6 +893,40 @@ func (p *Planner) planExprEvery(e *ast.Expr, iter planiter) error {
|
||||
})
|
||||
|
||||
err := p.planTerm(every.Domain, func() error {
|
||||
// Assert that the domain is a collection type:
|
||||
// block outer
|
||||
// block a
|
||||
// isArray
|
||||
// br 1: break outer, and continue
|
||||
// block b
|
||||
// isObject
|
||||
// br 1: break outer, and continue
|
||||
// block c
|
||||
// isSet
|
||||
// br 1: break outer, and continue
|
||||
// br 1: invalid domain, break every
|
||||
|
||||
aBlock := &ir.Block{}
|
||||
p.appendStmtToBlock(&ir.IsArrayStmt{Source: p.ltarget}, aBlock)
|
||||
p.appendStmtToBlock(&ir.BreakStmt{Index: 1}, aBlock)
|
||||
|
||||
bBlock := &ir.Block{}
|
||||
p.appendStmtToBlock(&ir.IsObjectStmt{Source: p.ltarget}, bBlock)
|
||||
p.appendStmtToBlock(&ir.BreakStmt{Index: 1}, bBlock)
|
||||
|
||||
cBlock := &ir.Block{}
|
||||
p.appendStmtToBlock(&ir.IsSetStmt{Source: p.ltarget}, cBlock)
|
||||
p.appendStmtToBlock(&ir.BreakStmt{Index: 1}, cBlock)
|
||||
|
||||
outerBlock := &ir.BlockStmt{Blocks: []*ir.Block{
|
||||
{
|
||||
Stmts: []ir.Stmt{
|
||||
&ir.BlockStmt{Blocks: []*ir.Block{aBlock, bBlock, cBlock}},
|
||||
&ir.BreakStmt{Index: 1}},
|
||||
},
|
||||
}}
|
||||
p.appendStmt(outerBlock)
|
||||
|
||||
return p.planScan(every.Key, func(ir.Local) error {
|
||||
p.appendStmt(&ir.ResetLocalStmt{
|
||||
Target: cond1,
|
||||
|
||||
+6
-12
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/open-policy-agent/opa/logging"
|
||||
)
|
||||
|
||||
// DoRequestWithClient is a convenience function to get the body of an http response with
|
||||
// DoRequestWithClient is a convenience function to get the body of a http response with
|
||||
// appropriate error-handling boilerplate and logging.
|
||||
func DoRequestWithClient(req *http.Request, client *http.Client, desc string, logger logging.Logger) ([]byte, error) {
|
||||
resp, err := client.Do(req)
|
||||
@@ -24,22 +24,16 @@ func DoRequestWithClient(req *http.Request, client *http.Client, desc string, lo
|
||||
"headers": resp.Header,
|
||||
}).Debug("Received response from " + desc + " service.")
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
if logger.GetLevel() == logging.Debug {
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err == nil {
|
||||
logger.Debug("Error response with response body: %s", body)
|
||||
}
|
||||
}
|
||||
// could be 404 for role that's not available, but cover all the bases
|
||||
return nil, errors.New(desc + " HTTP request returned unexpected status: " + resp.Status)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
// deal with problems reading the body, whatever those might be
|
||||
return nil, errors.New(desc + " HTTP response body could not be read: " + err.Error())
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
logger.Debug("Error response with response body: %s", body)
|
||||
// could be 404 for role that's not available, but cover all the bases
|
||||
return nil, errors.New(desc + " HTTP request returned unexpected status: " + resp.Status)
|
||||
}
|
||||
return body, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user