git - Github 提交/推送规则,检查两个文件是否具有相同的变量列表
问题描述
我的 Github 存储库中有两个用Ballerina语言编写的文件。
即,ballerina.conf
用于ballerina.conf.example
存储类似的配置变量列表。
在这些文件中,我将 ACTUAL 用户凭据(用于连接到多个系统)保存在ballerina.conf
文件中。
但是在将项目提交到 GitHub 时,我只想提交ballerina.conf.example
文件。我可以省略ballerina.conf
文件中的.gitignore
文件。
我的问题是,用户有时可能会忘记在ballerina.conf
和ballerina.conf.example
文件中包含相同的变量。
ballerina.conf -> DB_USERNAME = 'cseuser'
ballerina.conf.example -> DB_USERNAME = '[dbusername]'
有没有办法在 Github 中强制执行规则,以便在提交/推送时比较这两个文件,新引入的变量在两个文件中?
例如,如果用户只在ballerina.conf
文件中引入了一个变量,我想拒绝提交/推送,向用户说明原因。即也将相同的变量添加到ballerina.conf.example
虚拟值中。
解决方案
刚刚发现芭蕾舞女演员语言本身提供了一种使用命令加密密码的方法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
推荐阅读
- apache-nifi - NiFi“架构注册表”无效
- graphql - Apollo graphql:makeExecutableSchema 和游乐场
- c# - 有时 IOrganizationService 对象为空
- javascript - 如何对 observable 上的数据数组进行排序?
- data-science - 预测时如何考虑特征?
- linphone - linphonecsh - 何时调用退出?
- opencl - 为什么这个简单的 OpenCL 代码没有向量化?
- ios - 在 Hour 和 Minute 之间添加冒号 (:) 并在 UIDatePicker 中禁用默认 AM/PM
- google-sheets - 是否可以在不使用脚本的情况下使用另一个单元格(甚至更好的行)被修改的日期来更新一个单元格?
- python - CDK 无法创建 CloudWatch Logs SubscriptionFilter