From d195552b7f0fb56c864c8a0f09e7ec855936a2e3 Mon Sep 17 00:00:00 2001 From: Lilla Vass Date: Wed, 6 Mar 2024 12:31:33 +0100 Subject: [PATCH] feat: make test suite steps params oss (#225) --- api/testsuite/v3/testsuite_types.go | 49 +++++++++++- api/testsuite/v3/zz_generated.deepcopy.go | 48 +++++++++++- pkg/tcl/testsuitestcl/steps.go | 61 --------------- .../testsuitestcl/zz_generated.deepcopy.go | 78 ------------------- 4 files changed, 92 insertions(+), 144 deletions(-) delete mode 100644 pkg/tcl/testsuitestcl/steps.go delete mode 100644 pkg/tcl/testsuitestcl/zz_generated.deepcopy.go diff --git a/api/testsuite/v3/testsuite_types.go b/api/testsuite/v3/testsuite_types.go index 5a0b1bf5..c35ac748 100644 --- a/api/testsuite/v3/testsuite_types.go +++ b/api/testsuite/v3/testsuite_types.go @@ -18,7 +18,6 @@ package v3 import ( commonv1 "github.com/kubeshop/testkube-operator/api/common/v1" - "github.com/kubeshop/testkube-operator/pkg/tcl/testsuitestcl" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -53,8 +52,8 @@ type TestSuiteStepSpec struct { // delay duration in time units // +kubebuilder:validation:Type:=string // +kubebuilder:validation:Format:=duration - Delay metav1.Duration `json:"delay,omitempty"` - ExecutionRequest *testsuitestcl.TestSuiteStepExecutionRequest `json:"executionRequest,omitempty"` + Delay metav1.Duration `json:"delay,omitempty"` + ExecutionRequest *TestSuiteStepExecutionRequest `json:"executionRequest,omitempty"` } // options to download artifacts from previous steps @@ -190,3 +189,47 @@ type TestSuiteList struct { func init() { SchemeBuilder.Register(&TestSuite{}, &TestSuiteList{}) } + +type ArgsModeType commonv1.ArgsModeType + +// TestSuiteStepExecutionRequest contains parameters to be used by the executions. +// These fields will be passed to the execution when a Test Suite is queued for execution. +// TestSuiteStepExecutionRequest parameters have the highest priority. They override the +// values coming from Test Suites, Tests, and Test Executions. +// +kubebuilder:object:generate=true +type TestSuiteStepExecutionRequest struct { + // test execution labels + ExecutionLabels map[string]string `json:"executionLabels,omitempty"` + Variables map[string]Variable `json:"variables,omitempty"` + // additional executor binary arguments + Args []string `json:"args,omitempty"` + // usage mode for arguments + ArgsMode ArgsModeType `json:"argsMode,omitempty"` + // executor binary command + Command []string `json:"command,omitempty"` + // whether to start execution sync or async + Sync bool `json:"sync,omitempty"` + // http proxy for executor containers + HttpProxy string `json:"httpProxy,omitempty"` + // https proxy for executor containers + HttpsProxy string `json:"httpsProxy,omitempty"` + // negative test will fail the execution if it is a success and it will succeed if it is a failure + NegativeTest bool `json:"negativeTest,omitempty"` + // job template extensions + JobTemplate string `json:"jobTemplate,omitempty"` + // job template extensions reference + JobTemplateReference string `json:"jobTemplateReference,omitempty"` + // cron job template extensions + CronJobTemplate string `json:"cronJobTemplate,omitempty"` + // cron job template extensions reference + CronJobTemplateReference string `json:"cronJobTemplateReference,omitempty"` + // scraper template extensions + ScraperTemplate string `json:"scraperTemplate,omitempty"` + // scraper template extensions reference + ScraperTemplateReference string `json:"scraperTemplateReference,omitempty"` + // pvc template extensions + PvcTemplate string `json:"pvcTemplate,omitempty"` + // pvc template extensions reference + PvcTemplateReference string `json:"pvcTemplateReference,omitempty"` + RunningContext *commonv1.RunningContext `json:"runningContext,omitempty"` +} diff --git a/api/testsuite/v3/zz_generated.deepcopy.go b/api/testsuite/v3/zz_generated.deepcopy.go index 3f1d8692..7f139bcc 100644 --- a/api/testsuite/v3/zz_generated.deepcopy.go +++ b/api/testsuite/v3/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ limitations under the License. package v3 import ( - "github.com/kubeshop/testkube-operator/pkg/tcl/testsuitestcl" + "github.com/kubeshop/testkube-operator/api/common/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -276,13 +276,57 @@ func (in *TestSuiteStatus) DeepCopy() *TestSuiteStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TestSuiteStepExecutionRequest) DeepCopyInto(out *TestSuiteStepExecutionRequest) { + *out = *in + if in.ExecutionLabels != nil { + in, out := &in.ExecutionLabels, &out.ExecutionLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Variables != nil { + in, out := &in.Variables, &out.Variables + *out = make(map[string]Variable, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Command != nil { + in, out := &in.Command, &out.Command + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.RunningContext != nil { + in, out := &in.RunningContext, &out.RunningContext + *out = new(v1.RunningContext) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestSuiteStepExecutionRequest. +func (in *TestSuiteStepExecutionRequest) DeepCopy() *TestSuiteStepExecutionRequest { + if in == nil { + return nil + } + out := new(TestSuiteStepExecutionRequest) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TestSuiteStepSpec) DeepCopyInto(out *TestSuiteStepSpec) { *out = *in out.Delay = in.Delay if in.ExecutionRequest != nil { in, out := &in.ExecutionRequest, &out.ExecutionRequest - *out = new(testsuitestcl.TestSuiteStepExecutionRequest) + *out = new(TestSuiteStepExecutionRequest) (*in).DeepCopyInto(*out) } } diff --git a/pkg/tcl/testsuitestcl/steps.go b/pkg/tcl/testsuitestcl/steps.go deleted file mode 100644 index 95943761..00000000 --- a/pkg/tcl/testsuitestcl/steps.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2024 Testkube. -// -// Licensed as a Testkube Pro file under the Testkube Community -// License (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// https://github.com/kubeshop/testkube-operator/blob/main/licenses/TCL.txt - -package testsuitestcl - -import ( - commonv1 "github.com/kubeshop/testkube-operator/api/common/v1" -) - -// +kubebuilder:object:generate=true -type Variable commonv1.Variable - -// +kubebuilder:object:generate=true -type ArgsModeType commonv1.ArgsModeType - -// TestSuiteStepExecutionRequest contains parameters to be used by the executions. -// These fields will be passed to the execution when a Test Suite is queued for execution. -// TestSuiteStepExecutionRequest parameters have the highest priority. They override the -// values coming from Test Suites, Tests, and Test Executions. -// +kubebuilder:object:generate=true -type TestSuiteStepExecutionRequest struct { - // test execution labels - ExecutionLabels map[string]string `json:"executionLabels,omitempty"` - Variables map[string]Variable `json:"variables,omitempty"` - // additional executor binary arguments - Args []string `json:"args,omitempty"` - // usage mode for arguments - ArgsMode ArgsModeType `json:"argsMode,omitempty"` - // executor binary command - Command []string `json:"command,omitempty"` - // whether to start execution sync or async - Sync bool `json:"sync,omitempty"` - // http proxy for executor containers - HttpProxy string `json:"httpProxy,omitempty"` - // https proxy for executor containers - HttpsProxy string `json:"httpsProxy,omitempty"` - // negative test will fail the execution if it is a success and it will succeed if it is a failure - NegativeTest bool `json:"negativeTest,omitempty"` - // job template extensions - JobTemplate string `json:"jobTemplate,omitempty"` - // job template extensions reference - JobTemplateReference string `json:"jobTemplateReference,omitempty"` - // cron job template extensions - CronJobTemplate string `json:"cronJobTemplate,omitempty"` - // cron job template extensions reference - CronJobTemplateReference string `json:"cronJobTemplateReference,omitempty"` - // scraper template extensions - ScraperTemplate string `json:"scraperTemplate,omitempty"` - // scraper template extensions reference - ScraperTemplateReference string `json:"scraperTemplateReference,omitempty"` - // pvc template extensions - PvcTemplate string `json:"pvcTemplate,omitempty"` - // pvc template extensions reference - PvcTemplateReference string `json:"pvcTemplateReference,omitempty"` - RunningContext *commonv1.RunningContext `json:"runningContext,omitempty"` -} diff --git a/pkg/tcl/testsuitestcl/zz_generated.deepcopy.go b/pkg/tcl/testsuitestcl/zz_generated.deepcopy.go deleted file mode 100644 index c8c6c5b0..00000000 --- a/pkg/tcl/testsuitestcl/zz_generated.deepcopy.go +++ /dev/null @@ -1,78 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -// Copyright 2024 Testkube. -// -// Licensed as a Testkube Pro file under the Testkube Community -// License (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// https://github.com/kubeshop/testkube-operator/blob/main/licenses/TCL.txt - -// Code generated by controller-gen. DO NOT EDIT. - -package testsuitestcl - -import ( - "github.com/kubeshop/testkube-operator/api/common/v1" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TestSuiteStepExecutionRequest) DeepCopyInto(out *TestSuiteStepExecutionRequest) { - *out = *in - if in.ExecutionLabels != nil { - in, out := &in.ExecutionLabels, &out.ExecutionLabels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Variables != nil { - in, out := &in.Variables, &out.Variables - *out = make(map[string]Variable, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.Args != nil { - in, out := &in.Args, &out.Args - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Command != nil { - in, out := &in.Command, &out.Command - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.RunningContext != nil { - in, out := &in.RunningContext, &out.RunningContext - *out = new(v1.RunningContext) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestSuiteStepExecutionRequest. -func (in *TestSuiteStepExecutionRequest) DeepCopy() *TestSuiteStepExecutionRequest { - if in == nil { - return nil - } - out := new(TestSuiteStepExecutionRequest) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Variable) DeepCopyInto(out *Variable) { - *out = *in - in.ValueFrom.DeepCopyInto(&out.ValueFrom) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Variable. -func (in *Variable) DeepCopy() *Variable { - if in == nil { - return nil - } - out := new(Variable) - in.DeepCopyInto(out) - return out -}