gears

package
v0.0.0-...-fd0b357 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GearPath     = "/flywheel/v0"
	ManifestName = "manifest.json"
	ConfigName   = "config.json"

	GearBuilderSectionKey = "custom.gear-builder"

	DefaultPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
)
View Source
const ExamplePythonScript = `` /* 2181-byte string literal not displayed */
View Source
const ExampleRunScript = `` /* 361-byte string literal not displayed */
View Source
const FwEnvVarPrefix = "FW_CONFIG_"
View Source
const GearBuilderCurlyMarks = `Additionally, some curly quotation marks (` + allCurlyCodePoints + `) were found in the manifest.
This is a common cause for errors on Mac computers.

Try opening the ` + ManifestName + ` file in a code editor (not a word processor).
You should always use straight quotation marks with JSON: "example".`
View Source
const GearBuilderInvalidJson = `The manifest in your current folder was not valid JSON.
This is usually due to forgetting a comma, or having an extra comma.

If you're lost, try dragging the ` + ManifestName + ` file to this online tool:
https://jsonlint.com

Or, on the command line, ` + "`cat " + ManifestName + " | jq`" + ` can be very helpful.
https://stedolan.github.io/jq

The specific parsing error was:
`
View Source
const GearBuilderSectionRectification = `This is usually due to using your own file, or an older version of the CLI.
Try adding something like this to your manifest:

"custom": {
	"gear-builder": {
		"category": "converter",
		"image": "python:3"
	}
}

Alternatively, create a new folder and try ` + "`fw gear create`" + ` there to create a new manifest.
`
View Source
const ManifestRequired = "This command requires a manifest. Try `fw gear create` first."

Variables

View Source
var (
	// Default to OS preference
	BaseTempDir = ""

	// Easily identified state dirs
	BaseTempPrefix = "fw-gear-builder-"
)
View Source
var AllowedConfigBashCharacters = regexp.MustCompile("[^' _0123456789ACBEDGFIHKJMLONQPSRUTWVYXZacbedgfihkjmlonqpsrutwvyxz]+")

Functions

func BasicApiKeyInput

func BasicApiKeyInput(apikey string) map[string]interface{}

func BasicInvocation

func BasicInvocation(config map[string]interface{}) map[string]interface{}

func BasicInvocationInput

func BasicInvocationInput(inputName, inputPath string) map[string]interface{}

func CheckDocker

func CheckDocker() (*client.Client, error)

func CreateInvocationComponents

func CreateInvocationComponents(gear *api.Gear, config map[string]interface{}, files map[string]string, context map[string]interface{}, apiKey string, apiKeyInputs []string) (map[string]string, []string, map[string]interface{})

Given a gear and invocation config, create a valid environment set, command, and invocation for launching. Mirrored in core Job.generate_request

func DockerOrBust

func DockerOrBust() *client.Client

func FetchName

func FetchName(client *api.Client) string

func FinishGearTicket

func FinishGearTicket(client *api.Client, ticket, repo, digest string)

func GearCreate

func GearCreate(client *api.Client, docker *client.Client)

func GearModify

func GearModify(docker *client.Client, quiet bool)

func GearRun

func GearRun(client *api.Client, docker *client.Client, apiKey string, gear *api.Gear, config map[string]interface{}, files map[string]string, context map[string]interface{}, apiKeyInputs []string)

func GearUpload

func GearUpload(client *api.Client, docker *client.Client, apiKey, domain string, gear *api.Gear)

func GenerateCommand

func GenerateCommand(use, short string, gearLookup func() *api.Gear, innerCmd CommandWithGear) *cobra.Command

Dynamically generate a command with flags that correspond to a gear

func GenerateExampleManifestAndModifier

func GenerateExampleManifestAndModifier(label, name, imageName, category string, env map[string]string, realName string) (*api.Gear, func(*api.Gear) *api.Gear)

Encapsulate the changes needed to modify an upstream manifest, or use a completely default one

func MakeGearTicket

func MakeGearTicket(client *api.Client, doc *api.GearDoc) (string, error)

func MakeGearTicketReslient

func MakeGearTicketReslient(client *api.Client, doc *api.GearDoc) string

