-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
endpoint_service.go
50 lines (45 loc) · 1.37 KB
/
endpoint_service.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
package v1alpha5
import (
"github.com/pkg/errors"
)
const (
// Endpoint services that are required and cannot be disabled
EndpointServiceEC2 = "ec2"
EndpointServiceECRAPI = "ecr.api"
EndpointServiceECRDKR = "ecr.dkr"
EndpointServiceS3 = "s3"
EndpointServiceSTS = "sts"
)
// Values for `AdditionalEndpointServices`
// Additional endpoint services
const (
EndpointServiceCloudFormation = "cloudformation"
EndpointServiceAutoscaling = "autoscaling"
EndpointServiceCloudWatch = "logs"
)
// RequiredEndpointServices returns a list of endpoint services that are required for a fully-private cluster
func RequiredEndpointServices() []string {
return []string{
EndpointServiceEC2,
EndpointServiceECRAPI,
EndpointServiceECRDKR,
EndpointServiceS3,
EndpointServiceSTS,
}
}
// ValidateAdditionalEndpointServices validates support for the specified additional endpoint services
func ValidateAdditionalEndpointServices(services []string) error {
seen := make(map[string]struct{})
for _, service := range services {
switch service {
case EndpointServiceCloudFormation, EndpointServiceAutoscaling, EndpointServiceCloudWatch:
if _, ok := seen[service]; ok {
return errors.Errorf("found duplicate endpoint service: %q", service)
}
seen[service] = struct{}{}
default:
return errors.Errorf("unsupported endpoint service %q", service)
}
}
return nil
}