client

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package client connects to the Epinio API's endpoints

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v1.9.0

func Delete[T any](c *Client, endpoint string, request any, response T) (T, error)

func Do added in v1.9.0

func Do[T any](c *Client, endpoint string, method string, requestBody any, response T) (T, error)

Do will execute a common JSON http request, marshalling the provided body, and unmarshalling the httpResponse into the response struct

func DoWithHandlers added in v1.9.0

func DoWithHandlers[T any](
	c *Client,
	endpoint string,
	method string,
	requestHandler RequestHandler,
	responseHandler ResponseHandler[T],
) (T, error)

DoWithHandlers will execute the request using the provided RequestHandler and ResponseHandler.

func Get added in v1.9.0

func Get[T any](c *Client, endpoint string, response T) (T, error)

func Patch added in v1.9.0

func Patch[T any](c *Client, endpoint string, request any, response T) (T, error)

func Post added in v1.9.0

func Post[T any](c *Client, endpoint string, request any, response T) (T, error)

Types

type APIError added in v1.9.0

type APIError struct {
	StatusCode int
	Err        *apierrors.ErrorResponse
}

func (*APIError) Error added in v1.9.0

func (e *APIError) Error() string

type Client

type Client struct {
	Settings   *epiniosettings.Settings
	HttpClient *http.Client
	// contains filtered or unexported fields
}

Client provides functionality for talking to an Epinio API server

func New

func New(ctx context.Context, settings *epiniosettings.Settings) *Client

New returns a new Epinio API client

func (*Client) AllApps

func (c *Client) AllApps() (models.AppList, error)

AllApps returns a list of all apps

func (*Client) AllConfigurations added in v0.6.0

func (c *Client) AllConfigurations() (models.ConfigurationResponseList, error)

AllConfigurations returns a list of all configurations, across all namespaces

func (*Client) AllServices added in v0.1.5

func (c *Client) AllServices() (models.ServiceList, error)

func (*Client) AppCreate

func (c *Client) AppCreate(request models.ApplicationCreateRequest, namespace string) (models.Response, error)

AppCreate creates an application resource

func (*Client) AppDelete

func (c *Client) AppDelete(namespace string, names []string) (models.ApplicationDeleteResponse, error)

AppDelete deletes an app

func (*Client) AppDeploy

func (c *Client) AppDeploy(request models.DeployRequest) (*models.DeployResponse, error)

AppDeploy deploys a staged app

func (*Client) AppExec added in v0.3.6

func (c *Client) AppExec(ctx context.Context, namespace string, appName, instance string, tty kubectlterm.TTY) error

func (*Client) AppExport added in v1.10.0

func (c *Client) AppExport(namespace, appName string, request models.AppExportRequest) (models.Response, error)

AppExport triggers an export of the app to a registry

func (*Client) AppGetPart added in v0.6.3

func (c *Client) AppGetPart(namespace, appName, part string) (models.AppPartResponse, error)

AppGetPart retrieves part of an app (values.yaml, chart, image)

func (*Client) AppImportGit

func (c *Client) AppImportGit(namespace string, name string, gitRef models.GitRef) (models.ImportGitResponse, error)

AppImportGit asks the server to import a git repo and put in into the blob store

func (*Client) AppLogs added in v0.6.1

func (c *Client) AppLogs(namespace, appName, stageID string, follow bool, printCallback func(tailer.ContainerLogLine)) error

AppLogs streams the logs of all the application instances, in the targeted namespace If stageID is an empty string, runtime application logs are streamed. If stageID is set, then the matching staging logs are streamed. Logs are streamed through the returned channel. There are 2 ways of stopping this method: 1. The websocket connection closes. 2. The context is canceled (used by the caller when printing of logs should be stopped).

func (*Client) AppMatch added in v0.9.0

func (c *Client) AppMatch(namespace, prefix string) (models.AppMatchResponse, error)

AppMatch returns all matching namespaces for the prefix

func (*Client) AppPortForward added in v0.4.0

func (c *Client) AppPortForward(namespace string, appName, instance string, opts *PortForwardOpts) error

AppPortForward will forward the local traffic to a remote app

func (*Client) AppRestart added in v0.6.0

func (c *Client) AppRestart(namespace string, appName string) (models.Response, error)

AppRestart restarts an app

func (*Client) AppRunning

func (c *Client) AppRunning(app models.AppRef) (models.Response, error)

AppRunning checks if the app is running

func (*Client) AppShow

func (c *Client) AppShow(namespace string, appName string) (models.App, error)

