action

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// List of runs annotations
	AnnotationRunType   = "run_type"
	AnnotationRefType   = "ref_type"
	AnnotationProjectID = "projectid"
	AnnotationUserID    = "userid"

	AnnotationRunCreationTrigger = "run_creation_trigger"
	AnnotationWebhookEvent       = "webhook_event"
	AnnotationWebhookSender      = "webhook_sender"

	AnnotationCommitSHA   = "commit_sha"
	AnnotationRef         = "ref"
	AnnotationMessage     = "message"
	AnnotationCommitLink  = "commit_link"
	AnnotationCompareLink = "compare_link"

	AnnotationBranch          = "branch"
	AnnotationBranchLink      = "branch_link"
	AnnotationTag             = "tag"
	AnnotationTagLink         = "tag_link"
	AnnotationPullRequestID   = "pull_request_id"
	AnnotationPullRequestLink = "pull_request_link"
)

Variables

View Source
var (
	SkipRunMessage = regexp.MustCompile(`.*\[ci skip\].*`)
)

Functions

func ErrFromRemote

func ErrFromRemote(resp *http.Response, err error) error

Types

type ActionHandler

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

func NewActionHandler

func NewActionHandler(logger *zap.Logger, sd *common.TokenSigningData, configstoreClient *csclient.Client, runserviceClient *rsclient.Client, agolaID, apiExposedURL, webExposedURL string) *ActionHandler

func (*ActionHandler) AddOrgMember

func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string, role cstypes.MemberRole) (*AddOrgMemberResponse, error)

func (*ActionHandler) Authorize

func (*ActionHandler) CanDoRunActions

func (h *ActionHandler) CanDoRunActions(ctx context.Context, runGroup string) (bool, error)

func (*ActionHandler) CanGetRun

func (h *ActionHandler) CanGetRun(ctx context.Context, runGroup string) (bool, error)

func (*ActionHandler) CreateOrg

func (*ActionHandler) CreateProject

func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectRequest) (*csapitypes.Project, error)

func (*ActionHandler) CreateProjectGroup

func (*ActionHandler) CreateRemoteSource

func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemoteSourceRequest) (*cstypes.RemoteSource, error)

func (*ActionHandler) CreateRuns

func (h *ActionHandler) CreateRuns(ctx context.Context, req *CreateRunRequest) error

func (*ActionHandler) CreateSecret

func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateSecretRequest) (*csapitypes.Secret, error)

func (*ActionHandler) CreateUser

func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest) (*cstypes.User, error)

func (*ActionHandler) CreateUserLA

func (*ActionHandler) CreateUserToken

func (h *ActionHandler) CreateUserToken(ctx context.Context, req *CreateUserTokenRequest) (string, error)

func (*ActionHandler) CreateVariable

func (*ActionHandler) CurrentUserID

func (h *ActionHandler) CurrentUserID(ctx context.Context) string

func (*ActionHandler) DeleteLogs added in v0.4.0

func (h *ActionHandler) DeleteLogs(ctx context.Context, req *DeleteLogsRequest) error

func (*ActionHandler) DeleteOrg

func (h *ActionHandler) DeleteOrg(ctx context.Context, orgRef string) error

func (*ActionHandler) DeleteProject

func (h *ActionHandler) DeleteProject(ctx context.Context, projectRef string) error

func (*ActionHandler) DeleteProjectGroup

func (h *ActionHandler) DeleteProjectGroup(ctx context.Context, projectRef string) error

func (*ActionHandler) DeleteRemoteSource

func (h *ActionHandler) DeleteRemoteSource(ctx context.Context, rsRef string) error

func (*ActionHandler) DeleteSecret

func (h *ActionHandler) DeleteSecret(ctx context.Context, parentType cstypes.ConfigType, parentRef, name string) error

func (*ActionHandler) DeleteUser

func (h *ActionHandler) DeleteUser(ctx context.Context, userRef string) error

func (*ActionHandler) DeleteUserLA

