/
add-on-app-mesh.go
70 lines (61 loc) · 2.28 KB
/
add-on-app-mesh.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 eksconfig
import (
"errors"
"time"
)
// AddOnAppMesh defines parameters for EKS cluster
// add-on "EKS App Mesh Integration".
type AddOnAppMesh struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create objects in.
Namespace string `json:"namespace"`
// ControllerImage is the image of appMesh controller
ControllerImage string `json:"controller-image"`
// InjectorImage is the image of appMesh injector
InjectorImage string `json:"injector-image"`
// PolicyCFNStackID is the CFN stack ID for policy.
PolicyCFNStackID string `json:"policy-cfn-stack-id,omitempty" read-only:"true"`
}
// EnvironmentVariablePrefixAddOnAppMesh is the environment variable prefix used for "eksconfig".
const EnvironmentVariablePrefixAddOnAppMesh = AWS_K8S_TESTER_EKS_PREFIX + "ADD_ON_APP_MESH_"
// IsEnabledAddOnAppMesh returns true if "AddOnAppMesh" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnAppMesh() bool {
if cfg.AddOnAppMesh == nil {
return false
}
if cfg.AddOnAppMesh.Enable {
return true
}
cfg.AddOnAppMesh = nil
return false
}
func getDefaultAddOnAppMesh() *AddOnAppMesh {
return &AddOnAppMesh{
Enable: false,
}
}
func (cfg *Config) validateAddOnAppMesh() error {
if !cfg.IsEnabledAddOnAppMesh() {
return nil
}
if !cfg.IsEnabledAddOnNodeGroups() && !cfg.IsEnabledAddOnManagedNodeGroups() {
return errors.New("AddOnAppMesh.Enable true but no node group is enabled")
}
if cfg.AddOnAppMesh.Namespace == "" {
cfg.AddOnAppMesh.Namespace = "appmesh-system"
}
return nil
}