builder

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

builder

Package builder provides a tar archive builder essentially for testing purposes.

Types

type ArchiveBuilder

type ArchiveBuilder struct { ... }

ArchiveBuilder is a tar archive builder.

func New

func New(w io.Writer) *ArchiveBuilder

New creates a new tar archive builder.

func (*ArchiveBuilder) Close

func (b *ArchiveBuilder) Close() error

Close closes the tar writer.

func (*ArchiveBuilder) With

func (b *ArchiveBuilder) With(bf ...Option) (*ArchiveBuilder, error)

With applies the given options to the builder.

type HeaderModifier

type HeaderModifier func(h *tar.Header) error

HeaderModifier is a function that modifies a tar header.

func WithAccessTime

func WithAccessTime(accessTime time.Time) HeaderModifier

WithAccessTime sets the access time of the header.

func WithChangeTime

func WithChangeTime(changeTime time.Time) HeaderModifier

WithChangeTime sets the change time of the header.

func WithGID

func WithGID(gid int) HeaderModifier

WithGID sets the GID of the header.

func WithLinkname

func WithLinkname(linkname string) HeaderModifier

WithLinkname sets the link name of the header.

func WithModTime

func WithModTime(modTime time.Time) HeaderModifier

WithModTime sets the modification time of the header.

func WithMode

func WithMode(mode int64) HeaderModifier

WithMode sets the mode of the header.

func WithName

func WithName(name string) HeaderModifier

WithName sets the name of the header.

func WithSize

func WithSize(size int64) HeaderModifier

WithSize sets the size of the header.

func WithTypeflag

func WithTypeflag(typeFlag byte) HeaderModifier

WithTypeflag sets the type flag of the header.

func WithUID

func WithUID(uid int) HeaderModifier

WithUID sets the UID of the header.

type Option

type Option func(tw *tar.Writer) error

Option is a function that configures the builder.

func Dir

func Dir(name string, hm ...HeaderModifier) Option

Dir adds a directory to the archive.

func FS

func FS(fsys fs.FS) Option

FS adds a file system to the archive.

func File

func File(name string, r io.Reader, hm ...HeaderModifier) Option

File adds a file to the archive.

func Hardlink(name, target string, hm ...HeaderModifier) Option

Hardlink adds a hard link to the archive.

func Symlink(name, target string, hm ...HeaderModifier) Option

Symlink adds a symbolic link to the archive.

Documentation

Overview

Package builder provides a tar archive builder essentially for testing purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveBuilder

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

ArchiveBuilder is a tar archive builder.

func New

func New(w io.Writer) *ArchiveBuilder

New creates a new tar archive builder.

func (*ArchiveBuilder) Close

func (b *ArchiveBuilder) Close() error

Close closes the tar writer.

func (*ArchiveBuilder) With

func (b *ArchiveBuilder) With(bf ...Option) (*ArchiveBuilder, error)

With applies the given options to the builder.

type HeaderModifier

type HeaderModifier func(h *tar.Header) error

HeaderModifier is a function that modifies a tar header.

func WithAccessTime

func WithAccessTime(accessTime time.Time) HeaderModifier

WithAccessTime sets the access time of the header.

func WithChangeTime

func WithChangeTime(changeTime time.Time) HeaderModifier

WithChangeTime sets the change time of the header.

func WithGID

func WithGID(gid int) HeaderModifier

WithGID sets the GID of the header.

func WithLinkname

func WithLinkname(linkname string) HeaderModifier

WithLinkname sets the link name of the header.

func WithModTime

func WithModTime(modTime time.Time) HeaderModifier

WithModTime sets the modification time of the header.

func WithMode

func WithMode(mode int64) HeaderModifier

WithMode sets the mode of the header.

func WithName

func WithName(name string) HeaderModifier

WithName sets the name of the header.

func WithSize

func WithSize(size int64) HeaderModifier

WithSize sets the size of the header.

func WithTypeflag

func WithTypeflag(typeFlag byte) HeaderModifier

WithTypeflag sets the type flag of the header.

func WithUID

func WithUID(uid int) HeaderModifier

WithUID sets the UID of the header.

type Option

type Option func(tw *tar.Writer) error

Option is a function that configures the builder.

func Dir

func Dir(name string, hm ...HeaderModifier) Option

Dir adds a directory to the archive.

func FS

func FS(fsys fs.FS) Option

FS adds a file system to the archive.

func File

func File(name string, r io.Reader, hm ...HeaderModifier) Option

File adds a file to the archive.

func Hardlink(name, target string, hm ...HeaderModifier) Option

Hardlink adds a hard link to the archive.

func Symlink(name, target string, hm ...HeaderModifier) Option

Symlink adds a symbolic link to the archive.

Jump to

Keyboard shortcuts

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