func (h *ActionHandler) DeleteUserLA(ctx context.Context, userRef, laID string) error

func (*ActionHandler) DeleteUserToken

func (h *ActionHandler) DeleteUserToken(ctx context.Context, userRef, tokenName string) error

func (*ActionHandler) DeleteVariable

func (h *ActionHandler) DeleteVariable(ctx context.Context, parentType cstypes.ConfigType, parentRef, name string) error

func (*ActionHandler) GetBadge

func (h *ActionHandler) GetBadge(ctx context.Context, projectRef, branch string) (string, error)

GetBadge return a badge for a project branch TODO(sgotti) also handle tags and PRs

func (*ActionHandler) GetGitSource

GetGitSource is a wrapper around common.GetGitSource that will also refresh the oauth2 access token and update the linked account when needed

func (*ActionHandler) GetLogs

func (h *ActionHandler) GetLogs(ctx context.Context, req *GetLogsRequest) (*http.Response, error)

func (*ActionHandler) GetOrg

func (h *ActionHandler) GetOrg(ctx context.Context, orgRef string) (*cstypes.Organization, error)

func (*ActionHandler) GetOrgMembers

func (h *ActionHandler) GetOrgMembers(ctx context.Context, orgRef string) (*OrgMembersResponse, error)

func (*ActionHandler) GetOrgs

func (*ActionHandler) GetProject

func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csapitypes.Project, error)

func (*ActionHandler) GetProjectGroup

func (h *ActionHandler) GetProjectGroup(ctx context.Context, projectGroupRef string) (*csapitypes.ProjectGroup, error)

func (*ActionHandler) GetProjectGroupProjects

func (h *ActionHandler) GetProjectGroupProjects(ctx context.Context, projectGroupRef string) ([]*csapitypes.Project, error)

func (*ActionHandler) GetProjectGroupSubgroups

func (h *ActionHandler) GetProjectGroupSubgroups(ctx context.Context, projectGroupRef string) ([]*csapitypes.ProjectGroup, error)

func (*ActionHandler) GetRemoteSource

func (h *ActionHandler) GetRemoteSource(ctx context.Context, rsRef string) (*cstypes.RemoteSource, error)

func (*ActionHandler) GetRemoteSources

func (h *ActionHandler) GetRemoteSources(ctx context.Context, req *GetRemoteSourcesRequest) ([]*cstypes.RemoteSource, error)

func (*ActionHandler) GetRun

func (h *ActionHandler) GetRun(ctx context.Context, runID string) (*rsapitypes.RunResponse, error)

func (*ActionHandler) GetRuns

func (*ActionHandler) GetSecrets

func (h *ActionHandler) GetSecrets(ctx context.Context, req *GetSecretsRequest) ([]*csapitypes.Secret, error)

func (*ActionHandler) GetUser

func (h *ActionHandler) GetUser(ctx context.Context, userRef string) (*cstypes.User, error)

func (*ActionHandler) GetUsers

func (h *ActionHandler) GetUsers(ctx context.Context, req *GetUsersRequest) ([]*cstypes.User, error)

func (*ActionHandler) GetVariables

func (*ActionHandler) GetVersion added in v0.3.0

func (*ActionHandler) HandleOauth2Callback

func (h *ActionHandler) HandleOauth2Callback(ctx context.Context, code, state string) (*RemoteSourceAuthResult, error)

func (*ActionHandler) HandleRemoteSourceAuth

func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSourceName, loginName, loginPassword string, requestType RemoteSourceRequestType, req interface{}) (*RemoteSourceAuthResponse, error)

func (*ActionHandler) HandleRemoteSourceAuthRequest

func (h *ActionHandler) HandleRemoteSourceAuthRequest(ctx context.Context, requestType RemoteSourceRequestType, requestString string, userAccessToken, oauth2AccessToken, oauth2RefreshToken string, oauth2AccessTokenExpiresAt time.Time) (*RemoteSourceAuthResult, error)

