common

package
v0.0.0-...-394dbd4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 41 Imported by: 6

Documentation

Index

Constants

View Source
const (
	FunctionsDockerImage     = "fnproject/fnserver"
	FuncfileDockerRuntime    = "docker"
	MinRequiredDockerVersion = "17.5.0"
	BuildxBuilderInstance    = "oci_fn_builder"
	DefaultAppShape          = modelsv2.AppShapeGENERICX86

	DefaultLocalDebugPort = 5678
)

Global docker variables.

View Source
const (
	DestinationTypeStream        = "stream"
	DestinationTypeQueue         = "queue"
	DestinationTypeNotifications = "notifications"
)
View Source
const (
	AnnotationOCIResourceFreeformTags = "oracle.com/oci/freeformTags"
	AnnotationOCIResourceDefinedTags  = "oracle.com/oci/definedTags"
)
View Source
const (
	ProvisionedConcurrencyStrategyNone     = "NONE"
	ProvisionedConcurrencyStrategyConstant = "CONSTANT"
	ProvisionedConcurrencyCountStep        = 40
)
View Source
const (
	V20180708         = 20180708
	LatestYamlVersion = V20180708
)
View Source
const V20180708Schema = `` /* 3341-byte string literal not displayed */

Variables

View Source
var CommandVerbose bool
View Source
var GlobalVerbose bool
View Source
var (
	// InitialVersion - inital fn version.
	InitialVersion = "0.0.1"
)
View Source
var ShapeMap = map[string][]string{
	modelsv2.AppShapeGENERICX86:    {"linux/amd64"},
	modelsv2.AppShapeGENERICARM:    {"linux/arm64"},
	modelsv2.AppShapeGENERICX86ARM: {"linux/arm64", "linux/amd64"},
}
View Source
var ShellCommander = newExecShellCommander
View Source
var TargetPlatformMap = map[string][]string{
	modelsv2.AppShapeGENERICX86:    {"amd64"},
	modelsv2.AppShapeGENERICARM:    {"arm64"},
	modelsv2.AppShapeGENERICX86ARM: {"amd64_arm64"},
}

Functions

func ApplyOCIResourceTagFlagsToAnnotations

func ApplyOCIResourceTagFlagsToAnnotations(
	annotations map[string]interface{},
	freeformSpecs []string,
	definedSpecs []string,
	removeFreeform []string,
	removeDefined []string,
	clearFreeform bool,
	clearDefined bool,
) (map[string]interface{}, error)

func ApplyOCIResourceTagsToAnnotations

func ApplyOCIResourceTagsToAnnotations(annotations map[string]interface{}, freeform map[string]string, defined OCIDefinedTags) map[string]interface{}

func BumpCommand

func BumpCommand() cli.Command

BumpCommand command to build function version.

func ConvertDefinedTagsToInterface

func ConvertDefinedTagsToInterface(tags OCIDefinedTags) map[string]map[string]interface{}

func DefaultBashComplete

func DefaultBashComplete(c *cli.Context)

DefaultBashComplete prints the list of all sub commands of the current command (without alias names)

func DeleteFunctions

func DeleteFunctions(c *cli.Context, client *fnclient.Fn, fns []*modelsv2.Fn) error

DeleteFunctions deletes all the functions provided to it. if provided nil it is a no-op

func DeleteTriggers

func DeleteTriggers(c *cli.Context, client *fnclient.Fn, triggers []*modelsv2.Trigger) error

DeleteTriggers deletes all the triggers provided to it. if provided nil it is a no-op

func EncodeFuncFileV20180708YAML

func EncodeFuncFileV20180708YAML(path string, ff *FuncFileV20180708) error

EncodeFuncfileYAML encodes function file.

func EncodeFuncfileYAML

func EncodeFuncfileYAML(path string, ff *FuncFile) error

EncodeFuncfileYAML encodes function file.

func Exists

func Exists(name string) bool

