client

package
v0.9.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: Apache-2.0, CC-BY-4.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client contains client for Jenkins API

Package mock is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroovyScriptExecutionFailed

type GroovyScriptExecutionFailed struct {
	ConfigurationType string
	Source            string
	Name              string
	Logs              string
}

GroovyScriptExecutionFailed is custom error type which indicates passed groovy script is invalid

func (GroovyScriptExecutionFailed) Error

type Jenkins

type Jenkins interface {
	GenerateToken(userName, tokenName string) (*UserToken, error)
	Info(ctx context.Context) (*gojenkins.ExecutorResponse, error)
	SafeRestart(ctx context.Context) error
	CreateNode(ctx context.Context, name string, numExecutors int, description string, remoteFS string, label string, options ...interface{}) (*gojenkins.Node, error)
	DeleteNode(ctx context.Context, name string) (bool, error)
	CreateFolder(ctx context.Context, name string, parents ...string) (*gojenkins.Folder, error)
	CreateJobInFolder(ctx context.Context, config string, jobName string, parentIDs ...string) (*gojenkins.Job, error)
	CreateJob(ctx context.Context, config string, options ...interface{}) (*gojenkins.Job, error)
	CreateOrUpdateJob(config, jobName string) (*gojenkins.Job, bool, error)
	RenameJob(ctx context.Context, job string, name string) *gojenkins.Job
	CopyJob(ctx context.Context, copyFrom string, newName string) (*gojenkins.Job, error)
	CreateView(ctx context.Context, name string, viewType string) (*gojenkins.View, error)
	DeleteJob(ctx context.Context, name string) (bool, error)
	BuildJob(ctx context.Context, name string, options map[string]string) (int64, error)
	GetNode(ctx context.Context, name string) (*gojenkins.Node, error)
	GetLabel(ctx context.Context, name string) (*gojenkins.Label, error)
	GetBuild(jobName string, number int64) (*gojenkins.Build, error)
	GetJob(ctx context.Context, id string, parentIDs ...string) (*gojenkins.Job, error)
	GetSubJob(ctx context.Context, parentID string, childID string) (*gojenkins.Job, error)
	GetFolder(ctx context.Context, id string, parents ...string) (*gojenkins.Folder, error)
	GetAllNodes(ctx context.Context) ([]*gojenkins.Node, error)
	GetAllBuildIds(ctx context.Context, job string) ([]gojenkins.JobBuild, error)
	GetAllJobNames(context.Context) ([]gojenkins.InnerJob, error)
	GetAllJobs(context.Context) ([]*gojenkins.Job, error)
	GetQueue(context.Context) (*gojenkins.Queue, error)
	GetQueueUrl() string
	GetQueueItem(ctx context.Context, id int64) (*gojenkins.Task, error)
	GetArtifactData(ctx context.Context, id string) (*gojenkins.FingerPrintResponse, error)
	GetPlugins(depth int) (*gojenkins.Plugins, error)
	UninstallPlugin(ctx context.Context, name string) error
	HasPlugin(ctx context.Context, name string) (*gojenkins.Plugin, error)
	InstallPlugin(ctx context.Context, name string, version string) error
	ValidateFingerPrint(ctx context.Context, id string) (bool, error)
	GetView(ctx context.Context, name string) (*gojenkins.View, error)
	GetAllViews(context.Context) ([]*gojenkins.View, error)
	Poll(ctx context.Context) (int, error)
	ExecuteScript(groovyScript string) (logs string, err error)
	GetNodeSecret(name string) (string, error)
}

Jenkins defines Jenkins API.

func NewBearerTokenAuthorization

func NewBearerTokenAuthorization(url, token string) (Jenkins, error)

NewBearerTokenAuthorization creates Jenkins API client with bearer token authorization.

func NewUserAndPasswordAuthorization

func NewUserAndPasswordAuthorization(url, userName, passwordOrToken string) (Jenkins, error)

NewUserAndPasswordAuthorization creates Jenkins API client with user and password authorization.

type JenkinsAPIConnectionSettings

type JenkinsAPIConnectionSettings struct {
	Hostname    string
	Port        int
	UseNodePort bool
}

JenkinsAPIConnectionSettings is struct that handle information about Jenkins API connection.