func (*ActionHandler) IsOrgOwner

func (h *ActionHandler) IsOrgOwner(ctx context.Context, orgID string) (bool, error)

func (*ActionHandler) IsProjectMember

func (h *ActionHandler) IsProjectMember(ctx context.Context, ownerType cstypes.ConfigType, ownerID string) (bool, error)

func (*ActionHandler) IsProjectOwner

func (h *ActionHandler) IsProjectOwner(ctx context.Context, ownerType cstypes.ConfigType, ownerID string) (bool, error)

func (*ActionHandler) IsUserAdmin

func (h *ActionHandler) IsUserAdmin(ctx context.Context) bool

func (*ActionHandler) IsUserLogged

func (h *ActionHandler) IsUserLogged(ctx context.Context) bool

func (*ActionHandler) IsUserLoggedOrAdmin

func (h *ActionHandler) IsUserLoggedOrAdmin(ctx context.Context) bool

func (*ActionHandler) IsVariableOwner

func (h *ActionHandler) IsVariableOwner(ctx context.Context, parentType cstypes.ConfigType, parentRef string) (bool, error)

func (*ActionHandler) LoginUser

func (*ActionHandler) ProjectCreateRun

func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch, tag, refName, commitSHA string) error

func (*ActionHandler) ProjectUpdateRepoLinkedAccount

func (h *ActionHandler) ProjectUpdateRepoLinkedAccount(ctx context.Context, projectRef string) (*csapitypes.Project, error)

func (*ActionHandler) ReconfigProject

func (h *ActionHandler) ReconfigProject(ctx context.Context, projectRef string) error

func (*ActionHandler) RefreshLinkedAccount

func (h *ActionHandler) RefreshLinkedAccount(ctx context.Context, rs *cstypes.RemoteSource, userName string, la *cstypes.LinkedAccount) (*cstypes.LinkedAccount, error)

RefreshLinkedAccount refreshed the linked account oauth2 access token and update linked account in the configstore

func (*ActionHandler) RegisterUser

func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserRequest) (*cstypes.User, error)

func (*ActionHandler) RemoveOrgMember

func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef string) error

func (*ActionHandler) RunAction

func (*ActionHandler) RunTaskAction

func (h *ActionHandler) RunTaskAction(ctx context.Context, req *RunTaskActionsRequest) error

func (*ActionHandler) UpdateProject

func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, req *UpdateProjectRequest) (*csapitypes.Project, error)

func (*ActionHandler) UpdateProjectGroup

func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef string, req *UpdateProjectGroupRequest) (*csapitypes.ProjectGroup, error)

func (*ActionHandler) UpdateRemoteSource

func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, req *UpdateRemoteSourceRequest) (*cstypes.RemoteSource, error)

func (*ActionHandler) UpdateSecret

func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretRequest) (*csapitypes.Secret, error)

func (*ActionHandler) UpdateUserLA

func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *cstypes.LinkedAccount) error

func (*ActionHandler) UpdateVariable

func (*ActionHandler) UserCreateRun

func (h *ActionHandler) UserCreateRun(ctx context.Context, req *UserCreateRunRequest) error

type AddOrgMemberResponse

type AddOrgMemberResponse struct {
	OrganizationMember *cstypes.OrganizationMember
	Org                *cstypes.Organization
	User               *cstypes.User
}

type AuthorizeRequest

type AuthorizeRequest struct {
	RemoteSourceName           string
	UserAccessToken            string
	Oauth2AccessToken          string
	Oauth2RefreshToken         string
	Oauth2AccessTokenExpiresAt time.Time
}

type AuthorizeResponse

type AuthorizeResponse struct {
	RemoteUserInfo   *gitsource.UserInfo
	RemoteSourceName string
}

type CreateOrgRequest

type CreateOrgRequest struct {
	Name       string
	Visibility cstypes.Visibility

	CreatorUserID string
}

type CreateProjectGroupRequest

