vcs

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MPL-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package vcs package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVCSProviderMap

func NewVCSProviderMap(
	ctx context.Context,
	logger logger.Logger,
	client *http.Client,
	tharsisURL string,
) (
	map[models.VCSProviderType]Provider,
	error,
)

NewVCSProviderMap returns a map containing a handler for each VCS provider type.

Types

type CreateVCSProviderInput

type CreateVCSProviderInput struct {
	URL                *string
	Name               string
	Description        string
	GroupID            string
	OAuthClientID      string
	OAuthClientSecret  string
	Type               models.VCSProviderType
	AutoCreateWebhooks bool
}

CreateVCSProviderInput is the input for creating a VCS provider.

type CreateVCSProviderResponse

type CreateVCSProviderResponse struct {
	VCSProvider           *models.VCSProvider
	OAuthAuthorizationURL string
}

CreateVCSProviderResponse is the response for creating a VCS provider

type CreateVCSRunInput

type CreateVCSRunInput struct {
	Workspace     *models.Workspace
	ReferenceName *string // Optional branch, commit hash or tag name to clone.
	IsDestroy     bool
}

CreateVCSRunInput is the input for creating a run via VCS.

type CreateWorkspaceVCSProviderLinkInput

type CreateWorkspaceVCSProviderLinkInput struct {
	Workspace           *models.Workspace
	ModuleDirectory     *string
	Branch              *string
	TagRegex            *string
	ProviderID          string
	RepositoryPath      string
	GlobPatterns        []string
	AutoSpeculativePlan bool
	WebhookDisabled     bool
}

CreateWorkspaceVCSProviderLinkInput is the input for creating a VCS provider link.

type CreateWorkspaceVCSProviderLinkResponse

type CreateWorkspaceVCSProviderLinkResponse struct {
	WebhookURL   *string
	Link         *models.WorkspaceVCSProviderLink
	WebhookToken []byte
}

CreateWorkspaceVCSProviderLinkResponse is the response for creating a workspace vcs provider link.

type DeleteVCSProviderInput

type DeleteVCSProviderInput struct {
	Provider *models.VCSProvider
	Force    bool
}

DeleteVCSProviderInput is the input for deleting a VCS provider.

type DeleteWorkspaceVCSProviderLinkInput

type DeleteWorkspaceVCSProviderLinkInput struct {
	Link  *models.WorkspaceVCSProviderLink
	Force bool
}

DeleteWorkspaceVCSProviderLinkInput is the input for deleting a workspace VCS provider link.

type GetVCSEventsInput

type GetVCSEventsInput struct {
	Sort              *db.VCSEventSortableField
	PaginationOptions *pagination.Options
	WorkspaceID       string
}

GetVCSEventsInput is the input for retrieving VCSEvents.

type GetVCSProvidersInput

type GetVCSProvidersInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.VCSProviderSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// Search returns only the VCS providers with a name or resource path that starts with the value of search
	Search *string
	// NamespacePath is the namespace to return VCS providers for
	NamespacePath string
	// IncludeInherited includes inherited VCS providers in the result
	IncludeInherited bool
}

GetVCSProvidersInput is the input for listing VCS providers.

type MockProvider

type MockProvider struct {
	mock.Mock
}

MockProvider is an autogenerated mock type for the Provider type

func NewMockProvider

func NewMockProvider(t mockConstructorTestingTNewMockProvider) *MockProvider

NewMockProvider creates a new instance of MockProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockProvider) BuildOAuthAuthorizationURL

func (_m *MockProvider) BuildOAuthAuthorizationURL(input *types.BuildOAuthAuthorizationURLInput) (string, error)

BuildOAuthAuthorizationURL provides a mock function with given fields: input

func (*MockProvider) BuildRepositoryURL

func (_m *MockProvider) BuildRepositoryURL(input *types.BuildRepositoryURLInput) (string, error)

BuildRepositoryURL provides a mock function with given fields: input

func (*MockProvider) CreateAccessToken

