ppi

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package ppi provides the plugin programming interface. The ppi can be used by plugin developers as support. It reduces the command line interface to a corresponding Go interface. In other words, if the developer implements this Go plugin interface, the ppi automatically provides a corresponding command line interface.

Index

Constants

View Source
const (
	OptPluginConfig     = "config"
	OptPlugingLogConfig = "log-config"
)

Variables

Functions

This section is empty.

Types

type AccessMethod

type AccessMethod interface {
	runtime.TypedObjectDecoder[AccessSpec]

	Name() string
	Version() string

	// Options provides the list of CLI options supported to compose the access
	// specification.
	Options() []options.OptionType

	// Description provides a general description for the access mehod kind.
	Description() string
	// Format describes the attributes of the dedicated version.
	Format() string

	ValidateSpecification(p Plugin, spec AccessSpec) (info *AccessSpecInfo, err error)
	Reader(p Plugin, spec AccessSpec, creds credentials.Credentials) (io.ReadCloser, error)
	ComposeAccessSpecification(p Plugin, opts Config, config Config) error
}

type AccessMethodBase

type AccessMethodBase struct {
	// contains filtered or unexported fields
}

func MustNewAccessMethodBase

func MustNewAccessMethodBase(name, version string, proto AccessSpec, desc string, format string) AccessMethodBase

func (*AccessMethodBase) Description

func (b *AccessMethodBase) Description() string

func (*AccessMethodBase) Format

func (b *AccessMethodBase) Format() string

func (*AccessMethodBase) Name

func (b *AccessMethodBase) Name() string

func (*AccessMethodBase) Version

func (b *AccessMethodBase) Version() string

type AccessMethodDescriptor

type AccessMethodDescriptor = descriptor.AccessMethodDescriptor

type AccessSpec

type AccessSpec = runtime.TypedObject

type AccessSpecInfo

type AccessSpecInfo = internal.AccessSpecInfo

type AccessSpecProvider

type AccessSpecProvider func() AccessSpec

type Action added in v0.3.0

type Action interface {
	Name() string
	Description() string
	DefaultSelectors() []string
	ConsumerType() string

	Execute(p Plugin, spec ActionSpec, creds credentials.DirectCredentials) (result ActionResult, err error)
}

type ActionResult added in v0.3.0

type ActionResult = action.ActionResult

type ActionSpec added in v0.3.0

type ActionSpec = action.ActionSpec

type ActionSpecInfo added in v0.3.0

type ActionSpecInfo = internal.ActionSpecInfo

type CLIOption

type CLIOption = descriptor.CLIOption

type Command added in v0.12.0

type Command interface {
	// Name of command used in the plugin.
	// This is also the default object type and is used to
	// name top-level commands in the CLI.
	Name() string
	Description() string
	Usage() string
	Short() string
	Example() string
	// ObjectType is optional and can be used
	// together with a verb. It then is used as
	// sub command name for the object type.
	// By default, the command name is used.
	ObjectType() string
	// Verb is optional and can be set
	// to place the command in the verb hierarchy of
	// the OCM CLI. It is used together with the ObjectType.
	// (command will be *ocm <verb> <object type>*.
	Verb() string
	// Realm is optional and is used to place the command
	// in a realm. This requires a verb.
	Realm() string
	CLIConfigRequired() bool

	Command() *cobra.Command
}

Command is the interface for a CLI command provided by a plugin.

type Config

type Config map[string]interface{}

Config is a generic structured config stored in a string map.

func (Config) ConvertFor added in v0.4.1

func (c Config) ConvertFor(list ...options.OptionType) error

func (Config) GetValue

func (c Config) GetValue(name string) (interface{}, bool)

type Descriptor

type Descriptor = descriptor.Descriptor

type DownloadResultProvider

type DownloadResultProvider func() (string, error)

type Downloader

type Downloader interface {
	Name() string
	Description() string
	ConfigSchema() []byte

	Writer(p Plugin, arttype, mediatype string, filepath string, config []byte) (io.WriteCloser, DownloadResultProvider, error)
}

type DownloaderDescriptor

type DownloaderDescriptor = descriptor.DownloaderDescriptor

type DownloaderKey

type DownloaderKey = descriptor.DownloaderKey

type Options

type Options struct {
	Config    json.RawMessage
	LogConfig json.RawMessage
}

func (*Options) AddFlags

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

type Plugin

