forked from acburdine/hideNsneak
/
stateStructs.go
181 lines (155 loc) · 6.28 KB
/
stateStructs.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package deployer
import "strings"
type State struct {
// Version is the state file protocol version.
Version int `json:"version"`
// TFVersion is the version of Terraform that wrote this state.
TFVersion string `json:"terraform_version,omitempty"`
// Serial is incremented on any operation that modifies
// the State file. It is used to detect potentially conflicting
// updates.
Serial int64 `json:"serial"`
// Modules contains all the modules in a breadth-first order
Modules []ModuleState `json:"modules"`
}
type ModuleState struct {
// Path is the import path from the root module. Modules imports are
// always disjoint, so the path represents amodule tree
Path []string `json:"path"`
// Locals are kept only transiently in-memory, because we can always
// re-compute them.
Locals map[string]interface{} `json:"-"`
// Outputs declared by the module and maintained for each module
// even though only the root module technically needs to be kept.
// This allows operators to inspect values at the boundaries.
Outputs map[string]*OutputState `json:"outputs"`
// Resources is a mapping of the logically named resource to
// the state of the resource. Each resource may actually have
// N instances underneath, although a user only needs to think
// about the 1:1 case.
Resources map[string]ResourceState `json:"resources"`
// Dependencies are a list of things that this module relies on
// existing to remain intact. For example: an module may depend
// on a VPC ID given by an aws_vpc resource.
//
// Terraform uses this information to build valid destruction
// orders and to warn the user if they're destroying a module that
// another resource depends on.
//
// Things can be put into this list that may not be managed by
// Terraform. If Terraform doesn't find a matching ID in the
// overall state, then it assumes it isn't managed and doesn't
// worry about it.
Dependencies []string `json:"depends_on"`
}
type OutputState struct {
// Sensitive describes whether the output is considered sensitive,
// which may lead to masking the value on screen in some cases.
Sensitive bool `json:"sensitive"`
// Type describes the structure of Value. Valid values are "string",
// "map" and "list"
Type string `json:"type"`
// Value contains the value of the output, in the structure described
// by the Type field.
Value interface{} `json:"value"`
}
type ResourceState struct {
// This is filled in and managed by Terraform, and is the resource
// type itself such as "mycloud_instance". If a resource provider sets
// this value, it won't be persisted.
Type string `json:"type"`
// Dependencies are a list of things that this resource relies on
// existing to remain intact. For example: an AWS instance might
// depend on a subnet (which itself might depend on a VPC, and so
// on).
//
// Terraform uses this information to build valid destruction
// orders and to warn the user if they're destroying a resource that
// another resource depends on.
//
// Things can be put into this list that may not be managed by
// Terraform. If Terraform doesn't find a matching ID in the
// overall state, then it assumes it isn't managed and doesn't
// worry about it.
Dependencies []string `json:"depends_on"`
// Primary is the current active instance for this resource.
// It can be replaced but only after a successful creation.
// This is the instances on which providers will act.
Primary InstanceState `json:"primary"`
// Provider is used when a resource is connected to a provider with an alias.
// If this string is empty, the resource is connected to the default provider,
// e.g. "aws_instance" goes with the "aws" provider.
// If the resource block contained a "provider" key, that value will be set here.
Provider string `json:"provider"`
}
type InstanceState struct {
// A unique ID for this resource. This is opaque to Terraform
// and is only meant as a lookup mechanism for the providers.
ID string `json:"id"`
// Attributes are basic information about the resource. Any keys here
// are accessible in variable format within Terraform configurations:
// ${resourcetype.name.attribute}.
Attributes map[string]interface{} `json:"attributes"`
// Meta is a simple K/V map that is persisted to the State but otherwise
// ignored by Terraform core. It's meant to be used for accounting by
// external client code. The value here must only contain Go primitives
// and collections.
Meta map[string]interface{} `json:"meta"`
// Tainted is used to mark a resource for recreation.
Tainted bool `json:"tainted"`
}
type ConfigWrappers struct {
EC2 []EC2ConfigWrapper
EC2ModuleCount int
DO []DOConfigWrapper
DropletModuleCount int
AWSAPI []AWSApiConfigWrapper
AWSAPIModuleCount int
Cloudfront []CloudfrontConfigWrapper
CloudfrontModuleCount int
Googlefront []GooglefrontConfigWrapper
GooglefrontModuleCount int
}
type ListStruct struct {
IP string
Provider string
Region string
Name string
Place int
Username string
PrivateKey string
}
func (listStruct *ListStruct) String() string {
return ("IP: " + listStruct.IP + " - Provider: " + listStruct.Provider + " - Region: " + listStruct.Region + " - Name: " + listStruct.Name)
}
type APIOutput struct {
TargetURI string
InvokeURI string
Provider string
Name string
}
func (output APIOutput) String() string {
return " - Target: " + output.TargetURI + " - Invoke URI: " + output.InvokeURI + " - Provider: " + output.Provider + " - Name: " + output.Name
}
type DomainFrontOutput struct {
Name string
Origin string
ID string
Invoke string
Provider string
Etag string
Status string
FunctionName string
RestrictUA string
}
func (output DomainFrontOutput) String() string {
if output.Provider == "GOOGLE" {
origin := strings.Replace(output.Origin, "_", ".", -1)
restrictedUA := output.RestrictUA
if output.RestrictUA == "" {
restrictedUA = "N/A"
}
return " - Origin: " + origin + " - Invoke: " + output.Invoke + " - Status: " + output.Status + " - RestrictedUA: " + restrictedUA + " - Provider: " + output.Provider
}
return " - Origin: " + output.Origin + " - Invoke: " + output.Invoke + " - Status: " + output.Status + " - Provider: " + output.Provider
}