diff --git a/test/framework/interface.go b/test/framework/interface.go index c126ecbe3dc3..a9acf258cdd5 100644 --- a/test/framework/interface.go +++ b/test/framework/interface.go @@ -22,6 +22,7 @@ type deployOptions struct { installationMode InstallationMode helmReleaseName string helmOpts map[string]string + ctlOpts map[string]string } type DeployOptionsFunc func(*deployOptions) @@ -53,6 +54,15 @@ func WithHelmOpt(name, value string) DeployOptionsFunc { } } +func WithCtlOpt(name, value string) DeployOptionsFunc { + return func(o *deployOptions) { + if o.ctlOpts == nil { + o.ctlOpts = map[string]string{} + } + o.ctlOpts[name] = value + } +} + func newDeployOpt(fs ...DeployOptionsFunc) *deployOptions { rv := &deployOptions{ installationMode: KumactlInstallationMode, diff --git a/test/framework/k8s_cluster.go b/test/framework/k8s_cluster.go index 64b014136ccd..1121696f07f4 100644 --- a/test/framework/k8s_cluster.go +++ b/test/framework/k8s_cluster.go @@ -232,10 +232,22 @@ func (c *K8sCluster) GetPodLogs(pod v1.Pod) (string, error) { // deployKumaViaKubectl uses kubectl to install kuma // using the resources from the `kumactl install control-plane` command func (c *K8sCluster) deployKumaViaKubectl(mode string, opts *deployOptions) error { - var args []string + argsMap := map[string]string{ + "--control-plane-image": kumaCPImage, + "--dataplane-image": kumaDPImage, + "--dataplane-init-image": kumaInitImage, + } switch mode { case core.Remote: - args = append(args, "--kds-global-address", opts.globalAddress) + argsMap["--kds-global-address"] = opts.globalAddress + } + for opt, value := range opts.ctlOpts { + argsMap[opt] = value + } + + var args []string + for k, v := range argsMap { + args = append(args, k, v) } yaml, err := c.controlplane.InstallCP(args...) if err != nil { @@ -471,11 +483,19 @@ func (c *K8sCluster) deleteKumaViaHelm(opts *deployOptions) (errs error) { } func (c *K8sCluster) deleteKumaViaKumactl(opts *deployOptions) error { - args := []string{} + argsMap := map[string]string{} switch c.controlplane.mode { case core.Remote: // kumactl remote deployment will fail if GlobalAddress is not specified - args = append(args, "--kds-global-address", "grpcs://0.0.0.0:5685") + argsMap["--kds-global-address"] = "grpcs://0.0.0.0:5685" + } + for opt, value := range opts.ctlOpts { + argsMap[opt] = value + } + + var args []string + for k, v := range argsMap { + args = append(args, k, v) } yaml, err := c.controlplane.InstallCP(args...) if err != nil { diff --git a/test/framework/kumactl.go b/test/framework/kumactl.go index a9337503b3aa..0b5916467b7e 100644 --- a/test/framework/kumactl.go +++ b/test/framework/kumactl.go @@ -114,9 +114,6 @@ func storeConfigToTempFile(name string, configData string) (string, error) { func (o *KumactlOptions) KumactlInstallCP(mode string, args ...string) (string, error) { cmd := []string{ "install", "control-plane", - "--control-plane-image", kumaCPImage, - "--dataplane-image", kumaDPImage, - "--dataplane-init-image", kumaInitImage, } cmd = append(cmd, "--mode", mode)