mirror of
https://github.com/containers/skopeo.git
synced 2025-06-20 20:14:58 +00:00
Close the PolicyContext, as required by the API
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
e90ad8614b
commit
c40f1485b0
@ -238,7 +238,7 @@ func isNotFoundImageError(err error) bool {
|
|||||||
errors.Is(err, ocilayout.ImageNotFoundError{})
|
errors.Is(err, ocilayout.ImageNotFoundError{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (replyBuf, error) {
|
func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (retReplyBuf replyBuf, retErr error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
var ret replyBuf
|
var ret replyBuf
|
||||||
@ -271,6 +271,12 @@ func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (replyBuf,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := policyContext.Destroy(); err != nil {
|
||||||
|
retErr = noteCloseFailure(retErr, "tearing down policy context", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
unparsedTopLevel := image.UnparsedInstance(imgsrc, nil)
|
unparsedTopLevel := image.UnparsedInstance(imgsrc, nil)
|
||||||
allowed, err := policyContext.IsRunningImageAllowed(context.Background(), unparsedTopLevel)
|
allowed, err := policyContext.IsRunningImageAllowed(context.Background(), unparsedTopLevel)
|
||||||
if !allowed || err != nil {
|
if !allowed || err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user