-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yoriyasu Yano <[email protected]>
- Loading branch information
1 parent
a9dc739
commit 9c1df8b
Showing
25 changed files
with
1,191 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**Logs** | ||
Any error logs indicating the bug. Please share debug logs as well (`--loglevel debug`). | ||
|
||
**Minimal reproducible example** | ||
Example code snippet, or github repo where running using `tf.libsonnet` will demonstrate the issue. | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/test" | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: lint-and-test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | ||
|
||
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 | ||
with: | ||
go-version: 1.19 | ||
|
||
- name: install jsonnet-bundler, jsonnetfmt, and jsonnet-lint | ||
run: | | ||
go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest | ||
go install github.com/google/go-jsonnet/cmd/jsonnet-lint@latest | ||
- name: check for fmt | ||
run: | | ||
find . -name "*.jsonnet" -or -name "*.libsonnet" | xargs -L1 jsonnetfmt --test | ||
- name: check for lint | ||
run: | | ||
export JSONNET_PATH="$(pwd)/vendor:$(pwd)" | ||
find . -name "*.jsonnet" -or -name "*.libsonnet" -not -path "*/vendor/*" \ | ||
| xargs -L1 -t jsonnet-lint | ||
golangci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 | ||
with: | ||
go-version: 1.19 | ||
|
||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1 | ||
with: | ||
version: v1.50.1 | ||
args: "--timeout=10m" | ||
working-directory: "test" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 | ||
|
||
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | ||
with: | ||
terraform_version: 1.3.6 | ||
terraform_wrapper: false | ||
|
||
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1 | ||
with: | ||
go-version: 1.19 | ||
cache: true | ||
cache-dependency-path: test/go.sum | ||
|
||
- name: run tests | ||
run: | | ||
cd test | ||
go test -v . |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# tf-libsonnet | ||
<h1 align="center">tf-libsonnet</h1> | ||
|
||
<p align="center"> | ||
<em>Generate Terraform with Jsonnet</em> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/fensak-io/tf-libsonnet/blob/main/LICENSE"> | ||
<img alt="LICENSE" src="https://img.shields.io/github/license/fensak-io/tf-libsonnet?style=for-the-badge"> | ||
</a> | ||
<a href="https://github.com/fensak-io/tf-libsonnet/actions/workflows/lint-and-test.yml?query=branch%3Amain"> | ||
<img alt="main branch CI" src="https://img.shields.io/github/workflow/status/fensak-io/tf-libsonnet/lint-and-test/main?logo=github&label=CI&style=for-the-badge"> | ||
</a> | ||
<a href="https://github.com/fensak-io/tf-libsonnet/releases/latest"> | ||
<img alt="latest release" src="https://img.shields.io/github/v/release/fensak-io/tf-libsonnet?style=for-the-badge"> | ||
</a> | ||
</p> | ||
|
||
This repository contains [Jsonnet](https://jsonnet.org/) functions for generating Terraform code. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"msgs": [ | ||
"hello", | ||
"world" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local h = import '_custom/helpers.libsonnet'; | ||
|
||
h.mergeAll([ | ||
{ msgs+: ['hello'] }, | ||
{ msgs+: ['world'] }, | ||
]) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"greeting": "hello", | ||
"message": "world" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
local h = import '_custom/helpers.libsonnet'; | ||
|
||
h.mergeAll([ | ||
{ greeting: 'hello' }, | ||
{ message: 'world' }, | ||
]) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"one": 1, | ||
"three": { | ||
"three": 3 | ||
}, | ||
"two": "2-" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local h = import '_custom/helpers.libsonnet'; | ||
|
||
local obj = { | ||
one: 1, | ||
two: '2-', | ||
three: { | ||
three: 3, | ||
}, | ||
}; | ||
|
||
{ | ||
[f.k]: f.v | ||
for f in h.objItems(obj) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"one": 1, | ||
"two": "2-" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local h = import '_custom/helpers.libsonnet'; | ||
|
||
local obj = { | ||
one: 1, | ||
two: '2-', | ||
three:: { | ||
three: 3, | ||
}, | ||
}; | ||
|
||
{ | ||
[f.k]: f.v | ||
for f in h.objItems(obj) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"one": 1, | ||
"three": { | ||
"three": 3 | ||
}, | ||
"two": "2-" | ||
} |
14 changes: 14 additions & 0 deletions
14
test/fixtures/helpers/objitemsall_with_hidden/test.jsonnet
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local h = import '_custom/helpers.libsonnet'; | ||
|
||
local obj = { | ||
one: 1, | ||
two: '2-', | ||
three:: { | ||
three: 3, | ||
}, | ||
}; | ||
|
||
{ | ||
[f.k]: f.v | ||
for f in h.objItemsAll(obj) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
tf.withData('null_data_source', 'foo', { | ||
inputs: { | ||
msg: 'hello world', | ||
}, | ||
}) | ||
+ tf.withOutput('output', { msg: '${data.null_data_source.foo.outputs.msg}' }) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
tf.withLocal('foo', { msg: 'hello world' }) | ||
+ tf.withOutput('output', '${local.foo}') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
tf.withOutput('output', { msg: 'hello world' }) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
local o = | ||
tf.withData('null_data_source', 'foo', { | ||
inputs: { | ||
msg: 'hello world', | ||
}, | ||
}) | ||
+ tf.withResource('null_resource', 'foo', {}) | ||
+ tf.withOutput('output', { | ||
msg: o._ref.data.null_data_source.foo.get('outputs.msg'), | ||
null_resource_id: o._ref.null_resource.foo.get('id'), | ||
}); | ||
|
||
o |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
tf.withResource('null_resource', 'foo', {}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
local tf = import 'main.libsonnet'; | ||
|
||
tf.withVariable('required_input', type='string') | ||
+ tf.withVariable('optional_number', isRequired=false, type='number', default=0) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module github.com/fensak-io/tf-libsonnet/test | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/google/go-jsonnet v0.19.1 | ||
github.com/gruntwork-io/terratest v0.41.6 | ||
github.com/onsi/gomega v1.24.1 | ||
) | ||
|
||
require ( | ||
cloud.google.com/go v0.83.0 // indirect | ||
cloud.google.com/go/storage v1.10.0 // indirect | ||
github.com/agext/levenshtein v1.2.3 // indirect | ||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect | ||
github.com/aws/aws-sdk-go v1.40.56 // indirect | ||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.3 // indirect | ||
github.com/google/go-cmp v0.5.9 // indirect | ||
github.com/googleapis/gax-go/v2 v2.0.5 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect | ||
github.com/hashicorp/go-getter v1.6.1 // indirect | ||
github.com/hashicorp/go-multierror v1.1.0 // indirect | ||
github.com/hashicorp/go-safetemp v1.0.0 // indirect | ||
github.com/hashicorp/go-version v1.3.0 // indirect | ||
github.com/hashicorp/hcl/v2 v2.9.1 // indirect | ||
github.com/hashicorp/terraform-json v0.13.0 // indirect | ||
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/jstemmer/go-junit-report v0.9.1 // indirect | ||
github.com/klauspost/compress v1.13.0 // indirect | ||
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/mitchellh/go-testing-interface v1.0.0 // indirect | ||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.7.0 // indirect | ||
github.com/tmccombs/hcl2json v0.3.3 // indirect | ||
github.com/ulikunitz/xz v0.5.8 // indirect | ||
github.com/zclconf/go-cty v1.9.1 // indirect | ||
go.opencensus.io v0.23.0 // indirect | ||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect | ||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect | ||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect | ||
golang.org/x/net v0.2.0 // indirect | ||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect | ||
golang.org/x/sys v0.2.0 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
golang.org/x/tools v0.1.12 // indirect | ||
google.golang.org/api v0.47.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect | ||
google.golang.org/grpc v1.38.0 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
sigs.k8s.io/yaml v1.2.0 // indirect | ||
) |
Oops, something went wrong.