-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathhelpers.go
More file actions
659 lines (526 loc) · 19.9 KB
/
helpers.go
File metadata and controls
659 lines (526 loc) · 19.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
// Copyright 2025 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0
package steps
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"net/http"
"slices"
"strconv"
"strings"
"time"
"github.com/cucumber/godog"
"github.com/prometheus/common/expfmt"
"github.com/redpanda-data/common-go/rpadmin"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/twmb/franz-go/pkg/kadm"
"github.com/twmb/franz-go/pkg/kgo"
"github.com/twmb/franz-go/pkg/sr"
appsv1 "k8s.io/api/apps/v1"
authenticationv1 "k8s.io/api/authentication/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/ptr"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
framework "github.com/redpanda-data/redpanda-operator/harpoon"
redpandav1alpha2 "github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2"
vectorizedv1alpha1 "github.com/redpanda-data/redpanda-operator/operator/api/vectorized/v1alpha1"
"github.com/redpanda-data/redpanda-operator/operator/pkg/client"
"github.com/redpanda-data/redpanda-operator/operator/pkg/client/acls"
"github.com/redpanda-data/redpanda-operator/operator/pkg/client/roles"
"github.com/redpanda-data/redpanda-operator/operator/pkg/client/users"
"github.com/redpanda-data/redpanda-operator/pkg/kube"
)
type delayedLog func() string
func (d *delayedLog) String() string {
return (*d)()
}
// delayLog is used for when you want to defer resolution of an error
// string for require.Eventually calls based on some value that is
// derived inside of the function closure
func delayLog(closure func() string) *delayedLog {
return ptr.To(delayedLog(closure))
}
type clusterClients struct {
cluster string
resourceTarget *redpandav1alpha2.User
factory *client.Factory
}
func (c *clusterClients) ACLs(ctx context.Context) *acls.Syncer {
t := framework.T(ctx)
syncer, err := c.factory.ACLs(ctx, c.resourceTarget)
require.NoError(t, err)
return syncer
}
func (c *clusterClients) Users(ctx context.Context) *users.Client {
t := framework.T(ctx)
client, err := c.factory.Users(ctx, c.resourceTarget)
require.NoError(t, err)
return client
}
func (c *clusterClients) Roles(ctx context.Context) *roles.Client {
t := framework.T(ctx)
client, err := c.factory.Roles(ctx, c.resourceTarget)
require.NoError(t, err)
return client
}
func (c *clusterClients) Kafka(ctx context.Context) *kgo.Client {
t := framework.T(ctx)
client, err := c.factory.KafkaClient(ctx, c.resourceTarget)
require.NoError(t, err)
return client
}
func (c *clusterClients) SchemaRegistry(ctx context.Context) *sr.Client {
t := framework.T(ctx)
client, err := c.factory.SchemaRegistryClient(ctx, c.resourceTarget)
require.NoError(t, err)
return client
}
func (c *clusterClients) RedpandaAdmin(ctx context.Context) *rpadmin.AdminAPI {
t := framework.T(ctx)
client, err := c.factory.RedpandaAdminClient(ctx, c.resourceTarget)
require.NoError(t, err)
return client
}
func (c *clusterClients) WithAuthentication(auth *client.UserAuth) *clusterClients {
return &clusterClients{
cluster: c.cluster,
resourceTarget: c.resourceTarget,
factory: c.factory.WithUserAuth(auth),
}
}
func (c *clusterClients) AsUser(ctx context.Context, user *redpandav1alpha2.User) *clusterClients {
t := framework.T(ctx)
require.NotNil(t, user.Spec.Authentication)
username := user.Name
password, err := user.Spec.Authentication.Password.Fetch(ctx, t, user.Namespace)
require.NoError(t, err)
mechanism := string(*user.Spec.Authentication.Type)
return c.WithAuthentication(&client.UserAuth{
Username: username,
Password: password,
Mechanism: mechanism,
})
}
func (c *clusterClients) ExpectUser(ctx context.Context, user string) {
t := framework.T(ctx)
t.Logf("Checking for user %q in cluster %q", user, c.cluster)
c.checkUser(ctx, user, true, fmt.Sprintf("User %q does not exist in cluster %q", user, c.cluster))
t.Logf("Found user %q in cluster %q", user, c.cluster)
}
func (c *clusterClients) ExpectNoUser(ctx context.Context, user string) {
t := framework.T(ctx)
t.Logf("Checking that user %q does not exist in cluster %q", user, c.cluster)
c.checkUser(ctx, user, false, fmt.Sprintf("User %q still exists in cluster %q", user, c.cluster))
t.Logf("Found no user %q in cluster %q", user, c.cluster)
}
func (c *clusterClients) ExpectRole(ctx context.Context, role string) {
t := framework.T(ctx)
t.Logf("Checking for role %q in cluster %q", role, c.cluster)
c.checkRole(ctx, role, true, fmt.Sprintf("Role %q does not exist in cluster %q", role, c.cluster))
t.Logf("Found role %q in cluster %q", role, c.cluster)
}
func (c *clusterClients) ExpectNoRole(ctx context.Context, role string) {
t := framework.T(ctx)
t.Logf("Checking that role %q does not exist in cluster %q", role, c.cluster)
c.checkRole(ctx, role, false, fmt.Sprintf("Role %q still exists in cluster %q", role, c.cluster))
t.Logf("Found no role %q in cluster %q", role, c.cluster)
}
func (c *clusterClients) ExpectSchema(ctx context.Context, schema string) {
t := framework.T(ctx)
t.Logf("Checking that schema %q exists in cluster %q", schema, c.cluster)
c.checkSchema(ctx, schema, true, fmt.Sprintf("Schema %q does not exist in cluster %q", schema, c.cluster))
t.Logf("Found schema %q in cluster %q", schema, c.cluster)
}
func (c *clusterClients) ExpectNoSchema(ctx context.Context, schema string) {
t := framework.T(ctx)
t.Logf("Checking that schema %q does not exist in cluster %q", schema, c.cluster)
c.checkSchema(ctx, schema, false, fmt.Sprintf("Schema %q still exists in cluster %q", schema, c.cluster))
t.Logf("Found no schema %q in cluster %q", schema, c.cluster)
}
func (c *clusterClients) checkSchema(ctx context.Context, schema string, exists bool, message string) {
t := framework.T(ctx)
var subjects []string
var err error
if !assert.Eventually(t, func() bool {
t.Logf("Pulling list of schema subjects from cluster")
schemaRegistry := c.SchemaRegistry(ctx)
subjects, err = schemaRegistry.Subjects(ctx)
if err != nil {
// just retry on error, sometimes v1 stuff is slow to come up even after
// the broker is marked as healthy
return false
}
return exists == slices.Contains(subjects, schema)
}, 10*time.Second, 1*time.Second, message) {
require.NoError(t, err)
t.Errorf("Final list of schema subjects: %v", subjects)
}
}
func (c *clusterClients) CreateTopic(ctx context.Context, topic string) {
t := framework.T(ctx)
admin := kadm.NewClient(c.Kafka(ctx))
defer admin.Close()
response, err := admin.CreateTopic(ctx, 1, 1, map[string]*string{}, topic)
require.NoError(t, err)
require.NoError(t, response.Err)
}
func (c *clusterClients) ExpectTopic(ctx context.Context, topic string) {
t := framework.T(ctx)
t.Logf("Checking that topic %q exists in cluster %q", topic, c.cluster)
c.checkTopic(ctx, topic, true, fmt.Sprintf("Topic %q does not exist in cluster %q", topic, c.cluster))
t.Logf("Found topic %q in cluster %q", topic, c.cluster)
}
func (c *clusterClients) ExpectNoTopic(ctx context.Context, topic string) {
t := framework.T(ctx)
t.Logf("Checking that topic %q does not exist in cluster %q", topic, c.cluster)
c.checkTopic(ctx, topic, false, fmt.Sprintf("Topic %q still exists in cluster %q", topic, c.cluster))
t.Logf("Found no topic %q in cluster %q", topic, c.cluster)
}
// Enable experimental feature support.
//
// The key must be equal to the current broker time expressed as unix epoch
// in seconds, and be within 1 hour.
func (c *clusterClients) EnableFeature(ctx context.Context, feature string) {
t := framework.T(ctx)
admin := c.RedpandaAdmin(ctx)
defer admin.Close()
_, err := admin.PatchClusterConfig(ctx, map[string]any{
"enable_developmental_unrecoverable_data_corrupting_features": time.Now().Unix(),
}, []string{})
require.NoError(t, err)
// now enable the feature
_, err = admin.PatchClusterConfig(ctx, map[string]any{
feature: true,
}, []string{})
require.NoError(t, err)
}
// Set log level for given logger.
func (c *clusterClients) SetLogLevel(ctx context.Context, level, logger string) {
t := framework.T(ctx)
admin := c.RedpandaAdmin(ctx)
defer admin.Close()
require.NoError(t, admin.SetLogLevel(ctx, logger, level, 0))
}
func (c *clusterClients) checkTopic(ctx context.Context, topic string, exists bool, message string) {
t := framework.T(ctx)
var topics kadm.TopicDetails
var err error
if !assert.Eventually(t, func() bool {
t.Logf("Pulling list of topics from cluster")
admin := kadm.NewClient(c.Kafka(ctx))
defer admin.Close()
topics, err = admin.ListTopics(ctx)
require.NoError(t, err)
require.NoError(t, topics.Error())
return exists == topics.Has(topic)
}, 10*time.Second, 1*time.Second, message) {
t.Errorf("Final list of topics: %v", topics.Names())
}
}
func (c *clusterClients) checkUser(ctx context.Context, user string, exists bool, message string) {
t := framework.T(ctx)
var users []string
var err error
if !assert.Eventually(t, func() bool {
t.Logf("Pulling list of users from cluster")
adminClient := c.RedpandaAdmin(ctx)
defer adminClient.Close()
users, err = adminClient.ListUsers(ctx)
require.NoError(t, err)
return exists == slices.Contains(users, user)
}, 10*time.Second, 1*time.Second, message) {
t.Errorf("Final list of users: %v", users)
}
}
func (c *clusterClients) checkRole(ctx context.Context, role string, exists bool, message string) {
t := framework.T(ctx)
if !assert.Eventually(t, func() bool {
t.Logf("Checking if role %q exists in cluster", role)
adminClient := c.RedpandaAdmin(ctx)
// Try to get role members - if it succeeds, role exists
_, err := adminClient.RoleMembers(ctx, role)
roleExists := err == nil
adminClient.Close()
return exists == roleExists
}, 30*time.Second, 2*time.Second, message) {
t.Errorf("Role %q existence check failed", role)
}
}
func versionedClientsForCluster(ctx context.Context, version, cluster string) *clusterClients {
version = getVersion(framework.T(ctx), version)
framework.T(ctx).Logf("Got versioned cluster %q", version)
if version == "vectorized" {
return v1ClientsForCluster(ctx, cluster)
}
return clientsForCluster(ctx, cluster)
}
func clientsForCluster(ctx context.Context, cluster string) *clusterClients {
t := framework.T(ctx)
t.Logf("Creating clients for cluster %q in namespace %q", cluster, t.Namespace())
// First verify the cluster exists
var testCluster redpandav1alpha2.Redpanda
clusterKey := t.ResourceKey(cluster)
if err := t.Get(ctx, clusterKey, &testCluster); err != nil {
t.Fatalf("Failed to find cluster %q in namespace %q: %v", cluster, t.Namespace(), err)
}
t.Logf("Found cluster %q with status: %+v", cluster, testCluster.Status)
// we construct a fake user to grab all of the clients for the cluster
referencer := &redpandav1alpha2.User{
ObjectMeta: metav1.ObjectMeta{
Namespace: t.Namespace(),
Name: "test-user-" + cluster, // Add a name for debugging
},
Spec: redpandav1alpha2.UserSpec{
ClusterSource: &redpandav1alpha2.ClusterSource{
ClusterRef: &redpandav1alpha2.ClusterRef{
Name: cluster,
},
},
},
}
t.Logf("Created fake user %q looking for cluster %q in namespace %q", referencer.Name, cluster, t.Namespace())
t.Logf("Fake user cluster ref: name=%q", referencer.Spec.ClusterSource.ClusterRef.Name)
factory := client.NewFactory(t.RestConfig(), t, nil).WithDialer(kube.NewPodDialer(t.RestConfig()).DialContext)
clients := &clusterClients{
resourceTarget: referencer,
cluster: cluster,
factory: factory,
}
t.Logf("Successfully created clients for cluster %q", cluster)
return clients
}
func v1ClientsForCluster(ctx context.Context, cluster string) *clusterClients {
t := framework.T(ctx)
t.Logf("Creating clients for cluster %q in namespace %q", cluster, t.Namespace())
// First verify the cluster exists
var testCluster vectorizedv1alpha1.Cluster
clusterKey := t.ResourceKey(cluster)
if err := t.Get(ctx, clusterKey, &testCluster); err != nil {
t.Fatalf("Failed to find cluster %q in namespace %q: %v", cluster, t.Namespace(), err)
}
t.Logf("Found cluster %q with status: %+v", cluster, testCluster.Status)
// we construct a fake user to grab all of the clients for the cluster
referencer := &redpandav1alpha2.User{
ObjectMeta: metav1.ObjectMeta{
Namespace: t.Namespace(),
Name: "test-user-" + cluster, // Add a name for debugging
},
Spec: redpandav1alpha2.UserSpec{
ClusterSource: &redpandav1alpha2.ClusterSource{
ClusterRef: &redpandav1alpha2.ClusterRef{
Group: ptr.To("redpanda.vectorized.io"),
Kind: ptr.To("Cluster"),
Name: cluster,
},
},
},
}
t.Logf("Created fake user %q looking for cluster %q in namespace %q", referencer.Name, cluster, t.Namespace())
t.Logf("Fake v1 user cluster ref: name=%q", referencer.Spec.ClusterSource.ClusterRef.Name)
factory := client.NewFactory(t.RestConfig(), t, nil).WithDialer(kube.NewPodDialer(t.RestConfig()).DialContext)
clients := &clusterClients{
resourceTarget: referencer,
cluster: cluster,
factory: factory,
}
t.Logf("Successfully created clients for cluster %q", cluster)
return clients
}
func usersFromACLTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User
for i, row := range table.Rows {
// skip the header row:
// | name | acls |
if i == 0 {
continue
}
name, acls := row.Cells[0].Value, row.Cells[1].Value
name, acls = strings.TrimSpace(name), strings.TrimSpace(acls)
users = append(users, userFromRow(t, version, cluster, name, "", "", acls))
}
return users
}
func usersFromAuthTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User
for i, row := range table.Rows {
// skip the header row:
// | name | password | mechanism |
if i == 0 {
continue
}
name, password, mechanism := row.Cells[0].Value, row.Cells[1].Value, row.Cells[2].Value
name, password, mechanism = strings.TrimSpace(name), strings.TrimSpace(password), strings.TrimSpace(mechanism)
users = append(users, userFromRow(t, version, cluster, name, password, mechanism, ""))
}
return users
}
func usersFromFullTable(t framework.TestingT, version, cluster string, table *godog.Table) []*redpandav1alpha2.User {
var users []*redpandav1alpha2.User
for i, row := range table.Rows {
// skip the header row:
// | name | password | mechanism | acls |
if i == 0 {
continue
}
name, password, mechanism, acls := row.Cells[0].Value, row.Cells[1].Value, row.Cells[2].Value, row.Cells[3].Value
name, password, mechanism, acls = strings.TrimSpace(name), strings.TrimSpace(password), strings.TrimSpace(mechanism), strings.TrimSpace(acls)
users = append(users, userFromRow(t, version, cluster, name, password, mechanism, acls))
}
return users
}
func userFromRow(t framework.TestingT, version, cluster, name, password, mechanism, acls string) *redpandav1alpha2.User {
version = getVersion(t, version)
user := &redpandav1alpha2.User{
ObjectMeta: metav1.ObjectMeta{
Namespace: t.Namespace(),
Name: name,
},
Spec: redpandav1alpha2.UserSpec{
ClusterSource: &redpandav1alpha2.ClusterSource{
ClusterRef: &redpandav1alpha2.ClusterRef{
Name: cluster,
},
},
},
}
if version == "vectorized" {
user.Spec.ClusterSource.ClusterRef.Group = ptr.To("redpanda.vectorized.io")
user.Spec.ClusterSource.ClusterRef.Kind = ptr.To("Cluster")
}
if mechanism != "" || password != "" {
user.Spec.Authentication = &redpandav1alpha2.UserAuthenticationSpec{
Type: ptr.To(redpandav1alpha2.SASLMechanism(mechanism)),
Password: redpandav1alpha2.Password{
Value: password,
ValueFrom: &redpandav1alpha2.PasswordSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: name + "-password",
},
},
},
},
}
}
if acls != "" {
user.Spec.Authorization = &redpandav1alpha2.UserAuthorizationSpec{}
require.NoError(t, json.Unmarshal([]byte(acls), &user.Spec.Authorization.ACLs))
}
return user
}
func checkStableResource(ctx context.Context, t framework.TestingT, o runtimeclient.Object) {
var previousResourceVersion string
var equalityChecks int
key := runtimeclient.ObjectKeyFromObject(o)
t.Logf("Ensuring that resource %q is stable", key.String())
require.Eventually(t, func() bool {
require.NoError(t, t.Get(ctx, key, o))
if previousResourceVersion == o.GetResourceVersion() {
equalityChecks++
} else {
equalityChecks = 0
}
// ensure we're stable for a 5 second window
if equalityChecks == 5 {
return true
}
previousResourceVersion = o.GetResourceVersion()
return false
}, 30*time.Second, 1*time.Second, "Resource never stabilized")
t.Logf("Resource %q has been stable for 5 seconds", key.String())
}
type operatorClients struct {
client http.Client
operatorPodName string
namespace string
schema string
token string
expectedStatusCode int
}
func (c *operatorClients) ExpectRequestRejected(ctx context.Context) {
t := framework.T(ctx)
url := fmt.Sprintf("%s://%s.%s:8443/metrics", c.schema, c.operatorPodName, c.namespace)
t.Logf("Request %s to operator", url)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
require.NoError(t, err)
req.Header.Set("Authorization", "Bearer "+c.token)
resp, err := c.client.Do(req)
require.NoError(t, err)
require.Equal(t, c.expectedStatusCode, resp.StatusCode)
defer resp.Body.Close()
}
func (c *operatorClients) ExpectCorrectMetricsResponse(ctx context.Context) {
t := framework.T(ctx)
url := fmt.Sprintf("%s://%s.%s:8443/metrics", c.schema, c.operatorPodName, c.namespace)
t.Logf("Request %s to operator", url)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
require.NoError(t, err)
req.Header.Set("Authorization", "Bearer "+c.token)
resp, err := c.client.Do(req)
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)
defer resp.Body.Close()
var parser expfmt.TextParser
_, err = parser.TextToMetricFamilies(resp.Body)
require.NoError(t, err)
}
func clientsForOperator(ctx context.Context, includeTLS bool, serviceAccountName, expectedStatusCode string) *operatorClients {
t := framework.T(ctx)
var dep appsv1.Deployment
require.NoError(t, t.Get(ctx, t.ResourceKey("redpanda-operator"), &dep))
var podList corev1.PodList
require.NoError(t, t.List(ctx, &podList, &runtimeclient.ListOptions{
LabelSelector: labels.SelectorFromSet(dep.Spec.Selector.MatchLabels),
}))
require.Len(t, podList.Items, 1, "expected 1 pod, got %d", len(podList.Items))
var tlsCfg tls.Config
schema := "http"
if includeTLS {
tlsCfg = tls.Config{InsecureSkipVerify: includeTLS} // nolint:gosec
schema = "https"
}
token := "non-existing-token"
if serviceAccountName != "" {
cs, err := kubernetes.NewForConfig(t.RestConfig())
require.NoError(t, err)
tokenResponse, err := cs.CoreV1().ServiceAccounts(t.Namespace()).CreateToken(ctx, serviceAccountName, &authenticationv1.TokenRequest{}, metav1.CreateOptions{})
require.NoError(t, err)
token = tokenResponse.Status.Token
}
statusCode := http.StatusOK
if expectedStatusCode != "" {
var err error
statusCode, err = strconv.Atoi(expectedStatusCode)
require.NoError(t, err)
}
return &operatorClients{
expectedStatusCode: statusCode,
token: token,
schema: schema,
namespace: t.Namespace(),
operatorPodName: podList.Items[0].Name,
client: http.Client{Transport: &http.Transport{
TLSClientConfig: &tlsCfg,
DialContext: kube.NewPodDialer(t.RestConfig()).DialContext,
}},
}
}
func getVersion(t framework.TestingT, version string) string {
version = strings.TrimSpace(version)
if version != "" {
return version
}
return t.Variant()
}