dijob.go 1.0 KB
Newer Older
L
liqingping 已提交
1 2 3 4 5 6
package testutils

import (
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

7
	div2alpha1 "opendilab.org/di-orchestrator/pkg/api/v2alpha1"
L
liqingping 已提交
8
	dicommon "opendilab.org/di-orchestrator/pkg/common"
L
liqingping 已提交
9 10
)

11 12
func NewDIJob() *div2alpha1.DIJob {
	return &div2alpha1.DIJob{
L
liqingping 已提交
13
		TypeMeta: metav1.TypeMeta{
14 15
			Kind:       div2alpha1.KindDIJob,
			APIVersion: div2alpha1.GroupVersion.String(),
L
liqingping 已提交
16 17 18 19 20
		},
		ObjectMeta: metav1.ObjectMeta{
			Name:      DIJobName,
			Namespace: DIJobNamespace,
		},
21
		Spec: div2alpha1.DIJobSpec{
22 23 24 25 26 27 28
			Template: corev1.PodTemplateSpec{
				Spec: corev1.PodSpec{
					Containers: []corev1.Container{
						{
							Name:    dicommon.DefaultContainerName,
							Image:   DIJobImage,
							Command: []string{"/bin/sh", "-c", "sleep", DefaultSleepDuration},
L
liqingping 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
						},
					},
				},
			},
		},
	}
}

func NewNamespace(namespace string) *corev1.Namespace {
	return &corev1.Namespace{
		TypeMeta: metav1.TypeMeta{
			APIVersion: "v1",
			Kind:       "Namespace",
		},
		ObjectMeta: metav1.ObjectMeta{
			Name: namespace,
		},
	}
}