Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Branch ¶
Branch is the helper function returns the branch name from reference name. For now, this method only supports branch reference. https://git-scm.com/book/en/v2/Git-Internals-Git-References
Types ¶
type FileCommit ¶
type FileCommit struct {
ID string `json:"id"`
Title string `json:"title"`
Message string `json:"message"`
CreatedTs int64 `json:"createdTs"`
URL string `json:"url"`
AuthorName string `json:"authorName"`
Added string `json:"added"`
}
FileCommit is the API message for a VCS file commit.
type FileCommitCreate ¶
type FileCommitCreate struct {
Branch string
Content string
CommitMessage string
LastCommitID string
}
FileCommitCreate is the payload for committing a new file.
type Provider ¶
type Provider interface {
// Returns the API URL for a given VCS instance URL
APIURL(instanceURL string) string
// Try to use this provider as an auth provider and fetch the user info from the OAuth context
//
// oauthCtx: OAuth context to write the file content
// instanceURL: VCS instance URL
TryLogin(ctx context.Context, oauthCtx common.OauthContext, instanceURL string) (*UserInfo, error)
// Fetch the user info of the given userID
//
// oauthCtx: OAuth context to write the file content
// instanceURL: VCS instance URL
// userID: the ID of the desired user
FetchUserInfo(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, userID int) (*UserInfo, error)
// Fetch all active members of a given repository
//
// oauthCtx: OAuth context to write the file content
// instanceURL: VCS instance URL
// repositoryID: the repository ID from the external VCS system (note this is NOT the ID of Bytebase's own repository resource)
FetchRepositoryActiveMemberList(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string) ([]*RepositoryMember, error)
// Commits a new file
//
// oauthCtx: OAuth context to write the file content
// instanceURL: VCS instance URL
// repositoryID: the repository ID from the external VCS system (note this is NOT the ID of Bytebase's own repository resource)
// filePath: file path to be written
// fileCommit: the new file commit info
CreateFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, fileCommit FileCommitCreate) error
// Overwrites an existing file
//
// Similar to CreateFile except it overwrites an existing file. The fileCommit shoud includes the "LastCommitID" field which is used to detect conflicting writes.
OverwriteFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, fileCommit FileCommitCreate) error
// Reads the file content. Returns an io.ReadCloser on success. If file does not exist, returns NotFound error.
//
// oauthCtx: OAuth context to read the file content
// instanceURL: VCS instance URL
// repositoryID: the repository ID from the external VCS system (note this is NOT the ID of Bytebase's own repository resource)
// filePath: file path to be read
// commitID: the specific version to be read
ReadFile(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, commitID string) (string, error)
// Reads the file metadata. Returns the file meta on success.
//
// Similar to ReadFile except it specifies a branch instead of a commitID.
ReadFileMeta(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, filePath string, branch string) (*FileMeta, error)
// Creates a webhook. Returns the created webhook ID on succeess.
//
// oauthCtx: OAuth context to create the webhook
// instanceURL: VCS instance URL
// repositoryID: the repository ID from the external VCS system (note this is NOT the ID of Bytebase's own repository resource)
// payload: the webhook payload
CreateWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, payload []byte) (string, error)
// Patches a webhook.
//
// The payload stores the patched field(s).
PatchWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, webhookID string, payload []byte) error
// Deletes a webhook.
DeleteWebhook(ctx context.Context, oauthCtx common.OauthContext, instanceURL string, repositoryID string, webhookID string) error
}
Provider is the interface for VCS provider.
func Get ¶
func Get(vcsType Type, providerConfig ProviderConfig) Provider
Get returns a vcs provider specified by its vcs type
type ProviderConfig ¶
ProviderConfig is the provider configuration.
type PushEvent ¶
type PushEvent struct {
VCSType Type `json:"vcsType"`
BaseDirectory string `json:"baseDir"`
Ref string `json:"ref"`
RepositoryID string `json:"repositoryId"`
RepositoryURL string `json:"repositoryUrl"`
RepositoryFullPath string `json:"repositoryFullPath"`
AuthorName string `json:"authorName"`
FileCommit FileCommit `json:"fileCommit"`
}
PushEvent is the API message for a VCS push event.
type RepositoryMember ¶
type RepositoryMember struct {
Email string `json:"email"`
Name string `json:"name"`
State State `json:"state"`
Role common.ProjectRole `json:"role"`
VCSRole string `json:"vcsRole"`
RoleProvider Type `json:"roleProvider"`
}
RepositoryMember is the API message for repository member info.
Click to show internal directories.
Click to hide internal directories.