Skip to content

Commit

Permalink
[4.14] [e2e test framework] Add a flag to add an annotation to Hosted…
Browse files Browse the repository at this point in the history
…Cluster

manual backport of openshift#3854

Signed-off-by: Oren Cohen <ocohen@redhat.com>
  • Loading branch information
orenc1 committed Apr 17, 2024
1 parent 83a47ba commit beea85d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/e2e/e2e_test.go
Expand Up @@ -105,6 +105,7 @@ func TestMain(m *testing.M) {
flag.BoolVar(&globalOpts.SkipAPIBudgetVerification, "e2e.skip-api-budget", false, "Bool to avoid send metrics to E2E Server on local test execution.")
flag.StringVar(&globalOpts.configurableClusterOptions.EtcdStorageClass, "e2e.etcd-storage-class", "", "The persistent volume storage class for etcd data volumes")
flag.BoolVar(&globalOpts.RequestServingIsolation, "e2e.test-request-serving-isolation", false, "If set, TestCreate creates a cluster with request serving isolation topology")
flag.Var(&globalOpts.configurableClusterOptions.Annotations, "e2e.annotations", "Annotations to apply to the HostedCluster (key=value). Can be specified multiple times")

flag.Parse()

Expand Down Expand Up @@ -398,6 +399,7 @@ type configurableClusterOptions struct {
PowerVSCloudConnection string
PowerVSVPC string
EtcdStorageClass string
Annotations stringMapVar
}

var nextAWSZoneIndex = 0
Expand Down Expand Up @@ -492,6 +494,12 @@ func (o *options) DefaultClusterOptions(t *testing.T) core.CreateOptions {
createOption.SSHKeyFile = o.configurableClusterOptions.SSHKeyFile
}

if o.configurableClusterOptions.Annotations != nil {
for k, v := range o.configurableClusterOptions.Annotations {
createOption.Annotations = append(createOption.Annotations, fmt.Sprintf("%s=%s", k, v))
}
}

return createOption
}

Expand Down Expand Up @@ -571,3 +579,24 @@ type stringSliceVar []string

func (s *stringSliceVar) String() string { return strings.Join(*s, ",") }
func (s *stringSliceVar) Set(v string) error { *s = append(*s, strings.Split(v, ",")...); return nil }

type stringMapVar map[string]string

func (s *stringMapVar) String() string {
if *s == nil {
return ""
}
return fmt.Sprintf("%v", *s)
}

func (s *stringMapVar) Set(value string) error {
split := strings.Split(value, "=")
if len(split) != 2 {
return fmt.Errorf("invalid argument: %s", value)
}
if *s == nil {
*s = map[string]string{}
}
map[string]string(*s)[split[0]] = split[1]
return nil
}

0 comments on commit beea85d

Please sign in to comment.