AppShow shows an app

func (*Client) AppStage

func (c *Client) AppStage(request models.StageRequest) (*models.StageResponse, error)

AppStage stages an app

func (*Client) AppUpdate

func (c *Client) AppUpdate(request models.ApplicationUpdateRequest, namespace string, appName string) (models.Response, error)

AppUpdate updates an app

func (*Client) AppUpload

func (c *Client) AppUpload(namespace string, name string, file FormFile) (models.UploadResponse, error)

AppUpload uploads a tarball for the named app, which is later used in staging

func (*Client) AppValidateCV added in v1.2.0

func (c *Client) AppValidateCV(namespace string, name string) (models.Response, error)

AppValidateCV validates the chart values of the specified app against its appchart

func (*Client) Apps

func (c *Client) Apps(namespace string) (models.AppList, error)

Apps returns a list of all apps in an namespace

func (*Client) AuthToken added in v0.3.6

func (c *Client) AuthToken() (models.AuthTokenResponse, error)

func (*Client) ChartList added in v0.8.0

func (c *Client) ChartList() ([]models.AppChart, error)

ChartList returns a list of all known application charts

func (*Client) ChartMatch added in v0.8.0

func (c *Client) ChartMatch(prefix string) (models.ChartMatchResponse, error)

ChartMatch returns all application charts whose name matches the prefix

func (*Client) ChartShow added in v0.8.0

func (c *Client) ChartShow(name string) (models.AppChart, error)

ChartShow returns a named application chart

func (*Client) ConfigurationApps added in v0.6.0

func (c *Client) ConfigurationApps(namespace string) (models.ConfigurationAppsResponse, error)

ConfigurationApps lists all the apps by configurations

func (*Client) ConfigurationBindingCreate added in v0.6.0

func (c *Client) ConfigurationBindingCreate(request models.BindRequest, namespace string, appName string) (models.BindResponse, error)

ConfigurationBindingCreate creates a binding from an app to a configurationclass

func (*Client) ConfigurationBindingDelete added in v0.6.0

func (c *Client) ConfigurationBindingDelete(namespace string, appName string, configurationName string) (models.Response, error)

ConfigurationBindingDelete deletes a binding from an app to a configurationclass

func (*Client) ConfigurationCreate added in v0.6.0

func (c *Client) ConfigurationCreate(request models.ConfigurationCreateRequest, namespace string) (models.Response, error)

ConfigurationCreate creates a configuration by invoking the associated API endpoint

func (*Client) ConfigurationDelete added in v0.6.0

func (c *Client) ConfigurationDelete(req models.ConfigurationDeleteRequest, namespace string, names []string) (models.ConfigurationDeleteResponse, error)

ConfigurationDelete deletes a configuration

func (*Client) ConfigurationMatch added in v0.9.0

func (c *Client) ConfigurationMatch(namespace, prefix string) (models.ConfigurationMatchResponse, error)

ConfigurationMatch returns all matching configurations for the prefix

func (*Client) ConfigurationShow added in v0.6.0

func (c *Client) ConfigurationShow(namespace string, name string) (models.ConfigurationResponse, error)

ConfigurationShow shows a configuration

func (*Client) ConfigurationUpdate added in v0.6.0

func (c *Client) ConfigurationUpdate(request models.ConfigurationUpdateRequest, namespace, name string) (models.Response, error)

ConfigurationUpdate updates a configuration by invoking the associated API endpoint

func (*Client) Configurations added in v0.6.0

func (c *Client) Configurations(namespace string) (models.ConfigurationResponseList, error)

Configurations returns a list of configurations for the specified namespace

func (*Client) DisableVersionWarning added in v1.4.0

func (c *Client) DisableVersionWarning()

func (*Client) Do added in v1.9.0

func (c *Client) Do(endpoint string, method string, body io.Reader) (*http.Response, error)

Do will execute a plain http request, returning the *http.Response

func (*Client) EnvList

func (c *Client) EnvList(namespace string, appName string) (models.EnvVariableMap, error)

EnvList returns a map of all env vars for an app

func (*Client) EnvMatch

func (c *Client) EnvMatch(namespace string, appName string, prefix string) (models.EnvMatchResponse, error)

EnvMatch returns all env vars matching the prefix

func (*Client) EnvSet

func (c *Client) EnvSet(request models.EnvVariableMap, namespace string, appName string) (models.Response, error)

EnvSet set env vars for an app

func (*Client) EnvShow

func (c *Client) EnvShow(namespace string, appName string, envName string) (models.EnvVariable, error)

