kubernetesk8s.io/kubernetes/pkg/util/io Index | Files

package io

import "k8s.io/kubernetes/pkg/util/io"

Index

Functions

func ConsistentRead

func ConsistentRead(filename string, attempts int) ([]byte, error)

ConsistentRead repeatedly reads a file until it gets the same content twice. This is useful when reading files in /proc that are larger than page size and kernel may modify them between individual read() syscalls.

Types

type NsenterWriter

type NsenterWriter struct{}

NsenterWriter is implementation of Writer interface that allows writing data to file using nsenter command. If a program (e.g. kubelet) runs in a container it may want to write data to a mounted device. Since in Docker, mount propagation mode is set to private, it will not see the mounted device in its own namespace. To work around this limitation one has to first enter hosts namespace (by using 'nsenter') and only then write data.

func (*NsenterWriter) WriteFile

func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile calls 'nsenter cat - > <the file>' and 'nsenter chmod' to create a file on the host.

type StdWriter

type StdWriter struct {
}

StdWriter implements Writer interface and uses standard libraries for writing data to files.

func (*StdWriter) WriteFile

func (writer *StdWriter) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile directly calls ioutil.WriteFile.

type Writer

type Writer interface {
	// WriteFile mimics ioutil.WriteFile.
	WriteFile(filename string, data []byte, perm os.FileMode) error
}

Writer is an interface which allows to write data to a file.

Source Files

consistentread.go writer.go

Version
v1.9.8-beta.0
Published
Apr 18, 2018
Platform
js/wasm
Imports
6 packages
Last checked
9 minutes ago

Tools for package owners.