/
add-on-nlb-hello-world.go
72 lines (62 loc) · 2.49 KB
/
add-on-nlb-hello-world.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
71
72
package eksconfig
import (
"errors"
"github.com/aws/aws-k8s-tester/pkg/timeutil"
)
// AddOnNLBHelloWorld defines parameters for EKS cluster
// add-on NLB hello-world service.
type AddOnNLBHelloWorld 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"`
TimeFrameCreate timeutil.TimeFrame `json:"time-frame-create" read-only:"true"`
TimeFrameDelete timeutil.TimeFrame `json:"time-frame-delete" read-only:"true"`
// Namespace is the namespace to create objects in.
Namespace string `json:"namespace"`
// DeploymentReplicas is the number of replicas to deploy using "Deployment" object.
DeploymentReplicas int32 `json:"deployment-replicas"`
// DeploymentNodeSelector is configured to overwrite existing node selector
// for NLB hello world deployment. If left empty, tester sets default selector.
DeploymentNodeSelector map[string]string `json:"deployment-node-selector"`
// NLBARN is the ARN of the NLB created from the service.
NLBARN string `json:"nlb-arn" read-only:"true"`
// NLBName is the name of the NLB created from the service.
NLBName string `json:"nlb-name" read-only:"true"`
// URL is the host name for hello-world service.
URL string `json:"url" read-only:"true"`
}
// EnvironmentVariablePrefixAddOnNLBHelloWorld is the environment variable prefix used for "eksconfig".
const EnvironmentVariablePrefixAddOnNLBHelloWorld = AWS_K8S_TESTER_EKS_PREFIX + "ADD_ON_NLB_HELLO_WORLD_"
// IsEnabledAddOnNLBHelloWorld returns true if "AddOnNLBHelloWorld" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnNLBHelloWorld() bool {
if cfg.AddOnNLBHelloWorld == nil {
return false
}
if cfg.AddOnNLBHelloWorld.Enable {
return true
}
cfg.AddOnNLBHelloWorld = nil
return false
}
func getDefaultAddOnNLBHelloWorld() *AddOnNLBHelloWorld {
return &AddOnNLBHelloWorld{
Enable: false,
DeploymentReplicas: 3,
DeploymentNodeSelector: make(map[string]string),
}
}
func (cfg *Config) validateAddOnNLBHelloWorld() error {
if !cfg.IsEnabledAddOnNLBHelloWorld() {
return nil
}
if !cfg.IsEnabledAddOnNodeGroups() && !cfg.IsEnabledAddOnManagedNodeGroups() {
return errors.New("AddOnNLBHelloWorld.Enable true but no node group is enabled")
}
if cfg.AddOnNLBHelloWorld.Namespace == "" {
cfg.AddOnNLBHelloWorld.Namespace = cfg.Name + "-nlb-hello-world"
}
return nil
}