Exists check file exists.

func ExtractAnnotations

func ExtractAnnotations(c *cli.Context) map[string]interface{}

ExtractAnnotations extract annotations from command flags.

func ExtractConfig

func ExtractConfig(configs []string) map[string]string

ExtractConfig parses key-value configuration into a map

func FindFuncfile

func FindFuncfile(path string) (string, error)

findFuncfile for a func.yaml/json/yml file in path

func GetContainerEngineType

func GetContainerEngineType() (string, error)

func GetDir

func GetDir(c *cli.Context) string

GetDir returns the dir if defined as a flag in cli.Context

func GetFuncYamlVersion

func GetFuncYamlVersion(oldFF map[string]interface{}) int

func GetWd

func GetWd() string

GetWd returns working directory.

func IsFuncFile

func IsFuncFile(path string, info os.FileInfo) bool

IsFuncFile check vaid funcfile.

func IsOracleProvider

func IsOracleProvider(p fnprovider.Provider) bool

IsOracleProvider reports whether the current provider is the OCI Functions provider.

func IsVerbose

func IsVerbose() bool

func ListFnsAndTriggersInApp

func ListFnsAndTriggersInApp(c *cli.Context, client *fnclient.Fn, app *modelsv2.App) ([]*modelsv2.Fn, []*modelsv2.Trigger, error)

ListFnsAndTriggersInApp lists all the functions associated with an app and all the triggers associated with each of those functions

func ListFnsInApp

func ListFnsInApp(c *cli.Context, client *fnclient.Fn, app *modelsv2.App) ([]*modelsv2.Fn, error)

ListFnsInApp gets all the functions associated with an app

func ListTriggersInFunc

func ListTriggersInFunc(c *cli.Context, client *fnclient.Fn, fn *modelsv2.Fn) ([]*modelsv2.Trigger, error)

ListTriggersInFunc gets all the triggers associated with a function

func LoadCLIJSONInput

func LoadCLIJSONInput(spec string, out interface{}) error

func MergeFuncFileInitYAML

func MergeFuncFileInitYAML(path string, ff *FuncFileV20180708) error

Merge the func.init.yaml from the initImage with a.ff

write out the new func file

func NormalizeWaitSettings

func NormalizeWaitSettings(maxWait, interval int) (int, int)

func OCIManagedResourceTagSettingNames

func OCIManagedResourceTagSettingNames(ff *FuncFileV20180708) []string

func ParseDetachedTimeoutSpec

func ParseDetachedTimeoutSpec(spec string) (string, int, error)

ParseDetachedTimeoutSpec validates a human-friendly detached timeout such as 20m or 1h and returns the original trimmed value plus the timeout in seconds.

func ParseFreeformTagSpecs

func ParseFreeformTagSpecs(specs []string) (map[string]string, error)

func PrintContextualInfo

func PrintContextualInfo()

func PrintDockerfileContent

func PrintDockerfileContent(dockerfile string, stdout io.Writer)

func PullImage

func PullImage(image string) error

func Push

func Push(ff *FuncFile) error

Push pushes to docker registry.

func PushV20180708

func PushV20180708(ff *FuncFileV20180708) error

Push pushes to docker registry.

func ReadInFuncFile

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

func RunBuild

func RunBuild(verbose bool, dir, imageName, dockerfile string, buildArgs []string, noCache bool, containerEngineType string, shape string) error

RunBuild runs function from func.yaml/json/yml.

func RunInitImage

func RunInitImage(initImage string, fName string) error

func SetDetachedTimeout

func SetDetachedTimeout(ff *FuncFileV20180708, timeout string)

SetDetachedTimeout stores detached timeout config in the function deploy section.

func SetOCIResourceTagsOnFuncFile

func SetOCIResourceTagsOnFuncFile(ff *FuncFileV20180708, freeform map[string]string, defined OCIDefinedTags)

func SetOnFailureDestination

