compute

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package compute contains commands to manage Compute@Edge packages.

Index

Constants

View Source
const IgnoreFilePath = ".fastlyignore"

IgnoreFilePath is the filepath name of the Fastly ignore file.

Variables

View Source
var InstallDir = func() string {
	if dir, err := os.UserConfigDir(); err == nil {
		return filepath.Join(dir, "fastly")
	}
	if dir, err := os.UserHomeDir(); err == nil {
		return filepath.Join(dir, ".fastly")
	}
	panic("unable to deduce user config dir or user home dir")
}()

InstallDir represents the directory where the Viceroy binary should be installed.

NOTE: This is a package level variable as it makes testing the behaviour of the package easier because the test code can replace the value when running the test suite.

Functions

func CreatePackageArchive added in v0.33.0

func CreatePackageArchive(files []string, destination string) error

CreatePackageArchive packages build artifacts as a Fastly package, which must be a GZipped Tar archive such as: package-name.tar.gz.

Due to a behavior of archiver.Archive() which recursively writes all files in a provided directory to the archive we first copy our input files to a temporary directory to ensure only the specified files are included and not any in the directory which may be ignored.

func FileNameWithoutExtension added in v0.33.0

func FileNameWithoutExtension(filename string) string

FileNameWithoutExtension returns a filename with its extension stripped.

func GetCrateVersionFromMetadata added in v0.33.0

func GetCrateVersionFromMetadata(metadata CargoMetadata, crate string) (*semver.Version, error)

GetCrateVersionFromMetadata searches for a crate inside a CargoMetadata tree and returns the crates version as a semver.Version.

func GetIgnoredFiles added in v0.33.0

func GetIgnoredFiles(filePath string) (files map[string]bool, err error)

GetIgnoredFiles reads the .fastlyignore file line-by-line and expands the glob pattern into a map containing all files it matches. If no ignore file is present it returns an empty map.

func GetLatestCrateVersion added in v0.8.0

func GetLatestCrateVersion(client api.HTTPClient, name string) (*semver.Version, error)

GetLatestCrateVersion fetches all versions of a given Rust crate from the crates.io HTTP API and returns the latest valid semver version.

func GetNonIgnoredFiles added in v0.33.0

func GetNonIgnoredFiles(base string, ignoredFiles map[string]bool) ([]string, error)

GetNonIgnoredFiles walks a filepath and returns all files don't exist in the provided ignore files map.

Types

type AssemblyScript added in v0.18.0

type AssemblyScript struct {
	// contains filtered or unexported fields
}

AssemblyScript implements a Toolchain for the AssemblyScript language.

func NewAssemblyScript added in v0.18.0

func NewAssemblyScript(timeout int) *AssemblyScript

NewAssemblyScript constructs a new AssemblyScript.

func (AssemblyScript) Build added in v0.18.0

func (a AssemblyScript) Build(out io.Writer, verbose bool) error

Build implements the Toolchain interface and attempts to compile the package AssemblyScript source to a Wasm binary.

func (AssemblyScript) Initialize added in v0.18.0

func (a AssemblyScript) Initialize(out io.Writer) error

Initialize implements the Toolchain interface and initializes a newly cloned package by installing required dependencies.

func (AssemblyScript) Verify added in v0.18.0

func (a AssemblyScript) Verify(out io.Writer) error

Verify implements the Toolchain interface and verifies whether the AssemblyScript language toolchain is correctly configured on the host.

type BuildCommand

type BuildCommand struct {
	cmd.Base

	// NOTE: these are public so that the "publish" composite command can set the
	// values appropriately before calling the Exec() function.
	PackageName string
	Lang        string
	IncludeSrc  bool
	Force       bool
	Timeout     int
	// contains filtered or unexported fields
}

BuildCommand produces a deployable artifact from files on the local disk.

func NewBuildCommand

func NewBuildCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data) *BuildCommand

NewBuildCommand returns a usable command registered under the parent.

func (*BuildCommand) Exec

func (c *BuildCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

type CargoCrateVersion added in v0.8.0

type CargoCrateVersion struct {
	Version string `json:"num"`
}

CargoCrateVersion models a Cargo crate version returned by the crates.io API.

type CargoCrateVersions added in v0.8.0

type CargoCrateVersions struct {
	Versions []CargoCrateVersion `json:"versions"`
}

CargoCrateVersions models a Cargo crate version returned by the crates.io API.

type CargoManifest

type CargoManifest struct {
	Package CargoPackage
}

CargoManifest models the package configuration properties of a Rust Cargo manifest which we are interested in and are read from the Cargo.toml manifest file within the $PWD of the package.

func (*CargoManifest) Read

func (m *CargoManifest) Read(fpath string) error

Read the contents of the Cargo.toml manifest from filename.

type CargoMetadata added in v0.13.0

type CargoMetadata struct {
	Package         []CargoPackage `json:"packages"`
	TargetDirectory string         `json:"target_directory"`
}

CargoMetadata models information about the workspace members and resolved dependencies of the current package via `cargo metadata` command output.

func (*CargoMetadata) Read added in v0.13.0

func (m *CargoMetadata) Read() error

Read the contents of the Cargo.lock file from filename.

type CargoPackage

type CargoPackage struct {
	Name         string         `toml:"name" json:"name"`
	Version      string         `toml:"version" json:"version"`
	Dependencies []CargoPackage `toml:"-" json:"dependencies"`
}

CargoPackage models the package configuration properties of a Rust Cargo package which we are interested in and is embedded within CargoManifest and CargoLock.

type DeployCommand

type DeployCommand struct {
	cmd.Base

	// NOTE: these are public so that the "publish" composite command can set the
	// values appropriately before calling the Exec() function.
	Manifest       manifest.Data
	Path           string
	Domain         string
	Backend        string
	BackendPort    uint
	Comment        cmd.OptionalString
	ServiceVersion cmd.OptionalServiceVersion
}

DeployCommand deploys an artifact previously produced by build.

func NewDeployCommand

func NewDeployCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data) *DeployCommand

