server

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxBodyInCache = 100 * 1024 * 1024
)

Variables

This section is empty.

Functions

func DoCommandBody added in v0.0.2

func DoCommandBody(ctx context.Context, client *Client, cmd command) (io.ReadCloser, error)

DoCommandBody performs Do for the given command and returns the response body. You need to close the io.ReadCloser after use.

func DoCommandResponse added in v0.0.2

func DoCommandResponse[C commandResponse[T], T any](ctx context.Context, client *Client, cmd C) (T, error)

DoCommandResponse performs do for the given command and returns the parsed body.

func NewCache added in v0.0.5

func NewCache[K comparable, V any]() *syncedCache[K, V]

Types

type BitbucketRepo

type BitbucketRepo struct {
	Client     *Client
	ProjectKey string
	RepoSlug   string
}

func (*BitbucketRepo) GetContent

func (r *BitbucketRepo) GetContent(ctx context.Context, component string, version string, filePath string) ([]byte, error)

GetContent implements server.BitbucketRepository.

func (*BitbucketRepo) GetTags

func (r *BitbucketRepo) GetTags(ctx context.Context) ([]*Tag, error)

GetTags implements server.BitbucketRepository.

type Client

type Client struct {
	BaseURL   string
	AccessKey SecretString
	Logger    *slog.Logger
	// MaxBodyInCache determines the max body size for requests in the cache.
	// Defaults to 100Mi.
	// Set to a negative value to disable caching.
	MaxBodyInCache int64
	// contains filtered or unexported fields
}

Client is a client for the Bitbucket repository.

func (*Client) AuthorizeRequest

func (c *Client) AuthorizeRequest(req *http.Request)

AuthorizeRequest adds an Authorization bearer header to the headers.

func (*Client) ClearCache added in v0.0.5

func (c *Client) ClearCache()

func (*Client) GetCommits added in v0.0.5

func (c *Client) GetCommits(ctx context.Context, cmd *GetCommitsCommand) (*GetCommitsResponse, error)

GetCommits returns an array of commits or a single commit.

func (*Client) GetFileContent

func (c *Client) GetFileContent(ctx context.Context, cmd *GetFileContentCommand) ([]byte, error)

GetFileContent retrieves text content from the file.

Use OpenRawFile if you want to read the file content.

func (*Client) GetFiles

func (c *Client) GetFiles(ctx context.Context, cmd *GetFilesCommand) (*GetFilesResponse, error)

GetFiles returns a GetFilesResponse that contains the list of files found.

func (*Client) GetFilesIterator

func (c *Client) GetFilesIterator(ctx context.Context, cmd *GetFilesCommand) (*FilesIterator, error)

GetFilesIterator returns a file interator for the FilePath in GetFilesCommand.

func (*Client) GetTags

func (c *Client) GetTags(ctx context.Context, cmd *GetTagsCommand) (*GetTagsResponse, error)

GetTags returns the tags in the repository.

func (*Client) OpenRawFile

func (c *Client) OpenRawFile(ctx context.Context, cmd *OpenRawFileCommand) (io.ReadCloser, error)

OpenRawFile opens the file as specified in the cmd parameter. The returned io.ReadCloser is the body of the response. You need to close the io.ReadCloser after use.

type Commit added in v0.0.5

type Commit struct {
	Committer Committer
	Timestamp time.Time
	Message   string
}

type Committer added in v0.0.5

type Committer struct {
	Name  string
	EMail string
}

type FileInfo

type FileInfo struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	Type string `json:"type"`
}

type FilesIterator

type FilesIterator struct {
	// contains filtered or unexported fields
}

FilesIterator is an iterator for the files in a directory in the repository.

func (*FilesIterator) Err

func (i *FilesIterator) Err() error

Err returns the last occured error.

func (*FilesIterator) Files added in v0.0.4

func (i *FilesIterator) Files() iter.Seq[*FileInfo]

Files returns a new iter iterator

func (*FilesIterator) Next

func (i *FilesIterator) Next() *FileInfo

Next returns the next FileInfo in the directory, or nil if all entries have been read.

type GetCommitsCommand added in v0.0.5

type GetCommitsCommand struct {
	ProjectKey string
	RepoSlug   string
	OrderBy    string
	Start      int
	Limit      int
	CommitID   string // optional
}

func (*GetCommitsCommand) ParseResponse added in v0.0.5

func (c *GetCommitsCommand) ParseResponse(data []byte) (*GetCommitsResponse, error)

func (*GetCommitsCommand) Validate added in v0.0.5

func (c *GetCommitsCommand) Validate() error

type GetCommitsResponse added in v0.0.5

type GetCommitsResponse struct {
	Commits []*Commit
}

type GetFileContentCommand

type GetFileContentCommand struct {
	FilePath   string
	ProjectKey string
	RepoSlug   string
	At         string
}

func (*GetFileContentCommand) ParseResponse

func (c *GetFileContentCommand) ParseResponse(data []byte) ([]byte, error)

func (*GetFileContentCommand) Validate

func (c *GetFileContentCommand) Validate() error

type GetFilesCommand

type GetFilesCommand struct {
	FilePath   string
	ProjectKey string
	RepoSlug   string
	At         string
	Start      int
	Limit      int
}

func (*GetFilesCommand) ParseResponse

func (c *GetFilesCommand) ParseResponse(data []byte) (*GetFilesResponse, error)

func (*GetFilesCommand) Validate

func (c *GetFilesCommand) Validate() error

type GetFilesResponse

type GetFilesResponse struct {
	Files     []*FileInfo
	Start     int
	NextStart int
	LastPage  bool
	Size      int
}

type GetTagsCommand

type GetTagsCommand struct {
	ProjectKey string
	RepoSlug   string
	OrderBy    string
}

GetTagsCommand is the command to retrieve all tags from the repository.

func (*GetTagsCommand) ParseResponse

func (c *GetTagsCommand) ParseResponse(data []byte) (*GetTagsResponse, error)

func (*GetTagsCommand) Validate

func (c *GetTagsCommand) Validate() error

type GetTagsResponse added in v0.0.5

type GetTagsResponse struct {
	Tags []*Tag
}

type OpenRawFileCommand

type OpenRawFileCommand struct {
	FilePath   string
	ProjectKey string
	RepoSlug   string
	At         string
}

func (*OpenRawFileCommand) Validate

func (c *OpenRawFileCommand) Validate() error

type SecretString

type SecretString string

Secret string masks the value for String to avoid accidental disclosure.

func (SecretString) Secret

func (s SecretString) Secret() string

Secret returns the secret value.

func (SecretString) String

func (s SecretString) String() string

String returns a masked value.

type Tag added in v0.0.5

type Tag struct {
	Name     string
	CommitID string
}

Jump to

Keyboard shortcuts

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