app

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const ResourceTypePattern = `^[A-Za-z_][A-Za-z0-9_]*$`

Variables

View Source
var GenericEmptySchema []byte

Functions

This section is empty.

Types

type ActionDefinition

type ActionDefinition struct {
	// Name is the unique identifier for the action.
	Name string
	// DisplayName is the name of the action as it should be displayed in the UI.
	DisplayName string
	// Description is a short description of the action.
	Description string
	// InputSchema is the parsed JSON schema for the input schema.
	InputSchema *JSONSchema
	// OutputSchema is the parsed JSON schema for the output schema.
	OutputSchema *JSONSchema
	// Handler is the function that will be called when the action is invoked.
	Handler func(context.Context, *ActionRequest) (*ActionResponse, error)
}

type ActionRequest

type ActionRequest struct {
	// Metadata contains information about the Project and User making the request.
	// This metadata does not contain information about the Resource being operated on.
	Metadata *Metadata
	// Resource is the resource being actioned, and contains the ExternalID of the resource,
	// as well as the properties at the time of the request.
	Resource *Resource
	// Action is the name of the action being performed.
	Action string
	// Input contains the input data for the request, after it has been validated against the schema.
	// Default values have already been applied to missing input properties.
	Input map[string]any
	// Environment contains the environment variables that are available to the operation.
	Environment map[string]EnvironmentVariable
}

ActionRequest contains the input data for an operation on a resource.

type ActionResponse

type ActionResponse struct {
	// Output contains the output data for the request. This data must validate against the output schema.
	Output map[string]any
}

type AppOption

type AppOption func(*appOptions)

func WithResourceDefinition

func WithResourceDefinition(rd ResourceDefinition) AppOption

func WithResourceDefinitions

func WithResourceDefinitions(rds ...ResourceDefinition) AppOption

type EnvironmentVariable added in v0.1.2

type EnvironmentVariable struct {
	Key   string
	Value string
	Type  EnvironmentVariableType
}

type EnvironmentVariableType added in v0.1.2

type EnvironmentVariableType string
const (
	ENVIRONMENT_VARIABLE_TYPE_VAR         EnvironmentVariableType = "variable"
	ENVIRONMENT_VARIABLE_TYPE_SECRET      EnvironmentVariableType = "secret"
	ENVIRONMENT_VARIABLE_TYPE_CERTIFICATE EnvironmentVariableType = "certificate"
	ENVIRONMENT_VARIABLE_TYPE_PRIVATE_KEY EnvironmentVariableType = "private_key"
	ENVIRONMENT_VARIABLE_TYPE_PUBLIC_KEY  EnvironmentVariableType = "public_key"
)

type HealthCheckFunc

type HealthCheckFunc func(context.Context) (*HealthCheckResponse, error)

type HealthCheckResponse

type HealthCheckResponse struct {
	Status  HealthCheckStatus
	Message string
}

type HealthCheckStatus

type HealthCheckStatus int
const (
	HealthCheckStatusUnknown   HealthCheckStatus = iota // unknown
	HealthCheckStatusHealthy                            // healthy
	HealthCheckStatusDegraded                           // degraded
	HealthCheckStatusDisrupted                          // disrupted
)

func (HealthCheckStatus) String

func (i HealthCheckStatus) String() string

type JSONSchema

type JSONSchema struct {
	*jsonschema.Schema
	// contains filtered or unexported fields
}

func MustParseJSONSchema

func MustParseJSONSchema(schema []byte) *JSONSchema

MustParseJSONSchema parses a JSON schema and returns a JSONSchema object. It will panic if the schema cannot be parsed.

func ParseJSONSchema

func ParseJSONSchema(schema []byte) (*JSONSchema, error)

ParseJSONSchema parses a JSON schema and returns a JSONSchema object. The schema is compiled with annotations extraction enabled.

type LifecycleStage

type LifecycleStage int

Represents a stage in the Developer Journey lifecycle.

const (
	LifecycleStageCode    LifecycleStage = iota + 1 // code
	LifecycleStageBuild                             // build
	LifecycleStageTest                              // test
	LifecycleStageRelease                           // release
	LifecycleStageDeploy                            // deploy
	LifecycleStageOperate                           // operate
	LifecycleStageMonitor                           // monitor
	LifecycleStageOther                             // other
)

func (LifecycleStage) String

func (i LifecycleStage) String() string
type Link struct {
	URL   string
	Title string
	Type  LinkType
}

type LinkType

type LinkType int
const (
	LinkTypeUnspecified    LinkType = iota // unspecified
	LinkTypeDocumentation                  // documentation
	LinkTypeAdministration                 // administration
	LinkTypeSupport                        // support
	LinkTypeEndpoint                       // endpoint
	LinkTypeExternal                       // external
)

func (LinkType) String

func (i LinkType) String() string

type ListFunc

type ListFunc func(context.Context, *ListRequest) (*ListResponse, error)

type ListRequest

type ListRequest struct {
	// Metadata contains information about the Project and User making the request.
	// This metadata does not contain information about the Resource being operated on.
	Metadata *Metadata
	// Resource is the resource being listed, and contains at least the Resource Type.
	Resource *Resource
	// Next is a token that can be used to fetch the next page of results.
	Next string
}

ListRequest contains the input data for listing resources.

type ListResponse

type ListResponse struct {
	Resources []*Resource
	// Next is a token that can be used to fetch the next page of results.
	Next string
}

