util

package
v1.0.0-alpha08 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package util contains utility functions used by various commands.

Index

Constants

View Source
const (
	LEVEL_0 = iota
	LEVEL_1
	LEVEL_2
	LEVEL_3
)

Variables

This section is empty.

Functions

func BinaryFileSystem

func BinaryFileSystem(root string) *binaryFileSystem

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func Download

func Download(url, target string) error

Download downloads resource given by url and writes it to target. target should not exist already, as it is created by the function.

func LoadTemplates

func LoadTemplates(path string, list ...string) (multitemplate.Render, error)

func Unzip

func Unzip(archive, target string) error

Unzip unzips the archive to target. Both archive and target should be paths in the filesystem. target is created if it doesn't exist already.

Types

type InstallManifestsRepo

type InstallManifestsRepo struct {
	// Namespace of the repo (e.g. hasura from github.com/hasura).
	Namespace string
	// Name of the repo (e.g. graphql-engine-install-manifests from
	// github.com/hasura/graphql-engine-install-manifests).
	Name string
}

InstallManifestsRepo is the GitHub repo where GraphQL Engine installation manifests are kept.

func (*InstallManifestsRepo) Download

func (i *InstallManifestsRepo) Download() (dir string, err error)

Download downloads the repo contents into a temporary directory and returns the directory path. It is the caller's responsibility to remove the directory after handling the contents.

func (*InstallManifestsRepo) ZipExtractedDirectory

func (i *InstallManifestsRepo) ZipExtractedDirectory() string

ZipExtractedDirectory returns the name of directory obtained after extracting the ZIP file downloaded from GitHub.

func (*InstallManifestsRepo) ZipURL

func (i *InstallManifestsRepo) ZipURL() string

ZipURL returns the URL to download the repo from GitHub in ZIP format.

type PrefixWriter

type PrefixWriter interface {
	// Write writes text with the specified indentation level.
	Write(level int, format string, a ...interface{})
	// WriteLine writes an entire line with no indentation level.
	WriteLine(a ...interface{})
	// Flush forces indendation to be reset.
	Flush()
}

PrefixWriter can write text at various indentation levels.

func NewPrefixWriter

func NewPrefixWriter(out io.Writer) PrefixWriter

NewPrefixWriter creates a new PrefixWriter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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