@@ -21,14 +21,14 @@ import (
21
21
"sort"
22
22
"strings"
23
23
24
- "github.com/GoogleCloudPlatform/terraformer/terraform_utils/terraformer_string "
24
+ "github.com/GoogleCloudPlatform/terraformer/terraformutils/terraformerstring "
25
25
26
- "github.com/GoogleCloudPlatform/terraformer/terraform_utils/provider_wrapper "
26
+ "github.com/GoogleCloudPlatform/terraformer/terraformutils/providerwrapper "
27
27
28
28
"github.com/spf13/pflag"
29
29
30
- "github.com/GoogleCloudPlatform/terraformer/terraform_utils "
31
- "github.com/GoogleCloudPlatform/terraformer/terraform_utils/terraform_output "
30
+ "github.com/GoogleCloudPlatform/terraformer/terraformutils "
31
+ "github.com/GoogleCloudPlatform/terraformer/terraformutils/terraformoutput "
32
32
33
33
"github.com/spf13/cobra"
34
34
)
@@ -75,7 +75,7 @@ func newImportCmd() *cobra.Command {
75
75
return cmd
76
76
}
77
77
78
- func Import (provider terraform_utils .ProviderGenerator , options ImportOptions , args []string ) error {
78
+ func Import (provider terraformutils .ProviderGenerator , options ImportOptions , args []string ) error {
79
79
err := provider .Init (args )
80
80
if err != nil {
81
81
return err
@@ -84,10 +84,10 @@ func Import(provider terraform_utils.ProviderGenerator, options ImportOptions, a
84
84
Provider : provider .GetName (),
85
85
Options : options ,
86
86
Args : args ,
87
- ImportedResource : map [string ][]terraform_utils .Resource {},
87
+ ImportedResource : map [string ][]terraformutils .Resource {},
88
88
}
89
89
90
- if terraformer_string .ContainsString (options .Resources , "*" ) {
90
+ if terraformerstring .ContainsString (options .Resources , "*" ) {
91
91
log .Println ("Attempting an import of ALL resources in " + provider .GetName ())
92
92
options .Resources = providerServices (provider )
93
93
}
@@ -104,15 +104,15 @@ func Import(provider terraform_utils.ProviderGenerator, options ImportOptions, a
104
104
return err
105
105
}
106
106
107
- providerWrapper , err := provider_wrapper .NewProviderWrapper (provider .GetName (), provider .GetConfig (), options .Verbose )
107
+ providerWrapper , err := providerwrapper .NewProviderWrapper (provider .GetName (), provider .GetConfig (), options .Verbose )
108
108
if err != nil {
109
109
return err
110
110
}
111
111
112
112
provider .GetService ().PopulateIgnoreKeys (providerWrapper )
113
113
provider .GetService ().InitialCleanup ()
114
114
115
- refreshedResources , err := terraform_utils .RefreshResources (provider .GetService ().GetResources (), providerWrapper )
115
+ refreshedResources , err := terraformutils .RefreshResources (provider .GetService ().GetResources (), providerWrapper )
116
116
if err != nil {
117
117
return err
118
118
}
@@ -139,23 +139,22 @@ func Import(provider terraform_utils.ProviderGenerator, options ImportOptions, a
139
139
if options .Plan {
140
140
path := Path (options .PathPattern , provider .GetName (), "terraformer" , options .PathOutput )
141
141
return ExportPlanFile (plan , path , "plan.json" )
142
- } else {
143
- return ImportFromPlan (provider , plan )
144
142
}
143
+ return ImportFromPlan (provider , plan )
145
144
}
146
145
147
- func ImportFromPlan (provider terraform_utils .ProviderGenerator , plan * ImportPlan ) error {
146
+ func ImportFromPlan (provider terraformutils .ProviderGenerator , plan * ImportPlan ) error {
148
147
options := plan .Options
149
148
importedResource := plan .ImportedResource
150
149
isServicePath := strings .Contains (options .PathPattern , "{service}" )
151
150
152
151
if options .Connect {
153
152
log .Println (provider .GetName () + " Connecting.... " )
154
- importedResource = terraform_utils .ConnectServices (importedResource , isServicePath , provider .GetResourceConnections ())
153
+ importedResource = terraformutils .ConnectServices (importedResource , isServicePath , provider .GetResourceConnections ())
155
154
}
156
155
157
156
if ! isServicePath {
158
- var compactedResources []terraform_utils .Resource
157
+ var compactedResources []terraformutils .Resource
159
158
for _ , resources := range importedResource {
160
159
compactedResources = append (compactedResources , resources ... )
161
160
}
@@ -174,30 +173,30 @@ func ImportFromPlan(provider terraform_utils.ProviderGenerator, plan *ImportPlan
174
173
return nil
175
174
}
176
175
177
- func printService (provider terraform_utils .ProviderGenerator , serviceName string , options ImportOptions , resources []terraform_utils .Resource , importedResource map [string ][]terraform_utils .Resource ) error {
176
+ func printService (provider terraformutils .ProviderGenerator , serviceName string , options ImportOptions , resources []terraformutils .Resource , importedResource map [string ][]terraformutils .Resource ) error {
178
177
log .Println (provider .GetName () + " save " + serviceName )
179
178
// Print HCL files for Resources
180
179
path := Path (options .PathPattern , provider .GetName (), serviceName , options .PathOutput )
181
- err := terraform_output .OutputHclFiles (resources , provider , path , serviceName , options .Compact , options .Output )
180
+ err := terraformoutput .OutputHclFiles (resources , provider , path , serviceName , options .Compact , options .Output )
182
181
if err != nil {
183
182
return err
184
183
}
185
- tfStateFile , err := terraform_utils .PrintTfState (resources )
184
+ tfStateFile , err := terraformutils .PrintTfState (resources )
186
185
if err != nil {
187
186
return err
188
187
}
189
188
// print or upload State file
190
189
if options .State == "bucket" {
191
190
log .Println (provider .GetName () + " upload tfstate to bucket " + options .Bucket )
192
- bucket := terraform_output .BucketState {
191
+ bucket := terraformoutput .BucketState {
193
192
Name : options .Bucket ,
194
193
}
195
194
if err := bucket .BucketUpload (path , tfStateFile ); err != nil {
196
195
return err
197
196
}
198
197
// create Bucket file
199
- if bucketStateDataFile , err := terraform_utils .Print (bucket .BucketGetTfData (path ), map [string ]struct {}{}, options .Output ); err == nil {
200
- terraform_output .PrintFile (path + "/bucket.tf" , bucketStateDataFile )
198
+ if bucketStateDataFile , err := terraformutils .Print (bucket .BucketGetTfData (path ), map [string ]struct {}{}, options .Output ); err == nil {
199
+ terraformoutput .PrintFile (path + "/bucket.tf" , bucketStateDataFile )
201
200
}
202
201
} else {
203
202
if serviceName == "" {
@@ -216,7 +215,7 @@ func printService(provider terraform_utils.ProviderGenerator, serviceName string
216
215
variables ["data" ] = map [string ]map [string ]interface {}{}
217
216
variables ["data" ]["terraform_remote_state" ] = map [string ]interface {}{}
218
217
if options .State == "bucket" {
219
- bucket := terraform_output .BucketState {
218
+ bucket := terraformoutput .BucketState {
220
219
Name : options .Bucket ,
221
220
}
222
221
for k := range provider .GetResourceConnections ()[serviceName ] {
@@ -243,11 +242,11 @@ func printService(provider terraform_utils.ProviderGenerator, serviceName string
243
242
}
244
243
// create variables file
245
244
if len (provider .GetResourceConnections ()[serviceName ]) > 0 && options .Connect && len (variables ["data" ]["terraform_remote_state" ]) > 0 {
246
- variablesFile , err := terraform_utils .Print (variables , map [string ]struct {}{"config" : {}}, options .Output )
245
+ variablesFile , err := terraformutils .Print (variables , map [string ]struct {}{"config" : {}}, options .Output )
247
246
if err != nil {
248
247
return err
249
248
}
250
- terraform_output .PrintFile (path + "/variables." + terraform_output .GetFileExtension (options .Output ), variablesFile )
249
+ terraformoutput .PrintFile (path + "/variables." + terraformoutput .GetFileExtension (options .Output ), variablesFile )
251
250
}
252
251
}
253
252
} else {
@@ -256,7 +255,7 @@ func printService(provider terraform_utils.ProviderGenerator, serviceName string
256
255
variables ["data" ] = map [string ]map [string ]interface {}{}
257
256
variables ["data" ]["terraform_remote_state" ] = map [string ]interface {}{}
258
257
if options .State == "bucket" {
259
- bucket := terraform_output .BucketState {
258
+ bucket := terraformoutput .BucketState {
260
259
Name : options .Bucket ,
261
260
}
262
261
variables ["data" ]["terraform_remote_state" ]["local" ] = map [string ]interface {}{
@@ -273,11 +272,11 @@ func printService(provider terraform_utils.ProviderGenerator, serviceName string
273
272
}
274
273
// create variables file
275
274
if options .Connect {
276
- variablesFile , err := terraform_utils .Print (variables , map [string ]struct {}{"config" : {}}, options .Output )
275
+ variablesFile , err := terraformutils .Print (variables , map [string ]struct {}{"config" : {}}, options .Output )
277
276
if err != nil {
278
277
return err
279
278
}
280
- terraform_output .PrintFile (path + "/variables." + terraform_output .GetFileExtension (options .Output ), variablesFile )
279
+ terraformoutput .PrintFile (path + "/variables." + terraformoutput .GetFileExtension (options .Output ), variablesFile )
281
280
}
282
281
}
283
282
}
@@ -292,7 +291,7 @@ func Path(pathPattern, providerName, serviceName, output string) string {
292
291
).Replace (pathPattern )
293
292
}
294
293
295
- func listCmd (provider terraform_utils .ProviderGenerator ) * cobra.Command {
294
+ func listCmd (provider terraformutils .ProviderGenerator ) * cobra.Command {
296
295
cmd := & cobra.Command {
297
296
Use : "list" ,
298
297
Short : "List supported resources for " + provider .GetName () + " provider" ,
@@ -309,7 +308,7 @@ func listCmd(provider terraform_utils.ProviderGenerator) *cobra.Command {
309
308
return cmd
310
309
}
311
310
312
- func providerServices (provider terraform_utils .ProviderGenerator ) []string {
311
+ func providerServices (provider terraformutils .ProviderGenerator ) []string {
313
312
var services []string
314
313
for k := range provider .GetSupportedService () {
315
314
services = append (services , k )
0 commit comments