Documentation ¶
Index ¶
- Variables
- func ErrorHandler(c *FakeConnector) *bone.Mux
- func ValidHandler(c *FakeConnector) *bone.Mux
- type AccessToken
- type AuthorizationCode
- type Callback
- type CallbackRequest
- type CallbackState
- type CallbackType
- type FakeConnector
- func (c *FakeConnector) AddCallback(t CallbackType) (*Callback, error)
- func (c *FakeConnector) AddResource(r *Resource)
- func (c *FakeConnector) CreateCode() (*AuthorizationCode, error)
- func (c *FakeConnector) GetCallback(ID manifold.ID) *Callback
- func (c *FakeConnector) GetCapturer(route string) (*RequestCapturer, error)
- func (c *FakeConnector) GetResource(id manifold.ID) *Resource
- func (c *FakeConnector) RemoveResource(ID manifold.ID) error
- func (c *FakeConnector) Start()
- func (c *FakeConnector) Stop() error
- func (c *FakeConnector) TriggerCallback(ID manifold.ID, state CallbackState, msg string, creds map[string]string) error
- type FakeConnectorConfig
- type GrantType
- type ProductProfile
- type ProductTarget
- type RequestCapturer
- type Resource
- type TokenRequest
- type UserProfile
- type UserTarget
Constants ¶
This section is empty.
Variables ¶
var ErrCallbackAlreadyResolved = errors.New("Callback Already Resolved")
ErrCallbackAlreadyResolved represents an error which occurs if the callback has already been resolved
var ErrCallbackNotFound = errors.New("Callback Not Found")
ErrCallbackNotFound represents an error which occurs if a callback does not exist
var ErrResourceNotFound = errors.New("Resource Not Found")
ErrResourceNotFound represents an error which occurrs if the resource does not exist
Functions ¶
func ErrorHandler ¶
func ErrorHandler(c *FakeConnector) *bone.Mux
ErrorHandler is a set of endpoints that just returns errors. This is to test how the providers handle errors from our end.
func ValidHandler ¶
func ValidHandler(c *FakeConnector) *bone.Mux
ValidHandler returns a set of endpoints that are valid and in use by the production connector.
Types ¶
type AccessToken ¶
type AccessToken struct { ID manifold.ID `json:"-"` AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` TokenType string `json:"token_type"` GrantType GrantType `json:"-"` }
AccessToken represents an access token granted by the fake connector for kicking off the oauth flow
type AuthorizationCode ¶
AuthorizationCode represents a code granted by the fake connector for kicking off the oauth flow
type Callback ¶
type Callback struct { ID manifold.ID `json:"id"` Mutex *sync.Mutex `json:"-"` Type CallbackType `json:"type"` State CallbackState `json:"state"` Message string `json:"message"` Credentials map[string]string `json:"-"` }
Callback represents a callback that is either pending or has been received from a provider
type CallbackRequest ¶
type CallbackRequest struct { State CallbackState `json:"state"` Message string `json:"message"` Credentials map[string]string `json:"credentials"` }
CallbackRequest represents a received callback from a provider
type CallbackState ¶
type CallbackState string
CallbackState represents a state reported by the provider regarding an operation
var ( PendingCallbackState CallbackState = "pending" DoneCallbackState CallbackState = "done" ErrorCallbackState CallbackState = "error" )
PendingCallbackState represents a callback which is pending (not resolved)
type CallbackType ¶
type CallbackType string
CallbackType represents a type of callback
var ( ResourceProvisionCallback CallbackType = "resource:provision" CredentialProvisionCallback CallbackType = "credential:provision" ResourceDeprovisionCallback CallbackType = "resource:deprovision" CredentialDeprovisionCallback CallbackType = "credential:deprovision" ResourceResizeCallback CallbackType = "resource:resize" )
ResourceProvisionCallback represents a callback related to a resource provision
type FakeConnector ¶
type FakeConnector struct { Config *FakeConnectorConfig OnCallback chan *Callback Server *http.Server // contains filtered or unexported fields }
FakeConnector represents a fake connector api server run by Grafton for use by providers to integrate with Manifold.
func (*FakeConnector) AddCallback ¶
func (c *FakeConnector) AddCallback(t CallbackType) (*Callback, error)
AddCallback stores the callback inside the FakeConnector
func (*FakeConnector) AddResource ¶
func (c *FakeConnector) AddResource(r *Resource)
AddResource stores a resource inside the connector
func (*FakeConnector) CreateCode ¶
func (c *FakeConnector) CreateCode() (*AuthorizationCode, error)
CreateCode returns an AuthorizationCode method
func (*FakeConnector) GetCallback ¶
func (c *FakeConnector) GetCallback(ID manifold.ID) *Callback
GetCallback returns a callback for the given id if it exists
func (*FakeConnector) GetCapturer ¶
func (c *FakeConnector) GetCapturer(route string) (*RequestCapturer, error)
GetCapturer returns a RequestCapturer for the given route, if no capturer exists, an error is returned.
func (*FakeConnector) GetResource ¶
func (c *FakeConnector) GetResource(id manifold.ID) *Resource
GetResource returns a Resource for the ID or nil
func (*FakeConnector) RemoveResource ¶ added in v0.6.4
func (c *FakeConnector) RemoveResource(ID manifold.ID) error
RemoveResource deletes a resource stored inside the connector
func (*FakeConnector) Start ¶
func (c *FakeConnector) Start()
Start the server or return an error if it couldn't be started
func (*FakeConnector) Stop ¶
func (c *FakeConnector) Stop() error
Stop the server or return an error if it couldn't be stopped
func (*FakeConnector) TriggerCallback ¶
func (c *FakeConnector) TriggerCallback(ID manifold.ID, state CallbackState, msg string, creds map[string]string) error
TriggerCallback updates the callback if it's still pending, and notifies any listeners
type FakeConnectorConfig ¶
type FakeConnectorConfig struct { Product string Port uint ClientID string ClientSecret string SigningKey string }
FakeConnectorConfig represents the values used to Configure a FakeConnector
type ProductProfile ¶
type ProductProfile struct { Type string `json:"type"` Target *ProductTarget `json:"target"` }
ProductProfile represents the data returned on GET /v1/self when the target type is a product
type ProductTarget ¶
ProductTarget represents the data returned on GET /v1/vself when the target type is product
type RequestCapturer ¶
type RequestCapturer struct { Route string // contains filtered or unexported fields }
RequestCapturer represents functionality for capturing and storing requests for a specific route
func (*RequestCapturer) Get ¶
func (r *RequestCapturer) Get() []interface{}
Get returns the requests captured by this Capturer
type Resource ¶
type Resource struct { ID manifold.ID `json:"id"` Plan string `json:"plan"` Product string `json:"product"` Region string `json:"region"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Resource represents a resource provisioned through Grafton
type TokenRequest ¶
type TokenRequest struct { ContentType string Code string AuthHeader bool ClientID string ClientSecret string GrantType GrantType ExpiresAt time.Time }
TokenRequest represents all of the important values from a request by a provider to create an OAuth Token
type UserProfile ¶
type UserProfile struct { Type string `json:"type"` Target *UserTarget `json:"target"` }
UserProfile represents the data returned on GET /v1/self when the target type is a user
type UserTarget ¶
UserTarget represents the contents of a response on GET /v1/self when the target is a user