func (_m *MockProvider) CreateAccessToken(ctx context.Context, input *types.CreateAccessTokenInput) (*types.AccessTokenPayload, error)

CreateAccessToken provides a mock function with given fields: ctx, input

func (*MockProvider) CreateWebhook

func (_m *MockProvider) CreateWebhook(ctx context.Context, input *types.CreateWebhookInput) (*types.WebhookPayload, error)

CreateWebhook provides a mock function with given fields: ctx, input

func (*MockProvider) DefaultURL added in v0.7.0

func (_m *MockProvider) DefaultURL() url.URL

DefaultURL provides a mock function with given fields:

func (*MockProvider) DeleteWebhook

func (_m *MockProvider) DeleteWebhook(ctx context.Context, input *types.DeleteWebhookInput) error

DeleteWebhook provides a mock function with given fields: ctx, input

func (*MockProvider) GetArchive

func (_m *MockProvider) GetArchive(ctx context.Context, input *types.GetArchiveInput) (*http.Response, error)

GetArchive provides a mock function with given fields: ctx, input

func (*MockProvider) GetDiff

GetDiff provides a mock function with given fields: ctx, input

func (*MockProvider) GetDiffs

func (_m *MockProvider) GetDiffs(ctx context.Context, input *types.GetDiffsInput) (*types.GetDiffsPayload, error)

GetDiffs provides a mock function with given fields: ctx, input

func (*MockProvider) GetProject

GetProject provides a mock function with given fields: ctx, input

func (*MockProvider) MergeRequestActionIsSupported

func (_m *MockProvider) MergeRequestActionIsSupported(action string) bool

MergeRequestActionIsSupported provides a mock function with given fields: action

func (*MockProvider) TestConnection

func (_m *MockProvider) TestConnection(ctx context.Context, input *types.TestConnectionInput) error

TestConnection provides a mock function with given fields: ctx, input

func (*MockProvider) ToVCSEventType

func (_m *MockProvider) ToVCSEventType(input *types.ToVCSEventTypeInput) models.VCSEventType

ToVCSEventType provides a mock function with given fields: input

type ProcessOAuthInput

type ProcessOAuthInput struct {
	AuthorizationCode string
	State             string
}

ProcessOAuthInput is the input for processing OAuth callback.

type ProcessWebhookEventInput

type ProcessWebhookEventInput struct {
	EventHeader      string
	Action           string // Type of action for a MR / PR.
	SourceRepository string // Repository from which the MR originated.
	SourceBranch     string // Source branch from which the MR originated.
	TargetBranch     string // Branch this MR is for.
	HeadCommitID     string // Head commit for an MR.
	Before           string // Commit SHA before the change (can be empty).
	After            string // Commit SHA after the change  (can be empty).
	Ref              string // Ref name starting with refs/heads or similar.
}

ProcessWebhookEventInput is the input for processing a webhook event.

type Provider

type Provider interface {
	DefaultURL() url.URL
	MergeRequestActionIsSupported(action string) bool
	ToVCSEventType(input *types.ToVCSEventTypeInput) models.VCSEventType
	BuildOAuthAuthorizationURL(input *types.BuildOAuthAuthorizationURLInput) (string, error)
	BuildRepositoryURL(input *types.BuildRepositoryURLInput) (string, error)
	TestConnection(ctx context.Context, input *types.TestConnectionInput) error
	GetProject(ctx context.Context, input *types.GetProjectInput) (*types.GetProjectPayload, error)
	GetDiff(ctx context.Context, input *types.GetDiffInput) (*types.GetDiffsPayload, error)
	GetDiffs(ctx context.Context, input *types.GetDiffsInput) (*types.GetDiffsPayload, error)
	GetArchive(ctx context.Context, input *types.GetArchiveInput) (*http.Response, error)
	CreateAccessToken(ctx context.Context, input *types.CreateAccessTokenInput) (*types.AccessTokenPayload, error)
	CreateWebhook(ctx context.Context, input *types.CreateWebhookInput) (*types.WebhookPayload, error)
	DeleteWebhook(ctx context.Context, input *types.DeleteWebhookInput) error
}

