devops

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 40 Imported by: 6

Documentation

Index

Constants

View Source
const (
	StatusActive     = "active"
	StatusDeleted    = "deleted"
	StatusDeleting   = "deleting"
	StatusFailed     = "failed"
	StatusPending    = "pending"
	StatusWorking    = "working"
	StatusSuccessful = "successful"
)
View Source
const (
	StatusColumn     = "status"
	StatusTimeColumn = "status_time"
)
View Source
const (
	VisibilityPrivate = "private"
	VisibilityPublic  = "public"
)
View Source
const (
	ProjectOwner      = "owner"
	ProjectMaintainer = "maintainer"
	ProjectDeveloper  = "developer"
	ProjectReporter   = "reporter"
)

define roles of DevOps

View Source
const (
	JenkinsAllUserRoleName = "kubesphere-user"
	JenkinsAdminRoleName   = "admin"
)
View Source
const (
	DevOpsProjectTableName         = "project"
	DevOpsProjectPrefix            = "project-"
	DevOpsProjectDescriptionColumn = "description"
	DevOpsProjectIdColumn          = "project.project_id"
	DevOpsProjectNameColumn        = "project.name"
	DevOpsProjectExtraColumn       = "project.extra"
	DevOpsProjectWorkSpaceColumn   = "project.workspace"
	DevOpsProjectCreateTimeColumn  = "project.create_time"
)
View Source
const (
	GetS2iBinaryURL = "http://ks-apiserver.kubesphere-system.svc/kapis/devops.kubesphere.io/v1alpha2/namespaces/%s/s2ibinaries/%s/file/%s"
)
View Source
const (
	KS_ADMIN = "admin"
)

Variables

View Source
var DefaultRoles = []*Role{
	{
		Name:        ProjectOwner,
		Description: "Owner have access to do all the operations of a DevOps project and own the highest permissions as well.",
	},
	{
		Name:        ProjectMaintainer,
		Description: "Maintainer have access to manage pipeline and credential configuration in a DevOps project.",
	},
	{
		Name:        ProjectDeveloper,
		Description: "Developer is able to view and trigger the pipeline.",
	},
	{
		Name:        ProjectReporter,
		Description: "Reporter is only allowed to view the status of the pipeline.",
	},
}
View Source
var DevOpsProjectColumns = GetColumnsFromStruct(&v1alpha2.DevOpsProject{})
View Source
var JenkinsOwnerProjectPermissionIds = &devops.ProjectPermissionIds{
	CredentialCreate:        true,
	CredentialDelete:        true,
	CredentialManageDomains: true,
	CredentialUpdate:        true,
	CredentialView:          true,
	ItemBuild:               true,
	ItemCancel:              true,
	ItemConfigure:           true,
	ItemCreate:              true,
	ItemDelete:              true,
	ItemDiscover:            true,
	ItemMove:                true,
	ItemRead:                true,
	ItemWorkspace:           true,
	RunDelete:               true,
	RunReplay:               true,
	RunUpdate:               true,
	SCMTag:                  true,
}

define the permission matrix of owner

View Source
var JenkinsPipelinePermissionMap = map[string]devops.ProjectPermissionIds{
	ProjectOwner: {
		CredentialCreate:        true,
		CredentialDelete:        true,
		CredentialManageDomains: true,
		CredentialUpdate:        true,
		CredentialView:          true,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           true,
		ItemCreate:              true,
		ItemDelete:              true,
		ItemDiscover:            true,
		ItemMove:                true,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  true,
	},
	ProjectMaintainer: {
		CredentialCreate:        true,
		CredentialDelete:        true,
		CredentialManageDomains: true,
		CredentialUpdate:        true,
		CredentialView:          true,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           true,
		ItemCreate:              true,
		ItemDelete:              true,
		ItemDiscover:            true,
		ItemMove:                true,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  true,
	},
	ProjectDeveloper: {
		CredentialCreate:        false,
		CredentialDelete:        false,
		CredentialManageDomains: false,
		CredentialUpdate:        false,
		CredentialView:          false,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           false,
		ItemCreate:              false,
		ItemDelete:              false,
		ItemDiscover:            true,
		ItemMove:                false,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  false,
	},
	ProjectReporter: {
		CredentialCreate:        false,
		CredentialDelete:        false,
		CredentialManageDomains: false,
		CredentialUpdate:        false,
		CredentialView:          false,
		ItemBuild:               false,
		ItemCancel:              false,
		ItemConfigure:           false,
		ItemCreate:              false,
		ItemDelete:              false,
		ItemDiscover:            true,
		ItemMove:                false,
		ItemRead:                true,
		ItemWorkspace:           false,
		RunDelete:               false,
		RunReplay:               false,
		RunUpdate:               false,
		SCMTag:                  false,
	},
}

define the permission matrix of pipeline, including owner, maintainer, developer, reporter

