Skip to content

Commit

Permalink
Merge branch 'develop' into vsukhin/feature/test-execution-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Feb 28, 2024
2 parents 31fd5c4 + 6a9821b commit 4ca5e27
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 338 deletions.
26 changes: 7 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
MIT License
Source code in this repository is variously licensed under the Testkube
Community License (TCL) and the MIT license.

Copyright (c) 2021 Kubeshop
Source code in a given file is licensed under the applicable license
for that source code. Source code is licensed under the MIT license
unless otherwise indicated in the header referenced at the beginning
of the file or specified by a LICENSE file in the same containing
folder as the file.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 4 additions & 4 deletions api/testworkflows/v1/base_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ type TestWorkflowSpecBase struct {
Config map[string]ParameterSchema `json:"config,omitempty"`

// global content that should be fetched into all containers
Content *Content `json:"content,omitempty"`
Content *Content `json:"content,omitempty" expr:"include"`

// defaults for the containers for all the TestWorkflow steps
Container *ContainerConfig `json:"container,omitempty"`
Container *ContainerConfig `json:"container,omitempty" expr:"include"`

// configuration for the scheduled job
Job *JobConfig `json:"job,omitempty"`
Job *JobConfig `json:"job,omitempty" expr:"include"`

// configuration for the scheduled pod
Pod *PodConfig `json:"pod,omitempty"`
Pod *PodConfig `json:"pod,omitempty" expr:"include"`
}
22 changes: 11 additions & 11 deletions api/testworkflows/v1/content_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ import (

type ContentGit struct {
// uri for the Git repository
Uri string `json:"uri,omitempty"`
Uri string `json:"uri,omitempty" expr:"template"`
// branch, commit or a tag name to fetch
Revision string `json:"revision,omitempty"`
Revision string `json:"revision,omitempty" expr:"template"`
// plain text username to fetch with
Username string `json:"username,omitempty"`
Username string `json:"username,omitempty" expr:"template"`
// external username to fetch with
UsernameFrom *corev1.EnvVarSource `json:"usernameFrom,omitempty"`
// plain text token to fetch with
Token string `json:"token,omitempty"`
Token string `json:"token,omitempty" expr:"template"`
// external token to fetch with
TokenFrom *corev1.EnvVarSource `json:"tokenFrom,omitempty"`
// authorization type for the credentials
AuthType testsv3.GitAuthType `json:"authType,omitempty"`
AuthType testsv3.GitAuthType `json:"authType,omitempty" expr:"template"`
// where to mount the fetched repository contents (defaults to "repo" directory in the data volume)
MountPath string `json:"mountPath,omitempty"`
MountPath string `json:"mountPath,omitempty" expr:"template"`
// paths to fetch for the sparse checkout
Paths []string `json:"paths,omitempty"`
Paths []string `json:"paths,omitempty" expr:"template"`
}

type ContentFile struct {
// path where the file should be accessible at
// +kubebuilder:validation:MinLength=1
Path string `json:"path"`
Path string `json:"path" expr:"template"`
// plain-text content to put inside
Content string `json:"content,omitempty"`
Content string `json:"content,omitempty" expr:"template"`
// external source to use
ContentFrom *corev1.EnvVarSource `json:"contentFrom,omitempty"`
// mode to use for the file
Expand All @@ -41,7 +41,7 @@ type ContentFile struct {

type Content struct {
// git repository details
Git *ContentGit `json:"git,omitempty"`
Git *ContentGit `json:"git,omitempty" expr:"include"`
// files to load
Files []ContentFile `json:"files,omitempty"`
Files []ContentFile `json:"files,omitempty" expr:"include"`
}
50 changes: 25 additions & 25 deletions api/testworkflows/v1/step_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ type RetryPolicy struct {
Count int32 `json:"count,omitempty"`

// until when it should retry (defaults to: "passed")
Until Expression `json:"until,omitempty"`
Until string `json:"until,omitempty" expr:"expression"`
}

type StepBase struct {
// readable name for the step
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" expr:"template"`

// expression to declare under which conditions the step should be run
// defaults to: "passed", except artifacts where it defaults to "always"
Condition Expression `json:"condition,omitempty"`
Condition string `json:"condition,omitempty" expr:"expression"`

// is the step expected to fail
Negative bool `json:"negative,omitempty"`
Expand All @@ -30,7 +30,7 @@ type StepBase struct {
VirtualGroup bool `json:"virtualGroup,omitempty"`

// policy for retrying the step
Retry *RetryPolicy `json:"retry,omitempty"`
Retry *RetryPolicy `json:"retry,omitempty" expr:"include"`

// maximum time this step may take
// +kubebuilder:validation:Pattern=^((0|[1-9][0-9]*)h)?((0|[1-9][0-9]*)m)?((0|[1-9][0-9]*)s)?((0|[1-9][0-9]*)ms)?$
Expand All @@ -41,49 +41,49 @@ type StepBase struct {
Delay string `json:"delay,omitempty"`

// content that should be fetched for this step
Content *Content `json:"content,omitempty"`
Content *Content `json:"content,omitempty" expr:"include"`

// script to run in a default shell for the container
Shell string `json:"shell,omitempty"`
Shell string `json:"shell,omitempty" expr:"template"`

// run specific container in the current step
Run *StepRun `json:"run,omitempty"`
Run *StepRun `json:"run,omitempty" expr:"include"`

// working directory to use for this step
WorkingDir *string `json:"workingDir,omitempty"`
WorkingDir *string `json:"workingDir,omitempty" expr:"template"`

// defaults for the containers in this step
Container *ContainerConfig `json:"container,omitempty"`
Container *ContainerConfig `json:"container,omitempty" expr:"include"`

// execute other Testkube resources
Execute *StepExecute `json:"execute,omitempty"`
Execute *StepExecute `json:"execute,omitempty" expr:"include"`

// scrape artifacts from the volumes
Artifacts *StepArtifacts `json:"artifacts,omitempty"`
Artifacts *StepArtifacts `json:"artifacts,omitempty" expr:"include"`
}

type IndependentStep struct {
StepBase `json:",inline"`
StepBase `json:",inline" expr:"include"`

// sub-steps to run
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Steps []IndependentStep `json:"steps,omitempty"`
Steps []IndependentStep `json:"steps,omitempty" expr:"include"`
}

type Step struct {
StepBase `json:",inline"`
StepBase `json:",inline" expr:"include"`

// multiple templates to include in this step
Use []TemplateRef `json:"use,omitempty"`
Use []TemplateRef `json:"use,omitempty" expr:"include"`

// single template to run in this step
Template *TemplateRef `json:"template,omitempty"`
Template *TemplateRef `json:"template,omitempty" expr:"include"`

// sub-steps to run
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Steps []Step `json:"steps,omitempty"`
Steps []Step `json:"steps,omitempty" expr:"include"`
}

type StepRun struct {
Expand All @@ -98,34 +98,34 @@ type StepExecute struct {
Async bool `json:"async,omitempty"`

// tests to run
Tests []StepExecuteTest `json:"tests,omitempty"`
Tests []StepExecuteTest `json:"tests,omitempty" expr:"include"`

// workflows to run
Workflows []StepExecuteWorkflow `json:"workflows,omitempty"`
Workflows []StepExecuteWorkflow `json:"workflows,omitempty" expr:"include"`
}

type StepExecuteTest struct {
// test name to run
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" expr:"template"`
}

type StepExecuteWorkflow struct {
// workflow name to run
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" expr:"template"`
// configuration to pass for the workflow
Config map[string]intstr.IntOrString `json:"config,omitempty"`
Config map[string]intstr.IntOrString `json:"config,omitempty" expr:"template"`
}

type StepArtifacts struct {
// compression options for the artifacts
Compress *ArtifactCompression `json:"compress,omitempty"`
Compress *ArtifactCompression `json:"compress,omitempty" expr:"include"`
// paths to fetch from the container
Paths []string `json:"paths,omitempty"`
Paths []string `json:"paths,omitempty" expr:"template"`
}

type ArtifactCompression struct {
// artifact name
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
Name string `json:"name" expr:"template"`
}
16 changes: 8 additions & 8 deletions api/testworkflows/v1/testworkflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ type TestWorkflowSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// templates to include at a top-level of workflow
Use []TemplateRef `json:"use,omitempty"`
Use []TemplateRef `json:"use,omitempty" expr:"include"`

TestWorkflowSpecBase `json:",inline"`
TestWorkflowSpecBase `json:",inline" expr:"include"`

// steps for setting up the workflow
Setup []Step `json:"setup,omitempty"`
Setup []Step `json:"setup,omitempty" expr:"include"`

// steps to execute in the workflow
Steps []Step `json:"steps,omitempty"`
Steps []Step `json:"steps,omitempty" expr:"include"`

// steps to run at the end of the workflow
After []Step `json:"after,omitempty"`
After []Step `json:"after,omitempty" expr:"include"`
}

// TemplateRef is the reference for the template inclusion
type TemplateRef struct {
// name of the template to include
Name string `json:"name"`
// trait configuration values if needed
Config map[string]intstr.IntOrString `json:"config,omitempty"`
Config map[string]intstr.IntOrString `json:"config,omitempty" expr:"template"`
}

// +kubebuilder:object:root=true
Expand All @@ -56,7 +56,7 @@ type TestWorkflow struct {
Description string `json:"description,omitempty"`

// TestWorkflow specification
Spec TestWorkflowSpec `json:"spec"`
Spec TestWorkflowSpec `json:"spec" expr:"include"`
}

//+kubebuilder:object:root=true
Expand All @@ -65,7 +65,7 @@ type TestWorkflow struct {
type TestWorkflowList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TestWorkflow `json:"items"`
Items []TestWorkflow `json:"items" expr:"include"`
}

func init() {
Expand Down
12 changes: 6 additions & 6 deletions api/testworkflows/v1/testworkflowtemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import (
type TestWorkflowTemplateSpec struct {
// Important: Run "make" to regenerate code after modifying this file

TestWorkflowSpecBase `json:",inline"`
TestWorkflowSpecBase `json:",inline" expr:"include"`

// steps for setting up the workflow
Setup []IndependentStep `json:"setup,omitempty"`
Setup []IndependentStep `json:"setup,omitempty" expr:"include"`

// steps to execute in the workflow
Steps []IndependentStep `json:"steps,omitempty"`
Steps []IndependentStep `json:"steps,omitempty" expr:"include"`

// steps to run at the end of the workflow
After []IndependentStep `json:"after,omitempty"`
After []IndependentStep `json:"after,omitempty" expr:"include"`
}

// +kubebuilder:object:root=true
Expand All @@ -44,7 +44,7 @@ type TestWorkflowTemplate struct {
Description string `json:"description,omitempty"`

// TestWorkflowTemplate specification
Spec TestWorkflowTemplateSpec `json:"spec"`
Spec TestWorkflowTemplateSpec `json:"spec" expr:"include"`
}

//+kubebuilder:object:root=true
Expand All @@ -53,7 +53,7 @@ type TestWorkflowTemplate struct {
type TestWorkflowTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TestWorkflowTemplate `json:"items"`
Items []TestWorkflowTemplate `json:"items" expr:"include"`
}

func init() {
Expand Down
Loading

0 comments on commit 4ca5e27

Please sign in to comment.