Debian Codegraph @

tfconfig/module.go

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