func (JenkinsAPIConnectionSettings) BuildJenkinsAPIUrl

func (j JenkinsAPIConnectionSettings) BuildJenkinsAPIUrl(serviceName string, serviceNamespace string, servicePort int32, serviceNodePort int32) string

BuildJenkinsAPIUrl returns Jenkins API URL.

func (JenkinsAPIConnectionSettings) Validate

func (j JenkinsAPIConnectionSettings) Validate() error

Validate validates jenkins API connection settings.

type MockJenkins

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

MockJenkins is a mock of Jenkins interface.

func NewMockJenkins

func NewMockJenkins(ctrl *gomock.Controller) *MockJenkins

NewMockJenkins creates a new mock instance.

func (*MockJenkins) BuildJob

func (m *MockJenkins) BuildJob(ctx context.Context, name string, options map[string]string) (int64, error)

BuildJob mocks base method.

func (*MockJenkins) CopyJob

func (m *MockJenkins) CopyJob(ctx context.Context, copyFrom, newName string) (*gojenkins.Job, error)

CopyJob mocks base method.

func (*MockJenkins) CreateFolder

func (m *MockJenkins) CreateFolder(ctx context.Context, name string, parents ...string) (*gojenkins.Folder, error)

CreateFolder mocks base method.

func (*MockJenkins) CreateJob

func (m *MockJenkins) CreateJob(ctx context.Context, config string, options ...interface{}) (*gojenkins.Job, error)

CreateJob mocks base method.

func (*MockJenkins) CreateJobInFolder

func (m *MockJenkins) CreateJobInFolder(ctx context.Context, config, jobName string, parentIDs ...string) (*gojenkins.Job, error)

CreateJobInFolder mocks base method.

func (*MockJenkins) CreateNode

func (m *MockJenkins) CreateNode(ctx context.Context, name string, numExecutors int, description, remoteFS, label string, options ...interface{}) (*gojenkins.Node, error)

CreateNode mocks base method.

func (*MockJenkins) CreateOrUpdateJob

func (m *MockJenkins) CreateOrUpdateJob(config, jobName string) (*gojenkins.Job, bool, error)

CreateOrUpdateJob mocks base method.

func (*MockJenkins) CreateView

func (m *MockJenkins) CreateView(ctx context.Context, name, viewType string) (*gojenkins.View, error)

CreateView mocks base method.

func (*MockJenkins) DeleteJob

func (m *MockJenkins) DeleteJob(ctx context.Context, name string) (bool, error)

DeleteJob mocks base method.

func (*MockJenkins) DeleteNode

func (m *MockJenkins) DeleteNode(ctx context.Context, name string) (bool, error)

DeleteNode mocks base method.

func (*MockJenkins) EXPECT

func (m *MockJenkins) EXPECT() *MockJenkinsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockJenkins) ExecuteScript

func (m *MockJenkins) ExecuteScript(groovyScript string) (string, error)

ExecuteScript mocks base method.

func (*MockJenkins) GenerateToken

func (m *MockJenkins) GenerateToken(userName, tokenName string) (*UserToken, error)

GenerateToken mocks base method.

func (*MockJenkins) GetAllBuildIds

func (m *MockJenkins) GetAllBuildIds(ctx context.Context, job string) ([]gojenkins.JobBuild, error)

GetAllBuildIds mocks base method.

func (*MockJenkins) GetAllJobNames

func (m *MockJenkins) GetAllJobNames(arg0 context.Context) ([]gojenkins.InnerJob, error)

GetAllJobNames mocks base method.

func (*MockJenkins) GetAllJobs

func (m *MockJenkins) GetAllJobs(arg0 context.Context) ([]*gojenkins.Job, error)

GetAllJobs mocks base method.

func (*MockJenkins) GetAllNodes

func (m *MockJenkins) GetAllNodes(ctx context.Context) ([]*gojenkins.Node, error)

GetAllNodes mocks base method.

func (*MockJenkins) GetAllViews

func (m *MockJenkins) GetAllViews(arg0 context.Context) ([]*gojenkins.View, error)

GetAllViews mocks base method.

func (*MockJenkins) GetArtifactData

