argo-cd/test/testdata.go

83 lines
1.6 KiB
Go

package test
import (
"github.com/argoproj/argo-cd/common"
appsv1 "k8s.io/api/apps/v1"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
const (
TestNamespace = "test-namespace"
TestAppInstanceName = "test-app-instance"
)
func DemoService() *apiv1.Service {
return &apiv1.Service{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Service",
},
ObjectMeta: metav1.ObjectMeta{
Name: "demo",
Namespace: TestNamespace,
Labels: map[string]string{
common.LabelKeyAppInstance: TestAppInstanceName,
},
},
Spec: apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(80),
},
},
Selector: map[string]string{
"app": "demo",
},
Type: "ClusterIP",
},
}
}
func DemoDeployment() *appsv1.Deployment {
var two int32 = 2
return &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1beta1",
Kind: "Deployment",
},
ObjectMeta: metav1.ObjectMeta{
Name: "demo",
Namespace: TestNamespace,
Labels: map[string]string{
common.LabelKeyAppInstance: TestAppInstanceName,
},
},
Spec: appsv1.DeploymentSpec{
Replicas: &two,
Template: apiv1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"app": "demo",
},
},
Spec: apiv1.PodSpec{
Containers: []apiv1.Container{
{
Name: "demo",
Image: "gcr.io/kuar-demo/kuard-amd64:1",
Ports: []apiv1.ContainerPort{
{
ContainerPort: 80,
},
},
},
},
},
},
},
}
}