Merge pull request #62244 from CaoShuFeng/raw

Automatic merge from submit-queue (batch tested with PRs 62244, 63685). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix "kubectl create --raw"

Before this change:
```
$ kubectl create -f  pod.json --raw=https://172.16.29.130:443/api/v1/namespaces/default/pods  --as=tom --as-group=aaaaa
Error from server (Forbidden): unknown
```

After this change:
```
$ kubectl create -f pod.json --raw=https://172.16.29.130:443/api/v1/namespaces/default/pods  --as=tom --as-group=aaaaa
Error from server (Forbidden): pods is forbidden: User "tom" cannot create pods in the namespace "default"
```

/assign @soltysh 
**Release note**:

```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-05-10 16:30:07 -07:00 committed by GitHub
commit 6203b621ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -284,12 +284,16 @@ func (o *CreateOptions) raw(f cmdutil.Factory) error {
}
}
// TODO post content with stream. Right now it ignores body content
bytes, err := restClient.Post().RequestURI(o.Raw).Body(data).DoRaw()
result := restClient.Post().RequestURI(o.Raw).Body(data).Do()
if err := result.Error(); err != nil {
return err
}
body, err := result.Raw()
if err != nil {
return err
}
fmt.Fprintf(o.Out, "%v", string(bytes))
fmt.Fprintf(o.Out, "%v", string(body))
return nil
}