func SetOnFailureDestination(ff *FuncFileV20180708, dest *OCIDestination)

SetOnFailureDestination stores an OCI on-failure destination in func.yaml config.

func SetOnSuccessDestination

func SetOnSuccessDestination(ff *FuncFileV20180708, dest *OCIDestination)

SetOnSuccessDestination stores an OCI on-success destination in func.yaml config.

func SetProvisionedConcurrency

func SetProvisionedConcurrency(ff *FuncFileV20180708, cfg *OCIProvisionedConcurrencyConfig)

SetProvisionedConcurrency stores provisioned concurrency config in the function deploy section.

func UserConfirmedMultiResourceDeletion

func UserConfirmedMultiResourceDeletion(aps []*modelsv2.App, fns []*modelsv2.Fn, trs []*modelsv2.Trigger) bool

UserConfirmedMultiResourceDeletion will prompt the user for confirmation to delete all the the resources

func ValidateFileAgainstSchema

func ValidateFileAgainstSchema(jsonFile, schema string) error

func ValidateFullImageName

func ValidateFullImageName(n string) error

ValidateFullImageName validates that the full image name (REGISTRY/name:tag) is allowed for push remember that private registries must be supported here

func ValidateProvisionedConcurrencyConfig

func ValidateProvisionedConcurrencyConfig(cfg *OCIProvisionedConcurrencyConfig) error

ValidateProvisionedConcurrencyConfig validates OCI provisioned concurrency values before they are sent to OCI.

func ValidateTagImageName

func ValidateTagImageName(n string) error

ValidateTagImageName validates that the last part of the image name (name:tag) is allowed for create/update

func WaitForAppState

func WaitForAppState(p provider.Provider, appID, targetState string, maxWaitSeconds, waitIntervalSeconds int) error

func WaitForFunctionState

func WaitForFunctionState(p provider.Provider, fnID, targetState string, maxWaitSeconds, waitIntervalSeconds int) error

func WalkFuncs

func WalkFuncs(root string, walkFn walkFuncsFunc) error

WalkFuncs is similar to filepath.Walk except only returns func.yaml's (so on per function)

func WalkFuncsV20180708

func WalkFuncsV20180708(root string, walkFn walkFuncsFuncV20180708) error

WalkFuncsV20180708 is similar to filepath.Walk except only returns func.yaml's (so on per function)

func WarnIfOCIManagedFunctionSettingsUnsupported

func WarnIfOCIManagedFunctionSettingsUnsupported(w io.Writer, p fnprovider.Provider, fnName string, ff *FuncFileV20180708) bool

WarnIfOCIManagedFunctionSettingsUnsupported emits a warning when func.yaml contains OCI-specific managed function settings but the active provider does not support OCI-managed function features.

func WarnUnsupportedOCIRequestControl

func WarnUnsupportedOCIRequestControl(p provider.Provider, control OCIRequestControl)

Types

type AppFile

type AppFile struct {
	Name        string                 `yaml:"name,omitempty" json:"name,omitempty"`
	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	SyslogURL   string                 `yaml:"syslog_url,omitempty" json:"syslog_url,omitempty"`
}

AppFile defines the internal structure of a app.yaml/json/yml

func LoadAppfile

func LoadAppfile(path string) (*AppFile, error)

LoadAppfile returns a parsed appfile.

type Expects

type Expects struct {
	Config []inputVar `yaml:"config" json:"config"`
}

Expects represents expected env vars in funcfile.

type FFTest

type FFTest struct {
	Name   string     `yaml:"name,omitempty" json:"name,omitempty"`
	Input  *InputMap  `yaml:"input,omitempty" json:"input,omitempty"`
	Output *OutputMap `yaml:"outoutput,omitempty" json:"output,omitempty"`
	Err    *string    `yaml:"err,omitempty" json:"err,omitempty"`
}

FFTest represents a test for a funcfile.

type FuncDeployConfig

