分离 client 中的真实和 fake 调用 k8s api,以便于 ut 不依赖于当前的 k8s 环境。 #914
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
ut 不依赖于当前的 k8s 环境,更快速进行 ut。
k8s_client.go: 将当前散落的 k8s client 调用逻辑和日志记录,统一封装到 中,职责更单一。
factory.go: 将创建和管理逻辑统一,方便调用和切换fake/real。
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
后续将逐步替换当前依赖 client.GetClient()的调用点,最终全部统一后,再替换 client.go。
另外,当前util 中对k8s 接口还有组合调用的逻辑部分,感觉不合理。后续也考虑将独立抽离成领域类,不混淆在 util 工具类中。
Does this PR introduce a user-facing change?:
nope