Documentation ¶
Index ¶
- Variables
- func PrepareCancelQueue(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string)
- func PrepareCommonPost(request *http.Request, responseBody string, ...) (response *http.Response)
- func PrepareCommonPostWithResponseCode(request *http.Request, responseBody string, responseCode int, ...) (response *http.Response)
- func PrepareFor500InstalledPluginList(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) (request *http.Request, response *http.Response)
- func PrepareForCancelShutdown(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, ...)
- func PrepareForEmptyAvaiablePluginList(roundTripper *mhttp.MockRoundTripper, rootURL string) (request *http.Request, response *http.Response)
- func PrepareForEmptyInstalledPluginList(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) (request *http.Request, response *http.Response)
- func PrepareForGetIdentity(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
- func PrepareForGetIssuer(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string) (request *http.Request, response *http.Response)
- func PrepareForGetIssuerWith500(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
- func PrepareForInstallPlugin(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName, user, passwd string)
- func PrepareForInstallPluginWithCode(roundTripper *mhttp.MockRoundTripper, statusCode int, ...) (response *http.Response)
- func PrepareForInstallPluginWithVersion(roundTripper *mhttp.MockRoundTripper, ...)
- func PrepareForManyAvaiablePlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) (request *http.Request, response *http.Response)
- func PrepareForManyInstalledPlugins(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) (request *http.Request, response *http.Response)
- func PrepareForNoAvailablePlugins(roundTripper *mhttp.MockRoundTripper, rootURL string) (requestCenter *http.Request, responseCenter *http.Response)
- func PrepareForOneAvaiablePlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) (request *http.Request, response *http.Response)
- func PrepareForPipelineJob(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string) (request *http.Request, response *http.Response)
- func PrepareForRequest500UpdateCenter(roundTripper *mhttp.MockRoundTripper, rootURL string) (requestCenter *http.Request, responseCenter *http.Response)
- func PrepareForRequestUpdateCenter(roundTripper *mhttp.MockRoundTripper, rootURL string) (requestCenter *http.Request, responseCenter *http.Response)
- func PrepareForShutdown(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, ...)
- func PrepareForToJSON(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
- func PrepareForToJenkinsfile(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
- func PrepareForUninstallPlugin(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName string) (request *http.Request, response *http.Response, requestCrumb *http.Request, ...)
- func PrepareForUninstallPluginWith500(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName string) (request *http.Request, response *http.Response, requestCrumb *http.Request, ...)
- func PrepareForUpdatePipelineJob(roundTripper *mhttp.MockRoundTripper, rootURL, script, user, password string)
- func PrepareForUploadPlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) (request *http.Request, response *http.Response, requestCrumb *http.Request, ...)
- func PrepareGetQueue(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string)
- func PrepareRestart(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, ...)
- func PrepareRestartDirectly(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, ...)
- func SetLanguage(lan string)
- func SetLogger(zapLogger *zap.Logger)
- type Client
- func (q *Client) GetIdentity() (identity JenkinsIdentity, err error)
- func (q *Client) PrepareShutdown(cancel bool) (err error)
- func (q *Client) Restart() (err error)
- func (q *Client) RestartDirectly() (err error)
- func (q *Client) Shutdown(safe bool) (err error)
- func (q *Client) ToJSON(jenkinsfile string) (result GenericResult, err error)
- func (q *Client) ToJenkinsfile(data string) (result GenericResult, err error)
- type GenericResult
- type JSONResult
- type JenkinsCore
- func (j *JenkinsCore) AuthHandle(request *http.Request) (err error)
- func (j *JenkinsCore) CrumbHandle(request *http.Request) error
- func (j *JenkinsCore) ErrorHandle(statusCode int, data []byte) (err error)
- func (j *JenkinsCore) GetClient() (client *http.Client)
- func (j *JenkinsCore) GetCrumb() (crumbIssuer *JenkinsCrumb, err error)
- func (j *JenkinsCore) PermissionError(statusCode int) (err error)
- func (j *JenkinsCore) ProxyHandle(request *http.Request)
- func (j *JenkinsCore) Request(method, api string, headers map[string]string, payload io.Reader) (statusCode int, data []byte, err error)
- func (j *JenkinsCore) RequestWithData(method, api string, headers map[string]string, payload io.Reader, ...) (err error)
- func (j *JenkinsCore) RequestWithResponse(method, api string, headers map[string]string, payload io.Reader) (response *http.Response, err error)
- func (j *JenkinsCore) RequestWithResponseHeader(method, api string, headers map[string]string, payload io.Reader, ...) (response *http.Response, err error)
- func (j *JenkinsCore) RequestWithoutData(method, api string, headers map[string]string, payload io.Reader, ...) (statusCode int, err error)
- type JenkinsCrumb
- type JenkinsIdentity
- type JenkinsfileResult
- type RequestMatcher
- type Result
Constants ¶
This section is empty.
Variables ¶
var AsFormRequest = map[string]string{httpdownloader.ContentType: httpdownloader.ApplicationForm}
AsFormRequest is the fixed header for the form request purpose
var Logger *zap.Logger
Functions ¶
func PrepareCancelQueue ¶
func PrepareCancelQueue(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string)
PrepareCancelQueue only for test
func PrepareCommonPost ¶
func PrepareCommonPost(request *http.Request, responseBody string, roundTripper *mhttp.MockRoundTripper, user, passwd, rootURL string) ( response *http.Response)
PrepareCommonPost only for test
func PrepareCommonPostWithResponseCode ¶ added in v0.0.8
func PrepareCommonPostWithResponseCode(request *http.Request, responseBody string, responseCode int, roundTripper *mhttp.MockRoundTripper, user, passwd, rootURL string) ( response *http.Response)
PrepareCommonPostWithResponseCode only for test
func PrepareFor500InstalledPluginList ¶
func PrepareFor500InstalledPluginList(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) ( request *http.Request, response *http.Response)
PrepareFor500InstalledPluginList only for test
func PrepareForCancelShutdown ¶
func PrepareForCancelShutdown(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, cancel bool)
PrepareForCancelShutdown only for test
func PrepareForEmptyAvaiablePluginList ¶
func PrepareForEmptyAvaiablePluginList(roundTripper *mhttp.MockRoundTripper, rootURL string) ( request *http.Request, response *http.Response)
PrepareForEmptyAvaiablePluginList only for test
func PrepareForEmptyInstalledPluginList ¶
func PrepareForEmptyInstalledPluginList(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) ( request *http.Request, response *http.Response)
PrepareForEmptyInstalledPluginList only for test
func PrepareForGetIdentity ¶
func PrepareForGetIdentity(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
PrepareForGetIdentity only for test
func PrepareForGetIssuer ¶
func PrepareForGetIssuer(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string) ( request *http.Request, response *http.Response)
PrepareForGetIssuer only for test
func PrepareForGetIssuerWith500 ¶
func PrepareForGetIssuerWith500(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
PrepareForGetIssuerWith500 only for test
func PrepareForInstallPlugin ¶
func PrepareForInstallPlugin(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName, user, passwd string)
PrepareForInstallPlugin only for test
func PrepareForInstallPluginWithCode ¶
func PrepareForInstallPluginWithCode(roundTripper *mhttp.MockRoundTripper, statusCode int, rootURL, pluginName, user, passwd string) (response *http.Response)
PrepareForInstallPluginWithCode only for test
func PrepareForInstallPluginWithVersion ¶
func PrepareForInstallPluginWithVersion(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName, version, user, passwd string)
PrepareForInstallPluginWithVersion only for test
func PrepareForManyAvaiablePlugin ¶
func PrepareForManyAvaiablePlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) ( request *http.Request, response *http.Response)
PrepareForManyAvaiablePlugin only for test
func PrepareForManyInstalledPlugins ¶
func PrepareForManyInstalledPlugins(roundTripper *mhttp.MockRoundTripper, rootURL string, depth int) ( request *http.Request, response *http.Response)
PrepareForManyInstalledPlugins only for test
func PrepareForNoAvailablePlugins ¶
func PrepareForNoAvailablePlugins(roundTripper *mhttp.MockRoundTripper, rootURL string) ( requestCenter *http.Request, responseCenter *http.Response)
PrepareForNoAvailablePlugins only for the test case
func PrepareForOneAvaiablePlugin ¶
func PrepareForOneAvaiablePlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) ( request *http.Request, response *http.Response)
PrepareForOneAvaiablePlugin only for test
func PrepareForPipelineJob ¶
func PrepareForPipelineJob(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string) ( request *http.Request, response *http.Response)
PrepareForPipelineJob only for test
func PrepareForRequest500UpdateCenter ¶
func PrepareForRequest500UpdateCenter(roundTripper *mhttp.MockRoundTripper, rootURL string) ( requestCenter *http.Request, responseCenter *http.Response)
PrepareForRequest500UpdateCenter only for the test case
func PrepareForRequestUpdateCenter ¶
func PrepareForRequestUpdateCenter(roundTripper *mhttp.MockRoundTripper, rootURL string) ( requestCenter *http.Request, responseCenter *http.Response)
PrepareForRequestUpdateCenter only for the test case
func PrepareForShutdown ¶
func PrepareForShutdown(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, safe bool)
PrepareForShutdown only for test
func PrepareForToJSON ¶ added in v0.0.10
func PrepareForToJSON(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
PrepareForToJSON only for test
func PrepareForToJenkinsfile ¶ added in v0.0.10
func PrepareForToJenkinsfile(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string)
PrepareForToJenkinsfile only for test
func PrepareForUninstallPlugin ¶
func PrepareForUninstallPlugin(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName string) ( request *http.Request, response *http.Response, requestCrumb *http.Request, responseCrumb *http.Response)
PrepareForUninstallPlugin only for test
func PrepareForUninstallPluginWith500 ¶
func PrepareForUninstallPluginWith500(roundTripper *mhttp.MockRoundTripper, rootURL, pluginName string) ( request *http.Request, response *http.Response, requestCrumb *http.Request, responseCrumb *http.Response)
PrepareForUninstallPluginWith500 only for test
func PrepareForUpdatePipelineJob ¶
func PrepareForUpdatePipelineJob(roundTripper *mhttp.MockRoundTripper, rootURL, script, user, password string)
PrepareForUpdatePipelineJob only for test
func PrepareForUploadPlugin ¶
func PrepareForUploadPlugin(roundTripper *mhttp.MockRoundTripper, rootURL string) ( request *http.Request, response *http.Response, requestCrumb *http.Request, responseCrumb *http.Response)
PrepareForUploadPlugin only for test
func PrepareGetQueue ¶
func PrepareGetQueue(roundTripper *mhttp.MockRoundTripper, rootURL, user, passwd string)
PrepareGetQueue only for test
func PrepareRestart ¶
func PrepareRestart(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, statusCode int)
PrepareRestart only for test
func PrepareRestartDirectly ¶
func PrepareRestartDirectly(roundTripper *mhttp.MockRoundTripper, rootURL, user, password string, statusCode int)
PrepareRestartDirectly only for test
Types ¶
type Client ¶
type Client struct {
JenkinsCore
}
Client hold the client of Jenkins core
func (*Client) GetIdentity ¶
func (q *Client) GetIdentity() (identity JenkinsIdentity, err error)
GetIdentity returns the identity of a Jenkins
func (*Client) PrepareShutdown ¶
PrepareShutdown Put Jenkins in a Quiet mode, in preparation for a restart. In that mode Jenkins don’t start any build
func (*Client) RestartDirectly ¶
RestartDirectly restart Jenkins directly
func (*Client) Shutdown ¶
Shutdown puts Jenkins into the quiet mode, wait for existing builds to be completed, and then shut down Jenkins
func (*Client) ToJSON ¶ added in v0.0.10
func (q *Client) ToJSON(jenkinsfile string) (result GenericResult, err error)
ToJSON turns a Jenkinsfile to JSON format Read details from https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/master/EXTENDING.md
func (*Client) ToJenkinsfile ¶ added in v0.0.10
func (q *Client) ToJenkinsfile(data string) (result GenericResult, err error)
ToJenkinsfile converts a JSON format data to Jenkinsfile Read details from https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/master/EXTENDING.md
type GenericResult ¶ added in v0.0.10
GenericResult represents a generic result interface
type JSONResult ¶ added in v0.0.10
type JSONResult struct { Result string `json:"result"` JSON map[string]interface{} `json:"json"` Errors []string `json:"errors"` }
JSONResult represents the JSON result
func (JSONResult) GetErrors ¶ added in v0.0.10
func (r JSONResult) GetErrors() []string
GetErrors returns the errors
func (JSONResult) GetResult ¶ added in v0.0.10
func (r JSONResult) GetResult() string
GetResult returns the result of this object
func (JSONResult) GetStatus ¶ added in v0.0.10
func (r JSONResult) GetStatus() string
GetStatus returns the status
type JenkinsCore ¶
type JenkinsCore struct { JenkinsCrumb Timeout time.Duration URL string InsecureSkipVerify bool UserName string Token string Proxy string ProxyAuth string Debug bool Output io.Writer RoundTripper http.RoundTripper }
JenkinsCore core information of Jenkins
func (*JenkinsCore) AuthHandle ¶
func (j *JenkinsCore) AuthHandle(request *http.Request) (err error)
AuthHandle takes care of the auth
func (*JenkinsCore) CrumbHandle ¶
func (j *JenkinsCore) CrumbHandle(request *http.Request) error
CrumbHandle handle crum with http request
func (*JenkinsCore) ErrorHandle ¶
func (j *JenkinsCore) ErrorHandle(statusCode int, data []byte) (err error)
ErrorHandle handles the error cases
func (*JenkinsCore) GetClient ¶
func (j *JenkinsCore) GetClient() (client *http.Client)
GetClient get the default http Jenkins client
func (*JenkinsCore) GetCrumb ¶
func (j *JenkinsCore) GetCrumb() (crumbIssuer *JenkinsCrumb, err error)
GetCrumb get the crumb from Jenkins
func (*JenkinsCore) PermissionError ¶
func (j *JenkinsCore) PermissionError(statusCode int) (err error)
PermissionError handles the no permission
func (*JenkinsCore) ProxyHandle ¶
func (j *JenkinsCore) ProxyHandle(request *http.Request)
ProxyHandle takes care of the proxy setting
func (*JenkinsCore) Request ¶
func (j *JenkinsCore) Request(method, api string, headers map[string]string, payload io.Reader) ( statusCode int, data []byte, err error)
Request make a common request
func (*JenkinsCore) RequestWithData ¶
func (j *JenkinsCore) RequestWithData(method, api string, headers map[string]string, payload io.Reader, successCode int, obj interface{}) (err error)
RequestWithData requests the api and parse the data into an interface
func (*JenkinsCore) RequestWithResponse ¶
func (j *JenkinsCore) RequestWithResponse(method, api string, headers map[string]string, payload io.Reader) ( response *http.Response, err error)
RequestWithResponse make a common request
type JenkinsCrumb ¶
JenkinsCrumb crumb for Jenkins
type JenkinsIdentity ¶
JenkinsIdentity belongs to a Jenkins
type JenkinsfileResult ¶ added in v0.0.10
type JenkinsfileResult struct { Result string `json:"result"` Jenkinsfile string `json:"jenkinsfile"` Errors []string `json:"errors"` }
JenkinsfileResult represents the Jenkinsfile result
func (JenkinsfileResult) GetErrors ¶ added in v0.0.10
func (r JenkinsfileResult) GetErrors() []string
GetErrors returns the errors
func (JenkinsfileResult) GetResult ¶ added in v0.0.10
func (r JenkinsfileResult) GetResult() string
GetResult returns the result
func (JenkinsfileResult) GetStatus ¶ added in v0.0.10
func (r JenkinsfileResult) GetStatus() string
GetStatus returns the status
type RequestMatcher ¶
type RequestMatcher struct {
// contains filtered or unexported fields
}
RequestMatcher to match the http request
func NewRequestMatcher ¶
func NewRequestMatcher(request *http.Request) *RequestMatcher
NewRequestMatcher create a request matcher will match request method and request path
func NewVerboseRequestMatcher ¶
func NewVerboseRequestMatcher(request *http.Request) *RequestMatcher
NewVerboseRequestMatcher create a verbose request matcher will match request method and request path
func (*RequestMatcher) Matches ¶
func (matcher *RequestMatcher) Matches(x interface{}) bool
Matches returns a matcher with given function
func (*RequestMatcher) String ¶
func (matcher *RequestMatcher) String() string
String returns the text of current object
func (*RequestMatcher) WithBody ¶
func (matcher *RequestMatcher) WithBody() *RequestMatcher
WithBody returns a matcher with body
func (*RequestMatcher) WithQuery ¶
func (matcher *RequestMatcher) WithQuery() *RequestMatcher
WithQuery returns a matcher with query
type Result ¶ added in v0.0.10
type Result struct { Status string `json:"status"` Data GenericResult `json:"data"` }
Result represents a generic result