Documentation
¶
Index ¶
- Constants
- func AuthHeaderValue(signature, accessKey string, signedHeaders []string) string
- func CanonicalHeaders(r *http.Request, signerHeaders []string) string
- func CanonicalQueryString(r *http.Request) string
- func CanonicalRequest(r *http.Request, signedHeaders []string) (string, error)
- func CanonicalURI(r *http.Request) string
- func HexEncodeSHA256Hash(body []byte) (string, error)
- func ParseHook(eventType EventType, payload []byte) (event interface{}, err error)
- func RequestPayload(r *http.Request) ([]byte, error)
- func SignStringToSign(stringToSign string, signingKey []byte) (string, error)
- func SignedHeaders(r *http.Request) []string
- func StringToSign(canonicalRequest string, t time.Time) (string, error)
- type AddCodehubHookPayload
- type AddCodehubHookResp
- type Author
- type Branch
- type BranchList
- type Branches
- type CodeHubClient
- func (c *CodeHubClient) AddWebhook(repoOwner, repoName string, codehubHookPayload *AddCodehubHookPayload) (string, error)
- func (c *CodeHubClient) BranchList(repoUUID string) ([]*Branch, error)
- func (c *CodeHubClient) DeleteCodehubWebhook(repoOwner, repoName, hookID string) error
- func (c *CodeHubClient) FileContent(repoUUID, branchName, path string) (*FileContent, error)
- func (c *CodeHubClient) FileTree(repoUUID, branchName, path string) ([]*TreeNode, error)
- func (c *CodeHubClient) GetLatestRepositoryCommit(repoOwner, repoName, branchName string) (*Commit, error)
- func (c *CodeHubClient) GetRepoUUID(repoName string) (string, error)
- func (c *CodeHubClient) GetYAMLContents(repoUUID, branchName, path string, isDir, split bool) ([]string, error)
- func (c *CodeHubClient) ListCodehubWebhooks(repoOwner, repoName, hookID string) ([]CodehubHook, error)
- func (c *CodeHubClient) NamespaceList() ([]*Namespace, error)
- func (c *CodeHubClient) RepoList(projectUUID, search string, pageSize int) ([]*Project, error)
- func (c *CodeHubClient) TagList(repoID string) ([]*Tag, error)
- type CodehubHook
- type Commit
- type CommitListResp
- type CommitListResult
- type DeleteCodehubWebhookResp
- type EventType
- type FileContent
- type FileContentResp
- type FileContentResult
- type FileTree
- type FileTreeResult
- type GetCodehubHookResp
- type GetCodehubHookResult
- type LastCommit
- type MergeEvent
- type MergeParams
- type Namespace
- type ObjectAttributes
- type Project
- type PushEvent
- type PushEventCommit
- type RepoInfo
- type RepoInfoResult
- type RepoListInfo
- type RepoListInfoResult
- type Repositories
- type Repositorys
- type Signer
- type Source
- type Tag
- type TagList
- type TagListResult
- type Tags
- type Target
- type TreeNode
- type Trees
- type User
- type WebhookProject
Constants ¶
View Source
const ( BasicDateFormat = "20060102T150405Z" Algorithm = "SDK-HMAC-SHA256" HeaderXDate = "X-Sdk-Date" HeaderHost = "host" HeaderAuthorization = "Authorization" HeaderContentSha256 = "X-Sdk-Content-Sha256" )
View Source
const ( PushEvents = "push_events" PullRequestEvent = "merge_requests_events" BranchOrTagCreateEvent = "tag_push_events" )
Variables ¶
This section is empty.
Functions ¶
func AuthHeaderValue ¶
Get the finalized value for the "Authorization" header. The signature parameter is the output from SignStringToSign
func CanonicalHeaders ¶
CanonicalHeaders
func CanonicalRequest ¶
Build a CanonicalRequest from a regular request string
CanonicalRequest =
HTTPRequestMethod + '\n' + CanonicalURI + '\n' + CanonicalQueryString + '\n' + CanonicalHeaders + '\n' + SignedHeaders + '\n' + HexEncode(Hash(RequestPayload))
func HexEncodeSHA256Hash ¶
HexEncodeSHA256Hash returns hexcode of sha256
func SignStringToSign ¶
Create the HWS Signature.
Types ¶
type AddCodehubHookPayload ¶
type AddCodehubHookResp ¶
type AddCodehubHookResp struct {
Result CodehubHook `json:"result"`
Status string `json:"status"`
}
type BranchList ¶
type Branches ¶
type Branches struct {
Commit Commit `json:"commit"`
Name string `json:"name"`
Protected bool `json:"protected"`
DevelopersCanPush bool `json:"developers_can_push"`
DevelopersCanMerge bool `json:"developers_can_merge"`
MasterCanPush bool `json:"master_can_push"`
MasterCanMerge bool `json:"master_can_merge"`
NoOneCanPush bool `json:"no_one_can_push"`
NoOneCanMerge bool `json:"no_one_can_merge"`
}
type CodeHubClient ¶
type CodeHubClient struct {
AK string `json:"ak"`
SK string `json:"sk"`
Region string `json:"region"`
ProxyAddr string `json:"proxy_addr"`
EnableProxy bool `json:"enable_proxy"`
}
func NewCodeHubClient ¶
func NewCodeHubClient(ak, sk, region, proxyAddr string, enableProxy bool) *CodeHubClient
func (*CodeHubClient) AddWebhook ¶
func (c *CodeHubClient) AddWebhook(repoOwner, repoName string, codehubHookPayload *AddCodehubHookPayload) (string, error)
func (*CodeHubClient) BranchList ¶
func (c *CodeHubClient) BranchList(repoUUID string) ([]*Branch, error)
func (*CodeHubClient) DeleteCodehubWebhook ¶
func (c *CodeHubClient) DeleteCodehubWebhook(repoOwner, repoName, hookID string) error
func (*CodeHubClient) FileContent ¶
func (c *CodeHubClient) FileContent(repoUUID, branchName, path string) (*FileContent, error)
func (*CodeHubClient) FileTree ¶
func (c *CodeHubClient) FileTree(repoUUID, branchName, path string) ([]*TreeNode, error)
func (*CodeHubClient) GetLatestRepositoryCommit ¶
func (c *CodeHubClient) GetLatestRepositoryCommit(repoOwner, repoName, branchName string) (*Commit, error)
func (*CodeHubClient) GetRepoUUID ¶
func (c *CodeHubClient) GetRepoUUID(repoName string) (string, error)
func (*CodeHubClient) GetYAMLContents ¶
func (c *CodeHubClient) GetYAMLContents(repoUUID, branchName, path string, isDir, split bool) ([]string, error)
func (*CodeHubClient) ListCodehubWebhooks ¶
func (c *CodeHubClient) ListCodehubWebhooks(repoOwner, repoName, hookID string) ([]CodehubHook, error)
func (*CodeHubClient) NamespaceList ¶
func (c *CodeHubClient) NamespaceList() ([]*Namespace, error)
type CodehubHook ¶
type CodehubHook struct {
ID int `json:"id"`
ProjectID int `json:"project_id"`
CreatedAt string `json:"created_at"`
EnableSslVerification bool `json:"enable_ssl_verification"`
PushEvents bool `json:"push_events"`
TagPushEvents bool `json:"tag_push_events"`
RepositoryUpdateEvents bool `json:"repository_update_events"`
MergeRequestsEvents bool `json:"merge_requests_events"`
IssuesEvents bool `json:"issues_events"`
NoteEvents bool `json:"note_events"`
PipelineEvents bool `json:"pipeline_events"`
WikiPageEvents bool `json:"wiki_page_events"`
}
type CommitListResp ¶
type CommitListResp struct {
Result CommitListResult `json:"result"`
Status string `json:"status"`
}
type CommitListResult ¶
type EventType ¶
type EventType string
EventType represents a Codehub event type.
const ( EventTypeMergeRequest EventType = "Merge Request Hook" EventTypePush EventType = "Push Hook" EventTypeTagPush EventType = "Tag Push Hook" )
List of available event types.
func HookEventType ¶
HookEventType returns the event type for the given request.
type FileContent ¶
type FileContentResp ¶
type FileContentResp struct {
Result FileContentResult `json:"result"`
Status string `json:"status"`
}
type FileContentResult ¶
type FileTree ¶
type FileTree struct {
Result FileTreeResult `json:"result"`
Status string `json:"status"`
}
type FileTreeResult ¶
type GetCodehubHookResp ¶
type GetCodehubHookResp struct {
Result GetCodehubHookResult `json:"result"`
Status string `json:"status"`
}
type GetCodehubHookResult ¶
type GetCodehubHookResult struct {
Hooks []CodehubHook `json:"hooks"`
}
type LastCommit ¶
type MergeEvent ¶
type MergeEvent struct {
ObjectKind string `json:"object_kind"`
EventType string `json:"event_type"`
User User `json:"user"`
Project WebhookProject `json:"project"`
ObjectAttributes ObjectAttributes `json:"object_attributes"`
Labels []interface{} `json:"labels"`
}
type MergeParams ¶
type MergeParams struct {
ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
}
type ObjectAttributes ¶
type ObjectAttributes struct {
AssigneeID interface{} `json:"assignee_id"`
AuthorID int `json:"author_id"`
CreatedAt string `json:"created_at"`
Description string `json:"description"`
HeadPipelineID interface{} `json:"head_pipeline_id"`
ID int `json:"id"`
IID int `json:"iid"`
LastEditedAt interface{} `json:"last_edited_at"`
LastEditedByID interface{} `json:"last_edited_by_id"`
MergeCommitSha interface{} `json:"merge_commit_sha"`
MergeError interface{} `json:"merge_error"`
MergeParams MergeParams `json:"merge_params"`
MergeStatus string `json:"merge_status"`
MergeUserID interface{} `json:"merge_user_id"`
MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
MilestoneID interface{} `json:"milestone_id"`
SourceBranch string `json:"source_branch"`
SourceProjectID int `json:"source_project_id"`
State string `json:"state"`
TargetBranch string `json:"target_branch"`
TargetProjectID int `json:"target_project_id"`
TimeEstimate int `json:"time_estimate"`
Title string `json:"title"`
UpdatedAt string `json:"updated_at"`
UpdatedByID interface{} `json:"updated_by_id"`
URL string `json:"url"`
Source Source `json:"source"`
Target Target `json:"target"`
LastCommit LastCommit `json:"last_commit"`
WorkInProgress bool `json:"work_in_progress"`
TotalTimeSpent int `json:"total_time_spent"`
HumanTotalTimeSpent interface{} `json:"human_total_time_spent"`
HumanTimeEstimate interface{} `json:"human_time_estimate"`
Action string `json:"action"`
}
type PushEvent ¶
type PushEvent struct {
ObjectKind string `json:"object_kind"`
EventName string `json:"event_name"`
Before string `json:"before"`
After string `json:"after"`
Ref string `json:"ref"`
CheckoutSha string `json:"checkout_sha"`
Message interface{} `json:"message"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
UserUsername string `json:"user_username"`
UserEmail string `json:"user_email"`
UserAvatar string `json:"user_avatar"`
ProjectID int `json:"project_id"`
Project WebhookProject `json:"project"`
Commits []PushEventCommit `json:"commits"`
TotalCommitsCount int `json:"total_commits_count"`
}
type PushEventCommit ¶
type RepoInfo ¶
type RepoInfo struct {
Result RepoInfoResult `json:"result"`
Status string `json:"status"`
}
type RepoInfoResult ¶
type RepoInfoResult struct {
Total int `json:"total"`
Repositorys []Repositorys `json:"repositorys"`
}
type RepoListInfo ¶
type RepoListInfo struct {
Result RepoListInfoResult `json:"result"`
Status string `json:"status"`
}
type RepoListInfoResult ¶
type RepoListInfoResult struct {
Total int `json:"total"`
Repositories []Repositories `json:"repositories"`
}
type Repositories ¶
type Repositories struct {
Star bool `json:"star"`
Status int `json:"status"`
UserRole interface{} `json:"userRole"`
RepositoryUUID string `json:"repository_uuid"`
RepositoryID int `json:"repository_id"`
RepositoryName string `json:"repository_name"`
SSHURL string `json:"ssh_url"`
HTTPSURL string `json:"https_url"`
GroupName string `json:"group_name"`
WebURL string `json:"web_url"`
VisibilityLevel int `json:"visibility_level"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
RepositorySize string `json:"repository_size"`
LfsSize string `json:"lfs_size"`
CreatorName string `json:"creator_name"`
DomainName string `json:"domain_name"`
IsOwner int `json:"is_owner"`
IamUserUUID string `json:"iam_user_uuid"`
ProjectUUID string `json:"project_uuid"`
ProjectIsDeleted string `json:"project_is_deleted"`
}
type Repositorys ¶
type Repositorys struct {
ID string `json:"id"`
RepoID string `json:"repoId"`
Name string `json:"name"`
SSHURL string `json:"sshUrl"`
HTTPURL string `json:"httpUrl"`
GroupName string `json:"groupName"`
WebURL string `json:"webUrl"`
VisibilityLevel int `json:"visibilityLevel"`
CreateAt string `json:"createAt"`
ProjectID string `json:"projectId"`
ProjectIsDelete string `json:"projectIsDelete"`
}
type Source ¶
type Source struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
CiConfigPath interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
}
type TagList ¶
type TagList struct {
Result TagListResult `json:"result"`
Status string `json:"status"`
}
type TagListResult ¶
type Target ¶
type Target struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
CiConfigPath interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
}
type WebhookProject ¶
type WebhookProject struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
CiConfigPath interface{} `json:"ci_config_path"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
}
Click to show internal directories.
Click to hide internal directories.