From 428d0c2e8e0a727d27681d3402d4671375043cf0 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Mon, 6 Sep 2021 18:58:51 +0800 Subject: [PATCH] support retriving get-only storage storage --- pkg/util/context/context.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/util/context/context.go b/pkg/util/context/context.go index 6e83421..d81b76d 100644 --- a/pkg/util/context/context.go +++ b/pkg/util/context/context.go @@ -23,3 +23,13 @@ func GetParentStorage(ctx context.Context) (rest.StandardStorage, bool) { } return parentStorage.(rest.StandardStorage), true } + +// GetParentStorageGetter tries getting the get-only parent storage from +// context. +func GetParentStorageGetter(ctx context.Context) (rest.Getter, bool) { + parentStorage := ctx.Value(parentStorageContextKey) + if parentStorage == nil { + return nil, false + } + return parentStorage.(rest.Getter), true +}