forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment_validator.go
37 lines (30 loc) · 1 KB
/
environment_validator.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
package application
import (
"errors"
"fmt"
"github.com/cloudfoundry/bosh-bootloader/storage"
)
var BBLNotFound error = errors.New("a bbl environment could not be found, please create a new environment before running this command again")
type EnvironmentValidator struct {
awsEnvironmentValidator environmentValidator
gcpEnvironmentValidator environmentValidator
}
type environmentValidator interface {
Validate(storage.State) error
}
func NewEnvironmentValidator(awsEnvironmentValidator environmentValidator, gcpEnvironmentValidator environmentValidator) EnvironmentValidator {
return EnvironmentValidator{
awsEnvironmentValidator: awsEnvironmentValidator,
gcpEnvironmentValidator: gcpEnvironmentValidator,
}
}
func (e EnvironmentValidator) Validate(state storage.State) error {
switch state.IAAS {
case "gcp":
return e.gcpEnvironmentValidator.Validate(state)
case "aws":
return e.awsEnvironmentValidator.Validate(state)
default:
return fmt.Errorf("invalid IAAS specified: %s", state.IAAS)
}
}