Documentation ¶
Overview ¶
Copyright 2019 Armory, Inc. *
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2019 Armory, Inc. *
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2019 Armory, Inc. *
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2019 Armory, Inc. *
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Package plank is a SDK for Spinnaker. It allows you to write Go code that interacts with Spinnaker's subservices.
- Copyright 2019 Armory, Inc. *
- Licensed under the Apache License, Version 2.0 (the "License")
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
Index ¶
- Variables
- type Application
- type Authorization
- type Client
- func (c *Client) ArmoryEndpointsEnabled() bool
- func (c *Client) CreateApplication(a *Application) error
- func (c *Client) CreateTask(app, desc string, payload interface{}) (*TaskRefResponse, error)
- func (c *Client) Delete(url string) error
- func (c *Client) DeletePipeline(p Pipeline) error
- func (c *Client) DeletePipelineByName(app, pipeline string) error
- func (c *Client) DeleteWithRetry(url string) error
- func (c *Client) DisableARmoryEndpoints()
- func (c *Client) EnableArmoryEndpoints()
- func (c *Client) Execute(application, pipeline string) (*PipelineRef, error)
- func (c *Client) Get(url string, dest interface{}) error
- func (c *Client) GetApplication(name string) (*Application, error)
- func (c *Client) GetApplications() (*[]Application, error)
- func (c *Client) GetPipelines(app string) ([]Pipeline, error)
- func (c *Client) GetTask(refURL string) (*ExecutionStatusResponse, error)
- func (c *Client) GetUser(name string) (*User, error)
- func (c *Client) GetWithRetry(url string, dest interface{}) error
- func (c *Client) HasAppWriteAccess(username, app string) (bool, error)
- func (c *Client) IsAdmin(username string) (bool, error)
- func (c *Client) PollTaskStatus(refURL string) (*ExecutionStatusResponse, error)
- func (c *Client) Post(url string, contentType ContentType, body interface{}, dest interface{}) error
- func (c *Client) PostWithRetry(url string, contentType ContentType, body interface{}, dest interface{}) error
- func (c *Client) Put(url string, contentType ContentType, body interface{}, dest interface{}) error
- func (c *Client) PutWithRetry(url string, contentType ContentType, body interface{}, dest interface{}) error
- func (c *Client) RequestWithRetry(f RequestFunction) error
- func (c *Client) ResyncFiat() error
- func (c *Client) UpsertPipeline(p Pipeline, id string) error
- type ClientOption
- func WithClient(client *http.Client) ClientOption
- func WithFiatUser(user string) ClientOption
- func WithMaxRetries(retries int) ClientOption
- func WithRetryIncrement(t time.Duration) ClientOption
- func WithTransport(transport *http.Transport) ClientOption
- func WithURLs(urls map[string]string) ClientOption
- type ContentType
- type DataSourcesType
- type ErrUnsupportedStatusCode
- type ExecutionStatusResponse
- type FailedResponse
- type PermissionsType
- type Pipeline
- type PipelineLockType
- type PipelineRef
- type RequestFunction
- type Task
- type TaskRefResponse
- type User
Constants ¶
This section is empty.
Variables ¶
var DefaultURLs = map[string]string{
"orca": "http://armory-orca:8083",
"front50": "http://armory-front50:8080",
"fiat": "http://armory-fiat:7003",
"gate": "http://armory-gate:8084",
}
DefaultURLs
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { Name string `json:"name" mapstructure:"name" yaml:"name" hcl:"name"` Email string `json:"email" mapstructure:"email" yaml:"email" hcl:"email"` Description string `json:"description,omitempty" mapstructure:"description" yaml:"description,omitempty" hcl:"description,omitempty"` User string `json:"user,omitempty" mapstructure:"user" yaml:"user,omitempty" hcl:"user,omitempty"` DataSources DataSourcesType `json:"dataSources,omitempty" mapstructure:"dataSources" yaml:"datasources,omitempty" hcl:"datasources,omitempty"` Permissions PermissionsType `json:"permissions,omitempty" mapstructure:"permissions" yaml:"permissions,omitempty" hcl:"permissions,omitempty"` }
Application as returned from the Spinnaker API.
type Authorization ¶
type Authorization struct { Name string `json:"name" yaml:"name" hcl:"name"` // Authorizations can be 'READ' 'WRITE' Authorizations []string `json:"authorizations" yaml:"authorizations" hcl:"authorizations"` }
Authorization describes permissinos for an account or application.
type Client ¶
type Client struct { URLs map[string]string FiatUser string ArmoryEndpoints bool // contains filtered or unexported fields }
Client for working with API servers that accept and return JSON payloads.
func New ¶
func New(opts ...ClientOption) *Client
New constructs a Client using a default client and sane non-shared http transport
func (*Client) ArmoryEndpointsEnabled ¶ added in v1.3.0
func (*Client) CreateApplication ¶
func (c *Client) CreateApplication(a *Application) error
CreateApplication does what it says.
func (*Client) CreateTask ¶
func (c *Client) CreateTask(app, desc string, payload interface{}) (*TaskRefResponse, error)
Create task puts the payload into the Task wrapper.
func (*Client) DeletePipeline ¶
DeletePipeline does what it says.
func (*Client) DeletePipelineByName ¶
func (*Client) DeleteWithRetry ¶
func (*Client) DisableARmoryEndpoints ¶ added in v1.3.0
func (c *Client) DisableARmoryEndpoints()
func (*Client) EnableArmoryEndpoints ¶ added in v1.3.0
func (c *Client) EnableArmoryEndpoints()
func (*Client) Execute ¶
func (c *Client) Execute(application, pipeline string) (*PipelineRef, error)
Execute a pipeline by application and pipeline.
func (*Client) GetApplication ¶
func (c *Client) GetApplication(name string) (*Application, error)
GetApplication returns the Application data struct for the given application name.
func (*Client) GetApplications ¶
func (c *Client) GetApplications() (*[]Application, error)
GetApplications returns all applications (you can see, at least)
func (*Client) GetPipelines ¶
Get returns an array of all the Spinnaker pipelines configured for app
func (*Client) GetWithRetry ¶
func (*Client) HasAppWriteAccess ¶
HasAppWriteAccess returns whether or not a user can write pipelines/configs/etc. for an app.
func (*Client) PollTaskStatus ¶
func (c *Client) PollTaskStatus(refURL string) (*ExecutionStatusResponse, error)
func (*Client) Post ¶
func (c *Client) Post(url string, contentType ContentType, body interface{}, dest interface{}) error
Post a JSON payload from the URL then decode it into the 'dest' arguement.
func (*Client) PostWithRetry ¶
func (c *Client) PostWithRetry(url string, contentType ContentType, body interface{}, dest interface{}) error
func (*Client) Put ¶
func (c *Client) Put(url string, contentType ContentType, body interface{}, dest interface{}) error
Post a JSON payload from the URL then decode it into the 'dest' arguement.
func (*Client) PutWithRetry ¶
func (c *Client) PutWithRetry(url string, contentType ContentType, body interface{}, dest interface{}) error
func (*Client) RequestWithRetry ¶
func (c *Client) RequestWithRetry(f RequestFunction) error
func (*Client) ResyncFiat ¶ added in v1.3.0
ResyncFiat calls to Fiat to tell it to resync its cache of applications and permissions. This uses an endpoint specific to Armory's distribution of Fiat; if ArmoryEndpoints is not set (it's false by default) this is a no-op.
type ClientOption ¶ added in v1.1.0
type ClientOption func(*Client)
func WithClient ¶ added in v1.1.0
func WithClient(client *http.Client) ClientOption
func WithFiatUser ¶ added in v1.1.0
func WithFiatUser(user string) ClientOption
func WithMaxRetries ¶ added in v1.1.0
func WithMaxRetries(retries int) ClientOption
func WithRetryIncrement ¶ added in v1.1.0
func WithRetryIncrement(t time.Duration) ClientOption
func WithTransport ¶ added in v1.1.0
func WithTransport(transport *http.Transport) ClientOption
func WithURLs ¶ added in v1.1.0
func WithURLs(urls map[string]string) ClientOption
type ContentType ¶
type ContentType string
const ( ApplicationJson ContentType = "application/json" ApplicationContextJson ContentType = "application/context+json" )
type DataSourcesType ¶
type DataSourcesType struct { Enabled []string `json:"enabled" mapstructure:"enabled" yaml:"enabled" hcl:"enabled"` Disabled []string `json:"disabled" mapstructure:"disabled" yaml:"disabled" hcl:"disabled"` }
DataSourcesType creates this block:
"dataSources": { "disabled": [], "enabled": ["canaryConfigs"] }
type ErrUnsupportedStatusCode ¶ added in v1.3.0
type ErrUnsupportedStatusCode struct {
Code int
}
func (*ErrUnsupportedStatusCode) Error ¶ added in v1.3.0
func (e *ErrUnsupportedStatusCode) Error() string
type ExecutionStatusResponse ¶
type FailedResponse ¶ added in v1.3.0
FailedResponse captures a 4xx/5xx response from the upstream Spinnaker service. It is expected that the caller destructures the response according to the structure they expect.
func (*FailedResponse) Error ¶ added in v1.3.0
func (e *FailedResponse) Error() string
type PermissionsType ¶ added in v1.3.0
type PermissionsType struct { Read []string `json:"READ" mapstructure:"READ" yaml:"READ" hcl:"READ"` Write []string `json:"WRITE" mapstructure:"WRITE" yaml:"WRITE" hcl:"WRITE"` Execute []string `json:"EXECUTE" mapstructure:"EXECUTE" yaml:"EXECUTE" hcl:"EXECUTE"` }
PermissionsType creates this block:
"permissions": { "READ": ["armory-io", "core"], "WRITE": ["armory-io", "core"] }
type Pipeline ¶
type Pipeline struct { ID string `json:"id,omitempty" yaml:"id,omitempty" hcl:"id,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty" hcl:"type,omitempty"` Name string `json:"name" yaml:"name" hcl:"name"` Application string `json:"application" yaml:"application" hcl:"application"` Description string `json:"description,omitempty" yaml:"description,omitempty" hcl:"description,omitempty"` ExecutionEngine string `json:"executionEngine,omitempty" yaml:"executionEngine,omitempty" hcl:"executionEngine,omitempty"` Parallel bool `json:"parallel" yaml:"parallel" hcl:"parallel"` LimitConcurrent bool `json:"limitConcurrent" yaml:"limitConcurrent" hcl:"limitConcurrent"` KeepWaitingPipelines bool `json:"keepWaitingPipelines" yaml:"keepWaitingPipelines" hcl:"keepWaitingPipelines"` Stages []map[string]interface{} `json:"stages,omitempty" yaml:"stages,omitempty" hcl:"stages,omitempty"` Triggers []map[string]interface{} `json:"triggers,omitempty" yaml:"triggers,omitempty" hcl:"triggers,omitempty"` Parameters []map[string]interface{} `json:"parameterConfig,omitempty" yaml:"parameterConfig,omitempty" hcl:"parameterConfig,omitempty"` Notifications []map[string]interface{} `json:"notifications,omitempty" yaml:"notifications,omitempty" hcl:"notifications,omitempty"` ExpectedArtifacts []map[string]interface{} `json:"expectedArtifacts,omitempty" yaml:"expectedArtifacts,omitempty" hcl:"expectedArtifacts,omitempty"` LastModifiedBy string `json:"lastModifiedBy" yaml:"lastModifiedBy" hcl:"lastModifiedBy"` Config interface{} `json:"config,omitempty" yaml:"config,omitempty" hcl:"config,omitempty"` UpdateTs string `json:"updateTs" yaml:"updateTs" hcl:"updateTs"` Locked PipelineLockType `json:"locked,omitempty" yaml:"locked,omitempty" hcl:"locked,omitempty"` }
Pipeline is the structure that comes back from Spinnaker representing a pipeline definition (different than an execution)
type PipelineLockType ¶
type PipelineRef ¶
type PipelineRef struct { // Ref is the path the the execution. Use it to get status updates. Ref string `json:"ref" yaml:"ref" hcl:"ref"` }
type RequestFunction ¶
type RequestFunction func() error
type TaskRefResponse ¶
type TaskRefResponse struct {
Ref string `json:"ref"`
}
type User ¶
type User struct { Name string `json:"name" yaml:"name" hcl:"name"` Admin bool `json:"admin" yaml:"admin" hcl:"admin"` Accounts []Authorization `json:"accounts" yaml:"accounts" hcl:"accounts"` Applications []Authorization `json:"applications" yaml:"applications" hcl:"applications"` }
User is returned by Fiat's /authorize endpoint.
func (*User) HasAppWriteAccess ¶
HasAppWriteAccess returns true if user has write access to given app.