首页 > 解决方案 > Github 提交/推送规则,检查两个文件是否具有相同的变量列表

问题描述

我的 Github 存储库中有两个用Ballerina语言编写的文件。
即,ballerina.conf用于ballerina.conf.example存储类似的配置变量列表。

在这些文件中,我将 ACTUAL 用户凭据(用于连接到多个系统)保存在ballerina.conf文件中。
但是在将项目提交到 GitHub 时,我只想提交ballerina.conf.example文件。我可以省略ballerina.conf文件中的.gitignore文件。

我的问题是,用户有时可能会忘记在ballerina.confballerina.conf.example文件中包含相同的变量。

ballerina.conf -> DB_USERNAME = 'cseuser'  
ballerina.conf.example -> DB_USERNAME = '[dbusername]'  

有没有办法在 Github 中强制执行规则,以便在提交/推送时比较这两个文件,新引入的变量在两个文件中?

例如,如果用户只在ballerina.conf文件中引入了一个变量,我想拒绝提交/推送,向用户说明原因。即也将相同的变量添加到ballerina.conf.example虚拟值中。

标签: gitgithubballerina

解决方案


刚刚发现芭蕾舞女演员语言本身提供了一种使用命令加密密码的方法ballerina encrypt

例如加密值:1234

以下是我尝试过的示例输出。

$ballerina encrypt 
Enter value:

Enter secret: 

Re-enter secret to verify:

Add the following to the runtime config:
@encrypted:{DMTaGYeDc2B9SBJmy5ekUSsYW8TV1uipLPTofy4zjr2Ke8eZ7khQbyDnKnNJ1kZm}

Or add to the runtime command line:
-e<param>=@encrypted:{DMTaGYeDc2B9SBJmy5ekUSsYW8TV1uipLPTofy4zjr2Ke8eZ7khQbyDnKnNJ1kZm}

我在ballerina.conf下面使用了加密值。

DB_USERNAME = "@encrypted:{l1WoT/u1YMX2+njesLjzKdpHXT7Vk03d830mjCFTSB+75aeohAO2AkEScotn7Wry}"

因此无需在 Github 中维护辅助文件。

更新

当运行 ballerina 服务时,ballerina 会要求输入您用来加密 ballerina.conf 文件中密码的密码。

$ballerina run integrator/
ballerina: enter secret for config value decryption: 
<type your encryption password here (not visible), 1234>

ballerina: started HTTP/WS endpoint 0.0.0.0:3001


2019-03-03 12:44:25,999 INFO  [integrator:0.0.0] - service started  

推荐阅读