Documentation
¶
Index ¶
- Constants
- func RenameWithFallback(src, dst string) error
- type ArchiveFileFilter
- type Storage
- func (s *Storage) Archive(artifact *sourcev1.Artifact, dir string, filter ArchiveFileFilter) (err error)
- func (s *Storage) ArtifactExist(artifact sourcev1.Artifact) bool
- func (s *Storage) AtomicWriteFile(artifact *sourcev1.Artifact, reader io.Reader, mode os.FileMode) (err error)
- func (s *Storage) Checksum(reader io.Reader) string
- func (s *Storage) Copy(artifact *sourcev1.Artifact, reader io.Reader) (err error)
- func (s *Storage) CopyFromPath(artifact *sourcev1.Artifact, path string) (err error)
- func (s *Storage) CopyToPath(artifact *sourcev1.Artifact, subPath, toPath string) error
- func (s *Storage) GarbageCollect(ctx context.Context, artifact sourcev1.Artifact, timeout time.Duration) ([]string, error)
- func (s *Storage) LocalPath(artifact sourcev1.Artifact) string
- func (s *Storage) Lock(artifact sourcev1.Artifact) (unlock func(), err error)
- func (s *Storage) MkdirAll(artifact sourcev1.Artifact) error
- func (s *Storage) NewArtifactFor(kind string, metadata metav1.Object, revision, fileName string) sourcev1.Artifact
- func (s *Storage) RemoveAll(artifact sourcev1.Artifact) (string, error)
- func (s *Storage) RemoveAllButCurrent(artifact sourcev1.Artifact) ([]string, error)
- func (s Storage) SetArtifactURL(artifact *sourcev1.Artifact)
- func (s Storage) SetHostname(URL string) string
- func (s *Storage) Symlink(artifact sourcev1.Artifact, linkName string) (string, error)
Constants ¶
const GarbageCountLimit = 1000
Variables ¶
This section is empty.
Functions ¶
func RenameWithFallback ¶
RenameWithFallback This is compatible dummy for github.com/fluxcd/source-controller/internal/fs:RenameWithFallback
Types ¶
type ArchiveFileFilter ¶
ArchiveFileFilter must return true if a file should not be included in the archive after inspecting the given path and/or os.FileInfo.
func SourceIgnoreFilter ¶
func SourceIgnoreFilter(ps []gitignore.Pattern, domain []string) ArchiveFileFilter
SourceIgnoreFilter returns an ArchiveFileFilter that filters out files matching sourceignore.VCSPatterns and any of the provided patterns. If an empty gitignore.Pattern slice is given, the matcher is set to sourceignore.NewDefaultMatcher.
type Storage ¶
type Storage struct {
// BasePath is the local directory path where the source artifacts are stored.
BasePath string `json:"basePath"`
// Hostname is the file server host name used to compose the artifacts URIs.
Hostname string `json:"hostname"`
// ArtifactRetentionTTL is the maximum number of artifacts to be kept in storage
// after a garbage collection.
ArtifactRetentionTTL time.Duration `json:"artifactRetentionTTL"`
// ArtifactRetentionRecords is the duration of time that artifacts will be kept in
// storage before being garbage collected.
ArtifactRetentionRecords int `json:"artifactRetentionRecords"`
}
Storage manages artifacts
func NewStorage ¶
func NewStorage(basePath string, hostname string, artifactRetentionTTL time.Duration, artifactRetentionRecords int) (*Storage, error)
NewStorage creates the storage helper for a given path and hostname.
func (*Storage) Archive ¶
func (s *Storage) Archive(artifact *sourcev1.Artifact, dir string, filter ArchiveFileFilter) (err error)
Archive atomically archives the given directory as a tarball to the given v1beta1.Artifact path, excluding directories and any ArchiveFileFilter matches. While archiving, any environment specific data (for example, the user and group name) is stripped from file headers. If successful, it sets the checksum and last update time on the artifact.
func (*Storage) ArtifactExist ¶
ArtifactExist returns a boolean indicating whether the v1beta1.Artifact exists in storage and is a regular file.
func (*Storage) AtomicWriteFile ¶
func (s *Storage) AtomicWriteFile(artifact *sourcev1.Artifact, reader io.Reader, mode os.FileMode) (err error)
AtomicWriteFile atomically writes the io.Reader contents to the v1beta1.Artifact path. If successful, it sets the checksum and last update time on the artifact.
func (*Storage) Checksum ¶
Checksum returns the SHA256 checksum for the data of the given io.Reader as a string.
func (*Storage) Copy ¶
Copy atomically copies the io.Reader contents to the v1beta1.Artifact path. If successful, it sets the checksum and last update time on the artifact.
func (*Storage) CopyFromPath ¶
CopyFromPath atomically copies the contents of the given path to the path of the v1beta1.Artifact. If successful, the checksum and last update time on the artifact is set.
func (*Storage) CopyToPath ¶
CopyToPath copies the contents in the (sub)path of the given artifact to the given path.
func (*Storage) GarbageCollect ¶
func (s *Storage) GarbageCollect(ctx context.Context, artifact sourcev1.Artifact, timeout time.Duration) ([]string, error)
GarbageCollect removes all garabge files in the artifact dir according to the provided retention options.
func (*Storage) LocalPath ¶
LocalPath returns the secure local path of the given artifact (that is: relative to the Storage.BasePath).
func (*Storage) NewArtifactFor ¶
func (s *Storage) NewArtifactFor(kind string, metadata metav1.Object, revision, fileName string) sourcev1.Artifact
NewArtifactFor returns a new v1beta1.Artifact.
func (*Storage) RemoveAllButCurrent ¶
RemoveAllButCurrent removes all files for the given v1beta1.Artifact base dir, excluding the current one.
func (Storage) SetArtifactURL ¶
SetArtifactURL sets the URL on the given v1beta1.Artifact.
func (Storage) SetHostname ¶
SetHostname sets the hostname of the given URL string to the current Storage.Hostname and returns the result.