rest

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package rest provides methods and functions to communicate with the MarbleRun Coordinator using its REST API.

Index

Constants

View Source
const (
	ManifestEndpoint     = "manifest"
	UpdateEndpoint       = "update"
	UpdateCancelEndpoint = "update-cancel"
	UpdateStatusEndpoint = "update-manifest"
	RecoverEndpoint      = "recover"
	SecretEndpoint       = "secrets"
	StatusEndpoint       = "status"
	ContentJSON          = "application/json"
	ContentPlain         = "text/plain"
)

Endpoints of the MarbleRun Coordinator REST API.

Variables

This section is empty.

Functions

func LoadClientCert added in v1.4.0

func LoadClientCert(flags *pflag.FlagSet) (*tls.Certificate, error)

LoadClientCert parses the command line flags to load a TLS client certificate.

func LoadCoordinatorCachedCert added in v1.4.0

func LoadCoordinatorCachedCert(flags *pflag.FlagSet, fs afero.Fs) (caCert []*pem.Block, err error)

LoadCoordinatorCachedCert loads a cached Coordinator certificate.

func SaveCoordinatorCachedCert added in v1.4.0

func SaveCoordinatorCachedCert(flags *pflag.FlagSet, fs afero.Fs, caCert []*pem.Block) error

SaveCoordinatorCachedCert saves the Coordinator's certificate to a cert cache.

func VerifyCoordinator

func VerifyCoordinator(
	ctx context.Context, out io.Writer, host, configFilename, k8sNamespace string,
	insecure bool, acceptedTCBStatuses []string,
) ([]*pem.Block, error)

VerifyCoordinator verifies the connection to the MarbleRun Coordinator.

Types

type Client

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

Client is a REST client for the MarbleRun Coordinator.

func NewClient

func NewClient(host string, caCert []*pem.Block, clientCert *tls.Certificate, insecureTLS bool) (*Client, error)

NewClient creates and returns an http client using the given certificate of the server. An optional clientCert can be used to enable client authentication.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, body io.Reader, queryParameters ...string) ([]byte, error)

Get sends a GET request to the Coordinator under the specified path. If body is non nil, it is sent as the request body. Query parameters can be provided as a list of strings, where each pair of strings is a key-value pair. On success, the data field of the JSON response is returned.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path, contentType string, body io.Reader) ([]byte, error)

Post sends a POST request to the Coordinator under the specified path. Optionally, a body can be provided.

Jump to

Keyboard shortcuts

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