spinnaker

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

README

Shore Spinnaker Plugin

The Spinnaker plugin implements the shore interface allowing, save, exec & test commands to work with a Spinnaker API backend.

Documentation

Overview

Package spinnaker - a `shore` backend implementation for Spinnaker APIs

An abstraction layer over Spinnaker communications, unifying the experience for `shore` developers when working with a `spinnaker` backend.

The abstraction implements the standard `shore-backend` interface from github.com/Autodesk/shore/pkg/backend/spinnaker

Index

Constants

View Source
const (
	// PipelineNotStarted - Pipeline is in NOT_STARTED state
	PipelineNotStarted = "NOT_STARTED"
	// PipelineRunning - Pipeline is in RUNNING state
	PipelineRunning = "RUNNING"
	// PipelinePaused - Pipeline is in PAUSED state
	PipelinePaused = "PAUSED"
	// PipelineSuspended - Pipeline is in SUSPENDED state
	PipelineSuspended = "SUSPENDED"
	// PipelineSucceeded - Pipeline is in SUCCEEDED state
	PipelineSucceeded = "SUCCEEDED"
	// PipelineFailedContinue - Pipeline is in FAILED_CONTINUE state
	PipelineFailedContinue = "FAILED_CONTINUE"
	// PipelineTerminal - Pipeline is in TERMINAL state
	PipelineTerminal = "TERMINAL"
	// PipelineCanceled - Pipeline is in CANCELED state
	PipelineCanceled = "CANCELED"
	// PipelineRedirect - Pipeline is in REDIRECT state
	PipelineRedirect = "REDIRECT"
	// PipelineStopped - Pipeline is in STOPPED state
	PipelineStopped = "STOPPED"
	// PipelineSkipped - Pipeline is in SKIPPED state
	PipelineSkipped = "SKIPPED"
	// PipelineBuffered - Pipeline is in BUFFERED state
	PipelineBuffered = "BUFFERED"
)

Variables

This section is empty.

Functions

func NewCustomCliError

func NewCustomCliError(pipelineName string, application string, res *http.Response, err error) error

NewCustomCliError produces Custom CLI error on HTTP communication issues

Types

type ApplicationControllerAPI

type ApplicationControllerAPI interface {
	GetPipelineConfigUsingGET(ctx context.Context, application string, pipelineName string) (map[string]interface{}, *http.Response, error)
}

ApplicationControllerAPI - Interface wrapper for the Application Controller API

type ApplicationControllerError

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

func NewApplicationControllerError

func NewApplicationControllerError(spinnakerErr error, response *http.Response) *ApplicationControllerError

NewApplicationControllerError returns an error which wraps an error and HTTP response from gateapi's ApplicationController. This provides a consistent interface for reading the response body, without having to deal with the quirky ways Spinnaker wraps errors and manages response body lifetimes.

func (ApplicationControllerError) Error

func (ApplicationControllerError) StatusCode

func (e ApplicationControllerError) StatusCode() int

type CustomCliError

type CustomCliError struct {
	PipelineName    string
	ApplicationName string
	StatusCode      int
	Err             error
}

CustomCliError - an error wrapper for the Spinnaker API errors

func (*CustomCliError) Error

func (e *CustomCliError) Error() string

type CustomSpinCLI

type CustomSpinCLI interface {
	Do(req *http.Request) ([]byte, *http.Response, error)
	Post(url string, args io.Reader) ([]byte, *http.Response, error)
	Get(url string, args io.Reader) ([]byte, *http.Response, error)
	ExecutePipeline(application, pipelineName string, args io.Reader) (*ExecutePipelineResponse, *http.Response, error)
	PipelineExecutionDetails(refID string, args io.Reader) (*PipelineExecutionDetailsResponse, *http.Response, error)
}

CustomSpinCLI is a wrapper the implementes specific requests that are either broken or unsupported by SpinCLI.

type CustomSpinClient

type CustomSpinClient struct {
	CustomSpinCLI
	Endpoint   string
	HTTPClient HTTPClient
}

CustomSpinClient is a wrapper the implementes specific requests that are either broken or unsupported by SpinCLI.

func (*CustomSpinClient) Do

func (cli *CustomSpinClient) Do(req *http.Request) ([]byte, *http.Response, error)

Do - Generic Do, same as http.Do provided by Golang http package

func (*CustomSpinClient) ExecutePipeline

func (cli *CustomSpinClient) ExecutePipeline(application, pipelineName string, args io.Reader) (*ExecutePipelineResponse, *http.Response, error)

