...

Source file src/k8s.io/cli-runtime/pkg/genericclioptions/io_options.go

Documentation: k8s.io/cli-runtime/pkg/genericclioptions

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package genericclioptions
    18  
    19  import (
    20  	"bytes"
    21  	"io"
    22  
    23  	"k8s.io/cli-runtime/pkg/genericiooptions"
    24  )
    25  
    26  // IOStreams provides the standard names for iostreams.  This is useful for embedding and for unit testing.
    27  // Inconsistent and different names make it hard to read and review code
    28  // DEPRECATED: use genericiooptions.IOStreams
    29  type IOStreams = genericiooptions.IOStreams
    30  
    31  // NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests
    32  // DEPRECATED: use genericiooptions.NewTestIOStreams
    33  func NewTestIOStreams() (genericiooptions.IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer) {
    34  	in := &bytes.Buffer{}
    35  	out := &bytes.Buffer{}
    36  	errOut := &bytes.Buffer{}
    37  
    38  	return IOStreams{
    39  		In:     in,
    40  		Out:    out,
    41  		ErrOut: errOut,
    42  	}, in, out, errOut
    43  }
    44  
    45  // NewTestIOStreamsDiscard returns a valid IOStreams that just discards
    46  // DEPRECATED: use genericiooptions.NewTestIOStreamsDiscard
    47  func NewTestIOStreamsDiscard() genericiooptions.IOStreams {
    48  	in := &bytes.Buffer{}
    49  	return IOStreams{
    50  		In:     in,
    51  		Out:    io.Discard,
    52  		ErrOut: io.Discard,
    53  	}
    54  }
    55  

View as plain text