Repository navigation
feat: kk.Picturespreview、kk.Getcorsfile、kk.addTask 支持通过环境变量配置 - #803
Open
yuhaibohotmail wants to merge 1 commit into
Open
yuhaibohotmail wants to merge 1 commit into
yuhaibohotmail wants to merge 1 commit into
Conversation
配置文件中大多数配置项使用 ${KK_XXX:默认值} 的写法,可以通过环境变量调整,
这三项写成了固定值 true,容器化部署时只能修改或挂载配置文件。
改为 ${KK_PICTURESPREVIEW:true}、${KK_GETCORSFILE:true}、${KK_ADDTASK:true},
与其它配置项保持一致,application.properties 与 test.properties 同步修改。
默认值不变,未设置环境变量时行为与之前相同。
新增 InterfaceSwitchEnvConfigTests,校验两份配置文件中这三项可通过环境变量
调整,且默认值仍为 true。
Signed-off-by: yuhaibo <yuhaibo@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景
server/src/main/config/application.properties里大多数配置项都写成${KK_XXX:默认值},可以通过环境变量调整,例如:而「权限与认证配置」一节里的这三项写成了固定值:
用 Docker 等容器方式部署时,其它配置项加一个
-e KK_XXX=...就能调整,这三项却只能修改或挂载整份配置文件,写法上也和其它配置项不一致。修改
把这三项改成与其它配置项相同的写法,
application.properties与test.properties同步修改:KK_前缀 + 配置项名转大写(参照simText→KK_SIMTEXT、convertMedias→KK_CONVERTMEDIAS);true,不设置环境变量时行为与之前完全相同;ConfigRefreshComponent→ConfigUtils.restorePropertiesFromEnvFormat)本来就支持这种写法。验证
新增
InterfaceSwitchEnvConfigTests,对application.properties、test.properties两份文件各检查这三项,3 条:shouldReadInterfaceSwitchesFromEnvironmentVariables:存在对应环境变量时,配置项解析为环境变量的值;shouldKeepInterfaceSwitchesEnabledByDefault:没有环境变量时解析为true;shouldKeepInterfaceSwitchesEnabledByDefaultWhenConfigIsReloaded:按配置热加载的方式处理后,默认仍为true。修改前先跑:第 1 条失败(
kk.Picturespreview in /application.properties must be configurable through KK_PICTURESPREVIEW ==> expected: <false> but was: <true>),另外 2 条通过;修改后 3 条全部通过。把其中任意一行改回固定值(试的是test.properties的kk.addTask),第 1 条重新失败。mvn -B -pl server test -Dtest='!ServerMainTests'(Windows,JDK 25):Tests run: 90, Failures: 0, Errors: 1。唯一的 1 条是ArchiveDirectorySecurityTests.cachedArchivePreviewRendersItsTreeWithoutAnEnumerationRequest,它要创建文件名带双引号的文件,Windows 不允许,在未修改的 master 上同样失败(master 为 87 条、同样 1 条 Error),与本次修改无关。