util

package
v0.0.0-...-db657e9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLicensePrefixFilters for LoadLicenseFiles, NOTICE and LICENSE
	DefaultLicensePrefixFilters = []string{"LICENSE", "NOTICE"}
)

Functions

func CopyFileToTarStream

func CopyFileToTarStream(stream *tar.Writer, path string, header *tar.Header) error

CopyFileToTarStream writes a file to a tar stream

func JSONMarshal

func JSONMarshal(input interface{}) ([]byte, error)

JSONMarshal marshals an arbitrary map to JSON; this only exists because JSON.Marshal insists on having maps that have string (and not interface{}) keys

func LoadLicenseFiles

func LoadLicenseFiles(filename string, targz io.Reader, prefixFilters ...string) (map[string][]byte, error)

LoadLicenseFiles iterates through a tar.gz file looking for anything that matches prefixFilters. Filename is for error generation only.

func SanitizeDockerName

func SanitizeDockerName(name string) string

SanitizeDockerName makes a string conform with the rules for Docker names

func TargzIterate

func TargzIterate(filename string, targz io.Reader, fn func(*tar.Reader, *tar.Header) error) error

TargzIterate iterates over the files it finds in a tar.gz file and calls a callback for each file encountered. Filename is only used for error generation.

func TempDir

func TempDir(dir, prefix string) (name string, err error)

TempDir overrides the default TempDir, since Docker needs this to be in your user folder.

func ValidatePath

func ValidatePath(path string, shouldBeDir bool, pathDescription string) error

ValidatePath validates that a path (file or dir) exists

func WriteToTarStream

func WriteToTarStream(stream *tar.Writer, data []byte, header tar.Header) error

WriteToTarStream writes a byte array of data into a tar stream

Types

This section is empty.

Jump to

Keyboard shortcuts

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