type FuncDeployConfig struct {
	OCI *OCIFunctionDeployConfig `yaml:"oci,omitempty" json:"oci,omitempty"`
}

FuncDeployConfig stores deploy-time configuration sections in func.yaml.

type FuncFile

type FuncFile struct {
	// just for posterity, this won't be set on old files, but we can check that
	Schema_version int `yaml:"schema_version,omitempty" json:"schema_version,omitempty"`

	Name string `yaml:"name,omitempty" json:"name,omitempty"`

	// Build params
	Version     string   `yaml:"version,omitempty" json:"version,omitempty"`
	Runtime     string   `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Entrypoint  string   `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
	Cmd         string   `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	Build       []string `yaml:"build,omitempty" json:"build,omitempty"`
	Tests       []FFTest `yaml:"tests,omitempty" json:"tests,omitempty"`
	BuildImage  string   `yaml:"build_image,omitempty" json:"build_image,omitempty"` // Image to use as base for building
	RunImage    string   `yaml:"run_image,omitempty" json:"run_image,omitempty"`     // Image to use for running
	ContentType string   `yaml:"content_type,omitempty" json:"content_type,omitempty"`

	// Route params
	// TODO embed models.Route
	Type        string                 `yaml:"type,omitempty" json:"type,omitempty"`
	Memory      uint64                 `yaml:"memory,omitempty" json:"memory,omitempty"`
	Cpus        string                 `yaml:"cpus,omitempty" json:"cpus,omitempty"`
	Timeout     *int32                 `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Path        string                 `yaml:"path,omitempty" json:"path,omitempty"`
	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	IDLETimeout *int32                 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Deploy      *FuncDeployConfig      `yaml:"deploy,omitempty" json:"deploy,omitempty"`

	// Run/test
	Expects Expects `yaml:"expects,omitempty" json:"expects,omitempty"`
}

FuncFile defines the internal structure of a func.yaml/json/yml

func BuildFunc

func BuildFunc(verbose bool, fpath string, funcfile *FuncFile, buildArg []string, noCache bool) (*FuncFile, error)

BuildFunc bumps version and builds function.

func BumpIt

func BumpIt(fpath string, vtype VType) (*FuncFile, error)

BumpIt returns updated funcfile

func FindAndParseFuncfile

func FindAndParseFuncfile(path string) (fpath string, ff *FuncFile, err error)

FindAndParseFuncfile for a func.yaml/json/yml file.

func LoadFuncfile

func LoadFuncfile(path string) (string, *FuncFile, error)

LoadFuncfile returns a parsed funcfile.

func ParseFuncfile

func ParseFuncfile(path string) (*FuncFile, error)

ParseFuncfile check file type to decode and parse.

func (*FuncFile) ImageName

func (ff *FuncFile) ImageName() string

ImageName returns the name of a funcfile image

func (*FuncFile) RuntimeTag

func (ff *FuncFile) RuntimeTag() (runtime, tag string)

RuntimeTag returns the runtime and tag.

type FuncFileV20180708

type FuncFileV20180708 struct {
	Schema_version int `yaml:"schema_version,omitempty" json:"schema_version,omitempty"`

	Name         string `yaml:"name,omitempty" json:"name,omitempty"`
	Version      string `yaml:"version,omitempty" json:"version,omitempty"`
	Runtime      string `yaml:"runtime,omitempty" json:"runtime,omitempty"`
	Build_image  string `yaml:"build_image,omitempty" json:"build_image,omitempty"` // Image to use as base for building
	Run_image    string `yaml:"run_image,omitempty" json:"run_image,omitempty"`     // Image to use for running
	Cmd          string `yaml:"cmd,omitempty" json:"cmd,omitempty"`
	Entrypoint   string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
	Content_type string `yaml:"content_type,omitempty" json:"content_type,omitempty"`
	Type         string `yaml:"type,omitempty" json:"type,omitempty"`
	Memory       uint64 `yaml:"memory,omitempty" json:"memory,omitempty"`
	Timeout      *int32 `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	IDLE_timeout *int32 `yaml:"idle_timeout,omitempty" json:"idle_timeout,omitempty"`

	Config      map[string]string      `yaml:"config,omitempty" json:"config,omitempty"`
	Annotations map[string]interface{} `yaml:"annotations,omitempty" json:"annotations,omitempty"`
	Deploy      *FuncDeployConfig      `yaml:"deploy,omitempty" json:"deploy,omitempty"`

	SigningDetails SigningDetails `yaml:"signing_details,omitempty" json:"signing_details,omitempty""`

	Build []string `yaml:"build,omitempty" json:"build,omitempty"`

	Expects  Expects   `yaml:"expects,omitempty" json:"expects,omitempty"`
	Triggers []Trigger `yaml:"triggers,omitempty" json:"triggers,omitempty"`
}