View Source
var JenkinsProjectPermissionMap = map[string]devops.ProjectPermissionIds{
	ProjectOwner: {
		CredentialCreate:        true,
		CredentialDelete:        true,
		CredentialManageDomains: true,
		CredentialUpdate:        true,
		CredentialView:          true,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           true,
		ItemCreate:              true,
		ItemDelete:              true,
		ItemDiscover:            true,
		ItemMove:                true,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  true,
	},
	ProjectMaintainer: {
		CredentialCreate:        true,
		CredentialDelete:        true,
		CredentialManageDomains: true,
		CredentialUpdate:        true,
		CredentialView:          true,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           false,
		ItemCreate:              true,
		ItemDelete:              false,
		ItemDiscover:            true,
		ItemMove:                false,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  true,
	},
	ProjectDeveloper: {
		CredentialCreate:        false,
		CredentialDelete:        false,
		CredentialManageDomains: false,
		CredentialUpdate:        false,
		CredentialView:          false,
		ItemBuild:               true,
		ItemCancel:              true,
		ItemConfigure:           false,
		ItemCreate:              false,
		ItemDelete:              false,
		ItemDiscover:            true,
		ItemMove:                false,
		ItemRead:                true,
		ItemWorkspace:           true,
		RunDelete:               true,
		RunReplay:               true,
		RunUpdate:               true,
		SCMTag:                  false,
	},
	ProjectReporter: {
		CredentialCreate:        false,
		CredentialDelete:        false,
		CredentialManageDomains: false,
		CredentialUpdate:        false,
		CredentialView:          false,
		ItemBuild:               false,
		ItemCancel:              false,
		ItemConfigure:           false,
		ItemCreate:              false,
		ItemDelete:              false,
		ItemDiscover:            true,
		ItemMove:                false,
		ItemRead:                true,
		ItemWorkspace:           false,
		RunDelete:               false,
		RunReplay:               false,
		RunUpdate:               false,
		SCMTag:                  false,
	},
}

define the permission matrix of DevOps, including owner, maintainer, developer, reporter

Functions

func GetColumnsFromStruct

func GetColumnsFromStruct(s interface{}) []string

func GetColumnsFromStructWithPrefix

func GetColumnsFromStructWithPrefix(prefix string, s interface{}) []string

func GetPipelineRoleName

func GetPipelineRoleName(projectId, role string) string

get roleName of the pipeline

func GetPipelineRolePattern

func GetPipelineRolePattern(projectId string) string

get pattern string of the project

func GetProjectRoleName

func GetProjectRoleName(projectId, role string) string

get roleName of the project

func GetProjectRolePattern

func GetProjectRolePattern(projectId string) string

get pattern string of the project

func GetSyncNowTime

func GetSyncNowTime() string

get unified sync current time

func NewDevOpsProject

func NewDevOpsProject(name, description, creator, extra, workspace string) *v1alpha2.DevOpsProject

func WithPrefix

func WithPrefix(prefix, str string) string

Types

type DevopsOperator

