Documentation
¶
Index ¶
Constants ¶
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 ¶
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 ¶
New returns an unauthenticated client for the StorageOS API. Authenticate() must be called before using the client.
func (*Client) Authenticate ¶
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 ¶
GetCluster fetches StorageOS configuration and returns a Cluster with the fetched data.
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.
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.