...
1 package k8s
2
3 import (
4 "time"
5
6 "edge-infra.dev/test/framework"
7 "edge-infra.dev/test/framework/config"
8 "edge-infra.dev/test/framework/gcp"
9 )
10
11
12 var Timeouts struct {
13 DefaultTimeout time.Duration `default:"30s" description:"default timeout for k8s operations"`
14 Tick time.Duration `default:"1s" description:"default tick interval for k8s operations to be retried"`
15 InstallTimeout time.Duration `default:"60s" description:"default timeout for installing components"`
16
17
18 }
19
20
21 var Runtime struct {
22 GKE bool `default:"false" description:"whether or not the test is being ran against a GKE cluster"`
23 }
24
25
26
27 var KonfigKonnector struct {
28 APIKey string `description:"path to key.json for service account that will be used with k8s cfg connector, required for non-GKE test runs"`
29 ServiceAccount string `description:"service account name to use when configurng k8s cfg connector on GKE via workload identity"`
30 }
31
32 func init() {
33 _ = config.AddOptions(&Timeouts, "k8s")
34 _ = config.AddOptions(&Runtime, "k8s")
35 _ = config.AddOptions(&KonfigKonnector, "k8s-cfg-conn")
36 }
37
38
39
40
41
42 func NeedsKonfigKonnector(f *framework.Framework) {
43
44
45 gcp.NeedsProjectID(f)
46
47 if Runtime.GKE && KonfigKonnector.ServiceAccount == "" {
48 f.Skip("KonfigKonnector", "missing service account for GKE runtime")
49 }
50
51 if !Runtime.GKE && KonfigKonnector.APIKey == "" {
52 f.Skip("KonfigKonnector", "missing key.json for non-GKE runtime")
53 }
54 }
55
View as plain text