NewDeployCommand returns a usable command registered under the parent.

func (*DeployCommand) Exec

func (c *DeployCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

type InitCommand

type InitCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

InitCommand initializes a Compute@Edge project package on the local machine.

func NewInitCommand

func NewInitCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data) *InitCommand

NewInitCommand returns a usable command registered under the parent.

func (*InitCommand) Exec

func (c *InitCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

type Language added in v0.18.0

type Language struct {
	Name            string
	DisplayName     string
	StarterKits     []config.StarterKit
	SourceDirectory string
	IncludeFiles    []string

	Toolchain
}

Language models a Compute@Edge source language.

func NewLanguage added in v0.18.0

func NewLanguage(options *LanguageOptions) *Language

NewLanguage constructs a new Language from a LangaugeOptions.

type LanguageOptions added in v0.18.0

type LanguageOptions struct {
	Name            string
	DisplayName     string
	StarterKits     []config.StarterKit
	SourceDirectory string
	IncludeFiles    []string
	Toolchain       Toolchain
}

LanguageOptions models configuration options for a Language.

type PackCommand added in v0.30.0

type PackCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

PackCommand takes a .wasm and builds the required tar/gzip package ready to be uploaded.

func NewPackCommand added in v0.30.0

func NewPackCommand(parent cmd.Registerer, globals *config.Data) *PackCommand

NewPackCommand returns a usable command registered under the parent.

func (*PackCommand) Exec added in v0.30.0

func (c *PackCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

type PublishCommand added in v0.27.0

type PublishCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

PublishCommand produces and deploys an artifact from files on the local disk.

func NewPublishCommand added in v0.27.0

func NewPublishCommand(parent cmd.Registerer, globals *config.Data, build *BuildCommand, deploy *DeployCommand) *PublishCommand

NewPublishCommand returns a usable command registered under the parent.

func (*PublishCommand) Exec added in v0.27.0

func (c *PublishCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

NOTE: unlike other non-aggregate commands that initialize a new text.Progress type for displaying progress information to the user, we don't use that in this command because the nested commands overlap the output in non-deterministic ways. It's best to leave those nested commands to handle the progress indicator.

type RootCommand

type RootCommand struct {
	cmd.Base
}

RootCommand is the parent command for all subcommands in this package. It should be installed under the primary root command.

func NewRootCommand

func NewRootCommand(parent cmd.Registerer, globals *config.Data) *RootCommand

NewRootCommand returns a new command registered in the parent.

func (*RootCommand) Exec

func (c *RootCommand) Exec(in io.Reader, out io.Writer) error

Exec implements the command interface.

type Rust

type Rust struct {
	// contains filtered or unexported fields
}

Rust implements a Toolchain for the Rust language.

func NewRust added in v0.18.0

func NewRust(client api.HTTPClient, config *config.Data, timeout int) *Rust

NewRust constructs a new Rust.

func (*Rust) Build

func (r *Rust) Build(out io.Writer, verbose bool) error

Build implements the Toolchain interface and attempts to compile the package Rust source to a Wasm binary.

func (Rust) IncludeFiles added in v0.18.0

func (r Rust) IncludeFiles() []string

IncludeFiles implements the Toolchain interface and returns a list of additional files to include in the package archive for Rust packages.

func (Rust) Initialize added in v0.18.0

func (r Rust) Initialize(out io.Writer) error

Initialize implements the Toolchain interface and initializes a newly cloned package. It is a noop for Rust as the Cargo toolchain handles these steps.

func (Rust) SourceDirectory added in v0.18.0

func (r Rust) SourceDirectory() string

SourceDirectory implements the Toolchain interface and returns the source directory for Rust packages.

func (*Rust) Verify

func (r *Rust) Verify(out io.Writer) error

Verify implments the Toolchain interface and verifies whether the Rust language toolchain is correctly configured on the host.

type ServeCommand added in v0.34.0

type ServeCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

ServeCommand produces and runs an artifact from files on the local disk.

func NewServeCommand added in v0.34.0

func NewServeCommand(parent cmd.Registerer, globals *config.Data, build *BuildCommand, viceroyVersioner update.Versioner) *ServeCommand

NewServeCommand returns a usable command registered under the parent.

func (*ServeCommand) Exec added in v0.34.0

func (c *ServeCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec implements the command interface.

type Toolchain

type Toolchain interface {
	Initialize(out io.Writer) error
	Verify(out io.Writer) error
	Build(out io.Writer, verbose bool) error
}

Toolchain abstracts a Compute@Edge source language toolchain.

type UpdateCommand

type UpdateCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

UpdateCommand calls the Fastly API to update packages.

func NewUpdateCommand

func NewUpdateCommand(parent cmd.Registerer, client api.HTTPClient, globals *config.Data) *UpdateCommand

NewUpdateCommand returns a usable command registered under the parent.

func (*UpdateCommand) Exec

func (c *UpdateCommand) Exec(in io.Reader, out io.Writer) (err error)

Exec invokes the application logic for the command.

type ValidateCommand

type ValidateCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

ValidateCommand validates a package archive.

func NewValidateCommand

func NewValidateCommand(parent cmd.Registerer, globals *config.Data) *ValidateCommand

NewValidateCommand returns a usable command registered under the parent.

func (*ValidateCommand) Exec

func (c *ValidateCommand) Exec(in io.Reader, out io.Writer) error

Exec implements the command interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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