validator

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const V1 = "application/vnd.drone.validate.v1+json"

V1 is version 1 of the validator API

Variables

View Source
var ErrBlock = errors.New("block")

ErrBlock is returned when the build should be blocked instead of throwing an error.

View Source
var ErrSkip = errors.New("skip")

ErrSkip is returned when the build should be skipped instead of throwing an error.

Functions

func Handler

func Handler(secret string, plugin Plugin, logs logger.Logger) http.Handler

Handler returns a http.Handler that accepts JSON-encoded HTTP requests to validate the yaml configuration, invokes the underlying plugin. A 2xx status code is returned if the configuration file is valid.

The handler verifies the authenticity of the HTTP request using the http-signature, and returns a 400 Bad Request if the signature is missing or invalid.

The handler can optionally encrypt the response body using aesgcm if the HTTP request includes the Accept-Encoding header set to aesgcm.

Types

type Plugin

type Plugin interface {
	Validate(context.Context, *Request) error
}

Plugin responds to a validator request.

func Client

func Client(endpoint, secret string, skipverify bool) Plugin

Client returns a new plugin client.

type Request

type Request struct {
	Build  drone.Build  `json:"build,omitempty"`
	Config drone.Config `json:"config,omitempty"`
	Repo   drone.Repo   `json:"repo,omitempty"`
	Token  drone.Token  `json:"token,omitempty"` // not implemented
}

Request defines a validator request.

Jump to

Keyboard shortcuts

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