Skip to content

Commit

Permalink
feat(testworkflows): add support for accompanying services (#257)
Browse files Browse the repository at this point in the history
* feat(testworkflows): add syntax for running accompanying services
* feat(testworkflows): add `use` for services
* feat(testworkflows): add `logs` for services
* chore(testworkflows): make the resulting YAML smaller
  • Loading branch information
rangoo94 authored May 16, 2024
1 parent 9c46a4f commit 6e48b6c
Show file tree
Hide file tree
Showing 8 changed files with 12,286 additions and 7,966 deletions.
45 changes: 45 additions & 0 deletions api/testworkflows/v1/service_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v1

import corev1 "k8s.io/api/core/v1"

type ServiceRestartPolicy string

const (
ServiceRestartPolicyOnFailure ServiceRestartPolicy = "OnFailure"
ServiceRestartPolicyNever ServiceRestartPolicy = "Never"
)

type IndependentServiceSpec struct {
StepExecuteStrategy `json:",inline" expr:"include"`

// should it fetch logs for that service
Logs bool `json:"logs,omitempty"`

// maximum time until reaching readiness
// +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)?$
Timeout string `json:"timeout,omitempty"`

// instructions for transferring files
Transfer []StepParallelTransfer `json:"transfer,omitempty" expr:"include"`

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

// configuration for the scheduled pod
Pod *PodConfig `json:"pod,omitempty" expr:"include"`

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

// Restart policy for the main container in the pod. One of OnFailure or Never.
RestartPolicy ServiceRestartPolicy `json:"restartPolicy,omitempty" expr:"template"`

// Probe to check if the service has started correctly
ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty" expr:"force"`
}

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

IndependentServiceSpec `json:",inline" expr:"include"`
}
13 changes: 10 additions & 3 deletions api/testworkflows/v1/step_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ type StepOperations struct {
}

type IndependentStep struct {
StepMeta `json:",inline" expr:"include"`
StepControl `json:",inline" expr:"include"`
StepSource `json:",inline" expr:"include"`
StepMeta `json:",inline" expr:"include"`
StepControl `json:",inline" expr:"include"`
StepSource `json:",inline" expr:"include"`

// list of accompanying services to start
Services map[string]IndependentServiceSpec `json:"services,omitempty" expr:"template,include"`

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

// steps to run before other operations in this step
Expand Down Expand Up @@ -106,6 +110,9 @@ type Step struct {

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

// list of accompanying services to start
Services map[string]ServiceSpec `json:"services,omitempty" expr:"template,include"`

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

// steps to run before other operations in this step
Expand Down
3 changes: 3 additions & 0 deletions api/testworkflows/v1/testworkflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type TestWorkflowSpec struct {

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

// list of accompanying services to start
Services map[string]ServiceSpec `json:"services,omitempty" expr:"template,include"`

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

Expand Down
3 changes: 3 additions & 0 deletions api/testworkflows/v1/testworkflowtemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type TestWorkflowTemplateSpec struct {

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

// list of accompanying services to start
Services map[string]IndependentServiceSpec `json:"services,omitempty" expr:"template,include"`

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

Expand Down
6 changes: 6 additions & 0 deletions api/testworkflows/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type PodConfig struct {
Annotations map[string]string `json:"annotations,omitempty" expr:"template,template"`

// volumes to include in the pod
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Volumes []corev1.Volume `json:"volumes,omitempty" expr:"force"`

// duration in seconds the pod may be active on the node
Expand All @@ -99,6 +101,8 @@ type PodConfig struct {
Subdomain string `json:"subdomain,omitempty" expr:"template"`

// If specified, the pod's scheduling constraints
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Affinity *corev1.Affinity `json:"affinity,omitempty" expr:"force"`

// If specified, the pod's tolerations.
Expand All @@ -120,6 +124,8 @@ type PodConfig struct {
PreemptionPolicy *corev1.PreemptionPolicy `json:"preemptionPolicy,omitempty" expr:"template"`

// TopologySpreadConstraints describes how a group of pods ought to spread across topology domains.
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty" expr:"force"`

// SchedulingGates is an opaque list of values that if specified will block scheduling the pod.
Expand Down
90 changes: 90 additions & 0 deletions api/testworkflows/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6e48b6c

Please sign in to comment.