mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #118443 from TommyStarK/kubectl-clean-code-bytes-buffer
kubectl: use bytes.Buffer.String
This commit is contained in:
commit
34abd36e88
@ -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) {
|
||||
|
@ -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())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user