Documentation ¶
Index ¶
- Constants
- Variables
- func BasicApiKeyInput(apikey string) map[string]interface{}
- func BasicInvocation(config map[string]interface{}) map[string]interface{}
- func BasicInvocationInput(inputName, inputPath string) map[string]interface{}
- func CheckDocker() (*client.Client, error)
- func CreateInvocationComponents(gear *api.Gear, config map[string]interface{}, files map[string]string, ...) (map[string]string, []string, map[string]interface{})
- func DockerOrBust() *client.Client
- func FetchName(client *api.Client) string
- func FinishGearTicket(client *api.Client, ticket, repo, digest string)
- func GearCreate(client *api.Client, docker *client.Client)
- func GearModify(docker *client.Client, quiet bool)
- func GearRun(client *api.Client, docker *client.Client, apiKey string, gear *api.Gear, ...)
- func GearUpload(client *api.Client, docker *client.Client, apiKey, domain string, ...)
- func GenerateCommand(use, short string, gearLookup func() *api.Gear, innerCmd CommandWithGear) *cobra.Command
- func GenerateExampleManifestAndModifier(label, name, imageName, category string, env map[string]string, ...) (*api.Gear, func(*api.Gear) *api.Gear)
- func MakeGearTicket(client *api.Client, doc *api.GearDoc) (string, error)
- func MakeGearTicketReslient(client *api.Client, doc *api.GearDoc) string
- func PrepareLocalRunFiles(gear *api.Gear, invocation map[string]interface{}, files map[string]string) ([]mount.Mount, func())
- func RandString() string
- func RandStringLower() string
- func RandStringOfLength(n int, runes []rune) string
- func RenderTemplate(template string, context map[string]interface{}) (string, error)
- func RequireCWDManifest() *api.Gear
- func TarCWD(out io.Writer) error
- func TranslateEnvArrayToEnv(envA []string) map[string]string
- func TranslateEnvToEnvArray(env map[string]string) []string
- func TryToLoadCWDManifest() *api.Gear
- func UntarGearFolder(reader io.Reader) error
- type CommandWithGear
- type D
- func (docker *D) CreateContainer(imageName string) (string, func())
- func (docker *D) CreateContainerForGear(imageName string, env map[string]string, command []string, ...) (string, func())
- func (docker *D) CreateContainerFromImage(imageName string, config *container.Config, hostConfig *container.HostConfig) (string, func())
- func (docker *D) EnsureImageLocal(imageName string)
- func (docker *D) ExpandFlywheelFolder(imageName, containerId string, defaultManifest *api.Gear, ...)
- func (docker *D) GetImageDetails(imageName string) (*types.ImageInspect, map[string]string)
- func (docker *D) InspectImage(imageName string) *types.ImageInspect
- func (docker *D) IsImageLocal(imageName string) bool
- func (docker *D) LoginToRegistry(client *api.Client, domain, apiKey string) string
- func (docker *D) ObserveContainer(containerID string) int64
- func (docker *D) PullImage(imageName string)
- func (docker *D) PushImage(imageDst, token string) string
- func (docker *D) PythonInstalled(imageName string) bool
- func (docker *D) SaveCwdIntoContainer(containerID string)
- func (docker *D) TagContainer(src, dst string)
- func (docker *D) TagImage(src, dst string)
- func (docker *D) WaitForContainerResults(containerID string) int64
- func (docker *D) WaitOnContainer(containerID string) int64
- type GearBuilderInfo
Constants ¶
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" )
const ExamplePythonScript = `` /* 2181-byte string literal not displayed */
const ExampleRunScript = `` /* 361-byte string literal not displayed */
const FwEnvVarPrefix = "FW_CONFIG_"
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".`
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: `
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.
`
const ManifestRequired = "This command requires a manifest. Try `fw gear create` first."
Variables ¶
var ( // Default to OS preference BaseTempDir = "" // Easily identified state dirs BaseTempPrefix = "fw-gear-builder-" )
var AllowedConfigBashCharacters = regexp.MustCompile("[^' _0123456789ACBEDGFIHKJMLONQPSRUTWVYXZacbedgfihkjmlonqpsrutwvyxz]+")
Functions ¶
func BasicApiKeyInput ¶
func BasicInvocation ¶
func BasicInvocationInput ¶
func CheckDocker ¶
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 FinishGearTicket ¶
func GearModify ¶
func GearUpload ¶
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 MakeGearTicketReslient ¶
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 RenderTemplate ¶
func RequireCWDManifest ¶
func TranslateEnvArrayToEnv ¶
func TranslateEnvToEnvArray ¶
func TryToLoadCWDManifest ¶
Tries to load a manifest from the current folder
func UntarGearFolder ¶
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 ¶
Clean up function params with embedded struct
func (*D) CreateContainer ¶
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 (*D) ExpandFlywheelFolder ¶
func (*D) GetImageDetails ¶
Return details with info parsed into gear format
func (*D) InspectImage ¶
func (docker *D) InspectImage(imageName string) *types.ImageInspect
func (*D) IsImageLocal ¶
func (*D) LoginToRegistry ¶
Generate auth token
func (*D) ObserveContainer ¶
Start and watch logs, get retcode
func (*D) PythonInstalled ¶
func (*D) SaveCwdIntoContainer ¶
func (*D) TagContainer ¶
func (*D) WaitForContainerResults ¶
Wait for container return code
func (*D) WaitOnContainer ¶
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.