ListResponse contains the output data for listing resources.

type Metadata

type Metadata struct {
	// ProjectID is the ID of the Tempest Project. This guaranteed to be unique.
	ProjectID string
	// ProjectName is the user defined name of the Tempest Project.
	ProjectName string
	// Owners are the user(s) who created or own the Project.
	Owners []Owner
	// Author is the user or team who created the Project.
	Author Owner
}

type OperationRequest

type OperationRequest struct {
	// Metadata contains information about the Project and User making the request.
	// This metadata does not contain information about the Resource being operated on.
	Metadata *Metadata
	// Resource is the resource being operated on, and contains the ExternalID of the resource,
	// as well as the properties at the time of the request.
	Resource *Resource
	// Input contains the input data for the request, after it has been validated against the schema.
	// Default values have already been applied to missing input properties.
	Input map[string]any
	// Environment contains the environment variables that are available to the operation.
	Environment map[string]EnvironmentVariable
}

OperationRequest contains the input data for an operation on a resource.

type OperationResponse

type OperationResponse struct {
	// Resource contains the properties of the resource after the operation has been performed.
	Resource *Resource
}

OperationResponse contains the output data for an operation on a resource.

type Owner

type Owner struct {
	Email string
	Name  string
	Type  OwnerType
}

type OwnerType

type OwnerType string
const (
	OwnerTypeUser OwnerType = "user"
	OwnerTypeTeam OwnerType = "team"
)

type Resource

type Resource struct {
	// ExternalID is the unique identifier for the resource in the external system.
	ExternalID string
	// DisplayName represents the human-readable name of the resource, to be displayed in the Tempest UI.
	DisplayName string
	// Type is the name of the ResourceDefinition that this resource is an instance of.
	Type string
	// Links are resource-specific links that can help users understand how to use this Resource.
	// A good example of a link is a LinkTypeExternal with a URL to the external system's UI for this resource.
	Links []*Link
	// Properties contains the properties of the resource. These properties are validated against the resource Properties schema.
	Properties map[string]any
}

type ResourceDefinition

type ResourceDefinition struct {
	// The type by which this resource is identified. Must match `ResourceTypePattern`.
	Type string
	// The display name of the type for Tempest to show in the UI.
	DisplayName string
	// A description of the Resource type.
	Description string
	// PropertiesSchema is the parsed JSON schema for the Properties.
	PropertiesSchema *JSONSchema
	// LifecycleStage represents how the Resource fits in the Developer Journey.
	LifecycleStage LifecycleStage
	// Links are links to documentation or other resources that can help users
	// understand how to use this Resource.
	Links []Link
	// Markdown formatted instructions for setting up or using the resource.
	// This field supports resource property variables in the format of {{ resource.<property name> }}.
	InstructionsMarkdown string
	// contains filtered or unexported fields
}

ResourceDefinition represents a type of resource that can be managed by Tempest.

func (*ResourceDefinition) AddActionDefinition

func (rd *ResourceDefinition) AddActionDefinition(ad ActionDefinition)

func (*ResourceDefinition) CreateFn

func (rd *ResourceDefinition) CreateFn(fn OperationFunc, inputSchema *JSONSchema)

CreateFn adds a Create operation Handler to the ResourceDefinition.

Tempest will use the inputSchema to validate the input data before calling the Handler. The Handler should create the resource in the external system and return the resource's ExternalID and properties. See the Create operation in the Printer example for an example implementation.

func (*ResourceDefinition) DeleteFn

func (rd *ResourceDefinition) DeleteFn(fn OperationFunc)

DeleteFn adds a Delete operation Handler to the ResourceDefinition.

The Handler should delete the resource in the external system. See the Delete operation in the Printer example for an example implementation.

func (*ResourceDefinition) HealthCheckFn

func (rd *ResourceDefinition) HealthCheckFn(fn HealthCheckFunc)

HealthCheckFn adds a HealthCheck Handler to the ResourceDefinition.

The Handler should return the provisioning health of the resource.

func (*ResourceDefinition) ListFn

func (rd *ResourceDefinition) ListFn(fn ListFunc)

ListFn adds a List Handler to the ResourceDefinition. The output will be validated against the ResourceDefinition's Properties schema.

The Handler should query the external system for all resources of this type and return them. See the List operation in the Printer example for an example implementation.

func (*ResourceDefinition) ReadFn

func (rd *ResourceDefinition) ReadFn(fn OperationFunc)

ReadFn adds a Read Operation to the ResourceDefinition.

The Handler should query the external system for the resource's current state and return it. See the Read operation in the Printer example for an example implementation.

func (*ResourceDefinition) UpdateFn

func (rd *ResourceDefinition) UpdateFn(fn OperationFunc, inputSchema *JSONSchema)

UpdateFn adds an Update operation Handler to the ResourceDefinition.

Tempest will use the inputSchema to validate the input data before calling the Handler. The Handler should update the resource in the external system and return the updated resource's properties. See the Update operation in the Printer example for an example implementation.

type TempestSchemaLoader added in v0.1.5

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

func NewTempestSchemaLoader added in v0.1.5

func NewTempestSchemaLoader() *TempestSchemaLoader

func (*TempestSchemaLoader) Load added in v0.1.5

func (l *TempestSchemaLoader) Load(location string) (any, error)

Jump to

Keyboard shortcuts

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