github - Jsonnet 的 std.lines(arr) 函数示例
问题描述
谁能帮我举一个 Jsonnet 的 std.lines(arr) 函数的例子?我正在尝试创建一个 bash 脚本来使用数组中的值克隆多个 git 存储库。我的数组结构如下所示。
gitRepo : [
{
github_repo: "github.com/abcd.git",
github_id: "tom",
github_access_token: "1aae0a6dc19aef327565"
},
{
github_repo: "github.com/qwerty.git",
github_id: "alice",
github_access_token: "2e2eef327565"
},
],
}
提前致谢...
解决方案
从 jsonnet google groups 中找到了解决方案。
local config = [
{
github_repo: 'github.com/abcd.git',
github_id: 'tom',
github_access_token: '1aae0a6dc19aef327565',
},
{
github_repo: 'github.com/qwerty.git',
github_id: 'alice',
github_access_token: '2e2eef327565',
},
];
std.lines([
'git clone %(github_repo)s --user=%(github_id)s --token=%(github_access_token)s' % item
for item in config
])
用jsonnet -S test.jsonnet
. (注意大写-S
标志)
推荐阅读
- c++ - 为什么 std::all_of() 的编码版本与对 std::all_of() 的调用不同?
- javascript - auth0 loginWithRedirect() 不同提供者的不同范围
- python - Python Selenium 等待不起作用/Java Selenium 问题
- r - R:函数返回未使用的参数
- loss-function - 我可以根据人口的子集为 GBM(或任何 ML 算法)指定损失函数吗?
- c# - Visual Studio 未找到任何引用或包
- windows - 无法在 Windows Server 上使用 Powershell 挂载 AzureFileShare
- android - 无法从 Kotlin 类中的 Java 类调用公共函数
- react-native - REACT NATIVE 回购之前购买的订单
- node.js - 如何将 POST 请求发送到 Firebase 函数