files

package
v0.51.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Overview

Package files provides primitives for enumerating and loading data from various file or file-like Source's and for writing output to filesystem files and directories.

This allows the rest of ytt code to process logically chunked streams of data without becoming entangled in the details of how to read or write data.

ytt processes files differently depending on their Type. For example, File instances that are TypeYAML are parsed as YAML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRootPath added in v0.24.0

func IsRootPath(path string) bool

func JoinPath

func JoinPath(pieces []string) string

func MakeRootPath added in v0.48.0

func MakeRootPath(path string) string

func ReadStdin added in v0.48.0

func ReadStdin() ([]byte, error)

ReadStdin only read stdin once

func SplitPath

func SplitPath(path string) ([]string, string)

func StripRootPath added in v0.24.0

func StripRootPath(path string) string

Types

type BytesSource

type BytesSource struct {
	// contains filtered or unexported fields
}

func NewBytesSource

func NewBytesSource(path string, data []byte) BytesSource

func (BytesSource) Bytes

func (s BytesSource) Bytes() ([]byte, error)

func (BytesSource) Description

func (s BytesSource) Description() string

func (BytesSource) RelativePath

func (s BytesSource) RelativePath() (string, error)

type CachedSource added in v0.17.0

type CachedSource struct {
	// contains filtered or unexported fields
}

func NewCachedSource added in v0.17.0

func NewCachedSource(src Source) *CachedSource

func (*CachedSource) Bytes added in v0.17.0

func (s *CachedSource) Bytes() ([]byte, error)

func (*CachedSource) Description added in v0.17.0

func (s *CachedSource) Description() string

func (*CachedSource) RelativePath added in v0.17.0

func (s *CachedSource) RelativePath() (string, error)

type File

type File struct {
	// contains filtered or unexported fields
}

func MustNewFileFromSource

func MustNewFileFromSource(fileSrc Source) *File

func NewFileFromSource

func NewFileFromSource(fileSrc Source) (*File, error)

func NewSortedFiles added in v0.13.0

func NewSortedFiles(files []*File) []*File

func NewSortedFilesFromPaths added in v0.13.0

func NewSortedFilesFromPaths(paths []string, opts SymlinkAllowOpts) ([]*File, error)

func (*File) Bytes

func (r *File) Bytes() ([]byte, error)

func (*File) Description

func (r *File) Description() string

func (*File) IsForOutput added in v0.4.0

func (r *File) IsForOutput() bool

func (*File) IsImplied added in v0.48.0

func (r *File) IsImplied() bool

IsImplied reports whether this file was implicitly included (found within an explicitly named directory) or not (named explicitly as input).

func (*File) IsLibrary

func (r *File) IsLibrary() bool

func (*File) IsTemplate

func (r *File) IsTemplate() bool

func (*File) MarkForOutput added in v0.4.0

func (r *File) MarkForOutput(forOutput bool)

func (*File) MarkRelativePath added in v0.4.0

func (r *File) MarkRelativePath(relPath string)

func (*File) MarkTemplate added in v0.4.0

func (r *File) MarkTemplate(template bool)

func (*File) MarkType added in v0.4.0

func (r *File) MarkType(t Type)

func (*File) OrderLess added in v0.13.0

func (r *File) OrderLess(otherFile *File) bool

func (*File) OriginalRelativePath added in v0.4.0

func (r *File) OriginalRelativePath() string

func (*File) RelativePath

func (r *File) RelativePath() string

func (*File) Type

func (r *File) Type() Type

type HTTPSource

type HTTPSource struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func NewHTTPSource

func NewHTTPSource(path string) HTTPSource

NewHTTPSource returns a new source of type HTTP

func (HTTPSource) Bytes

func (s HTTPSource) Bytes() ([]byte, error)

func (HTTPSource) Description

func (s HTTPSource) Description() string

func (HTTPSource) RelativePath

func (s HTTPSource) RelativePath() (string, error)

type LocalSource

type LocalSource struct {
	// contains filtered or unexported fields
}

func NewLocalSource

func NewLocalSource(path, dir string) LocalSource

func NewRegularFileLocalSource added in v0.2.0

func NewRegularFileLocalSource(path, dir string, fi os.FileInfo, opts SymlinkAllowOpts) (LocalSource, error)

func (LocalSource) Bytes

func (s LocalSource) Bytes() ([]byte, error)

Bytes returns bytes of the read file

func (LocalSource) Description

func (s LocalSource) Description() string

Description return LocalSource's (i.e. file's) path

func (LocalSource) RelativePath

func (s LocalSource) RelativePath() (string, error)

type OutputDirectory

type OutputDirectory struct {
	// contains filtered or unexported fields
}

func NewOutputDirectory

func NewOutputDirectory(path string, files []OutputFile, ui ui.UI) *OutputDirectory

func (*OutputDirectory) Files

func (d *OutputDirectory) Files() []OutputFile

func (*OutputDirectory) Write

func (d *OutputDirectory) Write() error

func (*OutputDirectory) WriteFiles added in v0.48.0

func (d *OutputDirectory) WriteFiles() error

type OutputFile

type OutputFile struct {
	// contains filtered or unexported fields
}

func NewOutputFile

func NewOutputFile(relativePath string, data []byte, markedType Type) OutputFile

func (OutputFile) Bytes

func (f OutputFile) Bytes() []byte

func (OutputFile) Create

func (f OutputFile) Create(dirPath string) error

func (OutputFile) Path

func (f OutputFile) Path(dirPath string) string

func (OutputFile) RelativePath

func (f OutputFile) RelativePath() string

func (OutputFile) Type added in v0.48.0

func (f OutputFile) Type() Type

type Source

type Source interface {
	Description() string
	RelativePath() (string, error)
	Bytes() ([]byte, error)
}

type StdinSource

type StdinSource struct {
	// contains filtered or unexported fields
}

func NewStdinSource

func NewStdinSource() StdinSource

func (StdinSource) Bytes

func (s StdinSource) Bytes() ([]byte, error)

func (StdinSource) Description

func (s StdinSource) Description() string

func (StdinSource) RelativePath

func (s StdinSource) RelativePath() (string, error)
type Symlink struct {
	// contains filtered or unexported fields
}

func (Symlink) IsAllowed added in v0.18.0

func (s Symlink) IsAllowed(opts SymlinkAllowOpts) error

type SymlinkAllowOpts added in v0.18.0

type SymlinkAllowOpts struct {
	AllowAll        bool
	AllowedDstPaths []string
}

type Type

type Type int
const (
	TypeUnknown Type = iota
	TypeYAML
	TypeText
	TypeStarlark
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL