admission

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package admission contains API for writing admission plugins.

Index

Constants

View Source
const ProtocolVersion = 1

ProtocolVersion will change if we have backward-incompatible changes.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, stdin io.ReadCloser, version string, handler Handler) error

Run executes the run loop of an admission plugin.

It connects to the host and starts handling admission checks (each in an individual goroutine) by calling the handler.

Blocks until the stdin closes (which indicates the plugin should terminate).

Types

type Handler

type Handler func(ctx context.Context, req *protocol.Admission, info InstanceInfo) error

Handler handles one admission request.

Called in a separate internal goroutine. It should return a grpc status error. To decide it can use the given `info` to fetch additional data about the package instance.

type InstanceInfo

type InstanceInfo interface {
	// VisitMetadata visits metadata entries attached to the package instance.
	//
	// Either visits all metadata or only entries with requested keys. Visits
	// entries in order of their registration time (the most recent first).
	// Fetches them in pages of `pageSize`. If `pageSize` is negative or zero,
	// uses some default size.
	//
	// Calls `cb` for each visited entry until all entries are successfully
	// visited or the callback returns false. Returns an error if the RPC to
	// the CIPD backend fails.
	VisitMetadata(ctx context.Context, keys []string, pageSize int, cb func(md *api.InstanceMetadata) bool) error
}

InstanceInfo fetches additional information about a package instance being checked for admission by the handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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