type Plugin interface {
	Name() string
	Version() string
	Descriptor() descriptor.Descriptor

	SetDescriptorTweaker(func(descriptor descriptor.Descriptor) descriptor.Descriptor)

	SetShort(s string)
	SetLong(s string)
	SetConfigParser(config func(raw json.RawMessage) (interface{}, error))
	ForwardLogging(b ...bool)

	RegisterDownloader(arttype, mediatype string, u Downloader) error
	GetDownloader(name string) Downloader
	GetDownloaderFor(arttype, mediatype string) Downloader

	RegisterUploader(arttype, mediatype string, u Uploader) error
	GetUploader(name string) Uploader
	GetUploaderFor(arttype, mediatype string) Uploader
	DecodeUploadTargetSpecification(data []byte) (UploadTargetSpec, error)

	RegisterAccessMethod(m AccessMethod) error
	DecodeAccessSpecification(data []byte) (AccessSpec, error)
	GetAccessMethod(name string, version string) AccessMethod

	RegisterAction(a Action) error
	DecodeAction(data []byte) (ActionSpec, error)
	GetAction(name string) Action

	RegisterValueMergeHandler(h ValueMergeHandler) error
	GetValueMergeHandler(name string) ValueMergeHandler

	RegisterValueSet(h ValueSet) error
	DecodeValueSet(purpose string, data []byte) (runtime.TypedObject, error)
	GetValueSet(purpose, name, version string) ValueSet

	RegisterCommand(c Command) error
	GetCommand(name string) Command
	Commands() []Command

	RegisterConfigType(c cpi.ConfigType) error
	GetConfigType(name string) *descriptor.ConfigTypeDescriptor
	ConfigTypes() []descriptor.ConfigTypeDescriptor

	GetOptions() *Options
	GetConfig() (interface{}, error)
}

func NewPlugin

func NewPlugin(name string, version string) Plugin

type UploadTargetSpec

type UploadTargetSpec = runtime.TypedObject

type UploadTargetSpecInfo

type UploadTargetSpecInfo = internal.UploadTargetSpecInfo

type Uploader

type Uploader interface {
	Decoders() UploadFormats

	Name() string
	Description() string

	ValidateSpecification(p Plugin, spec UploadTargetSpec) (info *UploadTargetSpecInfo, err error)
	Writer(p Plugin, arttype, mediatype string, hint string, spec UploadTargetSpec, creds credentials.Credentials) (io.WriteCloser, AccessSpecProvider, error)
}

type UploaderBase

type UploaderBase = nameDescription

func MustNewUploaderBase

func MustNewUploaderBase(name, desc string) UploaderBase

type UploaderDescriptor

type UploaderDescriptor = descriptor.UploaderDescriptor

type UploaderKey

type UploaderKey = descriptor.UploaderKey

type Value added in v0.4.1

type Value = runtime.RawValue

type ValueMergeData added in v0.4.1

type ValueMergeData struct {
	Local   Value `json:"local"`
	Inbound Value `json:"inbound"`
}

type ValueMergeHandler added in v0.4.1

type ValueMergeHandler interface {
	Name() string
	Description() string

	Execute(p Plugin, local Value, inbound Value, config json.RawMessage) (result ValueMergeResult, err error)
}

type ValueMergeResult added in v0.4.1

type ValueMergeResult struct {
	Modified bool   `json:"modified"`
	Value    Value  `json:"value"`
	Message  string `json:"message,omitempty"`
}

type ValueSet added in v0.4.1

type ValueSet interface {
	runtime.TypedObjectDecoder[AccessSpec]

	Name() string
	Version() string

	// Purposes describes the purposes the set should be ued for.
	// So far, only the purpose PURPOSE_ROUTINGSLIP is defined.
	Purposes() []string

	// Options provides the list of CLI options supported to compose the access
	// specification.
	Options() []options.OptionType

	// Description provides a general description for the access mehod kind.
	Description() string
	// Format describes the attributes of the dedicated version.
	Format() string

	ValidateSpecification(p Plugin, spec runtime.TypedObject) (info *ValueSetInfo, err error)
	ComposeSpecification(p Plugin, opts Config, config Config) error
}

type ValueSetBase added in v0.4.1

type ValueSetBase struct {
	// contains filtered or unexported fields
}

func MustNewValueSetBase added in v0.4.1

func MustNewValueSetBase(name, version string, proto runtime.TypedObject, purposes []string, desc string, format string) ValueSetBase

func (*ValueSetBase) Description added in v0.4.1

func (b *ValueSetBase) Description() string

func (*ValueSetBase) Format added in v0.4.1

func (b *ValueSetBase) Format() string

func (*ValueSetBase) Name added in v0.4.1

func (b *ValueSetBase) Name() string

func (*ValueSetBase) Purposes added in v0.4.1

func (b *ValueSetBase) Purposes() []string

func (*ValueSetBase) Version added in v0.4.1

func (b *ValueSetBase) Version() string

type ValueSetInfo added in v0.4.1

type ValueSetInfo = internal.ValueSetInfo

Directories

Path Synopsis
doc
The config package can be used if the plugin should provide the ocm configuration from the calling OCM library.
The config package can be used if the plugin should provide the ocm configuration from the calling OCM library.
The logging package can be used if the plugin should handle the ocm logging configuration from the calling OCM library.
The logging package can be used if the plugin should handle the ocm logging configuration from the calling OCM library.

Jump to

Keyboard shortcuts

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