Documentation ¶
Index ¶
- Variables
- func CopyContents(pathHandle, contents any) error
- func PathModifierAppendIndex(path string, i int) string
- func PrepareHandle[S, H any](base afero.Fs, pathSet S, initialContents any) (H, error)
- func ValidateCopyContentsInput(pathHandle, dirContents any, allowNilField bool) error
- func ValidatePrepareInput(pathSet, pathHandle any) error
- func WriteSplitting(fsys afero.Fs, opt fsutil.SafeWriteOption, path string, perm fs.FileMode, ...) ([]string, error)
- type ReaderSplitter
- type SafeWriter
- type SplittedFileHash
- type SplittedFileMetadata
- type SplittingStorage
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidInput = errors.New("invalid input")
Functions ¶
func CopyContents ¶
CopyContents copies each field of contents to its corresponding field of pathHandle.
pathHandle and contents must be flat structs and must only contain exported afero.Fs, fs.FS fields respectively.
type pathHandle struct { RuntimeEnvFiles afero.Fs } type Contents struct { RuntimeEnvFiles fs.FS } composePath, err := composeloader.CopyContents( pathHandle, Contents{ RuntimeEnvFiles: fstest.MapFS{ "foo.env": &fstest.MapFile{ Data: []byte{}, Mode: 0o664, ModTime: time.Now(), }, "bar.env": &fstest.MapFile{ Data: []byte{}, Mode: 0o664, ModTime: time.Now(), }, }, }, )
func PathModifierAppendIndex ¶
PathModifierAppendIndex appends path with "_" + i. i will be padded with "0" to be 3 digits. If i > 999 or i < -99, number will be 4 digits or 3 digits with minus sign.
PathModifierAppendIndex removes filepath.Separator from tail if path is suffixed with it.
func PrepareHandle ¶
func ValidatePrepareInput ¶
Types ¶
type ReaderSplitter ¶
type ReaderSplitter interface { // Size returns limit size. // io.Reader returned from Next reads up to this size. // The last reader may reads less than Size. Size() int // Next returns size limited readers. // If ok is true, r is non nil and r reads up to given size. // Next and r.Read are not goroutine safe. // Calling Next before r is fully consumed causes an undefined behavior. Next() (r io.Reader, ok bool) }
ReadSplitter returns splitted readers sequentially.
func SplitReader ¶
func SplitReader(r io.Reader, size uint) ReaderSplitter
SplitReader returns ReaderSplitter splitting at size. It will panic if size is 0.
type SafeWriter ¶
type SafeWriter struct {
// contains filtered or unexported fields
}
func NewSafeWriter ¶
func NewSafeWriter(fsys afero.Fs, option fsutil.SafeWriteOption) *SafeWriter
func (*SafeWriter) CleanTmp ¶
func (s *SafeWriter) CleanTmp() error
func (*SafeWriter) Fsys ¶
func (s *SafeWriter) Fsys() afero.Fs
type SplittedFileHash ¶
type SplittedFileMetadata ¶
type SplittedFileMetadata struct { Total SplittedFileHash Splitted []SplittedFileHash }
type SplittingStorage ¶
type SplittingStorage struct {
// contains filtered or unexported fields
}
func NewSplittingStorage ¶
func NewSplittingStorage( fileFsys *SafeWriter, metadataFsys *SafeWriter, splitSize uint, pathModifier func(s string, i int) string, safeWriteOption fsutil.SafeWriteOption, ) *SplittingStorage
func (*SplittingStorage) Read ¶
func (s *SplittingStorage) Read(path string) (r io.ReadCloser, size int, err error)
Click to show internal directories.
Click to hide internal directories.