utils

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MediaTypeTextPlain         = MediaType("text/plain; charset=utf-8")
	MediaTypeOctetStream       = MediaType("application/octet-stream")
	MediaTypeHTML              = MediaType("text/html")
	MediaTypeJSON              = MediaType("application/json")
	MediaTypeMultipartFormData = MediaType("multipart/form-data")
	MediaTypeFormURLEncoded    = MediaType("application/x-www-form-urlencoded")
	MediaTypeZip               = MediaType("application/zip")
)

The set of known MediaTypes

View Source
const (
	// FunctionsRoot is the root directory for functions and dependencies
	FunctionsRoot = "functions"
)

Variables

View Source
var (
	// HostingRoot is the root directory for hosting assets and attributes
	HostingRoot = "hosting"
	// HostingFilesDirectory is the directory to place the static hosting assets
	HostingFilesDirectory = fmt.Sprintf("%s/files", HostingRoot)
	// HostingAttributes is the file that stores the static hosting asset descriptions struct
	HostingAttributes = fmt.Sprintf("%s/metadata.json", HostingRoot)
	// HostingCacheFileName is the file that stores the cached hosting asset data
	HostingCacheFileName = ".asset-cache.json"
)
View Source
var (
	// CLIVersion represents the current version of the CLI. This version is dynamically replaced at build-time
	CLIVersion = "1.0.0"

	// CLIOSArch represents the OS Architecture of the CLI. It is used to select the appropriate URL for the CLI
	// binary based on the user's OS
	CLIOSArch string
)

Functions

func CheckForNewCLIVersion

func CheckForNewCLIVersion(client HTTPClient) string

CheckForNewCLIVersion looks for and returns a url for a new version of the CLI, if one exists. Any errors are swallowed.

func GenerateFileHashStr added in v1.2.0

func GenerateFileHashStr(fName string) (string, error)

GenerateFileHashStr takes a file name and opens and generates a string of the hash.Hash for that file

func GetContentTypeByExtension added in v1.2.0

func GetContentTypeByExtension(ext string) (string, bool)

GetContentTypeByExtension takes an extension (String) and outputs the default content type used to represent it

func GetDirectoryContainingFile

func GetDirectoryContainingFile(wd, filename string) (string, error)

GetDirectoryContainingFile searches upwards for a valid Stitch app directory

func IsDefaultContentType added in v1.2.0

func IsDefaultContentType(cType string) bool

IsDefaultContentType that takes a content / MIME type and outputs if it is one of the default content-types in fileName

func RandomAlphaNumericSpecialString

func RandomAlphaNumericSpecialString(length int) string

RandomAlphaNumericSpecialString generates a new random alphanumeric key with special characters

func RandomAlphaNumericSpecialStringStrict

func RandomAlphaNumericSpecialStringStrict(length int) string

RandomAlphaNumericSpecialStringStrict generates a new random alphanumeric key with special characters

func RandomAlphaNumericString

func RandomAlphaNumericString(length int) string

RandomAlphaNumericString generates a new random alphanumeric key

func RandomAlphaString

func RandomAlphaString(length int) string

RandomAlphaString generates a new random alphabetic string of given length

func ResolveAppDirectory added in v1.5.0

func ResolveAppDirectory(appPath, workingDirectory string) (string, error)

ResolveAppDirectory returns the directory path for an app

func ResolveAppInstanceData added in v1.5.0

func ResolveAppInstanceData(appID, path string) (models.AppInstanceData, error)

ResolveAppInstanceData loads data for an app from a stitch.json file located in the provided directory path, merging in any overridden parameters from command line flags

func UnmarshalFromDir

func UnmarshalFromDir(path string) (map[string]interface{}, error)

UnmarshalFromDir unmarshals a Stitch app from the given directory into a map[string]interface{}

func WriteFileToDir added in v1.2.0

func WriteFileToDir(dest string, data io.Reader) error

WriteFileToDir writes the data to dest and creates the necessary directories along the path

func WriteZipToDir

func WriteZipToDir(dest string, zipData io.Reader, overwrite bool) error

WriteZipToDir takes a destination and an io.Reader containing zip data and unpacks it

Types

type HTTPClient

type HTTPClient interface {
	Get(url string) (*http.Response, error)
}

HTTPClient represents the minimum HTTP client required to check for version information

type MediaType

type MediaType string

MediaType defines the type of HTTP media in a request/response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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