func (m *MockJenkins) GetArtifactData(ctx context.Context, id string) (*gojenkins.FingerPrintResponse, error)

GetArtifactData mocks base method.

func (*MockJenkins) GetBuild

func (m *MockJenkins) GetBuild(jobName string, number int64) (*gojenkins.Build, error)

GetBuild mocks base method.

func (*MockJenkins) GetFolder

func (m *MockJenkins) GetFolder(ctx context.Context, id string, parents ...string) (*gojenkins.Folder, error)

GetFolder mocks base method.

func (*MockJenkins) GetJob

func (m *MockJenkins) GetJob(ctx context.Context, id string, parentIDs ...string) (*gojenkins.Job, error)

GetJob mocks base method.

func (*MockJenkins) GetLabel

func (m *MockJenkins) GetLabel(ctx context.Context, name string) (*gojenkins.Label, error)

GetLabel mocks base method.

func (*MockJenkins) GetNode

func (m *MockJenkins) GetNode(ctx context.Context, name string) (*gojenkins.Node, error)

GetNode mocks base method.

func (*MockJenkins) GetNodeSecret

func (m *MockJenkins) GetNodeSecret(name string) (string, error)

GetNodeSecret mocks base method.

func (*MockJenkins) GetPlugins

func (m *MockJenkins) GetPlugins(depth int) (*gojenkins.Plugins, error)

GetPlugins mocks base method.

func (*MockJenkins) GetQueue

func (m *MockJenkins) GetQueue(arg0 context.Context) (*gojenkins.Queue, error)

GetQueue mocks base method.

func (*MockJenkins) GetQueueItem

func (m *MockJenkins) GetQueueItem(ctx context.Context, id int64) (*gojenkins.Task, error)

GetQueueItem mocks base method.

func (*MockJenkins) GetQueueUrl

func (m *MockJenkins) GetQueueUrl() string

GetQueueUrl mocks base method.

func (*MockJenkins) GetSubJob

func (m *MockJenkins) GetSubJob(ctx context.Context, parentID, childID string) (*gojenkins.Job, error)

GetSubJob mocks base method.

func (*MockJenkins) GetView

func (m *MockJenkins) GetView(ctx context.Context, name string) (*gojenkins.View, error)

GetView mocks base method.

func (*MockJenkins) HasPlugin

func (m *MockJenkins) HasPlugin(ctx context.Context, name string) (*gojenkins.Plugin, error)

HasPlugin mocks base method.

func (*MockJenkins) Info

Info mocks base method.

func (*MockJenkins) InstallPlugin

func (m *MockJenkins) InstallPlugin(ctx context.Context, name, version string) error

InstallPlugin mocks base method.

func (*MockJenkins) Poll

func (m *MockJenkins) Poll(ctx context.Context) (int, error)

Poll mocks base method.

func (*MockJenkins) RenameJob

func (m *MockJenkins) RenameJob(ctx context.Context, job, name string) *gojenkins.Job

RenameJob mocks base method.

func (*MockJenkins) SafeRestart

func (m *MockJenkins) SafeRestart(ctx context.Context) error

SafeRestart mocks base method.

func (*MockJenkins) UninstallPlugin

func (m *MockJenkins) UninstallPlugin(ctx context.Context, name string) error

UninstallPlugin mocks base method.

func (*MockJenkins) ValidateFingerPrint

func (m *MockJenkins) ValidateFingerPrint(ctx context.Context, id string) (bool, error)

ValidateFingerPrint mocks base method.

type MockJenkinsMockRecorder

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

MockJenkinsMockRecorder is the mock recorder for MockJenkins.

func (*MockJenkinsMockRecorder) BuildJob

func (mr *MockJenkinsMockRecorder) BuildJob(ctx, name, options interface{}) *gomock.Call

BuildJob indicates an expected call of BuildJob.

func (*MockJenkinsMockRecorder) CopyJob

func (mr *MockJenkinsMockRecorder) CopyJob(ctx, copyFrom, newName interface{}) *gomock.Call

CopyJob indicates an expected call of CopyJob.

func (*MockJenkinsMockRecorder) CreateFolder

func (mr *MockJenkinsMockRecorder) CreateFolder(ctx, name interface{}, parents ...interface{}) *gomock.Call

