requests

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Args      []string
	Dir       string
	IsTesting bool
}

type Engine

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

Engine is responsible for storing all the templates, validating incoming requests, serving OpenAPI specifications, and running worker cue-based workflows

func Load

func Load(config *Config) (*Engine, error)

func (*Engine) GetWorkflowsForRequest

func (e *Engine) GetWorkflowsForRequest(req *oapi.Request) ([]cue.Path, error)

func (*Engine) OpenAPISpec

func (e *Engine) OpenAPISpec(kind string) ([]byte, error)

OpenAPISpec takes a Request Template kind and returns an OpenAPI JSON specification for it. If the Request Template kind does not exist, or there's an error generating the OpenAPI spec, an error is returned.

There are little options to filter which Request Types should be included in the OpenAPI specification. What happens here is that an empty cue Instance is built and the specific Request Template is programmtically filled in to the empty instance

func (*Engine) RunTests

func (e *Engine) RunTests(config *TestConfig) (*TestResult, error)

func (*Engine) RunWorkflow

func (e *Engine) RunWorkflow(wfPath cue.Path, req *oapi.Request) (cue.Value, error)

RunWorkflow takes a cue path to a workflow and a request and runs the workflow at the given path, replacing the input with the spec from the given request

func (*Engine) TemplatesForService

func (e *Engine) TemplatesForService(service *oapi.Service) []*Template

func (*Engine) ValidateRequest

func (e *Engine) ValidateRequest(body io.Reader) (*oapi.NewRequest, error)

type MatchLabels

type MatchLabels map[string]string

type ServiceSelector

type ServiceSelector struct {
	MatchLabels MatchLabels `json:"matchLabels"`
}

type Template

type Template struct {
	Def   TemplateDef
	Value cue.Value
}

type TemplateDef

type TemplateDef struct {
	Kind            string          `json:"kind"`
	ServiceSelector ServiceSelector `json:"serviceSelector"`
}

TemplateDef defines the fields of a CUE-based Template for decoding and identifying which definitions in CUE are Request Templates

type TestCase

type TestCase struct {
	Path   cue.Path
	Msg    string
	Pass   bool
	Output cue.Value
}

func (*TestCase) Fail

func (tc *TestCase) Fail(msg string)

func (*TestCase) Failf

func (tc *TestCase) Failf(format string, args ...any)

type TestConfig

type TestConfig struct {
	Filter string
}

type TestResult

type TestResult struct {
	Tests []*TestCase
}

func (*TestResult) Print

func (t *TestResult) Print(verbose bool)

func (*TestResult) Run

func (t *TestResult) Run(path cue.Path, f func(t *TestCase))

Jump to

Keyboard shortcuts

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