-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): introduce container-runtime runner (#1493)
Signed-off-by: odubajDT <[email protected]> Signed-off-by: odubajDT <[email protected]> Co-authored-by: Giovanni Liva <[email protected]>
- Loading branch information
Showing
25 changed files
with
1,990 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: lifecycle.keptn.sh/v1alpha3 | ||
kind: KeptnTaskDefinition | ||
metadata: | ||
name: container-sleep | ||
spec: | ||
container: | ||
name: testy-test | ||
image: busybox:1.36.0 | ||
command: | ||
- 'sh' | ||
- '-c' | ||
- 'sleep 30' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ spec: | |
version: 0.1.1 | ||
preDeploymentEvaluations: | ||
- app-pre-deploy-eval-1 | ||
preDeploymentTasks: | ||
- container-sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ spec: | |
version: 0.1.1 | ||
preDeploymentEvaluations: | ||
- app-pre-deploy-eval-2 | ||
preDeploymentTasks: | ||
- container-sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ spec: | |
version: 0.1.1 | ||
- name: podtato-head-hat | ||
version: 0.1.2 | ||
preDeploymentTasks: | ||
- container-sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
operator/apis/lifecycle/v1alpha3/keptntaskdefinition_types_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package v1alpha3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
var jsTaskDef = &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{ | ||
Function: &FunctionSpec{ | ||
Inline: Inline{ | ||
Code: "some code", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
var containerTaskDef = &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{ | ||
Container: &ContainerSpec{ | ||
Container: &v1.Container{ | ||
Image: "image", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func Test_SpecExists(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
taskDef *KeptnTaskDefinition | ||
want bool | ||
}{ | ||
{ | ||
name: "js builder", | ||
taskDef: jsTaskDef, | ||
want: true, | ||
}, | ||
{ | ||
name: "container builder", | ||
taskDef: containerTaskDef, | ||
want: true, | ||
}, | ||
{ | ||
name: "empty builder", | ||
taskDef: &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
require.Equal(t, tt.want, tt.taskDef.SpecExists()) | ||
}) | ||
} | ||
} | ||
|
||
func Test_IsJSSpecDefined(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
taskDef *KeptnTaskDefinition | ||
want bool | ||
}{ | ||
{ | ||
name: "defined", | ||
taskDef: jsTaskDef, | ||
want: true, | ||
}, | ||
{ | ||
name: "empty", | ||
taskDef: &KeptnTaskDefinition{}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
require.Equal(t, tt.want, tt.taskDef.IsJSSpecDefined()) | ||
}) | ||
} | ||
} | ||
|
||
func Test_IsVolumeMountPresent(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
taskDef *KeptnTaskDefinition | ||
want bool | ||
}{ | ||
{ | ||
name: "defined", | ||
taskDef: &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{ | ||
Container: &ContainerSpec{ | ||
Container: &v1.Container{ | ||
Image: "image", | ||
VolumeMounts: []v1.VolumeMount{ | ||
{ | ||
Name: "name", | ||
MountPath: "path", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "empty", | ||
taskDef: &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{ | ||
Container: &ContainerSpec{ | ||
Container: &v1.Container{ | ||
Image: "image", | ||
VolumeMounts: []v1.VolumeMount{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "nil", | ||
taskDef: &KeptnTaskDefinition{ | ||
Spec: KeptnTaskDefinitionSpec{ | ||
Container: &ContainerSpec{ | ||
Container: &v1.Container{ | ||
Image: "image", | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
require.Equal(t, tt.want, tt.taskDef.IsVolumeMountPresent()) | ||
}) | ||
} | ||
} | ||
|
||
func Test_IsContainerSpecDefined(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
taskDef *KeptnTaskDefinition | ||
want bool | ||
}{ | ||
{ | ||
name: "defined", | ||
taskDef: containerTaskDef, | ||
want: true, | ||
}, | ||
{ | ||
name: "empty", | ||
taskDef: &KeptnTaskDefinition{}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
require.Equal(t, tt.want, tt.taskDef.IsContainerSpecDefined()) | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.