type DevopsOperator interface {
	CreateDevOpsProject(workspace string, project *v1alpha3.DevOpsProject) (*v1alpha3.DevOpsProject, error)
	GetDevOpsProject(workspace string, projectName string) (*v1alpha3.DevOpsProject, error)
	DeleteDevOpsProject(workspace string, projectName string) error
	UpdateDevOpsProject(workspace string, project *v1alpha3.DevOpsProject) (*v1alpha3.DevOpsProject, error)
	ListDevOpsProject(workspace string, limit, offset int) (api.ListResult, error)

	CreatePipelineObj(projectName string, pipeline *v1alpha3.Pipeline) (*v1alpha3.Pipeline, error)
	GetPipelineObj(projectName string, pipelineName string) (*v1alpha3.Pipeline, error)
	DeletePipelineObj(projectName string, pipelineName string) error
	UpdatePipelineObj(projectName string, pipeline *v1alpha3.Pipeline) (*v1alpha3.Pipeline, error)
	ListPipelineObj(projectName string, limit, offset int) (api.ListResult, error)

	CreateCredentialObj(projectName string, s *v1.Secret) (*v1.Secret, error)
	GetCredentialObj(projectName string, secretName string) (*v1.Secret, error)
	DeleteCredentialObj(projectName string, secretName string) error
	UpdateCredentialObj(projectName string, secret *v1.Secret) (*v1.Secret, error)
	ListCredentialObj(projectName string, query *query.Query) (api.ListResult, error)

	GetPipeline(projectName, pipelineName string, req *http.Request) (*devops.Pipeline, error)
	ListPipelines(req *http.Request) (*devops.PipelineList, error)
	GetPipelineRun(projectName, pipelineName, runId string, req *http.Request) (*devops.PipelineRun, error)
	ListPipelineRuns(projectName, pipelineName string, req *http.Request) (*devops.PipelineRunList, error)
	StopPipeline(projectName, pipelineName, runId string, req *http.Request) (*devops.StopPipeline, error)
	ReplayPipeline(projectName, pipelineName, runId string, req *http.Request) (*devops.ReplayPipeline, error)
	RunPipeline(projectName, pipelineName string, req *http.Request) (*devops.RunPipeline, error)
	GetArtifacts(projectName, pipelineName, runId string, req *http.Request) ([]devops.Artifacts, error)
	GetRunLog(projectName, pipelineName, runId string, req *http.Request) ([]byte, error)
	GetStepLog(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error)
	GetNodeSteps(projectName, pipelineName, runId, nodeId string, req *http.Request) ([]devops.NodeSteps, error)
	GetPipelineRunNodes(projectName, pipelineName, runId string, req *http.Request) ([]devops.PipelineRunNodes, error)
	SubmitInputStep(projectName, pipelineName, runId, nodeId, stepId string, req *http.Request) ([]byte, error)
	GetNodesDetail(projectName, pipelineName, runId string, req *http.Request) ([]devops.NodesDetail, error)

	GetBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) (*devops.BranchPipeline, error)
	GetBranchPipelineRun(projectName, pipelineName, branchName, runId string, req *http.Request) (*devops.PipelineRun, error)
	StopBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) (*devops.StopPipeline, error)
	ReplayBranchPipeline(projectName, pipelineName, branchName, runId string, req *http.Request) (*devops.ReplayPipeline, error)
	RunBranchPipeline(projectName, pipelineName, branchName string, req *http.Request) (*devops.RunPipeline, error)
	GetBranchArtifacts(projectName, pipelineName, branchName, runId string, req *http.Request) ([]devops.Artifacts, error)
	GetBranchRunLog(projectName, pipelineName, branchName, runId string, req *http.Request) ([]byte, error)
	GetBranchStepLog(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, http.Header, error)
	GetBranchNodeSteps(projectName, pipelineName, branchName, runId, nodeId string, req *http.Request) ([]devops.NodeSteps, error)
	GetBranchPipelineRunNodes(projectName, pipelineName, branchName, runId string, req *http.Request) ([]devops.BranchPipelineRunNodes, error)
	SubmitBranchInputStep(projectName, pipelineName, branchName, runId, nodeId, stepId string, req *http.Request) ([]byte, error)
	GetBranchNodesDetail(projectName, pipelineName, branchName, runId string, req *http.Request) ([]devops.NodesDetail, error)
	GetPipelineBranch(projectName, pipelineName string, req *http.Request) (*devops.PipelineBranch, error)
	ScanBranch(projectName, pipelineName string, req *http.Request) ([]byte, error)

	GetConsoleLog(projectName, pipelineName string, req *http.Request) ([]byte, error)
	GetCrumb(req *http.Request) (*devops.Crumb, error)

	GetSCMServers(scmId string, req *http.Request) ([]devops.SCMServer, error)
	GetSCMOrg(scmId string, req *http.Request) ([]devops.SCMOrg, error)
	GetOrgRepo(scmId, organizationId string, req *http.Request) (devops.OrgRepo, error)
	CreateSCMServers(scmId string, req *http.Request) (*devops.SCMServer, error)
	Validate(scmId string, req *http.Request) (*devops.Validates, error)

	GetNotifyCommit(req *http.Request) ([]byte, error)
	GithubWebhook(req *http.Request) ([]byte, error)

	CheckScriptCompile(projectName, pipelineName string, req *http.Request) (*devops.CheckScript, error)
	CheckCron(projectName string, req *http.Request) (*devops.CheckCronRes, error)

	ToJenkinsfile(req *http.Request) (*devops.ResJenkinsfile, error)
	ToJson(req *http.Request) (*devops.ResJson, error)
}

type JkError

type JkError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

func (*JkError) Error

func (err *JkError) Error() string

type PipelineSonarGetter

type PipelineSonarGetter interface {
	GetPipelineSonar(projectId, pipelineId string) ([]*sonarqube.SonarStatus, error)
	GetMultiBranchPipelineSonar(projectId, pipelineId, branchId string) ([]*sonarqube.SonarStatus, error)
}

func NewPipelineSonarGetter

func NewPipelineSonarGetter(devopClient devops.BuildGetter, sonarClient sonarqube.SonarInterface) PipelineSonarGetter

type ProjectCredentialGetter

type ProjectCredentialGetter interface {
	GetProjectCredentialUsage(projectId, credentialId string) (*devops.Credential, error)
}

func NewProjectCredentialOperator

func NewProjectCredentialOperator(devopsClient devops.Interface) ProjectCredentialGetter

type Role

type Role struct {
	Name        string `json:"name" description:"role's name e.g. owner'"`
	Description string `json:"description" description:"role 's description'"`
}

type S2iBinaryUploader

type S2iBinaryUploader interface {
	UploadS2iBinary(namespace, name, md5 string, header *multipart.FileHeader) (*v1alpha1.S2iBinary, error)

	DownloadS2iBinary(namespace, name, fileName string) (string, error)
}

func NewS2iBinaryUploader

func NewS2iBinaryUploader(client versioned.Interface, informers externalversions.SharedInformerFactory, s3Client s3.Interface) S2iBinaryUploader

Jump to

Keyboard shortcuts

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