@@ -3,33 +3,101 @@ package mocks
33import  (
44	contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1" 
55	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 
6+ 	"k8s.io/apimachinery/pkg/runtime" 
67)
78
89const  (
910	Namespace          =  "default" 
10- 	StableServiceName  =  "argo-rollouts-stable-service" 
11- 	CanaryServiceName  =  "argo-rollouts-canary-service" 
12- 	HTTPProxyName      =  "argo-rollouts-httpproxy" 
11+ 	StableServiceName  =  "argo-rollouts-stable" 
12+ 	CanaryServiceName  =  "argo-rollouts-canary" 
13+ 
14+ 	HTTPProxyName                =  "argo-rollouts" 
15+ 	ValidHTTPProxyName           =  "argo-rollouts-valid" 
16+ 	OutdatedHTTPProxyName        =  "argo-rollouts-outdated" 
17+ 	InvalidHTTPProxyName         =  "argo-rollouts-invalid" 
18+ 	FalseConditionHTTPProxyName  =  "argo-rollouts-false-condition" 
19+ 
20+ 	HTTPProxyGeneration     =  1 
21+ 	HTTPProxyDesiredWeight  =  20 
1322)
1423
15- var  HTTPProxyObj  =  contourv1.HTTPProxy {
16- 	ObjectMeta : metav1.ObjectMeta {
17- 		Name :      HTTPProxyName ,
18- 		Namespace : Namespace ,
19- 	},
20- 	Spec : contourv1.HTTPProxySpec {
21- 		Routes : []contourv1.Route {
24+ func  MakeObjects () []runtime.Object  {
25+ 	httpProxy  :=  newHTTPProxy (HTTPProxyName )
26+ 
27+ 	validHttpProxy  :=  newHTTPProxy (ValidHTTPProxyName )
28+ 
29+ 	invalidHttpProxy  :=  newHTTPProxy (InvalidHTTPProxyName )
30+ 	invalidHttpProxy .Status  =  contourv1.HTTPProxyStatus {
31+ 		Conditions : []contourv1.DetailedCondition {
32+ 			{
33+ 				Condition : contourv1.Condition {
34+ 					Type :               contourv1 .ConditionTypeServiceError ,
35+ 					Status :             contourv1 .ConditionTrue ,
36+ 					ObservedGeneration : HTTPProxyGeneration ,
37+ 				},
38+ 			},
39+ 		},
40+ 	}
41+ 
42+ 	outdatedHttpProxy  :=  newHTTPProxy (OutdatedHTTPProxyName )
43+ 	outdatedHttpProxy .Generation  =  HTTPProxyGeneration  +  1 
44+ 
45+ 	falseConditionHttpProxy  :=  newHTTPProxy (FalseConditionHTTPProxyName )
46+ 	falseConditionHttpProxy .Status  =  contourv1.HTTPProxyStatus {
47+ 		Conditions : []contourv1.DetailedCondition {
2248			{
23- 				Services : []contourv1.Service {
24- 					{
25- 						Name :   StableServiceName ,
26- 						Weight : 100 ,
49+ 				Condition : contourv1.Condition {
50+ 					Type :               contourv1 .ValidConditionType ,
51+ 					Status :             contourv1 .ConditionFalse ,
52+ 					ObservedGeneration : HTTPProxyGeneration ,
53+ 				},
54+ 			},
55+ 		},
56+ 	}
57+ 
58+ 	objs  :=  []runtime.Object {
59+ 		httpProxy ,
60+ 		validHttpProxy ,
61+ 		invalidHttpProxy ,
62+ 		outdatedHttpProxy ,
63+ 		falseConditionHttpProxy ,
64+ 	}
65+ 	return  objs 
66+ }
67+ 
68+ func  newHTTPProxy (name  string ) * contourv1.HTTPProxy  {
69+ 	return  & contourv1.HTTPProxy {
70+ 		ObjectMeta : metav1.ObjectMeta {
71+ 			Name :       name ,
72+ 			Namespace :  Namespace ,
73+ 			Generation : HTTPProxyGeneration ,
74+ 		},
75+ 		Spec : contourv1.HTTPProxySpec {
76+ 			Routes : []contourv1.Route {
77+ 				{
78+ 					Services : []contourv1.Service {
79+ 						{
80+ 							Name :   StableServiceName ,
81+ 							Weight : 100  -  HTTPProxyDesiredWeight ,
82+ 						},
83+ 						{
84+ 							Name :   CanaryServiceName ,
85+ 							Weight : HTTPProxyDesiredWeight ,
86+ 						},
2787					},
28- 					{
29- 						Name : CanaryServiceName ,
88+ 				},
89+ 			},
90+ 		},
91+ 		Status : contourv1.HTTPProxyStatus {
92+ 			Conditions : []contourv1.DetailedCondition {
93+ 				{
94+ 					Condition : contourv1.Condition {
95+ 						Type :               contourv1 .ValidConditionType ,
96+ 						Status :             contourv1 .ConditionTrue ,
97+ 						ObservedGeneration : HTTPProxyGeneration ,
3098					},
3199				},
32100			},
33101		},
34- 	}, 
102+ 	}
35103}
0 commit comments