Documentation ¶
Overview ¶
Package repo provides bkrepo client.
Index ¶
- Constants
- func GenBlockNodePath(opt *NodeOption) (string, error)
- func GenNodeFullPath(sign string) (string, error)
- func GenNodePath(opt *NodeOption) (string, error)
- func GenRepoName(bizID uint32) (string, error)
- func GenS3NodeFullPath(bizID uint32, sign string) (string, error)
- type BkRepoBaseResp
- type Client
- func (c *Client) CreateRepo(ctx context.Context, req *CreateRepoReq) error
- func (c *Client) DeleteNode(ctx context.Context, nodePath string) error
- func (c *Client) DeleteRepo(ctx context.Context, bizID uint32, forced bool) error
- func (c *Client) FileMetadataHead(ctx context.Context, nodePath string) (*FileMetadataValue, error)
- func (c *Client) GenerateTempDownloadURL(ctx context.Context, req *GenerateTempDownloadURLReq) (string, error)
- func (c *Client) IsNodeExist(ctx context.Context, nodePath string) (bool, error)
- func (c *Client) IsProjectExist(ctx context.Context) error
- func (c *Client) ProjectID() string
- func (c *Client) QueryMetadata(ctx context.Context, opt *NodeOption) (map[string]string, error)
- type Config
- type Configuration
- type CreateRepoReq
- type DownloadFileReq
- type FileMetadataValue
- type GenerateTempDownloadURLData
- type GenerateTempDownloadURLReq
- type GenerateTempDownloadURLResp
- type InitMultipartUploadData
- type InitMultipartUploadResp
- type NodeMeta
- type NodeOption
- type QueryMetaResp
- type UploadData
- type UploadFileReq
- type UploadResp
Constants ¶
const ( // RepositoryType is repository type. RepositoryType = "GENERIC" // CategoryType is bscp repository category. CategoryType = "LOCAL" // RepositoryCfgType repository configuration type. RepositoryCfgType = "local" )
const ( // HeaderKeyMETA file metadata in the format base64 (key1=value1&key2=value2). key is case sensitive. HeaderKeyMETA = "X-BKREPO-META" // HeaderKeyUID is repo uid header key. HeaderKeyUID = "X-BKREPO-UID" // HeaderKeySHA256 is repo file sha256 header key. HeaderKeySHA256 = "X-BKREPO-SHA256" // HeaderKeyOverwrite is repo upload overwrite flag header key. HeaderKeyOverwrite = "X-BKREPO-OVERWRITE" // HeaderKeyUploadID is repo multipart upload id header key. HeaderKeyUploadID = "X-BKREPO-UPLOAD-ID" // HeaderKeySequence is repo multipart upload part num header key. HeaderKeySequence = "X-BKREPO-SEQUENCE" )
header key.
const ( // ErrCodeNodeAlreadyExist repo node already exist. ErrCodeNodeAlreadyExist = 251012 // ErrCodeNodeNotExist repo node not exist. ErrCodeNodeNotExist = 251010 )
error code.
Variables ¶
This section is empty.
Functions ¶
func GenBlockNodePath ¶
func GenBlockNodePath(opt *NodeOption) (string, error)
GenBlockNodePath generate node multipart upload path. repo path format: /generic/block/{project}/{repoName}/{fullPath} normal path format: /generic/block/{project}/bscp-{version}-{biz_id}/file/{file sha256}
func GenNodeFullPath ¶
GenNodeFullPath generate node full path, like "/file/c7d78b78205a2619eb2b80558f85ee188836ef5f4f317f8587ee38bc3712a8a"
func GenNodePath ¶
func GenNodePath(opt *NodeOption) (string, error)
GenNodePath generate node upload/download path by download method. repo path format: /generic/{project}/{repoName}/{fullPath} normal path format: /generic/{project}/bscp-{version}-{biz_id}/file/{file sha256}
func GenRepoName ¶
GenRepoName generate repo repository name, like "bscp-{version}-{biz_id}".
Types ¶
type BkRepoBaseResp ¶
type BkRepoBaseResp struct { Code int `json:"code"` Message string `json:"message"` TraceID string `json:"traceId"` }
BkRepoBaseResp bk repo base response struct
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is repo client.
func NewClient ¶
func NewClient(repoSetting cc.BaseRepo, reg prometheus.Registerer) (*Client, error)
NewClient new repo client.
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(ctx context.Context, req *CreateRepoReq) error
CreateRepo create new repository in repo.
func (*Client) DeleteNode ¶
DeleteNode delete node.
func (*Client) DeleteRepo ¶
DeleteRepo delete repository in repo. param force: whether to force deletion. If false, the warehouse cannot be deleted when there are files in the warehouse
func (*Client) FileMetadataHead ¶
FileMetadataHead get head data.
func (*Client) GenerateTempDownloadURL ¶
func (c *Client) GenerateTempDownloadURL(ctx context.Context, req *GenerateTempDownloadURLReq) (string, error)
GenerateTempDownloadURL generate temp download url.
func (*Client) IsNodeExist ¶
IsNodeExist judge repo node already exist.
func (*Client) IsProjectExist ¶
IsProjectExist judge repo bscp project already exist.
func (*Client) QueryMetadata ¶
QueryMetadata query node metadata info. If node not exist, return data is {}.
type Config ¶
type Config struct { // Addrs repo server addresses. Addrs []string // Token repo auth token. Token string // Project repo bscp project name. Project string // User repo bscp project admin user name. User string }
Config repo config.
type Configuration ¶
type Configuration struct { // Type is configuration type(local). Type string `json:"type"` }
Configuration is repo configuration.
type CreateRepoReq ¶
type CreateRepoReq struct { // ProjectID is bscp project name in repo. ProjectID string `json:"projectId"` // Name is name of new repo. Name string `json:"name"` // Type is type of new repo(GENERIC). Type string `json:"type"` // Category is category type of new repo(LOCAL). Category string `json:"category"` // Public is repo public flag, default false not public to download. Public bool `json:"public"` // Configuration is configuration for new repo. Configuration Configuration `json:"configuration"` // Description is repo memo description. Description string `json:"description"` }
CreateRepoReq is repo create repo request struct.
type DownloadFileReq ¶
type DownloadFileReq struct { // BizID is business ID BizID uint32 `json:"bizID"` // AppID is application ID AppID uint32 `json:"appID"` // Sign is sha256 encoding of file Sign string `json:"sign"` }
DownloadFileReq is repo download file request struct
type FileMetadataValue ¶
FileMetadataValue ..
type GenerateTempDownloadURLData ¶
type GenerateTempDownloadURLData struct { // ProjectID is bscp project name in repo. ProjectID string `json:"projectId"` // RepoName is name of new repo. RepoName string `json:"repoName"` // FullPath is node full path. FullPath string `json:"fullPath"` // URL is temp download url. URL string `json:"url"` // AuthorizedUserList is authorized user list. AuthorizedUserList []string `json:"authorizedUserList"` // AuthorizedIpList is authorized ip list. AuthorizedIpList []string `json:"authorizedIpList"` // ExpireDate is expire date. ExpireDate string `json:"expireDate"` // Permits is count limit for download. Permits uint32 `json:"permits"` // Type is download type. Type string `json:"type"` }
GenerateTempDownloadURLData is repo generate temp download url response data struct.
type GenerateTempDownloadURLReq ¶
type GenerateTempDownloadURLReq struct { // ProjectID is bscp project name in repo. ProjectID string `json:"projectId"` // RepoName is name of new repo. RepoName string `json:"repoName"` // FullPathSet is node full path set. FullPathSet []string `json:"fullPathSet"` // ExpireSeconds is expire seconds. ExpireSeconds uint32 `json:"expireSeconds"` // Permits is count limit for download. Permits uint32 `json:"permits"` // Type is download type. Type string `json:"type"` }
GenerateTempDownloadURLReq is repo generate temp download url request struct.
type GenerateTempDownloadURLResp ¶
type GenerateTempDownloadURLResp struct { BkRepoBaseResp // Data is response data. Data []GenerateTempDownloadURLData `json:"data"` }
GenerateTempDownloadURLResp is repo generate temp download url response struct.
type InitMultipartUploadData ¶
type InitMultipartUploadData struct { UploadID string `json:"uploadId"` ExpireSeconds int `json:"expireSeconds"` }
InitMultipartUploadData is repo init multipart upload response data struct
type InitMultipartUploadResp ¶
type InitMultipartUploadResp struct { BkRepoBaseResp Data *InitMultipartUploadData `json:"data"` }
InitMultipartUploadResp is repo init multipart upload response struct
type NodeMeta ¶
type NodeMeta struct { BizID uint32 `json:"biz_id"` AppID []uint32 `json:"app_id"` TmplSpaceID []uint32 `json:"template_space_id"` }
NodeMeta node metadata info.
type NodeOption ¶
type NodeOption struct { // Project bscp project in repo, optional. auth method is not required this parameter. Project string // BizID biz id. BizID uint32 // Sign file sha256. Sign string }
NodeOption used to generate node path.
type QueryMetaResp ¶
type QueryMetaResp struct { Code uint32 `json:"code"` Message string `json:"message"` Data map[string]string `json:"data"` }
QueryMetaResp query metadata repo return response.
type UploadData ¶
type UploadData struct { Size int64 `json:"size"` // bkrepo always return 0 Sha256 string `json:"sha256"` }
UploadData upload data
type UploadFileReq ¶
type UploadFileReq struct { // BizID is business ID BizID uint32 `json:"bizID"` // AppID is application ID AppID uint32 `json:"appID"` // Content is base64 encoded content of file Content string `json:"content"` }
UploadFileReq is repo upload file request struct
type UploadResp ¶
type UploadResp struct { BkRepoBaseResp Data *UploadData `json:"data"` }
UploadResp upload response Docs https://github.com/TencentBlueKing/bk-repo/blob/master/docs/apidoc/generic/simple.md