Documentation
¶
Index ¶
Constants ¶
View Source
const ( EnvOctopusHost = "OCTOPUS_HOST" EnvOctopusApiKey = "OCTOPUS_API_KEY" EnvOctopusSpace = "OCTOPUS_SPACE" )
Variables ¶
This section is empty.
Functions ¶
func ValidateMandatoryEnvironment ¶ added in v0.1.0
Types ¶
type Client ¶
type Client struct {
// Underlying HTTP Client (settable for mocking in unit tests).
// If nil, will use the system default HTTP client to connect to the Octopus Deploy server
HttpClient *http.Client
// TODO this should be an interface rather than a struct, but this requires changing the SDK, we'll get round to that
// Octopus API Client not scoped to any space. nullable, lazily created by Get()
SystemClient *octopusApiClient.Client
// TODO this should be an interface rather than a struct, but this requires changing the SDK, we'll get round to that
// Octopus API Client scoped to the current space. nullable, lazily created by Get()
SpaceScopedClient *octopusApiClient.Client
// the Server URL, obtained from OCTOPUS_HOST
ApiUrl *url.URL
// the Octopus API Key, obtained from OCTOPUS_API_KEY
ApiKey string
// the Octopus SpaceNameOrID to work within. Obtained from OCTOPUS_SPACE (TODO: or --space=XYZ on the command line??)
// Required for commands that need a space, but may be omitted for server-wide commands such as listing teams
SpaceNameOrID string
// After the space lookup process has occurred, we cache a reference to the SpaceNameOrID object for future use
// May be nil if we haven't done space lookup yet
ActiveSpace *spaces.Space
Ask question.AskProvider
}
func (*Client) GetActiveSpace ¶ added in v0.2.0
func (*Client) GetHostUrl ¶ added in v0.2.0
func (*Client) GetSpacedClient ¶ added in v0.2.0
func (c *Client) GetSpacedClient() (*octopusApiClient.Client, error)
func (*Client) GetSystemClient ¶ added in v0.2.0
func (c *Client) GetSystemClient() (*octopusApiClient.Client, error)
func (*Client) SetSpaceNameOrId ¶ added in v0.2.0
type ClientFactory ¶
type ClientFactory interface {
// GetSpacedClient returns an Octopus api Client instance which is bound to the Space
// specified in the OCTOPUS_SPACE environment variable, or the command line. It should be the default
GetSpacedClient() (*octopusApiClient.Client, error)
// GetSystemClient returns an Octopus api Client instance which isn't bound to any Space.
// Use it for things that live outside of a space, such as Teams, or Spaces themselves
GetSystemClient() (*octopusApiClient.Client, error)
// GetActiveSpace returns the currently selected space.
// Note this is lazily populated when you call GetSpacedClient;
// if you have not yet done so then it may return nil
GetActiveSpace() *spaces.Space
// SetSpaceNameOrId replaces whichever space name or ID was picked up from the environment or selected
// interactively. This resets the internal cache inside the ClientFactory, meaning that the next time
// someone calls GetSpacedClient we will have to query the Octopus Server to look up spaceNameOrId,
// and any calls to GetActiveSpace before that will return nil
SetSpaceNameOrId(spaceNameOrId string)
// GetHostUrl returns the current set API URL as a string
GetHostUrl() string
}
func NewClientFactory ¶ added in v0.2.0
func NewClientFactory(httpClient *http.Client, host string, apiKey string, spaceNameOrID string, ask question.AskProvider) (ClientFactory, error)
func NewClientFactoryFromEnvironment ¶ added in v0.2.0
func NewClientFactoryFromEnvironment(ask question.AskProvider) (ClientFactory, error)
NewClientFactoryFromEnvironment Creates a new Client wrapper structure by reading the environment. specifies nil for the HTTP Client, so this is not for unit tests; use NewClientFactory(... instead)
Click to show internal directories.
Click to hide internal directories.