EnvShow shows an env variable

func (*Client) EnvUnset

func (c *Client) EnvUnset(namespace string, appName string, envName string) (models.Response, error)

EnvUnset removes an env var

func (*Client) ExportregistryList added in v1.10.0

func (c *Client) ExportregistryList() ([]models.ExportregistryResponse, error)

ExportregistryList returns a list of all known application exportregistries

func (*Client) ExportregistryMatch added in v1.10.0

func (c *Client) ExportregistryMatch(prefix string) (models.ExportregistriesMatchResponse, error)

ExportregistryMatch returns all application exportregistries whose name matches the prefix

func (*Client) GitconfigCreate added in v1.10.0

func (c *Client) GitconfigCreate(request models.GitconfigCreateRequest) (models.Response, error)

GitconfigCreate creates a gitconfig

func (*Client) GitconfigDelete added in v1.10.0

func (c *Client) GitconfigDelete(gitconfigs []string) (models.Response, error)

GitconfigDelete deletes a gitconfig

func (*Client) GitconfigShow added in v1.10.0

func (c *Client) GitconfigShow(gitconfig string) (models.Gitconfig, error)

GitconfigShow shows a gitconfig

func (*Client) Gitconfigs added in v1.10.0

func (c *Client) Gitconfigs() (models.GitconfigList, error)

Gitconfigs returns a list of gitconfigs

func (*Client) GitconfigsMatch added in v1.10.0

func (c *Client) GitconfigsMatch(prefix string) (models.GitconfigsMatchResponse, error)

GitconfigsMatch returns all matching gitconfigs for the prefix

func (*Client) Headers added in v1.9.0

func (c *Client) Headers() http.Header

func (*Client) Info

func (c *Client) Info() (models.InfoResponse, error)

Info returns information about Epinio and its components

func (*Client) Me added in v1.11.0

func (c *Client) Me() (models.MeResponse, error)

Me returns the current user

func (*Client) NamespaceCreate

func (c *Client) NamespaceCreate(request models.NamespaceCreateRequest) (models.Response, error)

NamespaceCreate creates a namespace

func (*Client) NamespaceDelete

func (c *Client) NamespaceDelete(namespaces []string) (models.Response, error)

NamespaceDelete deletes a namespace

func (*Client) NamespaceShow added in v0.1.4

func (c *Client) NamespaceShow(namespace string) (models.Namespace, error)

NamespaceShow shows a namespace

func (*Client) Namespaces

func (c *Client) Namespaces() (models.NamespaceList, error)

Namespaces returns a list of namespaces

func (*Client) NamespacesMatch

func (c *Client) NamespacesMatch(prefix string) (models.NamespacesMatchResponse, error)

NamespacesMatch returns all matching namespaces for the prefix

func (*Client) ServiceApps

func (c *Client) ServiceApps(namespace string) (models.ServiceAppsResponse, error)

ServiceApps lists a map from services to bound apps, for the namespace

func (*Client) ServiceBind added in v0.6.3

func (c *Client) ServiceBind(request models.ServiceBindRequest, namespace, name string) (models.Response, error)

func (*Client) ServiceCatalog added in v0.6.2

func (c *Client) ServiceCatalog() (models.CatalogServices, error)

func (*Client) ServiceCatalogMatch added in v0.9.0

func (c *Client) ServiceCatalogMatch(prefix string) (models.CatalogMatchResponse, error)

ServiceCatalogMatch returns all matching namespaces for the prefix

func (*Client) ServiceCatalogShow added in v0.6.2

func (c *Client) ServiceCatalogShow(serviceName string) (*models.CatalogService, error)

func (*Client) ServiceCreate

func (c *Client) ServiceCreate(request models.ServiceCreateRequest, namespace string) (models.Response, error)

func (*Client) ServiceDelete

func (c *Client) ServiceDelete(request models.ServiceDeleteRequest, namespace string, names []string) (models.ServiceDeleteResponse, error)

func (*Client) ServiceList added in v0.7.0

func (c *Client) ServiceList(namespace string) (models.ServiceList, error)

func (*Client) ServiceMatch added in v0.9.0

func (c *Client) ServiceMatch(namespace, prefix string) (models.ServiceMatchResponse, error)

ServiceMatch returns all matching services for the prefix

func (*Client) ServicePortForward added in v1.9.0

func (c *Client) ServicePortForward(namespace string, serviceName string, opts *PortForwardOpts) error

ServicePortForward will forward the local traffic to a remote app

func (*Client) ServiceShow