CreateFolder indicates an expected call of CreateFolder.

func (*MockJenkinsMockRecorder) CreateJob

func (mr *MockJenkinsMockRecorder) CreateJob(ctx, config interface{}, options ...interface{}) *gomock.Call

CreateJob indicates an expected call of CreateJob.

func (*MockJenkinsMockRecorder) CreateJobInFolder

func (mr *MockJenkinsMockRecorder) CreateJobInFolder(ctx, config, jobName interface{}, parentIDs ...interface{}) *gomock.Call

CreateJobInFolder indicates an expected call of CreateJobInFolder.

func (*MockJenkinsMockRecorder) CreateNode

func (mr *MockJenkinsMockRecorder) CreateNode(ctx, name, numExecutors, description, remoteFS, label interface{}, options ...interface{}) *gomock.Call

CreateNode indicates an expected call of CreateNode.

func (*MockJenkinsMockRecorder) CreateOrUpdateJob

func (mr *MockJenkinsMockRecorder) CreateOrUpdateJob(config, jobName interface{}) *gomock.Call

CreateOrUpdateJob indicates an expected call of CreateOrUpdateJob.

func (*MockJenkinsMockRecorder) CreateView

func (mr *MockJenkinsMockRecorder) CreateView(ctx, name, viewType interface{}) *gomock.Call

CreateView indicates an expected call of CreateView.

func (*MockJenkinsMockRecorder) DeleteJob

func (mr *MockJenkinsMockRecorder) DeleteJob(ctx, name interface{}) *gomock.Call

DeleteJob indicates an expected call of DeleteJob.

func (*MockJenkinsMockRecorder) DeleteNode

func (mr *MockJenkinsMockRecorder) DeleteNode(ctx, name interface{}) *gomock.Call

DeleteNode indicates an expected call of DeleteNode.

func (*MockJenkinsMockRecorder) ExecuteScript

func (mr *MockJenkinsMockRecorder) ExecuteScript(groovyScript interface{}) *gomock.Call

ExecuteScript indicates an expected call of ExecuteScript.

func (*MockJenkinsMockRecorder) GenerateToken

func (mr *MockJenkinsMockRecorder) GenerateToken(userName, tokenName interface{}) *gomock.Call

GenerateToken indicates an expected call of GenerateToken.

func (*MockJenkinsMockRecorder) GetAllBuildIds

func (mr *MockJenkinsMockRecorder) GetAllBuildIds(ctx, job interface{}) *gomock.Call

GetAllBuildIds indicates an expected call of GetAllBuildIds.

func (*MockJenkinsMockRecorder) GetAllJobNames

func (mr *MockJenkinsMockRecorder) GetAllJobNames(arg0 interface{}) *gomock.Call

GetAllJobNames indicates an expected call of GetAllJobNames.

func (*MockJenkinsMockRecorder) GetAllJobs

func (mr *MockJenkinsMockRecorder) GetAllJobs(arg0 interface{}) *gomock.Call

GetAllJobs indicates an expected call of GetAllJobs.

func (*MockJenkinsMockRecorder) GetAllNodes

func (mr *MockJenkinsMockRecorder) GetAllNodes(ctx interface{}) *gomock.Call

GetAllNodes indicates an expected call of GetAllNodes.

func (*MockJenkinsMockRecorder) GetAllViews

func (mr *MockJenkinsMockRecorder) GetAllViews(arg0 interface{}) *gomock.Call

GetAllViews indicates an expected call of GetAllViews.

func (*MockJenkinsMockRecorder) GetArtifactData

func (mr *MockJenkinsMockRecorder) GetArtifactData(ctx, id interface{}) *gomock.Call

GetArtifactData indicates an expected call of GetArtifactData.

func (*MockJenkinsMockRecorder) GetBuild

func (mr *MockJenkinsMockRecorder) GetBuild(jobName, number interface{}) *gomock.Call

GetBuild indicates an expected call of GetBuild.

func (*MockJenkinsMockRecorder) GetFolder

func (mr *MockJenkinsMockRecorder) GetFolder(ctx, id interface{}, parents ...interface{}) *gomock.Call

GetFolder indicates an expected call of GetFolder.

