-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
285 additions
and
98 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
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
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,13 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCat_getContainer(t *testing.T) { | ||
x := Cat{} | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, []string{"cat"}, c.Args) | ||
} |
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
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,56 @@ | ||
package v1alpha1 | ||
|
||
import corev1 "k8s.io/api/core/v1" | ||
|
||
// +kubebuilder:skipversion | ||
type containerBuilder corev1.Container | ||
|
||
func (b containerBuilder) init(req getContainerReq) containerBuilder { | ||
b.Name = CtrMain | ||
b.Image = req.runnerImage | ||
b.ImagePullPolicy = req.imagePullPolicy | ||
b.Env = req.env | ||
b.VolumeMounts = []corev1.VolumeMount{req.volumeMount} | ||
b.Resources = SmallResourceRequirements | ||
b.Lifecycle = req.lifecycle | ||
return b | ||
} | ||
|
||
func (b containerBuilder) args(args ...string) containerBuilder { | ||
b.Args = args | ||
return b | ||
} | ||
|
||
func (b containerBuilder) image(x string) containerBuilder { | ||
b.Image = x | ||
return b | ||
} | ||
|
||
func (b containerBuilder) resources(x corev1.ResourceRequirements) containerBuilder { | ||
b.Resources = x | ||
return b | ||
} | ||
|
||
func (b containerBuilder) command(x ...string) containerBuilder { | ||
b.Command = x | ||
return b | ||
} | ||
|
||
func (b containerBuilder) appendEnv(x ...corev1.EnvVar) containerBuilder { | ||
b.Env = append(b.Env, x...) | ||
return b | ||
} | ||
|
||
func (b containerBuilder) workingDir(x string) containerBuilder { | ||
b.WorkingDir = x | ||
return b | ||
} | ||
|
||
func (b containerBuilder) appendVolumeMounts(x ...corev1.VolumeMount) containerBuilder { | ||
b.VolumeMounts = append(b.VolumeMounts, x...) | ||
return b | ||
} | ||
|
||
func (b containerBuilder) build() corev1.Container { | ||
return corev1.Container(b) | ||
} |
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,15 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_containerBuilder(t *testing.T) { | ||
c := containerBuilder{}. | ||
init(getContainerReq{}). | ||
build() | ||
assert.Equal(t, "main", c.Name) | ||
assert.Equal(t, SmallResourceRequirements, c.Resources) | ||
} |
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,24 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestContainer_getContainer(t *testing.T) { | ||
x := Container{ | ||
Image: "my-image", | ||
VolumeMounts: []corev1.VolumeMount{{Name: "my-vm"}}, | ||
Command: []string{"my-cmd"}, | ||
Args: []string{"my-args"}, | ||
Env: []corev1.EnvVar{{Name: "my-envvar"}}, | ||
} | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, x.Image, c.Image) | ||
assert.Contains(t, c.VolumeMounts, c.VolumeMounts[0]) | ||
assert.Equal(t, x.Command, c.Command) | ||
assert.Equal(t, x.Args, c.Args) | ||
assert.Equal(t, x.Env, c.Env) | ||
} |
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
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,13 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestExpand_getContainer(t *testing.T) { | ||
x := Expand{} | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, []string{"expand"}, c.Args) | ||
} |
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
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,13 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFilter_getContainer(t *testing.T) { | ||
const x Filter = "my-filter" | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, []string{"filter", "my-filter"}, c.Args) | ||
} |
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
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,13 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFlatten_getContainer(t *testing.T) { | ||
x := Flatten{} | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, []string{"flatten"}, c.Args) | ||
} |
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
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,23 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestGit_getContainer(t *testing.T) { | ||
x := Git{ | ||
Image: "my-image", | ||
Command: []string{"my-command"}, | ||
Env: []corev1.EnvVar{{Name: "my-env"}}, | ||
} | ||
c := x.getContainer(getContainerReq{}) | ||
|
||
assert.Equal(t, x.Image, c.Image) | ||
assert.Equal(t, x.Command, c.Command) | ||
assert.Equal(t, x.Env, c.Env) | ||
assert.Equal(t, PathWorkingDir, c.WorkingDir) | ||
assert.Equal(t, LargeResourceRequirements, c.Resources) | ||
} |
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
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,23 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func TestGroup_getContainer(t *testing.T) { | ||
x := Group{ | ||
Key: "my-key", | ||
EndOfGroup: "my-eog", | ||
Format: "my-fmt", | ||
Storage: &Storage{ | ||
Name: "my-storage", | ||
SubPath: "my-sub-path", | ||
}, | ||
} | ||
c := x.getContainer(getContainerReq{}) | ||
assert.Equal(t, []string{"group", "my-key", "my-eog", "my-fmt"}, c.Args) | ||
assert.Contains(t, c.VolumeMounts, corev1.VolumeMount{Name: "my-storage", MountPath: "/var/run/argo-dataflow/groups", SubPath: "my-sub-path"}) | ||
} |
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
Oops, something went wrong.