repo

package
v0.0.0-...-7404c28 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package repo provides bkrepo client.

Index

Constants

View Source
const (
	// RepositoryType is repository type.
	RepositoryType = "GENERIC"
	// CategoryType is bscp repository category.
	CategoryType = "LOCAL"
	// RepositoryCfgType repository configuration type.
	RepositoryCfgType = "local"
)
View Source
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.

View Source
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

func GenNodeFullPath(sign string) (string, error)

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

func GenRepoName(bizID uint32) (string, error)

GenRepoName generate repo repository name, like "bscp-{version}-{biz_id}".

func GenS3NodeFullPath

func GenS3NodeFullPath(bizID uint32, sign string) (string, error)

GenS3NodeFullPath ..

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

func (c *Client) DeleteNode(ctx context.Context, nodePath string) error

DeleteNode delete node.

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(ctx context.Context, bizID uint32, forced bool) error

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

func (c *Client) FileMetadataHead(ctx context.Context, nodePath string) (*FileMetadataValue, error)

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

func (c *Client) IsNodeExist(ctx context.Context, nodePath string) (bool, error)

IsNodeExist judge repo node already exist.

func (*Client) IsProjectExist

func (c *Client) IsProjectExist(ctx context.Context) error

IsProjectExist judge repo bscp project already exist.

func (*Client) ProjectID

func (c *Client) ProjectID() string

ProjectID return repo project id.

func (*Client) QueryMetadata

func (c *Client) QueryMetadata(ctx context.Context, opt *NodeOption) (map[string]string, error)

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

type FileMetadataValue struct {
	ByteSize int64  `json:"byte_size"`
	Sha256   string `json:"sha256"`
}

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.

func (NodeMeta) String

func (c NodeMeta) String() (string, error)

String get content meta repo request format.

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

Jump to

Keyboard shortcuts

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