FuncFileV20180708 defines the latest internal structure of a func.yaml/json/yml

func BuildFuncV20180708

func BuildFuncV20180708(verbose bool, fpath string, funcfile *FuncFileV20180708, buildArg []string, noCache bool, shape string, localDebug bool) (*FuncFileV20180708, error)

BuildFunc bumps version and builds function.

func BumpItV20180708

func BumpItV20180708(fpath string, vtype VType) (*FuncFileV20180708, error)

BumpIt returns updated funcfile

func FindAndParseFuncFileV20180708

func FindAndParseFuncFileV20180708(path string) (fpath string, ff *FuncFileV20180708, err error)

func LoadFuncFileV20180708

func LoadFuncFileV20180708(path string) (string, *FuncFileV20180708, error)

func ParseFuncFileV20180708

func ParseFuncFileV20180708(path string) (ff *FuncFileV20180708, err error)

func (*FuncFileV20180708) HasOCIManagedFunctionSettings

func (ff *FuncFileV20180708) HasOCIManagedFunctionSettings() bool

HasOCIManagedFunctionSettings reports whether the func.yaml contains OCI-specific managed function settings that require OCI provider support.

func (*FuncFileV20180708) ImageNameV20180708

func (ff *FuncFileV20180708) ImageNameV20180708() string

ImageName returns the name of a funcfile image

func (*FuncFileV20180708) OCIManagedFunctionSettingNames

func (ff *FuncFileV20180708) OCIManagedFunctionSettingNames() []string

OCIManagedFunctionSettingNames returns the OCI-managed function setting groups present in func.yaml in a stable order for warnings and diagnostics.

type InputMap

type InputMap struct {
	Body interface{}
}

InputMap to be used within FFTest.

type NotFoundError

type NotFoundError struct {
	S string
}

NotFoundError represents error string.

func NewNotFoundError

func NewNotFoundError(s string) *NotFoundError

NewNotFoundError returns a new error.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type OCIDefinedTags

type OCIDefinedTags map[string]map[string]interface{}

OCIDefinedTags stores user-friendly defined tag values for func.yaml persistence. Values may be strings, numbers, booleans, objects, arrays, or null.

func ConvertDefinedTagsFromInterface

func ConvertDefinedTagsFromInterface(tags map[string]map[string]interface{}) OCIDefinedTags

func ParseDefinedTagSpecs

func ParseDefinedTagSpecs(specs []string) (OCIDefinedTags, error)

type OCIDestination

type OCIDestination struct {
	Type string `yaml:"type,omitempty" json:"type,omitempty"`
	OCID string `yaml:"ocid,omitempty" json:"ocid,omitempty"`
}

OCIDestination represents an OCI destination reference stored in func.yaml.

func ParseOCIDestinationSpec

func ParseOCIDestinationSpec(flagName, spec string) (*OCIDestination, error)

ParseOCIDestinationSpec parses a shorthand destination spec like stream:<ocid>.

type OCIDetachedModeConfig

