Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: support validate requires version for theme #3150

Merged
merged 6 commits into from
Jan 18, 2023

Conversation

guqing
Copy link
Member

@guqing guqing commented Jan 13, 2023

What type of PR is this?

/kind feature
/milestone 2.2.x
/kind api-change

What this PR does / why we need it:

主题支持 requires 版本验证

  • 主题安装和更新时会校验 requires,如果不通过则抛出异常。
  • 主题重载或者 halo 升级后导致主题 requires 不满足条件,则会在 status 中将 phase 标记为 failed

⚠️ 特别说明:

  • 由于之前主题的 require 字段沿用了 1.x 版本,并没有发现与插件的 requires 属性命名不相同,因此添加了一个 requires 属性,并将 require 标记为过时,后续移除它,这个改动不算是破坏性,但如果主题需要版本校验则需要更改 theme.yaml 为 requires
  • 校验后如果有错误则 console 端应该提示主题升级,这样可以避免用户不知情导致很长时间主题端模板都渲染错误问题。可以通过判断 status.phase 是否为 FAILED 来展示 conditions 的第一个 item 的信息。
  • 例如 halo 升级后 requires 不满足条件这种情况,并且这个主题被启用,也不会去取消激活(requires 不满足条件不会导致主题无法激活)。

Console 需要做适配
综上,console 应该需要:

  • 修改 Halo 版本要求 的字段取值,从 require -> requires
  • 提供错误信息展示,让用户知道主题不适配应该升级等错误。

Which issue(s) this PR fixes:

Fixes #3088

Special notes for your reviewer:

how to test it?

  • 测试安装、升级在 requires 满足条件和不满足时的状况是否符合描述中所述情况。
  • 主题重载时加载了一个新的 requires 值触发不满足系统要求条件会在 status 中有错误信息,但不影响主题激活

/cc @halo-dev/sig-halo

Does this PR introduce a user-facing change?

主题支持 requires 版本验证,原 Halo 版本要求属性从 require 更名为 requires

@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Jan 13, 2023
@f2c-ci-robot f2c-ci-robot bot added this to the 2.2.x milestone Jan 13, 2023
@f2c-ci-robot f2c-ci-robot bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jan 13, 2023
@guqing guqing requested a review from JohnNiang January 16, 2023 08:39
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

可以使用 halo-dev/console#826 配合测试。

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Jan 17, 2023
Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Jan 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2023
@f2c-ci-robot f2c-ci-robot bot merged commit da07d75 into halo-dev:main Jan 18, 2023
@guqing guqing deleted the feature/3088 branch January 18, 2023 08:17
@ruibaby ruibaby modified the milestones: 2.2.x, 2.2.0 Jan 18, 2023
f2c-ci-robot bot pushed a commit to halo-dev/console that referenced this pull request Jan 19, 2023
)

#### What type of PR is this?

/kind feature

#### What this PR does / why we need it:

修改主题的 `spec.require` 字段为 `spec.requires`,以及支持显示错误信息。适配:halo-dev/halo#3150

#### Which issue(s) this PR fixes:

Fixes halo-dev/halo#3088

#### Screenshots:

<img width="1692" alt="image" src="https://user-images.githubusercontent.com/21301288/212800478-0fe53ae8-4e31-4810-89aa-4b06d1b700fb.png">
<img width="1056" alt="image" src="https://user-images.githubusercontent.com/21301288/212800550-7edd7c0a-564c-4df4-baee-b3ffe6b3352d.png">

#### Special notes for your reviewer:

测试方式:

1. Halo 切换到 halo-dev/halo#3150 分支。
2. Console 需要 `pnpm install`。
3. 修改主题的 `spec.requires`,根据 halo-dev/halo#3150 中的测试条件修改这个值。
4. 检查是否可以显示异常版本信息。

#### Does this PR introduce a user-facing change?

```release-note
Console 端支持显示主题的版本异常信息
```
JohnNiang pushed a commit to JohnNiang/halo that referenced this pull request Mar 2, 2023
…alo-dev/console#826)

#### What type of PR is this?

/kind feature

#### What this PR does / why we need it:

修改主题的 `spec.require` 字段为 `spec.requires`,以及支持显示错误信息。适配:halo-dev#3150

#### Which issue(s) this PR fixes:

Fixes halo-dev#3088

#### Screenshots:

<img width="1692" alt="image" src="https://user-images.githubusercontent.com/21301288/212800478-0fe53ae8-4e31-4810-89aa-4b06d1b700fb.png">
<img width="1056" alt="image" src="https://user-images.githubusercontent.com/21301288/212800550-7edd7c0a-564c-4df4-baee-b3ffe6b3352d.png">

#### Special notes for your reviewer:

测试方式:

1. Halo 切换到 halo-dev#3150 分支。
2. Console 需要 `pnpm install`。
3. 修改主题的 `spec.requires`,根据 halo-dev#3150 中的测试条件修改这个值。
4. 检查是否可以显示异常版本信息。

#### Does this PR introduce a user-facing change?

```release-note
Console 端支持显示主题的版本异常信息
```
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

主题安装和升级支持版本校验
3 participants