Distinguish unresolved from resolved-empty required resources
还没有人认领这个 Issue。
评估
调研方向
首先阅读 request.get_required_resource 和 get_required_resources API 及其 docstring,然后比较对应的 require_schema/get_required_schema 行为。定义支持的 unresolved、absent 和 present 情况,并通过测试确认所选择的 API 形式;完成的标准是调用方无需重复 membership check 即可区分这些状态。
由索引模型根据 Issue 内容生成。
描述
What problem are you facing?
request.get_required_resource (and get_required_resources) returns None/[] in two semantically different cases: the requirement hasn't been resolved by Crossplane yet, and the requirement resolved but matched nothing. The only way to tell them apart is to also check name in req.required_resources, which the get_required_resources docstring documents as a caveat the caller must handle by hand.
This distinction matters whenever a function gates on an external resource. "Not resolved yet" is transient — wait and let Crossplane re-call. "Resolved, matched nothing" is a real state — the resource was deleted, or its reference is a typo — and usually wants a different response (e.g. a warning, or holding steady rather than waiting). Functions end up reimplementing the same in-then-get dance. We hit it twice in one project: once gating a hydration Job on an auth Secret, and once gating replica placement on a referenced cache being resolvable.
How could this Function help solve your problem?
A small helper that classifies a required resource into the three states, so callers don't each re-derive it from the in check. Roughly:
class Resolution(enum.Enum):
UNRESOLVED = "unresolved" # Crossplane hasn't fetched it yet (key absent)
ABSENT = "absent" # resolved, but nothing matched
PRESENT = "present" # resolved and found
def resolve_required(req, name) -> tuple[Resolution, dict | None]: ...
A list variant (and possibly the same for require_schema/get_required_schema, which has the analogous distinction) would round it out. Naming/placement and whether this is an enum vs. a small result type are open — happy to send a PR once there's a preferred shape.
- 主要语言
- Python
- 星标
- 12
- 派生
- 15
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 7
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crossplane/function-sdk-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
crossplane/function-sdk-python#199 · 4 条评论 · 3 个 reaction ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
crossplane/function-sdk-python#129 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 10/100
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
crossplane/function-sdk-python#5 · 1 条评论 ·
查看 crossplane/function-sdk-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 90/100
learningequality/ricecooker#747 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 76/100
run-llama/llama_index#23199 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
KhronosGroup/glTF-Blender-IO#2769 ·