-
Notifications
You must be signed in to change notification settings - Fork 283
/
curatedpackages.go
91 lines (79 loc) · 2.49 KB
/
curatedpackages.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package framework
import (
"os"
"testing"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
)
type PackageConfig struct {
*HelmInstallConfig
bundleURI string
packageConfiguration *v1alpha1.PackageConfiguration
}
func WithPackageConfig(t *testing.T, bundleURI, chartName, chartURI,
chartVersion string, chartValues []string, packageConfiguration *v1alpha1.PackageConfiguration,
) ClusterE2ETestOpt {
return func(e *ClusterE2ETest) {
e.PackageConfig = &PackageConfig{
HelmInstallConfig: &HelmInstallConfig{
chartName: chartName,
chartURI: chartURI,
chartVersion: chartVersion,
chartValues: chartValues,
HelmClient: buildHelm(t),
},
packageConfiguration: packageConfiguration,
bundleURI: bundleURI,
}
}
}
const (
eksaPackagesRegion = "EKSA_AWS_SECRET_ACCESS_KEY"
eksaPackagesAccessKey = "EKSA_AWS_ACCESS_KEY_ID"
eksaPackagesSecretKey = "EKSA_AWS_REGION"
route53AccessKey = "ROUTE53_ACCESS_KEY_ID"
route53SecretKey = "ROUTE53_SECRET_ACCESS_KEY"
route53Region = "ROUTE53_REGION"
route53ZoneID = "ROUTE53_ZONEID"
)
var requiredPackagesEnvVars = []string{
eksaPackagesRegion,
eksaPackagesAccessKey,
eksaPackagesSecretKey,
}
var requiredCertManagerEnvVars = []string{
route53Region,
route53AccessKey,
route53SecretKey,
route53ZoneID,
}
// RequiredPackagesEnvVars returns the list of packages env vars.
func RequiredPackagesEnvVars() []string {
return requiredPackagesEnvVars
}
// RequiredCertManagerEnvVars returns the list of cert manager env vars.
func RequiredCertManagerEnvVars() []string {
return requiredCertManagerEnvVars
}
// CheckCuratedPackagesCredentials will exit out if the Curated Packages environment variables are not set.
func CheckCuratedPackagesCredentials(t *testing.T) {
for _, env := range requiredPackagesEnvVars {
_, ok := os.LookupEnv(env)
if !ok {
t.Fatalf("Error Unset Packages environment variable: %v is required", env)
}
}
}
// CheckCertManagerCredentials will exit if route53 credentials are not set.
func CheckCertManagerCredentials(t *testing.T) {
for _, env := range requiredCertManagerEnvVars {
_, ok := os.LookupEnv(env)
if !ok {
t.Fatalf("Error Unset Cert Manager environment variable: %v is required", env)
}
}
}
// GetRoute53Configs returns route53 configurations for cert-manager.
func GetRoute53Configs() (string, string, string, string) {
return os.Getenv(route53AccessKey), os.Getenv(route53SecretKey),
os.Getenv(route53Region), os.Getenv(route53ZoneID)
}