forked from terraform-docs/terraform-docs
-
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.
Move github.com/hashicorp/terraform-config-inspect to internal/tfconfig
Internally we depend on terraform-config-inspect, but at the moment they state that they consider the project is feature-complete and they do not accept any enhancement pull requests, as such we've decided to bring over the project as internal package here rather than being a vendor dependency and apply the fix from @jstewmon from hashicorp/terraform-config-inspect#24 directly here. Since the terraform-config-inspect is considered to be feature-complete we don't expect to have any more changes on the package, and if there was a change on upstream we're going to bring it down in the corresponding package.
- Loading branch information
Showing
130 changed files
with
5,848 additions
and
680 deletions.
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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,59 @@ | ||
package tfconfig | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/go-test/deep" | ||
) | ||
|
||
func TestLoadModule(t *testing.T) { | ||
fixturesDir := "testdata" | ||
testDirs, err := ioutil.ReadDir(fixturesDir) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
for _, info := range testDirs { | ||
if !info.IsDir() { | ||
continue | ||
} | ||
t.Run(info.Name(), func(t *testing.T) { | ||
name := info.Name() | ||
path := filepath.Join(fixturesDir, name) | ||
|
||
wantSrc, err := ioutil.ReadFile(filepath.Join(path, name+".out.json")) | ||
if err != nil { | ||
t.Fatalf("failed to read result file: %s", err) | ||
} | ||
var want map[string]interface{} | ||
err = json.Unmarshal(wantSrc, &want) | ||
if err != nil { | ||
t.Fatalf("failed to parse result file: %s", err) | ||
} | ||
|
||
gotObj, _ := LoadModule(path) | ||
if gotObj == nil { | ||
t.Fatalf("result object is nil; want a real object") | ||
} | ||
|
||
gotSrc, err := json.Marshal(gotObj) | ||
if err != nil { | ||
t.Fatalf("result is not JSON-able: %s", err) | ||
} | ||
var got map[string]interface{} | ||
err = json.Unmarshal(gotSrc, &got) | ||
if err != nil { | ||
t.Fatalf("failed to parse the actual result (!?): %s", err) | ||
} | ||
|
||
if diff := deep.Equal(got, want); diff != nil { | ||
for _, problem := range diff { | ||
t.Errorf("%s", problem) | ||
} | ||
} | ||
}) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
72 changes: 72 additions & 0 deletions
72
internal/tfconfig/testdata/basics-json/basics-json.out.json
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 @@ | ||
{ | ||
"path": "testdata/basics-json", | ||
"required_providers": { | ||
"null": {} | ||
}, | ||
"variables": { | ||
"A": { | ||
"name": "A", | ||
"default": "A default", | ||
"required": false, | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 3 | ||
} | ||
}, | ||
"B": { | ||
"name": "B", | ||
"description": "The B variable", | ||
"default": null, | ||
"required": true, | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 6 | ||
} | ||
} | ||
}, | ||
"outputs": { | ||
"A": { | ||
"name": "A", | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 11 | ||
} | ||
}, | ||
"B": { | ||
"name": "B", | ||
"description": "I am B", | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 14 | ||
} | ||
} | ||
}, | ||
"managed_resources": { | ||
"null_resource.A": { | ||
"mode": "managed", | ||
"type": "null_resource", | ||
"name": "A", | ||
"provider": { | ||
"name": "null" | ||
}, | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 21 | ||
} | ||
}, | ||
"null_resource.B": { | ||
"mode": "managed", | ||
"type": "null_resource", | ||
"name": "B", | ||
"provider": { | ||
"name": "null" | ||
}, | ||
"pos": { | ||
"filename": "testdata/basics-json/basics.tf.json", | ||
"line": 22 | ||
} | ||
} | ||
}, | ||
"data_resources": {}, | ||
"module_calls": {} | ||
} |
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,25 @@ | ||
{ | ||
"variable": { | ||
"A": { | ||
"default": "A default" | ||
}, | ||
"B": { | ||
"description": "The B variable" | ||
} | ||
}, | ||
"output": { | ||
"A": { | ||
"value": "${var.A}" | ||
}, | ||
"B": { | ||
"description": "I am B", | ||
"value": "${var.A}" | ||
} | ||
}, | ||
"resource": { | ||
"null_resource": { | ||
"A": {}, | ||
"B": {} | ||
} | ||
} | ||
} |
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 @@ | ||
{ | ||
"path": "testdata/basics", | ||
"required_providers": { | ||
"null": {} | ||
}, | ||
"variables": { | ||
"A": { | ||
"name": "A", | ||
"default": "A default", | ||
"required": false, | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 1 | ||
} | ||
}, | ||
"B": { | ||
"name": "B", | ||
"description": "The B variable", | ||
"default": null, | ||
"required": true, | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 5 | ||
} | ||
} | ||
}, | ||
"outputs": { | ||
"A": { | ||
"name": "A", | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 9 | ||
} | ||
}, | ||
"B": { | ||
"name": "B", | ||
"description": "I am B", | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 13 | ||
} | ||
} | ||
}, | ||
"managed_resources": { | ||
"null_resource.A": { | ||
"mode": "managed", | ||
"type": "null_resource", | ||
"name": "A", | ||
"provider": { | ||
"name": "null" | ||
}, | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 18 | ||
} | ||
}, | ||
"null_resource.B": { | ||
"mode": "managed", | ||
"type": "null_resource", | ||
"name": "B", | ||
"provider": { | ||
"name": "null" | ||
}, | ||
"pos": { | ||
"filename": "testdata/basics/basics.tf", | ||
"line": 19 | ||
} | ||
} | ||
}, | ||
"data_resources": {}, | ||
"module_calls": {} | ||
} |
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,18 @@ | ||
|
||
# Module `testdata/basics` | ||
|
||
Provider Requirements: | ||
* **null:** (any version) | ||
|
||
## Input Variables | ||
* `A` (default `"A default"`) | ||
* `B` (required): The B variable | ||
|
||
## Output Values | ||
* `A` | ||
* `B`: I am B | ||
|
||
## Managed Resources | ||
* `null_resource.A` from `null` | ||
* `null_resource.B` from `null` | ||
|
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,19 @@ | ||
variable "A" { | ||
default = "A default" | ||
} | ||
|
||
variable "B" { | ||
description = "The B variable" | ||
} | ||
|
||
output "A" { | ||
value = "${var.A}" | ||
} | ||
|
||
output "B" { | ||
description = "I am B" | ||
value = "${var.A}" | ||
} | ||
|
||
resource "null_resource" "A" {} | ||
resource "null_resource" "B" {} |
Oops, something went wrong.