func (*MockJenkinsMockRecorder) GetJob

func (mr *MockJenkinsMockRecorder) GetJob(ctx, id interface{}, parentIDs ...interface{}) *gomock.Call

GetJob indicates an expected call of GetJob.

func (*MockJenkinsMockRecorder) GetLabel

func (mr *MockJenkinsMockRecorder) GetLabel(ctx, name interface{}) *gomock.Call

GetLabel indicates an expected call of GetLabel.

func (*MockJenkinsMockRecorder) GetNode

func (mr *MockJenkinsMockRecorder) GetNode(ctx, name interface{}) *gomock.Call

GetNode indicates an expected call of GetNode.

func (*MockJenkinsMockRecorder) GetNodeSecret

func (mr *MockJenkinsMockRecorder) GetNodeSecret(name interface{}) *gomock.Call

GetNodeSecret indicates an expected call of GetNodeSecret.

func (*MockJenkinsMockRecorder) GetPlugins

func (mr *MockJenkinsMockRecorder) GetPlugins(depth interface{}) *gomock.Call

GetPlugins indicates an expected call of GetPlugins.

func (*MockJenkinsMockRecorder) GetQueue

func (mr *MockJenkinsMockRecorder) GetQueue(arg0 interface{}) *gomock.Call

GetQueue indicates an expected call of GetQueue.

func (*MockJenkinsMockRecorder) GetQueueItem

func (mr *MockJenkinsMockRecorder) GetQueueItem(ctx, id interface{}) *gomock.Call

GetQueueItem indicates an expected call of GetQueueItem.

func (*MockJenkinsMockRecorder) GetQueueUrl

func (mr *MockJenkinsMockRecorder) GetQueueUrl() *gomock.Call

GetQueueUrl indicates an expected call of GetQueueUrl.

func (*MockJenkinsMockRecorder) GetSubJob

func (mr *MockJenkinsMockRecorder) GetSubJob(ctx, parentID, childID interface{}) *gomock.Call

GetSubJob indicates an expected call of GetSubJob.

func (*MockJenkinsMockRecorder) GetView

func (mr *MockJenkinsMockRecorder) GetView(ctx, name interface{}) *gomock.Call

GetView indicates an expected call of GetView.

func (*MockJenkinsMockRecorder) HasPlugin

func (mr *MockJenkinsMockRecorder) HasPlugin(ctx, name interface{}) *gomock.Call

HasPlugin indicates an expected call of HasPlugin.

func (*MockJenkinsMockRecorder) Info

func (mr *MockJenkinsMockRecorder) Info(ctx interface{}) *gomock.Call

Info indicates an expected call of Info.

func (*MockJenkinsMockRecorder) InstallPlugin

func (mr *MockJenkinsMockRecorder) InstallPlugin(ctx, name, version interface{}) *gomock.Call

InstallPlugin indicates an expected call of InstallPlugin.

func (*MockJenkinsMockRecorder) Poll

func (mr *MockJenkinsMockRecorder) Poll(ctx interface{}) *gomock.Call

Poll indicates an expected call of Poll.

func (*MockJenkinsMockRecorder) RenameJob

func (mr *MockJenkinsMockRecorder) RenameJob(ctx, job, name interface{}) *gomock.Call

RenameJob indicates an expected call of RenameJob.

func (*MockJenkinsMockRecorder) SafeRestart

func (mr *MockJenkinsMockRecorder) SafeRestart(ctx interface{}) *gomock.Call

SafeRestart indicates an expected call of SafeRestart.

func (*MockJenkinsMockRecorder) UninstallPlugin

func (mr *MockJenkinsMockRecorder) UninstallPlugin(ctx, name interface{}) *gomock.Call

UninstallPlugin indicates an expected call of UninstallPlugin.

func (*MockJenkinsMockRecorder) ValidateFingerPrint

func (mr *MockJenkinsMockRecorder) ValidateFingerPrint(ctx, id interface{}) *gomock.Call

ValidateFingerPrint indicates an expected call of ValidateFingerPrint.

type UserToken

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

UserToken defines user token for Jenkins API communication

func (*UserToken) GetToken

func (token *UserToken) GetToken() string

GetToken returns user token

Jump to

Keyboard shortcuts

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