sdk

package
v0.85.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePropertiesMap

func CalculatePropertiesMap(s *schema_validator.Schema, m *SchemaPropertiesMap) error

Denormalize the properties of a json schema

func CompileJSONSchema

func CompileJSONSchema(in []byte) (*schema_validator.Schema, error)

func FromConfig

func FromConfig(data Configuration, v any) error

func SummaryTable added in v0.14.0

func SummaryTable(req *ExecutionRequest, opts ...RenderOpt) (string, error)

Types

type AttachmentRequest

type AttachmentRequest struct {
	Payload          Configuration
	RegistrationInfo *RegistrationResponse
}

type AttachmentResponse

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

type AvailablePlugins

type AvailablePlugins []*FanOutP

List of loaded integrations

func (AvailablePlugins) Cleanup added in v0.13.0

func (i AvailablePlugins) Cleanup()

func (AvailablePlugins) FindByID

func (i AvailablePlugins) 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 {
	Workflow    *ChainloopMetadataWorkflow
	WorkflowRun *ChainloopMetadataWorkflowRun
}

type ChainloopMetadataWorkflow added in v0.14.0

type ChainloopMetadataWorkflow struct {
	ID, Name, Team, Project string
}

type ChainloopMetadataWorkflowRun added in v0.14.0

type ChainloopMetadataWorkflowRun struct {
	ID                string
	State             string
	StartedAt         time.Time
	FinishedAt        time.Time
	RunnerType        string
	RunURL            string
	AttestationDigest 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
	// Return if the integration is subscribed to the material type
	IsSubscribedTo(materialType string) bool
}

Implemented by the core struct

type Credentials

type Credentials struct {
	URL, Username, Password string
}

type ExecuteAttestation

type ExecuteAttestation struct {
	Envelope *dsse.Envelope
	// Hash of the envelope
	Hash      crv1.Hash
	Statement *intoto.Statement
	Predicate chainloop.NormalizablePredicate
}

type ExecuteInput

type ExecuteInput struct {
	Attestation *ExecuteAttestation
	Materials   []*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
	FanOutPlugin
}

Interface required to be implemented by any 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 plugin 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) IsSubscribedTo

func (i *FanOutIntegration) IsSubscribedTo(m string) bool

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 FanOutP added in v0.13.0

type FanOutP struct {
	FanOut
	DisposeFunc func()
}

type FanOutPlugin

type FanOutPlugin 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 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 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
	SubscribedMaterials []*InputMaterial
	// Schemas in JSON schema format
	RegistrationJSONSchema, AttachmentJSONSchema []byte
}

type NewOpt

type NewOpt func(*FanOutIntegration)

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
}

type RenderOpt added in v0.14.0

type RenderOpt func(r *renderer) error

func WithFormat added in v0.14.0

func WithFormat(format string) RenderOpt

func WithMaxSize added in v0.16.0

func WithMaxSize(max int) RenderOpt

type SchemaPropertiesMap

type SchemaPropertiesMap map[string]*SchemaProperty

type SchemaProperty

type SchemaProperty struct {
	// Name of the property
	Name string
	// optional description
	Description string
	// Type of the property (string, boolean, number)
	Type string
	// If the property is required
	Required bool
	// Optional format (email, host)
	Format string
}

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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