func (c *Client) ServiceShow(namespace, name string) (*models.Service, error)

func (*Client) ServiceUnbind added in v0.8.0

func (c *Client) ServiceUnbind(request models.ServiceUnbindRequest, namespace, name string) (models.Response, error)

func (*Client) ServiceUpdate added in v0.3.0

func (c *Client) ServiceUpdate(request models.ServiceUpdateRequest, namespace, name string) (models.Response, error)

ServiceUpdate updates a service by invoking the associated API endpoint

func (*Client) SetHeader added in v1.9.0

func (c *Client) SetHeader(key, value string)

func (*Client) StagingComplete

func (c *Client) StagingComplete(namespace string, id string) (models.Response, error)

StagingComplete checks if the staging process is complete

func (*Client) VersionWarningEnabled added in v1.4.0

func (c *Client) VersionWarningEnabled() bool

VersionWarningEnabled returns true if versionWarning field is either not set of true. That makes "true" the default value unless DisableVersionWarning is called.

type FormFile added in v1.9.0

type FormFile interface {
	io.Reader
	Name() string
}

FormFile is a file that can be used with the FileUpload request handler

type PortForwardOpts added in v0.4.0

type PortForwardOpts struct {
	Address      []string
	Ports        []string
	StopChannel  chan struct{}
	ReadyChannel chan struct{}
	Out          io.Writer
	ErrOut       io.Writer
}

func NewPortForwardOpts added in v0.4.0

func NewPortForwardOpts(address, ports []string) *PortForwardOpts

type RequestHandler added in v1.9.0

type RequestHandler func(method, url string) (*http.Request, error)

RequestHandler is a method that will return a *http.Request from a method and url

func NewFileUploadRequestHandler added in v1.9.0

func NewFileUploadRequestHandler(file FormFile) RequestHandler

NewFileUploadRequestHandler creates a multipart/form-data request to upload the provided file

func NewFormURLEncodedRequestHandler added in v1.9.0

func NewFormURLEncodedRequestHandler(data url.Values) RequestHandler

NewFormURLEncodedRequestHandler creates a application/x-www-form-urlencoded request encoding the provided data

func NewHTTPRequestHandler added in v1.9.0

func NewHTTPRequestHandler(body io.Reader) RequestHandler

NewHTTPRequestHandler return a plain *http.Request with the provided body

func NewJSONRequestHandler added in v1.9.0

func NewJSONRequestHandler(body any) RequestHandler

NewJSONRequestHandler creates a request marshalling the provided body into JSON

type ResponseHandler added in v1.9.0

type ResponseHandler[T any] func(httpResponse *http.Response) (T, error)

ResponseHandler is a method that will handle a *http.Response to return a typed struct

func NewHTTPResponseHandler added in v1.9.0

func NewHTTPResponseHandler[T *http.Response]() ResponseHandler[T]

NewHTTPResponseHandler is a no-op ResponseHandler that returns the plain *http.Response that can be directly used

func NewJSONResponseHandler added in v1.9.0

func NewJSONResponseHandler[T any](logger logr.Logger, response T) ResponseHandler[T]

NewJSONResponseHandler will try to unmarshal the response body into the provided struct

type ServicePortForwarder added in v1.9.0

type ServicePortForwarder struct {
	Client             *Client
	Endpoint           string
	ListeningAddresses []ListenAddress
	Ports              []ForwardedPort
	StopChan           <-chan struct{}
}

func NewServicePortForwarder added in v1.9.0

func NewServicePortForwarder(client *Client, endpoint string, addresses []string, ports []string, stopChan <-chan struct{}) (*ServicePortForwarder, error)

func (*ServicePortForwarder) ForwardPorts added in v1.9.0

func (pf *ServicePortForwarder) ForwardPorts() error

type Upgrader added in v0.3.6

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

Upgrader implements the spdy.Upgrader interface. It delegates to spdy.SpdyRoundTripper but handles Epinio errors (like 404) first. The upstream upgrader would simply ignore 404 in cases when app or namespace is not found. Here: https://github.com/kubernetes/apimachinery/blob/v0.21.4/pkg/util/httpstream/spdy/roundtripper.go#L343

func NewUpgrader added in v0.3.6

func NewUpgrader(cfg spdy.RoundTripperConfig) *Upgrader

func (*Upgrader) NewConnection added in v0.3.6

func (upgr *Upgrader) NewConnection(resp *http.Response) (httpstream.Connection, error)

func (*Upgrader) RoundTrip added in v0.3.6

func (upgr *Upgrader) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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