type OCIDetachedModeConfig struct {
	Timeout   string          `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	OnSuccess *OCIDestination `yaml:"on_success,omitempty" json:"on_success,omitempty"`
	OnFailure *OCIDestination `yaml:"on_failure,omitempty" json:"on_failure,omitempty"`
}

OCIDetachedModeConfig stores detached mode settings for OCI Functions.

type OCIFunctionDeployConfig

type OCIFunctionDeployConfig struct {
	ProvisionedConcurrency *OCIProvisionedConcurrencyConfig `yaml:"provisioned_concurrency,omitempty" json:"provisioned_concurrency,omitempty"`
	DetachedMode           *OCIDetachedModeConfig           `yaml:"detached_mode,omitempty" json:"detached_mode,omitempty"`
	PBF                    *OCIPBFSourceConfig              `yaml:"pbf,omitempty" json:"pbf,omitempty"`
	FreeformTags           map[string]string                `yaml:"freeform_tags,omitempty" json:"freeform_tags,omitempty"`
	DefinedTags            OCIDefinedTags                   `yaml:"defined_tags,omitempty" json:"defined_tags,omitempty"`
}

OCIFunctionDeployConfig stores OCI-specific deploy configuration for a function.

type OCIPBFSourceConfig

type OCIPBFSourceConfig struct {
	ListingID string `yaml:"listing_id,omitempty" json:"listing_id,omitempty"`
}

OCIPBFSourceConfig stores Pre-Built Function source details for OCI Functions.

type OCIProvisionedConcurrencyConfig

type OCIProvisionedConcurrencyConfig struct {
	Strategy string `yaml:"strategy,omitempty" json:"strategy,omitempty"`
	Count    *int   `yaml:"count,omitempty" json:"count,omitempty"`
}

OCIProvisionedConcurrencyConfig stores provisioned concurrency settings for OCI Functions.

func ParseProvisionedConcurrencySpec

func ParseProvisionedConcurrencySpec(spec string) (*OCIProvisionedConcurrencyConfig, error)

ParseProvisionedConcurrencySpec parses a curated provisioned concurrency CLI value. Supported values are:

  • none
  • constant:<count>

type OCIRequestControl

type OCIRequestControl struct {
	IfMatch             string
	WaitForState        string
	MaxWaitSeconds      int
	WaitIntervalSeconds int
}

func ExtractOCIRequestControl

func ExtractOCIRequestControl(c *cli.Context) OCIRequestControl

func (OCIRequestControl) HasIfMatch

func (o OCIRequestControl) HasIfMatch() bool

func (OCIRequestControl) HasWait

func (o OCIRequestControl) HasWait() bool

type OutputMap

type OutputMap struct {
	Body interface{}
}

OutputMap to be used within FFTest.

type ShellCommand

type ShellCommand interface {
	Start() error
	Run() error
	Wait() error
	Kill() error
	SetStdOut(io.Writer)
	SetStdErr(io.Writer)
}

type SigningDetails

type SigningDetails struct {
	ImageCompartmentId string `yaml:"image_compartment_id,omitempty" json:"image_compartment_id,omitempty"`
	KmsKeyId           string `yaml:"kms_key_id,omitempty" json:"kms_key_id,omitempty"`
	KmsKeyVersionId    string `yaml:"kms_key_version_id,omitempty" json:"kms_key_version_id,omitempty"`
	SigningAlgorithm   string `yaml:"signing_algorithm,omitempty" json:"signing_algorithm,omitempty"`
}

SigningDetails defines configuration for signing a function image

type Trigger

type Trigger struct {
	Name   string `yaml:"name,omitempty" json:"name,omitempty"`
	Type   string `yaml:"type,omitempty" json:"type,omitempty"`
	Source string `yaml:"source,omitempty" json:"source,omitempty"`
}

Trigger represents a trigger for a FuncFileV20180708

type VType

type VType int

VType represents the version type

const (
	Patch VType = iota
	Minor
	Major
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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