Skip to content

Commit b5fab9e

Browse files
authored
Updated unit tests (#4)
1 parent 15e0ea2 commit b5fab9e

File tree

15 files changed

+747
-160
lines changed

15 files changed

+747
-160
lines changed

.github/workflows/build.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
- name: Run Unit Tests
3232
run: |
3333
go test -covermode=count -coverprofile=profile.cov ./pkg/...
34-
# - name: Send coverage
35-
# env:
36-
# COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
# run: |
38-
# GO111MODULE=off go get github.com/mattn/goveralls
39-
# $(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github
34+
- name: Send coverage
35+
env:
36+
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
GO111MODULE=off go get github.com/mattn/goveralls
39+
$(go env GOPATH)/bin/goveralls -coverprofile=profile.cov -service=github

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
This project provides a native ingress controller which can be deployed on OCI. The ingress module leverages
33
on the existing OCI load balancer features to act as an ingress controller for cluster services.
44

5+
[![Go Report Card](https://goreportcard.com/badge/github.com/oracle/oci-native-ingress-controller)](https://goreportcard.com/report/github.com/oracle/oci-native-ingress-controller)
6+
[![License](http://img.shields.io/badge/license-UPL%201.0-blue.svg)](https://oss.oracle.com/licenses/upl/)
7+
[![Release](https://img.shields.io/github/v/release/oracle/oci-native-ingress-controller)](https://img.shields.io/github/v/release/oracle/oci-native-ingress-controller)
8+
[![Coverage Status](https://coveralls.io/repos/github/oracle/oci-native-ingress-controller/badge.svg?branch=master)](https://coveralls.io/github/oracle/oci-native-ingress-controller?branch=master)
9+
510
## Getting Started
611
Please have a look at [Getting Started](./GettingStarted.md)
712

api/v1beta1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package v1beta1
1414

1515
import (
1616
"sigs.k8s.io/controller-runtime/pkg/scheme"
17-
17+
1818
"k8s.io/apimachinery/pkg/runtime/schema"
1919
)
2020

api/v1beta1/ingressclassparameters_types.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@
1010
package v1beta1
1111

1212
import (
13-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414
)
1515

1616
// IngressClassParametersSpec defines the desired state of IngressClassParameters
1717
type IngressClassParametersSpec struct {
18-
// +kubebuilder:validation:MaxLength=255
19-
// +kubebuilder:validation:MinLength=1
20-
CompartmentId string `json:"compartmentId,omitempty"`
21-
22-
// +kubebuilder:validation:MaxLength=255
23-
// +kubebuilder:validation:MinLength=1
24-
SubnetId string `json:"subnetId,omitempty"`
25-
26-
LoadBalancerName string `json:"loadBalancerName,omitempty"`
27-
28-
IsPrivate bool `json:"isPrivate,omitempty"`
29-
30-
ReservedPublicAddressId string `json:"reservedPublicAddressId,omitempty"`
31-
32-
// +kubebuilder:validation:Minimum=10
33-
// +kubebuilder:validation:Maximum=8000
34-
// +kubebuilder:validation:ExclusiveMaximum=false
35-
// +kubebuilder:default:=10
36-
MinBandwidthMbps int `json:"minBandwidthMbps,omitempty"`
37-
38-
// +kubebuilder:validation:Minimum=10
39-
// +kubebuilder:validation:Maximum=8000
40-
// +kubebuilder:validation:ExclusiveMaximum=false
41-
// +kubebuilder:default:=100
42-
MaxBandwidthMbps int `json:"maxBandwidthMbps,omitempty"`
18+
// +kubebuilder:validation:MaxLength=255
19+
// +kubebuilder:validation:MinLength=1
20+
CompartmentId string `json:"compartmentId,omitempty"`
21+
22+
// +kubebuilder:validation:MaxLength=255
23+
// +kubebuilder:validation:MinLength=1
24+
SubnetId string `json:"subnetId,omitempty"`
25+
26+
LoadBalancerName string `json:"loadBalancerName,omitempty"`
27+
28+
IsPrivate bool `json:"isPrivate,omitempty"`
29+
30+
ReservedPublicAddressId string `json:"reservedPublicAddressId,omitempty"`
31+
32+
// +kubebuilder:validation:Minimum=10
33+
// +kubebuilder:validation:Maximum=8000
34+
// +kubebuilder:validation:ExclusiveMaximum=false
35+
// +kubebuilder:default:=10
36+
MinBandwidthMbps int `json:"minBandwidthMbps,omitempty"`
37+
38+
// +kubebuilder:validation:Minimum=10
39+
// +kubebuilder:validation:Maximum=8000
40+
// +kubebuilder:validation:ExclusiveMaximum=false
41+
// +kubebuilder:default:=100
42+
MaxBandwidthMbps int `json:"maxBandwidthMbps,omitempty"`
4343
}
4444

4545
// IngressClassParametersStatus defines the observed state of IngressClassParameters
@@ -54,22 +54,22 @@ type IngressClassParametersStatus struct {
5454
// +kubebuilder:printcolumn:name="Private",type=boolean,JSONPath=`.spec.isPrivate`
5555
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
5656
type IngressClassParameters struct {
57-
metav1.TypeMeta `json:",inline"`
58-
metav1.ObjectMeta `json:"metadata,omitempty"`
59-
60-
Spec IngressClassParametersSpec `json:"spec,omitempty"`
61-
Status IngressClassParametersStatus `json:"status,omitempty"`
57+
metav1.TypeMeta `json:",inline"`
58+
metav1.ObjectMeta `json:"metadata,omitempty"`
59+
60+
Spec IngressClassParametersSpec `json:"spec,omitempty"`
61+
Status IngressClassParametersStatus `json:"status,omitempty"`
6262
}
6363

6464
//+kubebuilder:object:root=true
6565

6666
// IngressClassParametersList contains a list of IngressClassParameters
6767
type IngressClassParametersList struct {
68-
metav1.TypeMeta `json:",inline"`
69-
metav1.ListMeta `json:"metadata,omitempty"`
70-
Items []IngressClassParameters `json:"items"`
68+
metav1.TypeMeta `json:",inline"`
69+
metav1.ListMeta `json:"metadata,omitempty"`
70+
Items []IngressClassParameters `json:"items"`
7171
}
7272

7373
func init() {
74-
SchemeBuilder.Register(&IngressClassParameters{}, &IngressClassParametersList{})
74+
SchemeBuilder.Register(&IngressClassParameters{}, &IngressClassParametersList{})
7575
}

pkg/auth/auth_service.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
const httpClientTimeout = 20 * time.Second
3232

3333
func GetConfigurationProvider(ctx context.Context, opts types.IngressOpts) (common.ConfigurationProvider, error) {
34-
auth, err := retrieveAuthConfig(ctx, opts, opts.LeaseLockNamespace)
34+
auth, err := RetrieveAuthConfig(ctx, opts, opts.LeaseLockNamespace)
3535
if err != nil {
3636
klog.Fatalf("Unable to handle authentication parameters", err)
3737
return nil, err
@@ -71,7 +71,7 @@ func setHTTPClientTimeout(
7171
}
7272
}
7373

74-
func retrieveAuthConfig(ctx context.Context, opts types.IngressOpts, namespace string) (*types.Auth, error) {
74+
func RetrieveAuthConfig(ctx context.Context, opts types.IngressOpts, namespace string) (*types.Auth, error) {
7575
authType := opts.AuthType
7676
principalType, err := types.MapToPrincipalType(authType)
7777
if err != nil {
@@ -98,7 +98,7 @@ func retrieveAuthConfig(ctx context.Context, opts types.IngressOpts, namespace s
9898
klog.Fatalf("Empty Configuration is found in the secret %s", authConfigSecretName)
9999
return nil, fmt.Errorf("auth config data is empty: %v", authConfigSecretName)
100100
}
101-
authCfg, err := parseAuthConfig(secret, authConfigSecretName)
101+
authCfg, err := ParseAuthConfig(secret, authConfigSecretName)
102102
if err != nil {
103103
klog.Fatalf("Missing auth config data: %s", authConfigSecretName)
104104
return nil, fmt.Errorf("missing auth config data: %v", err)
@@ -114,7 +114,7 @@ func retrieveAuthConfig(ctx context.Context, opts types.IngressOpts, namespace s
114114
return auth, nil
115115
}
116116

117-
func parseAuthConfig(secret *v1.Secret, authConfigSecretName string) (*types.AuthConfig, error) {
117+
func ParseAuthConfig(secret *v1.Secret, authConfigSecretName string) (*types.AuthConfig, error) {
118118
authYaml := &types.AuthConfigYaml{}
119119
err := yaml.Unmarshal(secret.Data["config"], &authYaml)
120120
if err != nil {

pkg/auth/auth_service_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package auth
2+
3+
import (
4+
"context"
5+
"encoding/base64"
6+
"fmt"
7+
"testing"
8+
9+
. "github.com/onsi/gomega"
10+
"github.com/oracle/oci-native-ingress-controller/pkg/types"
11+
v1 "k8s.io/api/core/v1"
12+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13+
)
14+
15+
const (
16+
PrivateKey = "SSLPrivateData = `-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAyxPEO9rowYQ6/sjpD4VxnGdChokq4b8LyOcnIFRMueihl+8S\napqbe96A3etQaMBANx2FcuFt9FcPSJaJU93i9hkw/FPa5d2+Kr7wgE3pwOPXPqOI\nxuaeQfUIZ4QcGNSs1utsSbj/i3RvJDgrUOI+RypT4erpQX2cQZ5tplaDd2SxBYWW\nyZUkVIRPXKyJm4Yft1CsKDtbEzzIdh69DlfyfWRDYWxfD9D/RflmDafbunXo1OC2\nUJ3MHi+tD2NxgCFVvOWiiE+BMD28e3mGVg6WvoFtcutahnvrFocHDWnoMK269AbI\nrZ1WuUKBxOlbWLz9XbbsxFYDskRqNk22GtrQ3QIDAQABAoIBACU1cfclnRAYElcs\nqMdXRAHMSbws1daXEqm08M5To9tMbI9SFqXBvktr8WC4BPusfhebKSBrfaIPcZVz\nP6ZGOZet9fPFyY3kmztp0Ncxb2sQVBf+Dsmi58xeATQ2WI+UKDcY27aGVwxOQS75\nu7YOPir77nKugB6nzUGYra6Um3H8hYNWTgWyiATb8Y0V4njCf8pAepGOptClyI1I\ni5fsEE6q52jbGeFRK2JTysG8ovABBdGYsS8XOUuZ+O/QktF/iFwFtMWdEur5tcOO\nRoPSrc/4H8pNpL7IhF0Iy/hpNoNsin7Gj4UBNi6dhrtcGz3zCGSKtldsootgSC2C\nKWd/rAECgYEA5sF6OZsLguVfCqmj3WiLM5I+YWC/HAmV9grb9puW35cQxfQegmdj\nInWk+rcotuFTBcTKjXDKT4C8vCZid2p0WnSWqLPWhPYg0p2awobZgjRy0HzvUgGJ\n/gWAEydzsUc8ojHrUBdJ2iyvjy+I8JWQcyQkBUGlPZj0IC5VUgODYD0CgYEA4Usg\nUCJqo35pLq0TmPSfUuMPzTV3StIft+r7S3g4HWpvrBQNKf6p96/Fjt2WaPhvAABB\nww8Pg2B97iSqR6Rg4Ba4BQQEfHtWCHQ2NuNOoNkRLTJqOxREk7+741Qy9EwgeDJ6\nrQqgrde1dLJPZDzQpbFoCLkIkQ6CL3jTkyDenSECgYEAmvZ1STgoy9eTMsrnY2mw\niYp9X9GjpYV+coOqYfrsn+yH9BfTYUli1qJgj4nuypmYsngMel2zTx6qIEQ6vez8\nhD5lapeSySmssyPp6Ra7/OeR7xbndI/aBn/VGYfV9shbHKUfXGK3Us/Nef+3G7Gl\nFt2/XtRNzobn8rCK1Y/MaxUCgYB6RFpKAxOanS0aLsX2+bNJuX7G4KBYE8cw+i7d\nG2Zg2HW4jr1CMDov+M2fpjRNzZ34AyutX4wMwZ42UuGytcv5cXr3BeIlaI4dUmxl\nx2DRvFwtCjJK08oP4TtnuTdaC8KHWOXo6V6gWfPZXDfn73VQpwIN0dWLW7NdbhZs\nv6bw4QKBgEXYPIf827EVz0XU+1wkjaLt+G40J9sAPk/a6qybF33BBbBhjDxMnest\nArGIjYo4IcYu5hzwnPy/B9WIFgz1iY31l01eP90zJ6q+xpCO5qSdSnjkfq1zrwzK\nBs7B72+hgS7VwRowRUbNanaZIZt0ZAiwQWN1+Dh7Bj+VbSxc/fna\n-----END RSA PRIVATE KEY-----`"
17+
data = "IwojIE9DSSBOYXRpdmUgSW5ncmVzcyBDb250cm9sbGVyCiMKIyBDb3B5cmlnaHQgKGMpIDIwMjMgT3JhY2xlIEFtZXJpY2EsIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLgojIExpY2Vuc2VkIHVuZGVyIHRoZSBVbml2ZXJzYWwgUGVybWlzc2l2ZSBMaWNlbnNlIHYgMS4wIGFzIHNob3duIGF0IGh0dHBzOi8vb3NzLm9yYWNsZS5jb20vbGljZW5zZXMvdXBsLwojCmF1dGg6CiAgcmVnaW9uOiB1cy1hc2hidXJuLTEKICBwYXNzcGhyYXNlOiBwYXNzCiAgdXNlcjogb2NpZDEudXNlci5vYzEuLmFhYWFhYWFhX2V4YW1wbGUKICBmaW5nZXJwcmludDogNjc6ZDk6NzQ6NGI6MjE6ZXhhbXBsZQogIHRlbmFuY3k6IG9jaWQxLnRlbmFuY3kub2MxLi5hYWFhYWFhYV9leGFtcGxl"
18+
)
19+
20+
func TestRetrieveAuthConfigInstanceAuthType(t *testing.T) {
21+
RegisterTestingT(t)
22+
opts := types.IngressOpts{
23+
AuthType: "instance",
24+
}
25+
cfg, err := RetrieveAuthConfig(context.TODO(), opts, "test")
26+
Expect(err == nil).Should(BeTrue())
27+
Expect(cfg.Type).Should(Equal(types.Instance))
28+
29+
}
30+
func TestRetrieveAuthConfigInstanceAuthTypeTestRetrieveAuthConfigInvalidAuthType(t *testing.T) {
31+
RegisterTestingT(t)
32+
authType := "random"
33+
opts := types.IngressOpts{
34+
AuthType: authType,
35+
}
36+
_, err := RetrieveAuthConfig(context.TODO(), opts, "test")
37+
Expect(err != nil).Should(BeTrue())
38+
Expect(err.Error()).Should(Equal(fmt.Sprintf("invalid auth principal type, %s", authType)))
39+
40+
}
41+
42+
func TestParseAuthConfig(t *testing.T) {
43+
RegisterTestingT(t)
44+
secret := getSampleSecret()
45+
authCfg, err := ParseAuthConfig(secret, "oci-config")
46+
Expect(err == nil).Should(BeTrue())
47+
Expect(authCfg.TenancyID).Should(Equal("ocid1.tenancy.oc1..aaaaaaaa_example"))
48+
Expect(authCfg.Region).Should(Equal("us-ashburn-1"))
49+
Expect(authCfg.UserID).Should(Equal("ocid1.user.oc1..aaaaaaaa_example"))
50+
Expect(authCfg.Fingerprint).Should(Equal("67:d9:74:4b:21:example"))
51+
err = authCfg.Validate()
52+
Expect(err == nil).Should(BeTrue())
53+
}
54+
55+
func getSampleSecret() *v1.Secret {
56+
dat, _ := base64.StdEncoding.DecodeString(data)
57+
secret := &v1.Secret{
58+
ObjectMeta: metav1.ObjectMeta{
59+
Namespace: "test",
60+
Name: "oci-config",
61+
},
62+
Data: map[string][]byte{
63+
"config": []byte(dat),
64+
"private-key": []byte(PrivateKey),
65+
},
66+
}
67+
return secret
68+
}

pkg/controllers/backend/backend.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Controller struct {
5656

5757
queue workqueue.RateLimitingInterface
5858

59-
client kubernetes.Interface
59+
clientset kubernetes.Interface
6060

6161
lbClient *loadbalancer.LoadBalancerClient
6262
}
@@ -79,7 +79,7 @@ func NewController(
7979
serviceLister: serviceLister,
8080
endpointLister: endpointLister,
8181
podLister: podLister,
82-
client: client,
82+
clientset: client,
8383
lbClient: lbClient,
8484
queue: workqueue.NewRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(10*time.Second, 5*time.Minute)),
8585
}
@@ -373,12 +373,12 @@ func (c *Controller) ensurePodReadinessCondition(pod *corev1.Pod, readinessGate
373373

374374
klog.InfoS("updating pod readiness gate from pod", "pod", klog.KObj(pod), "gate", readinessGate)
375375

376-
patchBytes, err := buildPodConditionPatch(pod, updatedCondition)
376+
patchBytes, err := BuildPodConditionPatch(pod, updatedCondition)
377377
if err != nil {
378378
return fmt.Errorf("unable to build pod condition for %s/%s: %w", pod.Namespace, pod.Name, err)
379379
}
380380

381-
_, err = c.client.CoreV1().Pods(pod.Namespace).Patch(context.TODO(), pod.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
381+
_, err = c.clientset.CoreV1().Pods(pod.Namespace).Patch(context.TODO(), pod.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
382382
if err != nil {
383383
return fmt.Errorf("unable to remove readiness gate %s from pod %s/%s: %w", readinessGate, pod.Namespace, pod.Name, err)
384384
}
@@ -388,7 +388,7 @@ func (c *Controller) ensurePodReadinessCondition(pod *corev1.Pod, readinessGate
388388
return nil
389389
}
390390

391-
func buildPodConditionPatch(pod *corev1.Pod, condition corev1.PodCondition) ([]byte, error) {
391+
func BuildPodConditionPatch(pod *corev1.Pod, condition corev1.PodCondition) ([]byte, error) {
392392
oldData, err := json.Marshal(corev1.Pod{
393393
Status: corev1.PodStatus{
394394
Conditions: nil,
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package backend
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"testing"
7+
8+
. "github.com/onsi/gomega"
9+
corev1 "k8s.io/api/core/v1"
10+
networkingv1 "k8s.io/api/networking/v1"
11+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+
"k8s.io/apimachinery/pkg/runtime"
13+
"k8s.io/client-go/informers"
14+
networkinginformers "k8s.io/client-go/informers/networking/v1"
15+
fakeclientset "k8s.io/client-go/kubernetes/fake"
16+
"k8s.io/client-go/kubernetes/typed/core/v1/fake"
17+
fake2 "k8s.io/client-go/kubernetes/typed/networking/v1/fake"
18+
corelisters "k8s.io/client-go/listers/core/v1"
19+
k8stesting "k8s.io/client-go/testing"
20+
21+
"k8s.io/client-go/tools/cache"
22+
)
23+
24+
func setUp(ctx context.Context, ingressClassList *networkingv1.IngressClassList, ingressList *networkingv1.IngressList, testService *corev1.Service,
25+
endpoints *corev1.Endpoints, pod *corev1.Pod) (networkinginformers.IngressClassInformer, networkinginformers.IngressInformer,
26+
corelisters.ServiceLister, corelisters.EndpointsLister, corelisters.PodLister, *fakeclientset.Clientset) {
27+
client := fakeclientset.NewSimpleClientset()
28+
client.NetworkingV1().(*fake2.FakeNetworkingV1).
29+
PrependReactor("list", "ingressclasses", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
30+
return true, ingressClassList, nil
31+
})
32+
33+
client.NetworkingV1().(*fake2.FakeNetworkingV1).
34+
PrependReactor("list", "ingresses", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
35+
return true, ingressList, nil
36+
})
37+
38+
client.CoreV1().Services("").(*fake.FakeServices).Fake.
39+
PrependReactor("get", "services", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
40+
return true, testService, nil
41+
})
42+
43+
client.CoreV1().(*fake.FakeCoreV1).
44+
PrependReactor("get", "endpoints", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
45+
return true, endpoints, nil
46+
})
47+
48+
client.CoreV1().(*fake.FakeCoreV1).
49+
PrependReactor("get", "pods", func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
50+
return true, pod, nil
51+
})
52+
53+
informerFactory := informers.NewSharedInformerFactory(client, 0)
54+
ingressClassInformer := informerFactory.Networking().V1().IngressClasses()
55+
ingressClassInformer.Lister()
56+
57+
ingressInformer := informerFactory.Networking().V1().Ingresses()
58+
ingressInformer.Lister()
59+
60+
serviceInformer := informerFactory.Core().V1().Services()
61+
serviceLister := serviceInformer.Lister()
62+
63+
endpointInformer := informerFactory.Core().V1().Endpoints()
64+
endpointLister := endpointInformer.Lister()
65+
66+
podInformer := informerFactory.Core().V1().Pods()
67+
podLister := podInformer.Lister()
68+
69+
informerFactory.Start(ctx.Done())
70+
cache.WaitForCacheSync(ctx.Done(), ingressClassInformer.Informer().HasSynced)
71+
cache.WaitForCacheSync(ctx.Done(), ingressInformer.Informer().HasSynced)
72+
cache.WaitForCacheSync(ctx.Done(), serviceInformer.Informer().HasSynced)
73+
cache.WaitForCacheSync(ctx.Done(), endpointInformer.Informer().HasSynced)
74+
cache.WaitForCacheSync(ctx.Done(), podInformer.Informer().HasSynced)
75+
return ingressClassInformer, ingressInformer, serviceLister, endpointLister, podLister, client
76+
}
77+
78+
func TestBuildPodConditionPatch(t *testing.T) {
79+
RegisterTestingT(t)
80+
pod := &corev1.Pod{
81+
TypeMeta: metav1.TypeMeta{
82+
APIVersion: "v1",
83+
Kind: "Pod",
84+
},
85+
Spec: corev1.PodSpec{
86+
Containers: []corev1.Container{
87+
{
88+
Name: "test",
89+
Image: "echoserver",
90+
},
91+
},
92+
},
93+
}
94+
newCondition := corev1.PodCondition{
95+
Type: corev1.ContainersReady,
96+
Status: corev1.ConditionTrue,
97+
}
98+
patch, err := BuildPodConditionPatch(pod, newCondition)
99+
Expect(err == nil).Should(Equal(true))
100+
Expect(bytes.Equal(patch, []byte("{\"status\":{\"conditions\":[{\"lastProbeTime\":null,\"lastTransitionTime\":null,\"status\":\"True\",\"type\":\"ContainersReady\"}]}}"))).Should(Equal(true))
101+
}

0 commit comments

Comments
 (0)