88 "strings"
99 "time"
1010
11+ . "github.com/onsi/ginkgo/v2"
1112 core "k8s.io/api/core/v1"
1213 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314 "k8s.io/client-go/kubernetes"
@@ -45,7 +46,10 @@ const crossplaneImageName = "nginx-crossplane:latest"
4546func ValidateNginxFieldExists (conf * Payload , expFieldCfg ExpectedNginxField ) error {
4647 b , err := json .Marshal (conf )
4748 if err != nil {
48- return fmt .Errorf ("error marshaling nginx config: %w" , err )
49+ marshalErr := fmt .Errorf ("error marshaling nginx config: %w" , err )
50+ GinkgoWriter .Printf ("%v\n " , marshalErr )
51+
52+ return marshalErr
4953 }
5054
5155 for _ , config := range conf .Config {
@@ -70,8 +74,10 @@ func ValidateNginxFieldExists(conf *Payload, expFieldCfg ExpectedNginxField) err
7074 }
7175 }
7276 }
77+ directiveErr := fmt .Errorf ("directive %s not found in: nginx config %s" , expFieldCfg .Directive , string (b ))
78+ GinkgoWriter .Printf ("ERROR: %v\n " , directiveErr )
7379
74- return fmt . Errorf ( "directive %s not found in: nginx config %s" , expFieldCfg . Directive , string ( b ))
80+ return directiveErr
7581}
7682
7783func fieldExistsInServer (
@@ -95,6 +101,12 @@ func fieldExistsInUpstream(
95101 expFieldCfg ExpectedNginxField ,
96102 directive Directive ,
97103) bool {
104+ GinkgoWriter .Printf (
105+ "Checking upstream %q for directive %q with value %q\n " ,
106+ directive .Args [0 ],
107+ expFieldCfg .Directive ,
108+ expFieldCfg .Value ,
109+ )
98110 if directive .Directive == "upstream" && directive .Args [0 ] == expFieldCfg .Upstream {
99111 for _ , directive := range directive .Block {
100112 if expFieldCfg .fieldFound (directive ) {
@@ -123,7 +135,18 @@ func (e ExpectedNginxField) fieldFound(directive *Directive) bool {
123135 valueMatch = strings .Contains (arg , e .Value )
124136 }
125137
126- return directive .Directive == e .Directive && valueMatch
138+ if directive .Directive == e .Directive && valueMatch {
139+ GinkgoWriter .Printf (
140+ "Found field %q with value %q in field %q with value %q\n " ,
141+ e .Directive ,
142+ e .Value ,
143+ directive .Directive ,
144+ arg ,
145+ )
146+ return true
147+ }
148+
149+ return false
127150}
128151
129152func fieldExistsInLocation (locationDirective * Directive , expFieldCfg ExpectedNginxField ) bool {
@@ -201,7 +224,10 @@ func injectCrossplaneContainer(
201224
202225 podClient := k8sClient .CoreV1 ().Pods (namespace )
203226 if _ , err := podClient .UpdateEphemeralContainers (ctx , ngfPodName , pod , metav1.UpdateOptions {}); err != nil {
204- return fmt .Errorf ("error adding ephemeral container: %w" , err )
227+ containerErr := fmt .Errorf ("error adding ephemeral container: %w" , err )
228+ GinkgoWriter .Printf ("%v\n " , containerErr )
229+
230+ return containerErr
205231 }
206232
207233 return nil
@@ -231,7 +257,10 @@ func createCrossplaneExecutor(
231257
232258 exec , err := remotecommand .NewSPDYExecutor (k8sConfig , http .MethodPost , req .URL ())
233259 if err != nil {
234- return nil , fmt .Errorf ("error creating executor: %w" , err )
260+ executorErr := fmt .Errorf ("error creating executor: %w" , err )
261+ GinkgoWriter .Printf ("%v\n " , executorErr )
262+
263+ return nil , executorErr
235264 }
236265
237266 return exec , nil
0 commit comments