set the content-type Header when the dynamic client sends the request

Kubernetes-commit: 2ad09c6a87b9150598c6119d653acc983c5c7a11
This commit is contained in:
scott
2021-08-12 20:17:07 +08:00
committed by Kubernetes Publisher
parent 7697067af7
commit 61ae14a896
2 changed files with 25 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ func (c *dynamicResourceClient) Create(ctx context.Context, obj *unstructured.Un
result := c.client.client.
Post().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
SetHeader("Content-Type", runtime.ContentTypeJSON).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do(ctx)
@@ -145,6 +146,7 @@ func (c *dynamicResourceClient) Update(ctx context.Context, obj *unstructured.Un
result := c.client.client.
Put().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
SetHeader("Content-Type", runtime.ContentTypeJSON).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do(ctx)
@@ -181,6 +183,7 @@ func (c *dynamicResourceClient) UpdateStatus(ctx context.Context, obj *unstructu
result := c.client.client.
Put().
AbsPath(append(c.makeURLSegments(name), "status")...).
SetHeader("Content-Type", runtime.ContentTypeJSON).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do(ctx)
@@ -211,6 +214,7 @@ func (c *dynamicResourceClient) Delete(ctx context.Context, name string, opts me
result := c.client.client.
Delete().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
SetHeader("Content-Type", runtime.ContentTypeJSON).
Body(deleteOptionsByte).
Do(ctx)
return result.Error()
@@ -225,6 +229,7 @@ func (c *dynamicResourceClient) DeleteCollection(ctx context.Context, opts metav
result := c.client.client.
Delete().
AbsPath(c.makeURLSegments("")...).
SetHeader("Content-Type", runtime.ContentTypeJSON).
Body(deleteOptionsByte).
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
Do(ctx)