forked from hashicorp/terraform-config-inspect
/
module.go
44 lines (37 loc) · 1.72 KB
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package tfconfig
// Module is the top-level type representing a parsed and processed Terraform
// module.
type Module struct {
// Path is the local filesystem directory where the module was loaded from.
Path string `json:"path"`
Variables map[string]*Variable `json:"variables"`
Outputs map[string]*Output `json:"outputs"`
RequiredCore []string `json:"required_core,omitempty"`
RequiredProviders map[string]*ProviderRequirement `json:"required_providers"`
ProviderConfigs map[string]*ProviderConfig `json:"provider_configs,omitempty"`
ManagedResources map[string]*Resource `json:"managed_resources"`
DataResources map[string]*Resource `json:"data_resources"`
ModuleCalls map[string]*ModuleCall `json:"module_calls"`
// Diagnostics records any errors and warnings that were detected during
// loading, primarily for inclusion in serialized forms of the module
// since this slice is also returned as a second argument from LoadModule.
Diagnostics Diagnostics `json:"diagnostics,omitempty"`
}
// ProviderConfig represents a provider block in the configuration
type ProviderConfig struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
}
// NewModule creates new Module representing Terraform module at the given path
func NewModule(path string) *Module {
return &Module{
Path: path,
Variables: make(map[string]*Variable),
Outputs: make(map[string]*Output),
RequiredProviders: make(map[string]*ProviderRequirement),
ProviderConfigs: make(map[string]*ProviderConfig),
ManagedResources: make(map[string]*Resource),
DataResources: make(map[string]*Resource),
ModuleCalls: make(map[string]*ModuleCall),
}
}