storageos

package
v0.0.0-...-c44a825 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default api port.
	DefaultPort = 5705

	// DefaultScheme is used for api endpoint.
	DefaultScheme = "http"

	// UsernameKey is the username field in StorageOS credential configuration.
	UsernameKey = "username"

	// PasswordKey is the password field in StorageOS credential configuration.
	PasswordKey = "password"

	// LogLevelDebug is the value of debug log level.
	LogLevelDebug = "debug"

	// LogLevelInfo is the value of debug log level.
	LogLevelInfo = "info"
)

Variables

View Source
var (
	// ErrNoAuthToken is returned when the API client did not get an error
	// during authentication but no valid auth token was returned.
	ErrNoAuthToken = errors.New("no token found in auth response")

	// HTTPTimeout is the time limit for requests made by the API Client. The
	// timeout includes connection time, any redirects, and reading the response
	// body. The timer remains running after Get, Head, Post, or Do return and
	// will interrupt reading of the Response.Body.
	HTTPTimeout = 10 * time.Second

	// AuthenticationTimeout is the time limit for authentication requests to
	// complete.  It should be longer than the HTTPTimeout.
	AuthenticationTimeout = 20 * time.Second
)

Functions

This section is empty.

Types

type Client

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

Client provides access to the StorageOS API.

func Mock

func Mock(api ControlPlane) *Client

Mocked returns a client that uses the provided ControlPlane api client. Intended for tests that use a mocked StorageOS api. This avoids having to publically expose the api on the Client struct.

func New

func New(endpoint string) (*Client, error)

New returns an unauthenticated client for the StorageOS API. Authenticate() must be called before using the client.

func (*Client) AddToken

func (c *Client) AddToken(ctx context.Context) context.Context

AddToken adds the current authentication token to a given context.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context, username, password string) error

Authenticate against the API and set the authentication token in the client to be used for subsequent API requests. The token must be refreshed periodically using AuthenticateRefresh(), or Authenticate() called again.

func (*Client) GetCluster

func (c *Client) GetCluster(ctx context.Context) (*Cluster, error)

GetCluster fetches StorageOS configuration and returns a Cluster with the fetched data.

func (*Client) UpdateCluster

func (c *Client) UpdateCluster(ctx context.Context, cluster *Cluster) error

UpdateCluster updates the configuration of a cluster.

type Cluster

type Cluster struct {
	DisableTelemetry      bool
	DisableCrashReporting bool
	DisableVersionCheck   bool
	LogLevel              string
	LogFormat             string
	Version               string
}

Cluster is the configuration of a StorageOS cluster.

func (*Cluster) IsEqual

func (c *Cluster) IsEqual(b *Cluster) bool

IsEqual checks if a cluster is equal to a given cluster in interms of configuration.

type ControlPlane

type ControlPlane interface {
	RefreshJwt(ctx context.Context) (api.UserSession, *http.Response, error)
	AuthenticateUser(ctx context.Context, authUserData api.AuthUserData) (api.UserSession, *http.Response, error)
	GetCluster(ctx context.Context) (api.Cluster, *http.Response, error)
	UpdateCluster(ctx context.Context, updateClusterData api.UpdateClusterData, localVarOptionals *api.UpdateClusterOpts) (api.Cluster, *http.Response, error)
}

ControlPlane is the subset of the StorageOS control plane ControlPlane that the operator requires. New methods should be added here as needed, then the mocks regenerated.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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