ExecutePipeline calls the POST endpoint of a pipeline to execute it

func (*CustomSpinClient) Get

func (cli *CustomSpinClient) Get(url string, args io.Reader) ([]byte, *http.Response, error)

Get - Generic Get request using the Spinnaker HTTP Client

func (*CustomSpinClient) PipelineExecutionDetails

func (cli *CustomSpinClient) PipelineExecutionDetails(refID string, args io.Reader) (*PipelineExecutionDetailsResponse, *http.Response, error)

func (*CustomSpinClient) Post

func (cli *CustomSpinClient) Post(url string, args io.Reader) ([]byte, *http.Response, error)

Post - Generic post request using the Spinnaker HTTP Client

type DeletePipelineResponse added in v0.0.12

type DeletePipelineResponse struct {
	StatusCode int
	App        string
	Name       string
}

type ExecutePipelineResponse

type ExecutePipelineResponse struct {
	Ref string
}

ExecutePipelineResponse - Spinnaker Execution Response which contains the RefID to a Spinnaker Pipeline Execution.

type HTTPClient

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

CustomSpinCLI is a wrapper the implementes specific requests that are either broken or unsupported by SpinCLI.

type MockApplicationControllerAPI

type MockApplicationControllerAPI struct{}

func (*MockApplicationControllerAPI) GetPipelineConfigUsingGET

func (a *MockApplicationControllerAPI) GetPipelineConfigUsingGET(ctx context.Context, application string, pipelineName string) (map[string]interface{}, *http.Response, error)

type MockApplicationControllerAPIWithEmptyID

type MockApplicationControllerAPIWithEmptyID struct{}

func (*MockApplicationControllerAPIWithEmptyID) GetPipelineConfigUsingGET

func (a *MockApplicationControllerAPIWithEmptyID) GetPipelineConfigUsingGET(ctx context.Context, application string, pipelineName string) (map[string]interface{}, *http.Response, error)

type MockCustomSpinCli

type MockCustomSpinCli struct {
	CustomSpinCLI
}

func (*MockCustomSpinCli) ExecutePipeline

func (s *MockCustomSpinCli) ExecutePipeline(application, pipelineName string, args io.Reader) (*ExecutePipelineResponse, *http.Response, error)

func (*MockCustomSpinCli) PipelineExecutionDetails

func (s *MockCustomSpinCli) PipelineExecutionDetails(refID string, args io.Reader) (*PipelineExecutionDetailsResponse, *http.Response, error)

type MockPipelineControllerAPI

type MockPipelineControllerAPI struct {
	mock.Mock
}

func (*MockPipelineControllerAPI) DeletePipelineUsingDELETE added in v0.0.12

func (p *MockPipelineControllerAPI) DeletePipelineUsingDELETE(ctx context.Context, application string, pipeline string) (*http.Response, error)

func (*MockPipelineControllerAPI) InvokePipelineConfigUsingPOST1

func (p *MockPipelineControllerAPI) InvokePipelineConfigUsingPOST1(ctx context.Context, application string, pipelineNameOrID string, localVarOptionals *spinGateApi.PipelineControllerApiInvokePipelineConfigUsingPOST1Opts) (*http.Response, error)

func (*MockPipelineControllerAPI) SavePipelineUsingPOST

func (p *MockPipelineControllerAPI) SavePipelineUsingPOST(ctx context.Context, pipeline interface{}, localVarOptionals *spinGateApi.PipelineControllerApiSavePipelineUsingPOSTOpts) (*http.Response, error)

type PipelineControllerAPI

type PipelineControllerAPI interface {
	SavePipelineUsingPOST(ctx context.Context, pipeline interface{}, localVarOptionals *spinGateApi.PipelineControllerApiSavePipelineUsingPOSTOpts) (*http.Response, error)
	DeletePipelineUsingDELETE(ctx context.Context, application string, pipelineName string) (*http.Response, error)
}

PipelineControllerAPI - Interface wrapper for the Pipeline Controller API

type PipelineExecutionDetailsResponse

type PipelineExecutionDetailsResponse struct {
	Type         string                   `json:"type"`
	Status       string                   `json:"status"`
	Canceled     bool                     `json:"canceled"`
	BuildTime    int                      `json:"buildTime"`
	StartTime    int                      `json:"startTime"`
	Application  string                   `json:"application"`
	Stages       []map[string]interface{} `json:"stages"`
	PipelineName string                   `json:"pipelineName"`
}

