Skip to content

Commit

Permalink
Merge pull request #2766 from DataDog/fricounet/fix-subresourcecreate…
Browse files Browse the repository at this point in the history
…options

 🐛 Fix SubResourceCreateOptions signature in subresource client
  • Loading branch information
k8s-ci-robot committed Apr 9, 2024
2 parents 290ce58 + 55c4331 commit 20f3f4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 20f3f4b

Please sign in to comment.