archive

package
v3.115.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ArchiveSig            = sig.ArchiveSig
	ArchiveHashProperty   = "hash"   // the dynamic property for an archive's hash.
	ArchiveAssetsProperty = "assets" // the dynamic property for an archive's assets.
	ArchivePathProperty   = "path"   // the dynamic property for an archive's path.
	ArchiveURIProperty    = "uri"    // the dynamic property for an archive's URI.
)
View Source
const (
	NotArchive     = iota // not an archive.
	TarArchive            // a POSIX tar archive.
	TarGZIPArchive        // a POSIX tar archive that has been subsequently compressed using GZip.
	ZIPArchive            // a multi-file ZIP archive.
	JARArchive            // a Java JAR file
)
View Source
const (
	// BookkeepingDir is the name of our bookkeeping folder, we store state here (like .git for git).
	// Copied from workspace.BookkeepingDir to break import cycle.
	BookkeepingDir = ".pulumi"
)

Variables

View Source
var ArchiveExts = map[string]Format{
	".tar":    TarArchive,
	".tgz":    TarGZIPArchive,
	".tar.gz": TarGZIPArchive,
	".zip":    ZIPArchive,
	".jar":    JARArchive,
}

ArchiveExts maps from a file extension and its associated archive and/or compression format.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	// Sig is the unique archive type signature (see properties.go).
	Sig string `json:"4dabf18193072939515e22adb298388d" yaml:"4dabf18193072939515e22adb298388d"`
	// Hash contains the SHA256 hash of the archive's contents.
	Hash string `json:"hash,omitempty" yaml:"hash,omitempty"`
	// Assets, when non-nil, is a collection of other assets/archives.
	Assets map[string]interface{} `json:"assets,omitempty" yaml:"assets,omitempty"`
	// Path is a non-empty string representing a path to a file on the current filesystem, for file archives.
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// URI is a non-empty URI (file://, http://, https://, etc), for URI-backed archives.
	URI string `json:"uri,omitempty" yaml:"uri,omitempty"`
}

Archive is a serialized archive reference. It is a union: thus, only one of its fields will be non-nil. Several helper routines exist as members in order to easily interact with archives of different kinds.

func Deserialize

func Deserialize(obj map[string]interface{}) (*Archive, bool, error)

DeserializeArchive checks to see if the map contains an archive, using its signature, and if so deserializes it.

func FromAssets

func FromAssets(assets map[string]interface{}) (*Archive, error)

func FromPath

func FromPath(path string) (*Archive, error)

func FromPathWithWD added in v3.115.0

func FromPathWithWD(path string, wd string) (*Archive, error)

func FromURI

func FromURI(uri string) (*Archive, error)

func (*Archive) Archive

func (a *Archive) Archive(format Format, w io.Writer) error

Archive produces a single archive stream in the desired format. It prefers to return the archive with as little copying as is feasible, however if the desired format is different from the source, it will need to translate.

func (*Archive) Bytes

func (a *Archive) Bytes(format Format) ([]byte, error)

Bytes fetches the archive contents as a byte slices. This is almost certainly the least efficient way to deal with the underlying streaming capabilities offered by assets and archives, but can be used in a pinch to interact with APIs that demand []bytes.

func (*Archive) EnsureHash

func (a *Archive) EnsureHash() error

EnsureHash computes the SHA256 hash of the archive's contents and stores it on the object.

func (*Archive) EnsureHashWithWD added in v3.115.0

func (a *Archive) EnsureHashWithWD(wd string) error

EnsureHash computes the SHA256 hash of the archive's contents and stores it on the object.

func (*Archive) Equals

func (a *Archive) Equals(other *Archive) bool

Equals returns true if a is value-equal to other. In this case, value equality is determined only by the hash: even if the contents of two archives come from different sources, they are treated as equal if their hashes match. Similarly, if the contents of two archives come from the same source but the archives have different hashes, the archives are not equal.

func (*Archive) GetAssets

func (a *Archive) GetAssets() (map[string]interface{}, bool)

func (*Archive) GetPath

func (a *Archive) GetPath() (string, bool)

func (*Archive) GetURI

func (a *Archive) GetURI() (string, bool)

func (*Archive) GetURIURL

func (a *Archive) GetURIURL() (*url.URL, bool, error)

GetURIURL returns the underlying URI as a parsed URL, provided it is one. If there was an error parsing the URI, it will be returned as a non-nil error object.

func (*Archive) HasContents

func (a *Archive) HasContents() bool

HasContents indicates whether or not an archive's contents can be read.

func (*Archive) IsAssets

func (a *Archive) IsAssets() bool

func (*Archive) IsPath

func (a *Archive) IsPath() bool

func (*Archive) IsURI

func (a *Archive) IsURI() bool

func (*Archive) Open

func (a *Archive) Open() (Reader, error)

Open returns an ArchiveReader that can be used to iterate over the named blobs that comprise the archive.

func (*Archive) ReadSourceArchive

func (a *Archive) ReadSourceArchive() (Format, io.ReadCloser, error)

ReadSourceArchive returns a stream to the underlying archive, if there is one.

func (*Archive) ReadSourceArchiveWithWD added in v3.115.0

func (a *Archive) ReadSourceArchiveWithWD(wd string) (Format, io.ReadCloser, error)

ReadSourceArchiveWithWD returns a stream to the underlying archive, if there is one.

func (*Archive) Serialize

func (a *Archive) Serialize() map[string]interface{}

Serialize returns a weakly typed map that contains the right signature for serialization purposes.

type Format

type Format int

Format indicates what archive and/or compression format an archive uses.

type Reader

type Reader interface {
	// Next returns the name and contents of the next member of the archive. If there are no more members in the
	// archive, this function returns ("", nil, io.EOF). The blob returned by a call to Next() must be read in full
	// before the next call to Next().
	Next() (string, *asset.Blob, error)

	// Close terminates the stream.
	Close() error
}

Reader presents the contents of an archive as a stream of named blobs.

Jump to

Keyboard shortcuts

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