func PrepareLocalRunFiles

func PrepareLocalRunFiles(gear *api.Gear, invocation map[string]interface{}, files map[string]string) ([]mount.Mount, func())

Lay out temporary files/directorys and set up a list of mounts needed for a local gear run.

func RandString

func RandString() string

func RandStringLower

func RandStringLower() string

func RandStringOfLength

func RandStringOfLength(n int, runes []rune) string

func RenderTemplate

func RenderTemplate(template string, context map[string]interface{}) (string, error)

func RequireCWDManifest

func RequireCWDManifest() *api.Gear

func TarCWD

func TarCWD(out io.Writer) error

func TranslateEnvArrayToEnv

func TranslateEnvArrayToEnv(envA []string) map[string]string

func TranslateEnvToEnvArray

func TranslateEnvToEnvArray(env map[string]string) []string

func TryToLoadCWDManifest

func TryToLoadCWDManifest() *api.Gear

Tries to load a manifest from the current folder

func UntarGearFolder

func UntarGearFolder(reader io.Reader) error

Types

type CommandWithGear

type CommandWithGear func(cmd *cobra.Command, args []string, gear *api.Gear, config map[string]interface{}, files map[string]string, context map[string]interface{}, apiKeyInputs []string)

Func sig that adds parsed gear information & invocation to standard Cobra sig

type D

type D struct {
	*client.Client
}

Clean up function params with embedded struct

func (*D) CreateContainer

func (docker *D) CreateContainer(imageName string) (string, func())

Ensure image is local first

func (*D) CreateContainerForGear

func (docker *D) CreateContainerForGear(imageName string, env map[string]string, command []string, mounts []mount.Mount) (string, func())

Consistent way to launch a local gear. Ensure image is local first

func (*D) CreateContainerFromImage

func (docker *D) CreateContainerFromImage(imageName string, config *container.Config, hostConfig *container.HostConfig) (string, func())

Ensure image is local first

func (*D) EnsureImageLocal

func (docker *D) EnsureImageLocal(imageName string)

func (*D) ExpandFlywheelFolder

func (docker *D) ExpandFlywheelFolder(imageName, containerId string, defaultManifest *api.Gear, modifier func(*api.Gear) *api.Gear)

func (*D) GetImageDetails

func (docker *D) GetImageDetails(imageName string) (*types.ImageInspect, map[string]string)

Return details with info parsed into gear format

func (*D) InspectImage

func (docker *D) InspectImage(imageName string) *types.ImageInspect

func (*D) IsImageLocal

func (docker *D) IsImageLocal(imageName string) bool

func (*D) LoginToRegistry

func (docker *D) LoginToRegistry(client *api.Client, domain, apiKey string) string

Generate auth token

func (*D) ObserveContainer

func (docker *D) ObserveContainer(containerID string) int64

Start and watch logs, get retcode

func (*D) PullImage

func (docker *D) PullImage(imageName string)

func (*D) PushImage

func (docker *D) PushImage(imageDst, token string) string

func (*D) PythonInstalled

func (docker *D) PythonInstalled(imageName string) bool

func (*D) SaveCwdIntoContainer

func (docker *D) SaveCwdIntoContainer(containerID string)

func (*D) TagContainer

func (docker *D) TagContainer(src, dst string)

func (*D) TagImage

func (docker *D) TagImage(src, dst string)

func (*D) WaitForContainerResults

func (docker *D) WaitForContainerResults(containerID string) int64

Wait for container return code

func (*D) WaitOnContainer

func (docker *D) WaitOnContainer(containerID string) int64

Wait for a retcode without logging

type GearBuilderInfo

type GearBuilderInfo struct {
	Category string `json:"category,omitempty"`
	Image    string `json:"image,omitempty"`
}

GearBuilderInfo holds persistent state, stored in the manifest for convenience and transparency. Could possibly end up in the SDK, but needs flexibility to add more fields later.

func ParseGearBuilerInformation

func ParseGearBuilerInformation(gear *api.Gear) *GearBuilderInfo

Extract GB info, failing verbosely if the structure is incorrect.

Jump to

Keyboard shortcuts

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