-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (59 loc) · 1.67 KB
/
main.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
package terraform
import (
"github.com/cjlapao/common-go/fileproc"
"github.com/cjlapao/common-go/helper"
"github.com/cjlapao/common-go/log"
"github.com/cjlapao/deployment-tools-go/module"
)
// Module Terraform Module
type Module struct {
VariableFileName string
Verbose bool
Exists bool
Version Version
Module *module.DeploymentToolsModule
}
var globalTerraformModule *Module
var logger = log.Get()
// Create Creates a terraform module to be used in the deployment tools
func Create() *Module {
if globalTerraformModule != nil {
return globalTerraformModule
}
module := Module{
Verbose: false,
Exists: false,
Module: &module.DeploymentToolsModule{
Name: "Terraform",
WindowsExecutableName: "terraform.exe",
LinuxExecutableName: "terraform",
GetOnlineVersions: GetOnlineVersions,
Download: Download,
GetLocalVersion: GetLocalVersion,
},
}
module.Module.GetLatestCachedVersion()
globalTerraformModule = &module
return globalTerraformModule
}
func (m *Module) ImportTest(filePath string, format ImportFormat, variables ...fileproc.Variable) {
if helper.FileExists(filePath) {
logger.Info("Found file %v, reading content", filePath)
content, err := helper.ReadFromFile(filePath)
if err != nil {
logger.Error(err)
return
}
if len(variables) > 0 {
content = fileproc.Process(content, variables...)
}
imp, err := m.ReadImportContent(content, format)
if err != nil {
logger.Error(err)
}
logger.Debug("ID: %v", imp.Azure.SubscriptionID)
for _, topic := range imp.Azure.ServiceBus.Topics {
logger.Debug("Topic Name: %v", topic.Name)
}
}
}