langs

package
v0.0.0-...-e5d88bd Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBoilerplateExists = errors.New("Function boilerplate already exists")
)

Functions

func IsFallbackSupported

func IsFallbackSupported(lang string) bool

Types

type BaseHelper

type BaseHelper struct {
}

BaseHelper is empty implementation of LangHelper for embedding in implementations.

func (*BaseHelper) AfterBuild

func (h *BaseHelper) AfterBuild() error

func (*BaseHelper) Cmd

func (h *BaseHelper) Cmd() (string, error)

func (*BaseHelper) CustomMemory

func (h *BaseHelper) CustomMemory() uint64

func (*BaseHelper) DockerfileBuildCmds

func (h *BaseHelper) DockerfileBuildCmds() []string

func (*BaseHelper) DockerfileCopyCmds

func (h *BaseHelper) DockerfileCopyCmds() []string

func (*BaseHelper) Entrypoint

func (h *BaseHelper) Entrypoint() (string, error)

func (*BaseHelper) FixImagesOnInit

func (h *BaseHelper) FixImagesOnInit() bool

func (*BaseHelper) GenerateBoilerplate

func (h *BaseHelper) GenerateBoilerplate(string) error

func (*BaseHelper) GetLatestFDKVersion

func (h *BaseHelper) GetLatestFDKVersion() (string, error)

func (*BaseHelper) HasBoilerplate

func (h *BaseHelper) HasBoilerplate() bool

func (*BaseHelper) HasPreBuild

func (h *BaseHelper) HasPreBuild() bool

func (*BaseHelper) IsMultiStage

func (h *BaseHelper) IsMultiStage() bool

func (*BaseHelper) PreBuild

func (h *BaseHelper) PreBuild() error

type DotnetLangHelper

type DotnetLangHelper struct {
	BaseHelper
	Version string
}

func (*DotnetLangHelper) BuildFromImage

func (lh *DotnetLangHelper) BuildFromImage() (string, error)

func (*DotnetLangHelper) Cmd

func (h *DotnetLangHelper) Cmd() (string, error)

func (*DotnetLangHelper) CustomMemory

func (h *DotnetLangHelper) CustomMemory() uint64

func (*DotnetLangHelper) DockerfileBuildCmds

func (h *DotnetLangHelper) DockerfileBuildCmds() []string

func (*DotnetLangHelper) DockerfileCopyCmds

func (h *DotnetLangHelper) DockerfileCopyCmds() []string

func (*DotnetLangHelper) Entrypoint

func (h *DotnetLangHelper) Entrypoint() (string, error)

func (*DotnetLangHelper) Extensions

func (lh *DotnetLangHelper) Extensions() []string

func (*DotnetLangHelper) FixImagesOnInit

func (h *DotnetLangHelper) FixImagesOnInit() bool

func (*DotnetLangHelper) GenerateBoilerplate

func (lh *DotnetLangHelper) GenerateBoilerplate(path string) error

func (*DotnetLangHelper) GetLatestFDKVersion

func (h *DotnetLangHelper) GetLatestFDKVersion() (string, error)

func (*DotnetLangHelper) Handles

func (h *DotnetLangHelper) Handles(lang string) bool

func (*DotnetLangHelper) HasBoilerplate

func (lh *DotnetLangHelper) HasBoilerplate() bool

func (*DotnetLangHelper) LangStrings

func (lh *DotnetLangHelper) LangStrings() []string

func (*DotnetLangHelper) RunFromImage

func (lh *DotnetLangHelper) RunFromImage() (string, error)

func (*DotnetLangHelper) Runtime

func (h *DotnetLangHelper) Runtime() string

type GoLangHelper

type GoLangHelper struct {
	BaseHelper
	Version string
}

func (*GoLangHelper) BuildFromImage

func (lh *GoLangHelper) BuildFromImage() (string, error)

func (*GoLangHelper) CustomMemory

func (h *GoLangHelper) CustomMemory() uint64

func (*GoLangHelper) DockerfileBuildCmds

func (h *GoLangHelper) DockerfileBuildCmds() []string

func (*GoLangHelper) DockerfileCopyCmds

func (h *GoLangHelper) DockerfileCopyCmds() []string

func (*GoLangHelper) Entrypoint

func (lh *GoLangHelper) Entrypoint() (string, error)

func (*GoLangHelper) Extensions

func (lh *GoLangHelper) Extensions() []string

func (*GoLangHelper) FixImagesOnInit

func (h *GoLangHelper) FixImagesOnInit() bool

func (*GoLangHelper) GenerateBoilerplate

func (lh *GoLangHelper) GenerateBoilerplate(path string) error

func (*GoLangHelper) GetLatestFDKVersion

