install

package
v0.2.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PathTOI         = "/toi"
	Inputs          = "inputs"
	Outputs         = "outputs"
	PathExec        = PathTOI + "/run"
	PathOutputs     = PathTOI + "/" + Outputs
	PathInputs      = PathTOI + "/" + Inputs
	InputParameters = "parameters"
	InputConfig     = "config"
	InputOCMConfig  = "ocmconfig"
	InputOCMRepo    = "ocmrepo"
)
View Source
const (
	TypeTOIPackage               = "toiPackage"
	PackageSpecificationMimeType = "application/vnd.toi.ocm.software.package.v1+yaml"
)
View Source
const (
	TypeTOIExecutor               = "toiExecutor"
	ExecutorSpecificationMimeType = "application/vnd.toi.ocm.software.executor.v1+yaml"
)

Variables

View Source
var ErrUndefined error = errors.New("nil reference")

Functions

func CheckCredentialRequests

func CheckCredentialRequests(executor *Executor, spec *PackageSpecification, espec *ExecutorSpecification) (map[string]CredentialsRequestSpec, map[string]string, error)

CheckCredentialRequests determine required credentials for executor.

func GetCredentials

func GetCredentials(ctx credentials.Context, spec *Credentials, req map[string]CredentialsRequestSpec, mapping map[string]string) (*globalconfig.Config, error)

func GetResource

func GetResource(res ocm.ResourceAccess, target interface{}) error

func ProcessConfig

func ProcessConfig(name string, octx ocm.Context, cv ocm.ComponentVersionAccess, resolver ocm.ComponentVersionResolver, template []byte, config []byte, libraries []metav1.ResourceReference, schemedata []byte) ([]byte, error)

func ValidateByScheme

func ValidateByScheme(src []byte, schemedata []byte) error

Types

type CredentialSpec

type CredentialSpec struct {
	// ConsumerId specifies the consumer id to look for the crentials
	ConsumerId credentials.ConsumerIdentity `json:"consumerId,omitempty"`
	// Reference refers to credentials store in some othe repo
	Reference *cpi.GenericCredentialsSpec `json:"reference,omitempty"`
	// Credentials are direct credentials (one of Reference or Credentials must be set)
	Credentials common.Properties `json:"credentials,omitempty"`

	// TargetConsumerId specifies the consumer id to feed with this crednetials
	TargetConsumerId credentials.ConsumerIdentity `json:"targetConsumerId,omitempty"`
}

type Credentials

type Credentials struct {
	Credentials map[string]CredentialSpec `json:"credentials,omitempty"`
}

func ParseCredentialSpecification

func ParseCredentialSpecification(data []byte, desc string) (*Credentials, error)

type CredentialsRequest

type CredentialsRequest struct {
	Credentials map[string]CredentialsRequestSpec `json:"credentials,omitempty"`
}

func ParseCredentialRequest

func ParseCredentialRequest(data []byte) (*CredentialsRequest, error)

type CredentialsRequestSpec

type CredentialsRequestSpec struct {
	// ConsumerId specified to consumer id the credentials are used for
	ConsumerId credentials.ConsumerIdentity `json:"consumerId,omitempty"`
	// Description described the usecase the credentials will be used for
	Description string `json:"description"`
	// Properties describes the meaning of the used properties for this
	// credential set.
	Properties common.Properties `json:"properties"`
	// Optional set to true make the request optional
	Optional bool `json:"optional,omitempty"`
}

func (*CredentialsRequestSpec) Match

type Driver

type Driver interface {
	SetConfig(props map[string]string) error
	Exec(op *Operation) (*OperationResult, error)
}

type Executor

type Executor struct {
	Actions           []string                  `json:"actions,omitempty"`
	ResourceRef       *metav1.ResourceReference `json:"resourceRef,omitempty"`
	Image             *Image                    `json:"image,omitempty"`
	CredentialMapping map[string]string         `json:"credentialMapping,omitempty"`
	ParameterMapping  json.RawMessage           `json:"parameterMapping,omitempty"`
	Config            json.RawMessage           `json:"config,omitempty"`
	Outputs           map[string]string         `json:"outputs,omitempty"`
}

type ExecutorContext

type ExecutorContext struct {
	Spec  ExecutorSpecification
	Image *Image
	CV    ocm.ComponentVersionAccess
}

func DetermineExecutor

func DetermineExecutor(executor *Executor, octx ocm.Context, cv ocm.ComponentVersionAccess, resolver ocm.ComponentVersionResolver) (*ExecutorContext, error)

type ExecutorSpecification

type ExecutorSpecification struct {
	CredentialsRequest `json:",inline"`
	Actions            []string                   `json:"actions,omitempty"`
	Image              *Image                     `json:"image,omitempty"`
	ImageRef           *metav1.ResourceReference  `json:"imageRef,omitempty"`
	Template           json.RawMessage            `json:"configTemplate,omitempty"`
	Libraries          []metav1.ResourceReference `json:"templateLibraries,omitempty"`
	Scheme             json.RawMessage            `json:"configScheme,omitempty"`
	Outputs            map[string]OutputSpec      `json:"outputs,omitempty"`
}

type Image

type Image struct {
	Ref    string `json:"ref"`
	Digest string `json:"digest"`
}

type Operation

type Operation struct {
	// Action is the action to be performed. It is passed a srgument to the executable
	Action string
	// ComponentVersion is the name of the root component/version to install
	ComponentVersion string
	// Image is the image to invoke
	Image Image
	// Environment contains environment variables that should be injected into the container execution
	Environment map[string]string
	// Files contains files that should be injected into the invocation image.
	Files map[string]accessio.BlobAccess
	// Outputs map of output (sub)paths (e.g. NAME) to the name of the output.
	// Indicates which outputs the driver should return the contents of in the OperationResult.
	Outputs map[string]string
	// Output stream for log messages from the driver
	Out io.Writer
	// Output stream for error messages from the driver
	Err io.Writer
}

Operation describes the data passed into the driver to run an operation.

type OperationResult

type OperationResult struct {
	// Outputs maps from the name of the output to its content.
	Outputs map[string][]byte

	// Error is any errors from executing the operation.
	Error error
}

OperationResult is the output of the Driver running an Operation.

type OutputSpec

type OutputSpec struct {
	Description string `json:"description,omitempty"`
}

type PackageSpecification

type PackageSpecification struct {
	CredentialsRequest `json:",inline"`
	Template           json.RawMessage            `json:"configTemplate,omitempty"`
	Libraries          []metav1.ResourceReference `json:"templateLibraries,omitempty"`
	Scheme             json.RawMessage            `json:"configScheme,omitempty"`
	Executors          []Executor                 `json:"executors"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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