forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate.go
41 lines (37 loc) · 1.12 KB
/
validate.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
package v20170930
import (
"fmt"
"strings"
"github.com/Azure/acs-engine/pkg/api/common"
)
// Validate implements APIObject
func (o *OrchestratorVersionProfile) Validate() error {
switch {
case strings.EqualFold(o.OrchestratorType, Kubernetes):
o.OrchestratorType = Kubernetes
case strings.EqualFold(o.OrchestratorType, DCOS):
o.OrchestratorType = DCOS
case strings.EqualFold(o.OrchestratorType, Swarm):
o.OrchestratorType = Swarm
case strings.EqualFold(o.OrchestratorType, DockerCE):
o.OrchestratorType = DockerCE
default:
return fmt.Errorf("Unsupported orchestrator '%s'", o.OrchestratorType)
}
return nil
}
// ValidateForUpgrade validates upgrade input data
func (o *OrchestratorProfile) ValidateForUpgrade() error {
switch o.OrchestratorType {
case DCOS, DockerCE, Swarm:
return fmt.Errorf("Upgrade is not supported for orchestrator %s", o.OrchestratorType)
case Kubernetes:
switch o.OrchestratorVersion {
case common.KubernetesVersion1Dot6Dot13:
case common.KubernetesVersion1Dot7Dot12:
default:
return fmt.Errorf("Upgrade to Kubernetes %s is not supported", o.OrchestratorVersion)
}
}
return nil
}