func (h *GoLangHelper) GetLatestFDKVersion() (string, error)

func (*GoLangHelper) Handles

func (h *GoLangHelper) Handles(lang string) bool

func (*GoLangHelper) HasBoilerplate

func (lh *GoLangHelper) HasBoilerplate() bool

func (*GoLangHelper) LangStrings

func (lh *GoLangHelper) LangStrings() []string

func (*GoLangHelper) RunFromImage

func (lh *GoLangHelper) RunFromImage() (string, error)

func (*GoLangHelper) Runtime

func (h *GoLangHelper) Runtime() string

type JavaLangHelper

type JavaLangHelper struct {
	BaseHelper
	// contains filtered or unexported fields
}

JavaLangHelper provides a set of helper methods for the lifecycle of Java Maven projects

func (*JavaLangHelper) BuildFromImage

func (h *JavaLangHelper) BuildFromImage() (string, error)

BuildFromImage returns the Docker image used to compile the Maven function project

func (*JavaLangHelper) Cmd

func (h *JavaLangHelper) Cmd() (string, error)

Cmd returns the Java runtime Docker entrypoint that will be executed when the function is executed.

func (*JavaLangHelper) CustomMemory

func (h *JavaLangHelper) CustomMemory() uint64

CustomMemory - no custom memory value here.

func (*JavaLangHelper) DockerfileBuildCmds

func (h *JavaLangHelper) DockerfileBuildCmds() []string

DockerfileBuildCmds returns the build stage steps to compile the Maven function project.

func (*JavaLangHelper) DockerfileCopyCmds

func (h *JavaLangHelper) DockerfileCopyCmds() []string

DockerfileCopyCmds returns the Docker COPY command to copy the compiled Java function jar and dependencies.

func (*JavaLangHelper) Extensions

func (h *JavaLangHelper) Extensions() []string

func (*JavaLangHelper) FixImagesOnInit

func (h *JavaLangHelper) FixImagesOnInit() bool

func (*JavaLangHelper) GenerateBoilerplate

func (h *JavaLangHelper) GenerateBoilerplate(path string) error

GenerateBoilerplate will generate function boilerplate for a Java runtime. The default boilerplate is for a Maven project.

func (*JavaLangHelper) GetLatestFDKVersion

func (h *JavaLangHelper) GetLatestFDKVersion() (string, error)

func (*JavaLangHelper) Handles

func (h *JavaLangHelper) Handles(lang string) bool

func (*JavaLangHelper) HasBoilerplate

func (h *JavaLangHelper) HasBoilerplate() bool

HasBoilerplate returns whether the Java runtime has boilerplate that can be generated.

func (*JavaLangHelper) HasPreBuild

func (h *JavaLangHelper) HasPreBuild() bool

HasPreBuild returns whether the Java Maven runtime has a pre-build step.

func (*JavaLangHelper) LangStrings

func (h *JavaLangHelper) LangStrings() []string

func (*JavaLangHelper) PreBuild

func (h *JavaLangHelper) PreBuild() error

PreBuild ensures that the expected the function is based is a maven project.

func (*JavaLangHelper) RunFromImage

func (h *JavaLangHelper) RunFromImage() (string, error)

RunFromImage returns the Docker image used to run the Java function.

func (*JavaLangHelper) Runtime

func (h *JavaLangHelper) Runtime() string

type KotlinLangHelper

type KotlinLangHelper struct {
	BaseHelper
	// contains filtered or unexported fields
}

KotlinLangHelper provides a set of helper methods for the lifecycle of Kotlin Maven projects

func (*KotlinLangHelper) BuildFromImage

func (h *KotlinLangHelper) BuildFromImage() (string, error)

BuildFromImage returns the Docker image used to compile the Maven function project

func (*KotlinLangHelper) Cmd

func (lh *KotlinLangHelper) Cmd() (string, error)

Cmd returns the Java runtime Docker entrypoint that will be executed when the function is executed.

func (*KotlinLangHelper) CustomMemory

func (h *KotlinLangHelper) CustomMemory() uint64

CustomMemory - no memory override here.

func (*KotlinLangHelper) DockerfileBuildCmds

func (lh *KotlinLangHelper) DockerfileBuildCmds() []string

DockerfileBuildCmds returns the build stage steps to compile the Maven function project.

func (*KotlinLangHelper) DockerfileCopyCmds

func (lh *KotlinLangHelper) DockerfileCopyCmds() []string

DockerfileCopyCmds returns the Docker COPY command to copy the compiled Kotlin function jar and dependencies.

func (*KotlinLangHelper) Extensions

func (h *KotlinLangHelper) Extensions() []string

func (*KotlinLangHelper) FixImagesOnInit

