forked from cloudfoundry/bosh-bootloader
/
command.go
35 lines (27 loc) · 792 Bytes
/
command.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
package commands
import (
"fmt"
"strings"
"github.com/cloudfoundry/bosh-bootloader/storage"
)
type Command interface {
CheckFastFails(subcommandFlags []string, state storage.State) error
Execute(subcommandFlags []string, state storage.State) error
Usage() string
}
func lbExists(lbType string) bool {
return lbType == "concourse" || lbType == "cf"
}
func certificateNameFor(lbType string, generator guidGenerator, envid string) (string, error) {
guid, err := generator.Generate()
if err != nil {
return "", err
}
var certificateName string
if envid == "" {
certificateName = fmt.Sprintf("%s-elb-cert-%s", lbType, guid)
} else {
certificateName = fmt.Sprintf("%s-elb-cert-%s-%s", lbType, guid, envid)
}
return strings.Replace(certificateName, ":", "-", -1), nil
}