type CreateProjectGroupRequest struct {
	CurrentUserID string
	Name          string
	ParentRef     string
	Visibility    cstypes.Visibility
}

type CreateProjectRequest

type CreateProjectRequest struct {
	Name                string
	ParentRef           string
	Visibility          cstypes.Visibility
	RemoteSourceName    string
	RepoPath            string
	SkipSSHHostKeyCheck bool
}

type CreateRemoteSourceRequest

type CreateRemoteSourceRequest struct {
	Name                string
	APIURL              string
	SkipVerify          bool
	Type                string
	AuthType            string
	Oauth2ClientID      string
	Oauth2ClientSecret  string
	SSHHostKey          string
	SkipSSHHostKeyCheck bool
	RegistrationEnabled *bool
	LoginEnabled        *bool
}

type CreateRunRequest

type CreateRunRequest struct {
	RunType            itypes.RunType
	RefType            itypes.RunRefType
	RunCreationTrigger itypes.RunCreationTriggerType

	Project             *cstypes.Project
	User                *cstypes.User
	RepoPath            string
	GitSource           gitsource.GitSource
	CommitSHA           string
	Message             string
	Branch              string
	Tag                 string
	Ref                 string
	PullRequestID       string
	SSHPrivKey          string
	SSHHostKey          string
	SkipSSHHostKeyCheck bool
	CloneURL            string

	WebhookEvent  string
	WebhookSender string

	CommitLink      string
	BranchLink      string
	TagLink         string
	PullRequestLink string

	// CompareLink is provided only when triggered by a webhook and contains the
	// commit compare link
	CompareLink string

	// fields only used with user direct runs
	UserRunRepoUUID string
	Variables       map[string]string
}

type CreateSecretRequest

type CreateSecretRequest struct {
	Name string

	ParentType cstypes.ConfigType
	ParentRef  string

	Type cstypes.SecretType

	// internal secret
	Data map[string]string

	// external secret
	SecretProviderID string
	Path             string
}

type CreateUserLARequest

type CreateUserLARequest struct {
	UserRef string

	RemoteSourceName           string
	UserAccessToken            string
	Oauth2AccessToken          string
	Oauth2RefreshToken         string
	Oauth2AccessTokenExpiresAt time.Time
}

type CreateUserLAResponse

type CreateUserLAResponse struct {
	LinkedAccount *cstypes.LinkedAccount
}

type CreateUserRequest

type CreateUserRequest struct {
	UserName string
}

type CreateUserTokenRequest

type CreateUserTokenRequest struct {
	UserRef   string
	TokenName string
}

type CreateVariableRequest

type CreateVariableRequest struct {
	Name string

	ParentType cstypes.ConfigType
	ParentRef  string

	Values []cstypes.VariableValue
}

type DeleteLogsRequest added in v0.4.0

type DeleteLogsRequest struct {
	RunID  string
	TaskID string
	Setup  bool
	Step   int
}

type GetLogsRequest

type GetLogsRequest struct {
	RunID  string
	TaskID string
	Setup  bool
	Step   int
	Follow bool
}

type GetOrgsRequest

type GetOrgsRequest struct {
	Start string
	Limit int
	Asc   bool
}

type GetRemoteSourcesRequest

type GetRemoteSourcesRequest struct {
	Start string
	Limit int
	Asc   bool
}

type GetRunsRequest

type GetRunsRequest struct {
	PhaseFilter  []string
	ResultFilter []string
	Group        string
	LastRun      bool
	ChangeGroups []string
	StartRunID   string
	Limit        int
	Asc          bool
}

type GetSecretsRequest

type GetSecretsRequest struct {
	ParentType cstypes.ConfigType
	ParentRef  string

	Tree             bool
	RemoveOverridden bool
}

type GetUsersRequest

type GetUsersRequest struct {
	Start string
	Limit int
	Asc   bool
}

type GetVariablesRequest

type GetVariablesRequest struct {
	ParentType cstypes.ConfigType
	ParentRef  string

	Tree             bool
	RemoveOverridden bool
}

