mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Add a dummy implementation of proxyutil.LineBuffer
Rather than actually assembling all of the rules we aren't going to use, just count them and throw them away.
This commit is contained in:
		@@ -17,7 +17,6 @@ limitations under the License.
 | 
			
		||||
package util
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
@@ -321,67 +320,6 @@ func GetClusterIPByFamily(ipFamily v1.IPFamily, service *v1.Service) string {
 | 
			
		||||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type LineBuffer struct {
 | 
			
		||||
	b     bytes.Buffer
 | 
			
		||||
	lines int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Write takes a list of arguments, each a string or []string, joins all the
 | 
			
		||||
// individual strings with spaces, terminates with newline, and writes to buf.
 | 
			
		||||
// Any other argument type will panic.
 | 
			
		||||
func (buf *LineBuffer) Write(args ...interface{}) {
 | 
			
		||||
	for i, arg := range args {
 | 
			
		||||
		if i > 0 {
 | 
			
		||||
			buf.b.WriteByte(' ')
 | 
			
		||||
		}
 | 
			
		||||
		switch x := arg.(type) {
 | 
			
		||||
		case string:
 | 
			
		||||
			buf.b.WriteString(x)
 | 
			
		||||
		case []string:
 | 
			
		||||
			for j, s := range x {
 | 
			
		||||
				if j > 0 {
 | 
			
		||||
					buf.b.WriteByte(' ')
 | 
			
		||||
				}
 | 
			
		||||
				buf.b.WriteString(s)
 | 
			
		||||
			}
 | 
			
		||||
		default:
 | 
			
		||||
			panic(fmt.Sprintf("unknown argument type: %T", x))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	buf.b.WriteByte('\n')
 | 
			
		||||
	buf.lines++
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// WriteBytes writes bytes to buffer, and terminates with newline.
 | 
			
		||||
func (buf *LineBuffer) WriteBytes(bytes []byte) {
 | 
			
		||||
	buf.b.Write(bytes)
 | 
			
		||||
	buf.b.WriteByte('\n')
 | 
			
		||||
	buf.lines++
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Reset clears buf
 | 
			
		||||
func (buf *LineBuffer) Reset() {
 | 
			
		||||
	buf.b.Reset()
 | 
			
		||||
	buf.lines = 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bytes returns the contents of buf as a []byte
 | 
			
		||||
func (buf *LineBuffer) Bytes() []byte {
 | 
			
		||||
	return buf.b.Bytes()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String returns the contents of buf as a string
 | 
			
		||||
func (buf *LineBuffer) String() string {
 | 
			
		||||
	return buf.b.String()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Lines returns the number of lines in buf. Note that more precisely, this returns the
 | 
			
		||||
// number of times Write() or WriteBytes() was called; it assumes that you never wrote
 | 
			
		||||
// any newlines to the buffer yourself.
 | 
			
		||||
func (buf *LineBuffer) Lines() int {
 | 
			
		||||
	return buf.lines
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RevertPorts is closing ports in replacementPortsMap but not in originalPortsMap. In other words, it only
 | 
			
		||||
// closes the ports opened in this sync.
 | 
			
		||||
func RevertPorts(replacementPortsMap, originalPortsMap map[netutils.LocalPort]netutils.Closeable) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user