idler

package
v0.0.0-...-9ac85d6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UnknownState used when the state isn't known, along with err
	UnknownState PodState = ""
	// Running represents a running pod
	Running = "running"
	// Starting represents pod that is starting
	Starting = "starting"
	// Idled represents pod that is idled
	Idled = "idled"
)
View Source
const (

	// OpenShiftAPIParam is the parameter name under which the OpenShift cluster API URL is passed using
	// Idle, UnIdle and IsIdle.
	OpenShiftAPIParam = "openshift_api_url"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a hand-rolled Idler client using plain HTTP requests.

func (*Client) Clusters

func (i *Client) Clusters() (map[string]string, error)

Clusters returns a map which maps the OpenShift API URL to the application DNS for this cluster. An empty map together with an error is returned if an error occurs.

func (*Client) State

func (i *Client) State(tenant string, openShiftAPIURL string) (PodState, error)

State returns the state of Jenkins instance for the specified tenant

func (*Client) UnIdle

func (i *Client) UnIdle(tenant string, openShiftAPIURL string) (int, error)

UnIdle initiates un-idling of the Jenkins instance for the specified tenant.

type ErrorCode

type ErrorCode uint32

ErrorCode is an integer that clients to can use to compare errors

type JenkinsInfo

type JenkinsInfo struct {
	State PodState `json:"state"`
}

JenkinsInfo contains Jenkins pod state

type Mock

type Mock struct {
	IdlerState PodState
	// contains filtered or unexported fields
}

Mock is a mock implementation of idler service

func NewMock

func NewMock(idlerAPI string, state PodState, throwError bool) (idler *Mock)

NewMock is a constructor for mock.Idler

func (*Mock) Clusters

func (i *Mock) Clusters() (map[string]string, error)

Clusters returns a map which maps the OpenShift API URL to the application DNS for this cluster. An empty map together with an error is returned if an error occurs.

func (*Mock) State

func (i *Mock) State(tenant string, openShiftAPIURL string) (PodState, error)

State just returns the value set in Idler.state

func (*Mock) UnIdle

func (i *Mock) UnIdle(tenant string, openShiftAPIURL string) (int, error)

UnIdle always unidles (mock)

type PodState

type PodState string

PodState represents status of the pod which could be running|starting|idled|

type ResponseError

type ResponseError struct {
	Code        ErrorCode `json:"code"`
	Description string    `json:"description"`
}

ResponseError contains and err description along with http status code

func (ResponseError) Error

func (e ResponseError) Error() string

type Service

type Service interface {
	UnIdle(tenant string, openShiftAPIURL string) (int, error)
	State(tenant string, openShiftAPIURL string) (PodState, error)
	Clusters() (map[string]string, error)
}

Service provides methods to talk to the idler client

func New

func New(url string) Service

New returns an instance of idler client on taking URL of idler service as an input.

type StatusResponse

type StatusResponse struct {
	Data   *JenkinsInfo    `json:"data,omitempty"`
	Errors []ResponseError `json:"errors,omitempty"`
}

StatusResponse provides jenkins status and errors that occurred while making the status API call to idler

Jump to

Keyboard shortcuts

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