Provider handles the logic for a specific type of vcs provider.

type ResetVCSProviderOAuthTokenInput

type ResetVCSProviderOAuthTokenInput struct {
	VCSProvider *models.VCSProvider
}

ResetVCSProviderOAuthTokenInput is the input for

type ResetVCSProviderOAuthTokenResponse

type ResetVCSProviderOAuthTokenResponse struct {
	VCSProvider           *models.VCSProvider
	OAuthAuthorizationURL string
}

ResetVCSProviderOAuthTokenResponse is the response for resetting a VCS OAuth token.

type Service

type Service interface {
	GetVCSProviderByID(ctx context.Context, id string) (*models.VCSProvider, error)
	GetVCSProviders(ctx context.Context, input *GetVCSProvidersInput) (*db.VCSProvidersResult, error)
	GetVCSProvidersByIDs(ctx context.Context, idList []string) ([]models.VCSProvider, error)
	CreateVCSProvider(ctx context.Context, input *CreateVCSProviderInput) (*CreateVCSProviderResponse, error)
	UpdateVCSProvider(ctx context.Context, input *UpdateVCSProviderInput) (*models.VCSProvider, error)
	DeleteVCSProvider(ctx context.Context, input *DeleteVCSProviderInput) error
	GetWorkspaceVCSProviderLinkByID(ctx context.Context, id string) (*models.WorkspaceVCSProviderLink, error)
	GetWorkspaceVCSProviderLinkByWorkspaceID(ctx context.Context, workspaceID string) (*models.WorkspaceVCSProviderLink, error)
	CreateWorkspaceVCSProviderLink(ctx context.Context, input *CreateWorkspaceVCSProviderLinkInput) (*CreateWorkspaceVCSProviderLinkResponse, error)
	UpdateWorkspaceVCSProviderLink(ctx context.Context, input *UpdateWorkspaceVCSProviderLinkInput) (*models.WorkspaceVCSProviderLink, error)
	DeleteWorkspaceVCSProviderLink(ctx context.Context, input *DeleteWorkspaceVCSProviderLinkInput) error
	GetVCSEventByID(ctx context.Context, id string) (*models.VCSEvent, error)
	GetVCSEvents(ctx context.Context, input *GetVCSEventsInput) (*db.VCSEventsResult, error)
	GetVCSEventsByIDs(ctx context.Context, idList []string) ([]models.VCSEvent, error)
	CreateVCSRun(ctx context.Context, input *CreateVCSRunInput) error
	ProcessWebhookEvent(ctx context.Context, input *ProcessWebhookEventInput) error
	ResetVCSProviderOAuthToken(ctx context.Context, input *ResetVCSProviderOAuthTokenInput) (*ResetVCSProviderOAuthTokenResponse, error)
	ProcessOAuth(ctx context.Context, input *ProcessOAuthInput) error
}

Service implements all the functionality related to version control providers.

func NewService

func NewService(
	ctx context.Context,
	logger logger.Logger,
	dbClient *db.Client,
	limitChecker limits.LimitChecker,
	idp *auth.IdentityProvider,
	httpClient *http.Client,
	activityService activityevent.Service,
	runService run.Service,
	workspaceService workspace.Service,
	taskManager asynctask.Manager,
	tharsisURL string,
	repositorySizeLimit int,
) (Service, error)

NewService creates an instance of Service

type UpdateVCSProviderInput

type UpdateVCSProviderInput struct {
	Provider *models.VCSProvider
}

UpdateVCSProviderInput is the input for updating a VCS provider.

type UpdateWorkspaceVCSProviderLinkInput

type UpdateWorkspaceVCSProviderLinkInput struct {
	Link *models.WorkspaceVCSProviderLink
}

UpdateWorkspaceVCSProviderLinkInput is the input for updating a VCS provider link.

Directories

Path Synopsis
Package github package
Package github package
Package gitlab package
Package gitlab package
Package types package
Package types package

Jump to

Keyboard shortcuts

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