type LoginUserRequest

type LoginUserRequest struct {
	RemoteSourceName           string
	UserAccessToken            string
	Oauth2AccessToken          string
	Oauth2RefreshToken         string
	Oauth2AccessTokenExpiresAt time.Time
}

type LoginUserResponse

type LoginUserResponse struct {
	Token string
	User  *cstypes.User
}

type OrgMemberResponse

type OrgMemberResponse struct {
	User *cstypes.User
	Role cstypes.MemberRole
}

type OrgMembersResponse

type OrgMembersResponse struct {
	Organization *cstypes.Organization
	Members      []*OrgMemberResponse
}

type RegisterUserRequest

type RegisterUserRequest struct {
	UserName                   string
	RemoteSourceName           string
	UserAccessToken            string
	Oauth2AccessToken          string
	Oauth2RefreshToken         string
	Oauth2AccessTokenExpiresAt time.Time
}

type RemoteSourceAuthResponse

type RemoteSourceAuthResponse struct {
	Oauth2Redirect string
	Response       interface{}
}

type RemoteSourceAuthResult

type RemoteSourceAuthResult struct {
	RequestType RemoteSourceRequestType
	Response    interface{}
}

type RemoteSourceRequestType

type RemoteSourceRequestType string
const (
	RemoteSourceRequestTypeCreateUserLA RemoteSourceRequestType = "createuserla"
	RemoteSourceRequestTypeLoginUser    RemoteSourceRequestType = "loginuser"
	RemoteSourceRequestTypeAuthorize    RemoteSourceRequestType = "authorize"
	RemoteSourceRequestTypeRegisterUser RemoteSourceRequestType = "registeruser"
)

type RunActionType

type RunActionType string
const (
	RunActionTypeRestart RunActionType = "restart"
	RunActionTypeCancel  RunActionType = "cancel"
	RunActionTypeStop    RunActionType = "stop"
)

type RunActionsRequest

type RunActionsRequest struct {
	RunID      string
	ActionType RunActionType

	// Restart
	FromStart bool
}

type RunTaskActionType

type RunTaskActionType string
const (
	RunTaskActionTypeApprove RunTaskActionType = "approve"
)

type RunTaskActionsRequest

type RunTaskActionsRequest struct {
	RunID  string
	TaskID string

	ActionType RunTaskActionType
}

type UpdateProjectGroupRequest

type UpdateProjectGroupRequest struct {
	Name      *string
	ParentRef *string

	Visibility *cstypes.Visibility
}

type UpdateProjectRequest

type UpdateProjectRequest struct {
	Name      *string
	ParentRef *string

	Visibility *cstypes.Visibility
}

type UpdateRemoteSourceRequest

type UpdateRemoteSourceRequest struct {
	RemoteSourceRef string

	Name                *string
	APIURL              *string
	SkipVerify          *bool
	Oauth2ClientID      *string
	Oauth2ClientSecret  *string
	SSHHostKey          *string
	SkipSSHHostKeyCheck *bool
	RegistrationEnabled *bool
	LoginEnabled        *bool
}

type UpdateSecretRequest

type UpdateSecretRequest struct {
	SecretName string

	Name string

	ParentType cstypes.ConfigType
	ParentRef  string

	Type cstypes.SecretType

	// internal secret
	Data map[string]string

	// external secret
	SecretProviderID string
	Path             string
}

type UpdateVariableRequest

type UpdateVariableRequest struct {
	VariableName string

	Name string

	ParentType cstypes.ConfigType
	ParentRef  string

	Values []cstypes.VariableValue
}

type UserCreateRunRequest

type UserCreateRunRequest struct {
	RepoUUID  string
	RepoPath  string
	Branch    string
	Tag       string
	Ref       string
	CommitSHA string
	Message   string

	PullRequestRefRegexes []string
	Variables             map[string]string
}

Jump to

Keyboard shortcuts

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