Skip to content

Commit ca3c62d

Browse files
committed
Fixups
1 parent e2e2d4a commit ca3c62d

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

pkg/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ func (po *SubResourcePatchOptions) ApplyToSubResourcePatch(o *SubResourcePatchOp
545545
}
546546

547547
// SubResourceApplyOptions are the options for a subresource
548-
// apply rquest.
548+
// apply request.
549549
type SubResourceApplyOptions struct {
550550
ApplyOptions
551551
SubResourceBody runtime.ApplyConfiguration

pkg/client/fake/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,12 @@ func (sw *fakeSubResourceClient) Apply(ctx context.Context, obj runtime.ApplyCon
13571357
patchOpts.Raw = applyOpts.AsPatchOptions()
13581358

13591359
if applyOpts.SubResourceBody != nil {
1360+
subResourceBodySerialized, err := json.Marshal(applyOpts.SubResourceBody)
1361+
if err != nil {
1362+
return fmt.Errorf("failed to serialize subresource body: %w", err)
1363+
}
13601364
subResourceBody := &unstructured.Unstructured{}
1361-
if err := json.Unmarshal(data, subResourceBody); err != nil {
1365+
if err := json.Unmarshal(subResourceBodySerialized, subResourceBody); err != nil {
13621366
return fmt.Errorf("failed to unmarshal subresource body: %w", err)
13631367
}
13641368
patchOpts.SubResourceBody = subResourceBody

pkg/client/fieldvalidation_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,13 @@ func TestWithStrictFieldValidation(t *testing.T) {
119119
_ = wrappedClient.Status().Create(ctx, dummyObj, dummyObj)
120120
_ = wrappedClient.Status().Update(ctx, dummyObj)
121121
_ = wrappedClient.Status().Patch(ctx, dummyObj, nil)
122+
_ = wrappedClient.Status().Apply(ctx, corev1applyconfigurations.Namespace(""), nil)
122123
_ = wrappedClient.SubResource("some-subresource").Create(ctx, dummyObj, dummyObj)
123124
_ = wrappedClient.SubResource("some-subresource").Update(ctx, dummyObj)
124125
_ = wrappedClient.SubResource("some-subresource").Patch(ctx, dummyObj, nil)
126+
_ = wrappedClient.SubResource("some-subresource").Apply(ctx, corev1applyconfigurations.Namespace(""), nil)
125127

126-
if expectedCalls := 10; calls != expectedCalls {
128+
if expectedCalls := 12; calls != expectedCalls {
127129
t.Fatalf("wrong number of calls to assertions: expected=%d; got=%d", expectedCalls, calls)
128130
}
129131
}

pkg/client/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type SubResourcePatchOption interface {
9797
ApplyToSubResourcePatch(*SubResourcePatchOptions)
9898
}
9999

100-
// SubResourceApplyOption configures a subresoruce apply request.
100+
// SubResourceApplyOption configures a subresource apply request.
101101
type SubResourceApplyOption interface {
102102
// ApplyToSubResourceApply applies the configuration on the given patch options.
103103
ApplyToSubResourceApply(*SubResourceApplyOptions)

pkg/client/patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
var (
2929
// Apply uses server-side apply to patch the given object.
3030
//
31-
// Deprecated: Use client.Client.Apply() instead.
31+
// Deprecated: Use client.Client.Apply() and client.Client.SubResource("subrsource").Apply() instead.
3232
Apply Patch = applyPatch{}
3333

3434
// Merge uses the raw object as a merge patch, without modifications.

0 commit comments

Comments
 (0)