scripting

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PythonContainerName = "chapar-python-executor"
	PythonExecutorName  = "Python"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerClient

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

DockerClient wraps the Docker SDK client

func NewDockerClient

func NewDockerClient() (*DockerClient, error)

NewDockerClient creates a new Docker client

func (*DockerClient) Close

func (dc *DockerClient) Close() error

Close closes the Docker client

type ExecParams

type ExecParams struct {
	Req *RequestData
	Res *ResponseData
	Env *domain.Environment
}

type ExecResult

type ExecResult struct {
	Req             *RequestData           `json:"-"`
	SetEnvironments map[string]interface{} `json:"set_environments"`
	Prints          []string               `json:"prints"`
}

type Executor

type Executor interface {
	Init(cfg domain.ScriptingConfig) error
	Execute(ctx context.Context, script string, params *ExecParams) (*ExecResult, error)
	Name() string
	Shutdown() error
}

func GetExecutor

func GetExecutor(language string, cfg domain.ScriptingConfig) (Executor, error)

type PythonExecutor

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

func NewPythonExecutor

func NewPythonExecutor(cfg domain.ScriptingConfig) *PythonExecutor

func (*PythonExecutor) Execute

func (p *PythonExecutor) Execute(ctx context.Context, script string, params *ExecParams) (*ExecResult, error)

func (*PythonExecutor) Init

func (*PythonExecutor) Name

func (p *PythonExecutor) Name() string

func (*PythonExecutor) Shutdown

func (p *PythonExecutor) Shutdown() error

type RequestData

type RequestData struct {
	// Body is the request body
	Body string `json:"body"`
	// when grpc is used, this field in the grpc method name otherwise it is the http method
	Method string `json:"method"`

	// URL is the request URL in case of grpc it is the server address
	URL string `json:"url"`

	// GRPC related fields
	Metadata map[string]string `json:"metadata"`

	// HTTP related fields
	Headers     map[string]string `json:"headers"`
	QueryParams map[string]string `json:"QueryParams"`
	PathParams  map[string]string `json:"pathParams"`
}

RequestData represents the HTTP request data that can be modified by scripts

func RequestDataFromDomain

func RequestDataFromDomain(req *domain.Request) *RequestData

type ResponseData

type ResponseData struct {
	StatusCode int               `json:"statusCode"`
	Headers    map[string]string `json:"headers"`
	Body       string            `json:"body"`
}

ResponseData represents the HTTP response data that can be accessed by scripts

Jump to

Keyboard shortcuts

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