type SpinCLI

SpinCLI is a wrapper for the spin-cli gateway client backed by swagger

type SpinClient

type SpinClient struct {
	*SpinCLI
	CustomSpinCLI
	// contains filtered or unexported fields
}

SpinClient - Concrete type requiring all the methods of the specified interfaces.

func NewClient

func NewClient(logger logrus.FieldLogger) *SpinClient

NewClient - Create a new default spinnaker client

func (*SpinClient) DeletePipeline added in v0.0.12

func (s *SpinClient) DeletePipeline(pipelineJSON string) (*http.Response, error)

DeletePipeline - deletes rendered pipeline (recursively, if there are nested pipelines)

func (*SpinClient) DeletePipelines added in v0.0.12

func (s *SpinClient) DeletePipelines(application string, pipelineNames []string, ch chan DeletePipelineResponse, errCh chan error)

DeletePipelines - asynchronously deletes pipelines list from the application provided as input. Writes results to ch. Error encountered is written to errCh and waits till all running in parallel deletion goroutines finish.

func (*SpinClient) ExecutePipeline

func (s *SpinClient) ExecutePipeline(argsJSON string, stringify bool) (string, *http.Response, error)

ExecutePipeline - Execute a spinnaker pipeline.

`patameters` are optional.

func (*SpinClient) GetPipeline

func (s *SpinClient) GetPipeline(application string, pipelineName string) (map[string]interface{}, *http.Response, error)

func (*SpinClient) GetPipelinesNamesAndApplication added in v0.0.12

func (s *SpinClient) GetPipelinesNamesAndApplication(pipelineJSON string) ([]string, string, error)

GetPipelinesNamesAndApplication - gets list of names of all pipelines and application name configured

func (*SpinClient) RunTest

func (s *SpinClient) RunTest(testName string, testConfig shore_testing.TestsConfig, testErrors map[string][]string, stringify bool) *TestPipelineResponse

func (*SpinClient) SavePipeline

func (s *SpinClient) SavePipeline(pipelineJSON string) (*http.Response, error)

SavePipeline - Creates or Update nested pipelines recursively

func (*SpinClient) TestPipeline

func (s *SpinClient) TestPipeline(testConfig shore_testing.TestsConfig, onChange func(), stringify bool) error

TestPipeline - Run a Spinnaker testing Currently returns a not-so-well formatted error. The intended solution is to create a shared API between `shore-cli` & the `backend` to expect well formatted struct for the CLI to render correctly. TODO: Design a struct to pass data back to `shore-cli` so the UI layer could render the test-results correctly.

func (*SpinClient) ValidateTestResponses

func (s *SpinClient) ValidateTestResponses(testResponse TestPipelineResponse, timeout int, testErrors map[string][]string) error

func (*SpinClient) WaitForPipelineToFinish

func (s *SpinClient) WaitForPipelineToFinish(refID string, timeout int) (string, *http.Response, error)

WaitForPipelineToFinish - Wait for the pipeline to finish running. This call uses sleeps and is a blocking call.

type TestPipelineResponse

type TestPipelineResponse struct {
	ExecutionDetails *PipelineExecutionDetailsResponse
	// contains filtered or unexported fields
}

type UI

type UI struct{}

UI A fake UI

func (*UI) Ask

func (ui *UI) Ask(string) (string, error)

Ask asks the user for input using the given query. The response is returned as the given string, or an error.

func (*UI) AskSecret

func (ui *UI) AskSecret(string) (string, error)

AskSecret asks the user for input using the given query, but does not echo the keystrokes to the terminal.

func (*UI) Error

func (ui *UI) Error(string)

Error is used for any error messages that might appear on standard error.

func (*UI) Info

func (ui *UI) Info(string)

Info is called for information related to the previous output. In general this may be the exact same as Output, but this gives Ui implementors some flexibility with output formats.

func (*UI) JsonOutput

func (ui *UI) JsonOutput(data interface{})

JsonOutput is used to output data in JSON format (probably?) Seems like the spin cli maintainers didn't follow standards, the method name should have been `JSONOutput` according to Golang best practices

func (*UI) Output

func (ui *UI) Output(string)

Output is called for normal standard output.

func (*UI) Success

func (ui *UI) Success(message string)

Success is used for success cases (probably?)

func (*UI) Warn

func (ui *UI) Warn(string)

Warn is used for any warning messages that might appear on standard error.

Jump to

Keyboard shortcuts

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