func (lh *KotlinLangHelper) FixImagesOnInit() bool

func (*KotlinLangHelper) GenerateBoilerplate

func (h *KotlinLangHelper) GenerateBoilerplate(path string) error

GenerateBoilerplate will generate function boilerplate for a Java runtime. The default boilerplate is for a Maven project.

func (*KotlinLangHelper) GetLatestFDKVersion

func (lh *KotlinLangHelper) GetLatestFDKVersion() (string, error)

func (*KotlinLangHelper) Handles

func (h *KotlinLangHelper) Handles(lang string) bool

func (*KotlinLangHelper) HasBoilerplate

func (h *KotlinLangHelper) HasBoilerplate() bool

HasBoilerplate returns whether the Java runtime has boilerplate that can be generated.

func (*KotlinLangHelper) HasPreBuild

func (lh *KotlinLangHelper) HasPreBuild() bool

HasPreBuild returns whether the Java Maven runtime has a pre-build step.

func (*KotlinLangHelper) LangStrings

func (h *KotlinLangHelper) LangStrings() []string

func (*KotlinLangHelper) PreBuild

func (lh *KotlinLangHelper) PreBuild() error

PreBuild ensures that the expected the function is based is a maven project.

func (*KotlinLangHelper) RunFromImage

func (h *KotlinLangHelper) RunFromImage() (string, error)

RunFromImage returns the Docker image used to run the Kotlin function.

func (*KotlinLangHelper) Runtime

func (h *KotlinLangHelper) Runtime() string

Runtime - return the correct runtime value for this helper.

type LangHelper

type LangHelper interface {
	// Handles return whether it can handle the passed in lang string or not
	Handles(string) bool
	// LangStrings returns list of supported language strings user can use for runtime
	LangStrings() []string
	// Extension is the file extension this helper supports. Eg: .java, .go, .js
	Extensions() []string
	// Runtime that will be used for the build (includes version)
	Runtime() string
	// BuildFromImage is the base image to build off, typically fnproject/LANG:dev
	BuildFromImage() (string, error)
	// RunFromImage is the base image to use for deployment (usually smaller than the build images)
	RunFromImage() (string, error)
	// If set to false, it will use a single Docker build step, rather than multi-stage
	IsMultiStage() bool
	// Dockerfile build lines for building dependencies or anything else language specific
	DockerfileBuildCmds() []string
	// DockerfileCopyCmds will run in second/final stage of multi-stage build to copy artifacts form the build stage
	DockerfileCopyCmds() []string
	// Entrypoint sets the Docker Entrypoint. One of Entrypoint or Cmd is required.
	Entrypoint() (string, error)
	// Cmd sets the Docker command. One of Entrypoint or Cmd is required.
	Cmd() (string, error)
	// CustomMemory allows a helper to specify a base memory amount, return "" to leave unspecified and let the runtime decide.
	CustomMemory() uint64
	HasPreBuild() bool
	PreBuild() error
	AfterBuild() error
	// HasBoilerplate indicates whether a language has support for generating function boilerplate.
	HasBoilerplate() bool
	// GenerateBoilerplate generates basic function boilerplate. Returns ErrBoilerplateExists if the function file
	// already exists.
	GenerateBoilerplate(string) error
	// FixImagesOnInit determines if images should be fixed on initialization - BuildFromImage and RunFromImage will be written to func.yaml
	FixImagesOnInit() bool
	// GetLatestFDKVersion checks the package repository and returns the latest version of FDK version if available.
	GetLatestFDKVersion() (string, error)
}

LangHelper is the interface that language helpers must implement.

func GetFallbackLangHelper

func GetFallbackLangHelper(lang string) LangHelper

func GetLangHelper

func GetLangHelper(lang string) LangHelper

GetLangHelper returns a LangHelper for the passed in language

func Helpers

func Helpers() []LangHelper

type NodeLangHelper

type NodeLangHelper struct {
	BaseHelper
	Version string
}

func (*NodeLangHelper) BuildFromImage

func (lh *NodeLangHelper) BuildFromImage() (string, error)

func (*NodeLangHelper) CustomMemory

func (h *NodeLangHelper) CustomMemory() uint64

CustomMemory - no memory override here.

func (*NodeLangHelper) DockerfileBuildCmds

func (h *NodeLangHelper) DockerfileBuildCmds() []string

func (*NodeLangHelper) DockerfileCopyCmds

func (h *NodeLangHelper) DockerfileCopyCmds() []string

func (*NodeLangHelper) Entrypoint

func (h *NodeLangHelper) Entrypoint() (string, error)

func (*NodeLangHelper) Extensions

func (lh *NodeLangHelper) Extensions() []string

func (*NodeLangHelper) FixImagesOnInit

