Merge pull request #118443 from TommyStarK/kubectl-clean-code-bytes-buffer

kubectl: use bytes.Buffer.String
This commit is contained in:
Kubernetes Prow Robot 2023-06-05 07:31:38 -07:00 committed by GitHub
commit 34abd36e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 9 deletions

View File

@ -163,7 +163,7 @@ func TestCreateClusterRole(t *testing.T) {
cmd.Run(cmd, []string{clusterRoleName})
actual := &rbac.ClusterRole{}
if err := runtime.DecodeInto(scheme.Codecs.UniversalDecoder(), buf.Bytes(), actual); err != nil {
t.Log(string(buf.Bytes()))
t.Log(buf.String())
t.Fatal(err)
}
if !equality.Semantic.DeepEqual(test.expectedClusterRole, actual) {

View File

@ -365,7 +365,7 @@ func TestLabelErrors(t *testing.T) {
return
}
if buf.Len() > 0 {
t.Errorf("buffer should be empty: %s", string(buf.Bytes()))
t.Errorf("buffer should be empty: %s", buf.String())
}
})
}

View File

@ -72,7 +72,7 @@ func TestSetEnvLocal(t *testing.T) {
err = opts.RunEnv()
assert.NoError(t, err)
if bufErr.Len() > 0 {
t.Errorf("unexpected error: %s", string(bufErr.String()))
t.Errorf("unexpected error: %s", bufErr.String())
}
if !strings.Contains(buf.String(), "replicationcontroller/cassandra") {
t.Errorf("did not set env: %s", buf.String())
@ -109,7 +109,7 @@ func TestSetEnvLocalNamespace(t *testing.T) {
err = opts.RunEnv()
assert.NoError(t, err)
if bufErr.Len() > 0 {
t.Errorf("unexpected error: %s", string(bufErr.String()))
t.Errorf("unexpected error: %s", bufErr.String())
}
if !strings.Contains(buf.String(), "namespace: existing-ns") {
t.Errorf("did not set env: %s", buf.String())
@ -146,7 +146,7 @@ func TestSetMultiResourcesEnvLocal(t *testing.T) {
err = opts.RunEnv()
assert.NoError(t, err)
if bufErr.Len() > 0 {
t.Errorf("unexpected error: %s", string(bufErr.String()))
t.Errorf("unexpected error: %s", bufErr.String())
}
expectedOut := "replicationcontroller/first-rc\nreplicationcontroller/second-rc\n"
if buf.String() != expectedOut {

View File

@ -5205,8 +5205,7 @@ func tabbedString(f func(io.Writer) error) (string, error) {
}
out.Flush()
str := string(buf.String())
return str, nil
return buf.String(), nil
}
type SortableResourceNames []corev1.ResourceName

View File

@ -464,8 +464,7 @@ func tabbedString(f func(io.Writer) error) (string, error) {
}
out.Flush()
str := string(buf.String())
return str, nil
return buf.String(), nil
}
// getChangeCause returns the change-cause annotation of the input object