/
input_generator.go
46 lines (37 loc) · 1.04 KB
/
input_generator.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
package azure
import (
"strings"
"github.com/cloudfoundry/bosh-bootloader/storage"
)
type InputGenerator struct {
}
func NewInputGenerator() InputGenerator {
return InputGenerator{}
}
func (i InputGenerator) Generate(state storage.State) (map[string]interface{}, error) {
simpleEnvId := strings.Replace(state.EnvID, "-", "", -1)
if len(simpleEnvId) > 20 {
simpleEnvId = simpleEnvId[:20]
}
input := map[string]interface{}{
"env_id": state.EnvID,
"simple_env_id": simpleEnvId,
"region": state.Azure.Region,
}
if state.LB.Cert != "" && state.LB.Key != "" {
input["pfx_cert_base64"] = state.LB.Cert
input["pfx_password"] = state.LB.Key
}
if state.LB.Domain != "" {
input["system_domain"] = state.LB.Domain
}
return input, nil
}
func (i InputGenerator) Credentials(state storage.State) map[string]string {
return map[string]string{
"subscription_id": state.Azure.SubscriptionID,
"tenant_id": state.Azure.TenantID,
"client_id": state.Azure.ClientID,
"client_secret": state.Azure.ClientSecret,
}
}