utils

package
v0.10.25 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const StuccoConfigEnv = "STUCCO_CONFIG"

StuccoConfigEnv is a name of environment variable that will be checked for stucco.json path if one is not provided

Variables

This section is empty.

Functions

func AddPathToZip

func AddPathToZip(path string, ignoreGlobs []string, w *zip.Writer) error

AddPathToZip appends contents of directory to zip, optionaly skipping files/directories matching gitignore like lines

func CopyToReader

func CopyToReader(r io.Reader) (br *bytes.Reader, err error)

CopyToReader returns new bytes.Reader with a copy of data read by r

func FieldName

func FieldName(parent, field string) string

FieldName returns resolver name for field

func IsLocal

func IsLocal(u *url.URL) bool

IsLocal returns true if url scheme is empty or equal file

func LoadConfigFile

func LoadConfigFile(fn string, v interface{}) (err error)

LoadConfigFile returns Config from file

func LocalOrRemoteReader

func LocalOrRemoteReader(u *url.URL) (rc io.ReadCloser, size int64, err error)

LocalOrRemoteReader creates a closable reader from url

func ReadConfigFile

func ReadConfigFile(fn string) (b []byte, err error)

ReadConfigFile loads stucco config from json or yaml file.

If extension is provided function loads config directly, otherwise it tries .json, .yaml and .yml extensions.

func ReadLocalOrRemoteFile

func ReadLocalOrRemoteFile(fn string) (b []byte, err error)

ReadLocalOrRemoteFile loads file from local storage or http depending on scheme in url

func ReaderAtToReader

func ReaderAtToReader(r io.ReaderAt, size int64) io.Reader

ReaderAtToReader returns a reader backed with ReaderAt

func SaveConfigFile

func SaveConfigFile(fn string, data interface{}) (err error)

SaveConfigFile saves config to file

func ZipAppend

func ZipAppend(filename string, files []ZipData) error

ZipAppend appends data to existing zip archive

func ZipAppendFromReader

func ZipAppendFromReader(r io.ReaderAt, size int64, files []ZipData) (io.Reader, error)

ZipAppendFromReader appends data to existing zip archive overwritting files that match name

func ZipFiles

func ZipFiles(filename string, files []ZipData) error

ZipFiles create new zip archive with files.

Types

type ZipData

type ZipData struct {
	Data     io.Reader
	Filename string
	Info     os.FileInfo
	Symlink  bool
}

ZipData Is a tuple with data and filename to be added to zip archive

func (*ZipData) AddFileToZip

func (z *ZipData) AddFileToZip(zipWriter *zip.Writer) error

AddFileToZip adds file represented by ZipData to zip archive

Jump to

Keyboard shortcuts

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