support

package
v2.0.0-...-98cc131 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

README

Support for TOI Executors

This package provides a generic command line tool support to provide TOI executor CLIs.

Such a CLI wraps an executor specific executor function. If no options are passed it complies to the TOI image binding contract.

For development purposes it can be called with a bunch of option to fake the file system binding and redirect it to explicitly specified files.

It provides a contract to the executor function of type

func(options *ExecutorOptions) error

which already reolves all those dependencies by providing an ExecutorOptions object with the prepared contract data, including access to to the ocm.ComponentVersionAccess of the component version providing the package to work on.

A typical main function of an executor could then look like:

     package main

     import (
        "os"

        "github.com/open-component-model/ocm/v2/pkg/contexts/clictx"

        "yourpackage"
     )

     func main() {
        ctx:=clictx.New()
        // special configuration of the context. e.g. setting a virstual filesystem
        c := support.NewCLICommand(ctx.OCMContext(), "your executor name", yourpackage.ExecutorFunction)
        if err := c.Execute(); err != nil {
            os.Exit(1)
        }
     }
 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCLICommand

func NewCLICommand(ctx ocm.Context, name string, exec func(options *ExecutorOptions) error) *cobra.Command

func NewVersionCommand

func NewVersionCommand() *cobra.Command

Types

type BootstrapperCLIOptions

type BootstrapperCLIOptions struct {
	ExecutorOptions
	logopts.Options
	CredentialSettings []string
	Settings           []string
}

func (*BootstrapperCLIOptions) AddFlags

func (o *BootstrapperCLIOptions) AddFlags(fs *pflag.FlagSet)

func (*BootstrapperCLIOptions) Complete

func (o *BootstrapperCLIOptions) Complete() error

type Executor

type Executor struct {
	Completed bool
	Options   *ExecutorOptions
	Run       func(o *ExecutorOptions) error
}

func (*Executor) Execute

func (e *Executor) Execute() error

type ExecutorOptions

type ExecutorOptions struct {
	Context              ocm.Context
	Logger               logging.Logger
	OutputContext        out.Context
	Action               string
	ComponentVersionName string
	Root                 string
	Inputs               string
	Outputs              string
	OCMConfig            string
	Config               string
	ConfigData           []byte
	Parameters           string
	ParameterData        []byte
	RepoPath             string
	Repository           ocm.Repository
	CredentialRepo       credentials.Repository
	ComponentVersion     ocm.ComponentVersionAccess
	Closer               func() error
}

func (*ExecutorOptions) Complete

func (o *ExecutorOptions) Complete() error

func (*ExecutorOptions) FileSystem

func (o *ExecutorOptions) FileSystem() vfs.FileSystem

Jump to

Keyboard shortcuts

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