func (h *NodeLangHelper) FixImagesOnInit() bool

func (*NodeLangHelper) GenerateBoilerplate

func (h *NodeLangHelper) GenerateBoilerplate(path string) error

func (*NodeLangHelper) GetLatestFDKVersion

func (h *NodeLangHelper) GetLatestFDKVersion() (string, error)

func (*NodeLangHelper) Handles

func (h *NodeLangHelper) Handles(lang string) bool

func (*NodeLangHelper) HasBoilerplate

func (h *NodeLangHelper) HasBoilerplate() bool

func (*NodeLangHelper) LangStrings

func (lh *NodeLangHelper) LangStrings() []string

func (*NodeLangHelper) RunFromImage

func (lh *NodeLangHelper) RunFromImage() (string, error)

func (*NodeLangHelper) Runtime

func (h *NodeLangHelper) Runtime() string

type PythonLangHelper

type PythonLangHelper struct {
	BaseHelper
	Version string
}

PythonLangHelper - python-specific init helper

func (*PythonLangHelper) BuildFromImage

func (h *PythonLangHelper) BuildFromImage() (string, error)

func (*PythonLangHelper) CustomMemory

func (h *PythonLangHelper) CustomMemory() uint64

CustomMemory - python is a hungry beast so specify a higher base memory here.

func (*PythonLangHelper) DockerfileBuildCmds

func (h *PythonLangHelper) DockerfileBuildCmds() []string

func (*PythonLangHelper) DockerfileCopyCmds

func (h *PythonLangHelper) DockerfileCopyCmds() []string

func (*PythonLangHelper) Entrypoint

func (h *PythonLangHelper) Entrypoint() (string, error)

func (*PythonLangHelper) Extensions

func (h *PythonLangHelper) Extensions() []string

func (*PythonLangHelper) FixImagesOnInit

func (h *PythonLangHelper) FixImagesOnInit() bool

func (*PythonLangHelper) GenerateBoilerplate

func (h *PythonLangHelper) GenerateBoilerplate(path string) error

GenerateBoilerplate - ...and here it is.

func (*PythonLangHelper) GetLatestFDKVersion

func (h *PythonLangHelper) GetLatestFDKVersion() (string, error)

func (*PythonLangHelper) Handles

func (h *PythonLangHelper) Handles(lang string) bool

func (*PythonLangHelper) HasBoilerplate

func (h *PythonLangHelper) HasBoilerplate() bool

HasBoilerplate - yep, we have boilerplate...

func (*PythonLangHelper) IsMultiStage

func (h *PythonLangHelper) IsMultiStage() bool

func (*PythonLangHelper) LangStrings

func (h *PythonLangHelper) LangStrings() []string

func (*PythonLangHelper) RunFromImage

func (h *PythonLangHelper) RunFromImage() (string, error)

func (*PythonLangHelper) Runtime

func (h *PythonLangHelper) Runtime() string

type RubyLangHelper

type RubyLangHelper struct {
	BaseHelper
	Version string
}

func (*RubyLangHelper) BuildFromImage

func (h *RubyLangHelper) BuildFromImage() (string, error)

func (*RubyLangHelper) CustomMemory

func (h *RubyLangHelper) CustomMemory() uint64

CustomMemory - no memory override here.

func (*RubyLangHelper) DockerfileBuildCmds

func (h *RubyLangHelper) DockerfileBuildCmds() []string

func (*RubyLangHelper) DockerfileCopyCmds

func (h *RubyLangHelper) DockerfileCopyCmds() []string

func (*RubyLangHelper) Entrypoint

func (h *RubyLangHelper) Entrypoint() (string, error)

func (*RubyLangHelper) Extensions

func (h *RubyLangHelper) Extensions() []string

func (*RubyLangHelper) FixImagesOnInit

func (h *RubyLangHelper) FixImagesOnInit() bool

func (*RubyLangHelper) GenerateBoilerplate

func (h *RubyLangHelper) GenerateBoilerplate(path string) error

func (*RubyLangHelper) GetLatestFDKVersion

func (h *RubyLangHelper) GetLatestFDKVersion() (string, error)

func (*RubyLangHelper) Handles

func (h *RubyLangHelper) Handles(lang string) bool

func (*RubyLangHelper) HasBoilerplate

func (h *RubyLangHelper) HasBoilerplate() bool

func (*RubyLangHelper) LangStrings

func (h *RubyLangHelper) LangStrings() []string

func (*RubyLangHelper) RunFromImage

func (h *RubyLangHelper) RunFromImage() (string, error)

func (*RubyLangHelper) Runtime

func (h *RubyLangHelper) Runtime() string

Jump to

Keyboard shortcuts

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