Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix SubResourceCreateOptions signature in subresource client #2766

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/client/client.go
Expand Up @@ -523,8 +523,8 @@ func (co *SubResourceCreateOptions) ApplyOptions(opts []SubResourceCreateOption)
return co
}

// ApplyToSubresourceCreate applies the the configuration on the given create options.
func (co *SubResourceCreateOptions) ApplyToSubresourceCreate(o *SubResourceCreateOptions) {
// ApplyToSubResourceCreate applies the the configuration on the given create options.
func (co *SubResourceCreateOptions) ApplyToSubResourceCreate(o *SubResourceCreateOptions) {
co.CreateOptions.ApplyToCreate(&co.CreateOptions)
}

Expand Down
18 changes: 9 additions & 9 deletions pkg/client/client_test.go
Expand Up @@ -809,7 +809,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC

By("reading the scale subresource")
scale := &autoscalingv1.Scale{}
err = cl.SubResource("scale").Get(ctx, dep, scale)
err = cl.SubResource("scale").Get(ctx, dep, scale, &client.SubResourceGetOptions{})
Expect(err).NotTo(HaveOccurred())
Expect(scale.Spec.Replicas).To(Equal(*dep.Spec.Replicas))
})
Expand All @@ -823,7 +823,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
Expect((err)).NotTo(HaveOccurred())

token := &authenticationv1.TokenRequest{}
err = cl.SubResource("token").Create(ctx, serviceAccount, token)
err = cl.SubResource("token").Create(ctx, serviceAccount, token, &client.SubResourceCreateOptions{})
Expect(err).NotTo(HaveOccurred())

Expect(token.Status.Token).NotTo(Equal(""))
Expand All @@ -845,7 +845,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
eviction := &policyv1.Eviction{
DeleteOptions: &metav1.DeleteOptions{GracePeriodSeconds: ptr.To(int64(0))},
}
err = cl.SubResource("eviction").Create(ctx, pod, eviction)
err = cl.SubResource("eviction").Create(ctx, pod, eviction, &client.SubResourceCreateOptions{})
Expect((err)).NotTo(HaveOccurred())

By("Asserting the pod is gone")
Expand All @@ -869,7 +869,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
binding := &corev1.Binding{
Target: corev1.ObjectReference{Name: node.Name},
}
err = cl.SubResource("binding").Create(ctx, pod, binding)
err = cl.SubResource("binding").Create(ctx, pod, binding, &client.SubResourceCreateOptions{})
Expect((err)).NotTo(HaveOccurred())

By("Asserting the pod is bound")
Expand All @@ -892,7 +892,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
Type: certificatesv1.CertificateApproved,
Status: corev1.ConditionTrue,
})
err = cl.SubResource("approval").Update(ctx, csr)
err = cl.SubResource("approval").Update(ctx, csr, &client.SubResourceUpdateOptions{})
Expect(err).NotTo(HaveOccurred())

By("Asserting the CSR is approved")
Expand All @@ -917,7 +917,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
Type: certificatesv1.CertificateApproved,
Status: corev1.ConditionTrue,
})
err = cl.SubResource("approval").Patch(ctx, csr, patch)
err = cl.SubResource("approval").Patch(ctx, csr, patch, &client.SubResourcePatchOptions{})
Expect(err).NotTo(HaveOccurred())

By("Asserting the CSR is approved")
Expand All @@ -936,10 +936,10 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
dep, err := clientset.AppsV1().Deployments(dep.Namespace).Create(ctx, dep, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())

By("Updating the scale subresurce")
By("Updating the scale subresource")
replicaCount := *dep.Spec.Replicas
scale := &autoscalingv1.Scale{Spec: autoscalingv1.ScaleSpec{Replicas: replicaCount}}
err = cl.SubResource("scale").Update(ctx, dep, client.WithSubResourceBody(scale))
err = cl.SubResource("scale").Update(ctx, dep, client.WithSubResourceBody(scale), &client.SubResourceUpdateOptions{})
Expect(err).NotTo(HaveOccurred())

By("Asserting replicas got updated")
Expand All @@ -961,7 +961,7 @@ U5wwSivyi7vmegHKmblOzNVKA5qPO8zWzqBC
replicaCount := *dep.Spec.Replicas
patch := client.MergeFrom(&autoscalingv1.Scale{})
scale := &autoscalingv1.Scale{Spec: autoscalingv1.ScaleSpec{Replicas: replicaCount}}
err = cl.SubResource("scale").Patch(ctx, dep, patch, client.WithSubResourceBody(scale))
err = cl.SubResource("scale").Patch(ctx, dep, patch, client.WithSubResourceBody(scale), &client.SubResourcePatchOptions{})
Expect(err).NotTo(HaveOccurred())

By("Asserting replicas got updated")
Expand Down