sdk

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromConfig

func FromConfig(data Configuration, v any) error

Types

type AttachmentRequest

type AttachmentRequest struct {
	Payload          Configuration
	RegistrationInfo *RegistrationResponse
}

type AttachmentResponse

type AttachmentResponse struct {
	// JSON serializable configuration to be persisted
	Configuration
}

type AvailableExtensions

type AvailableExtensions []FanOut

List of loaded integrations

func (AvailableExtensions) FindByID

func (i AvailableExtensions) FindByID(id string) (FanOut, error)

FindByID returns the integration with the given ID from the list of available integrations If not found, an error is returned

type ChainloopMetadata

type ChainloopMetadata struct {
	WorkflowID      string
	WorkflowName    string
	WorkflowProject string

	WorkflowRunID string
}

type Configuration

type Configuration []byte

Configuration represents any raw configuration to be stored in the DB This wrapper is just a way to clearly indicate that the content needs to be JSON serializable

func ToConfig

func ToConfig(m any) (Configuration, error)

type Core

type Core interface {
	fmt.Stringer
	// Return information about the integration
	Describe() *IntegrationInfo
	ValidateRegistrationRequest(jsonPayload []byte) error
	ValidateAttachmentRequest(jsonPayload []byte) error
}

Implemented by the core struct

type Credentials

type Credentials struct {
	URL, Username, Password string
}

type ExecuteAttestation

type ExecuteAttestation struct {
	Envelope  *dsse.Envelope
	Statement *in_toto.Statement
	Predicate chainloop.NormalizablePredicate
}

type ExecuteInput

type ExecuteInput struct {
	Attestation *ExecuteAttestation
	Material    *ExecuteMaterial
}

An execute method will receive either the envelope or a material as input The material will contain its content as well as the metadata

type ExecuteMaterial

type ExecuteMaterial struct {
	*chainloop.NormalizedMaterial
	// Content of the material already downloaded
	Content []byte
}

type ExecutionRequest

type ExecutionRequest struct {
	*ChainloopMetadata
	Input            *ExecuteInput
	RegistrationInfo *RegistrationResponse
	AttachmentInfo   *AttachmentResponse
}

ExecutionRequest is the request to execute the integration

type FanOut

type FanOut interface {
	// Implemented by the fanout base
	Core
	// To be implemented per integration
	FanOutExtension
}

Interface required to be implemented by any integration

type FanOutExtension

type FanOutExtension interface {
	// Validate, marshall and return the configuration that needs to be persisted
	Register(ctx context.Context, req *RegistrationRequest) (*RegistrationResponse, error)
	// Validate that the attachment configuration is valid in the context of the provided registration
	Attach(ctx context.Context, req *AttachmentRequest) (*AttachmentResponse, error)
	// Execute the integration
	Execute(ctx context.Context, req *ExecutionRequest) error
}

To be implemented per integration

type FanOutFactory

type FanOutFactory = func(l log.Logger) (FanOut, error)

type FanOutIntegration

type FanOutIntegration struct {
	Logger *log.Helper
	// contains filtered or unexported fields
}

FanOutIntegration represents an extension point for integrations to be able to fanOut subscribed inputs

func NewFanOut

func NewFanOut(p *NewParams, opts ...NewOpt) (*FanOutIntegration, error)

func (*FanOutIntegration) Describe

func (i *FanOutIntegration) Describe() *IntegrationInfo

func (*FanOutIntegration) String

func (i *FanOutIntegration) String() string

func (*FanOutIntegration) ValidateAttachmentRequest

func (i *FanOutIntegration) ValidateAttachmentRequest(jsonPayload []byte) error

Validate the attachment payload against the attachment JSON schema

func (*FanOutIntegration) ValidateRegistrationRequest

func (i *FanOutIntegration) ValidateRegistrationRequest(jsonPayload []byte) error

Validate the registration payload against the registration JSON schema

type InputMaterial

type InputMaterial struct {
	// Name of the material kind that the integration expects
	Type schemaapi.CraftingSchema_Material_MaterialType
}

type InputSchema

type InputSchema struct {
	// Structs defining the registration and attachment schemas
	Registration, Attachment any
}

type Inputs

type Inputs struct {
	DSSEnvelope bool
	Materials   []*InputMaterial
}

An integration can be subscribed to an envelope and/or a list of materials To subscribe to any material type it will use schemaapi.CraftingSchema_Material_MATERIAL_TYPE_UNSPECIFIED

type IntegrationInfo

type IntegrationInfo struct {
	// Identifier of the integration
	ID string
	// Integration version
	Version string
	// Integration description
	Description string
	// Kind of inputs does the integration expect as part of the execution
	SubscribedInputs *Inputs
	// Schemas in JSON schema format
	RegistrationJSONSchema, AttachmentJSONSchema []byte
}

type NewOpt

type NewOpt func(*FanOutIntegration)

func WithEnvelope

func WithEnvelope() NewOpt

func WithInputMaterial

func WithInputMaterial(materialType schemaapi.CraftingSchema_Material_MaterialType) NewOpt

type NewParams

type NewParams struct {
	ID, Version, Description string
	Logger                   log.Logger
	InputSchema              *InputSchema
}

type RegistrationRequest

type RegistrationRequest struct {
	// Custom Payload to be used by the integration
	Payload Configuration
}

type RegistrationResponse

type RegistrationResponse struct {
	// Credentials to be persisted in Credentials Manager
	// JSON serializable
	Credentials *Credentials
	// Configuration to be persisted in DB
	Configuration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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