Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-JIRA: [e2e test framework] Add a flag to add an annotation to HostedCluster #3854

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/e2e/e2e_test.go
Expand Up @@ -115,6 +115,7 @@ func TestMain(m *testing.M) {
flag.StringVar(&globalOpts.ManagementClusterNamespace, "e2e.management-cluster-namespace", "", "Namespace of the management cluster's HostedCluster (required to test request serving isolation)")
flag.StringVar(&globalOpts.ManagementClusterName, "e2e.management-cluster-name", "", "Name of the management cluster's HostedCluster (required to test request serving isolation)")
flag.BoolVar(&globalOpts.DisablePKIReconciliation, "e2e.disable-pki-reconciliation", false, "If set, TestUpgradeControlPlane will upgrade the control plane without reconciling the pki components")
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 @@ -425,6 +426,7 @@ type configurableClusterOptions struct {
PowerVSTransitGatewayLocation string
PowerVSTransitGateway string
EtcdStorageClass string
Annotations stringMapVar
}

var nextAWSZoneIndex = 0
Expand Down Expand Up @@ -523,6 +525,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 @@ -608,3 +616,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
}