api

package module
v0.0.0-...-8e8ec3f Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 10 Imported by: 4

README

DC/OS Secrets Client

Go client to manage DC/OS secrets

Documentation

Index

Constants

View Source
const (
	DefaultClusterURL = "https://master.mesos"
)

Variables

View Source
var (
	ErrKeyEmpty = errors.New("Secret path cannot be empty")
)
View Source
var (
	ErrNotImplemented = errors.New("API not implemented")
)

Functions

func GenerateACSToken

func GenerateACSToken(config TokenConfig) (string, error)

GenerateACSToken creates a new DC/OS token that can be used by API calls

func NewAPIError

func NewAPIError(body []byte) error

Types

type APIError

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

func (*APIError) Error

func (e *APIError) Error() string

type Config

type Config struct {

	// ClusterURL is the base URL of the DC/OS admin router.
	ClusterURL string

	// Insecure if true, indicates that the client does not verify server's
	// certificate chain. Not recommended as the connection could be susceptible to
	// man-in-the-middle attacks. When false, valid CACertFile should be provided.
	Insecure bool

	// CACertFile is the location of the root certificate authorities that clients
	// use when verifying server certificates. Not needed when Insecure flag is set.
	CACertFile string

	// ACSToken DC/OS authentication token used to authorize the API calls to the
	// admin router. Remember, that the DC/OS token expires after some time (five
	// days by default). So, it is recommended to refrest the token. Use the
	// GenerateACSToken() method to update the token at regular intervals or on
	// failure (401 Unauthorized).
	ACSToken string
}

Config contains the options needed by the client to connect and authenticate

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig has default options in the config, which can be overwritten

type CreateTokenRequest

type CreateTokenRequest struct {
	UID      string `json:"uid,omitempty"`
	Password string `json:"password,omitempty"`
}

CreateTokenRequest request object to the create token API

type CreateTokenResponse

type CreateTokenResponse struct {
	Token string `json:"token,omitempty"`
}

CreateTokenResponse response object from the create token API

type DCOSSecrets

type DCOSSecrets interface {
	UpdateACSToken(token string)
	GetSecret(store, key string) (*Secret, error)
	CreateSecret(store, key string, secret *Secret) error
	UpdateSecret(store, key string, secret *Secret) error
	CreateOrUpdateSecret(store, key string, secret *Secret) error
	DeleteSecret(store, key string) error
	RevokeSecret(store, key string) error
	RenewSecret(store, key string, duration int64) error
}

func NewClient

func NewClient(config Config) (DCOSSecrets, error)

type ErrorResponse

type ErrorResponse struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient interface is used to mock the http.Client

type Secret

type Secret struct {
	Value string `json:"value,omitempty"`
}

type TokenConfig

type TokenConfig struct {
	Config
	// Username username of the user who has access to the APIs. The Username
	// and Password are needed to generate the DC/OS ACS token.
	Username string

	// Password password of the user to generate the ACS token.
	Password string
}

func DefaultTokenConfig

func DefaultTokenConfig() TokenConfig

Directories

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

Jump to

Keyboard shortcuts

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