api

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheRegistryNotFound = "Cache registry not found"
	CacheEntryNotFound    = "Cache entry not found"
)

Variables

View Source
var (
	ErrCacheEntryNotFound = errors.New("cache entry not found")
)

Functions

This section is empty.

Types

type CacheClient

type CacheClient interface {
	// CacheRegistry retrieves information about a cache registry.
	// Returns the registry configuration or an error if not found.
	CacheRegistry(ctx context.Context, registry string) (CacheRegistryResp, error)

	// CachePeekExists checks if a cache entry exists for the given key.
	// Returns the cache metadata, a boolean indicating existence (true if found), and any error.
	// When the cache entry is not found, returns (resp, false, nil) with resp.Message set.
	CachePeekExists(ctx context.Context, registry string, req CachePeekReq) (CachePeekResp, bool, error)

	// CacheCreate creates a new cache entry and returns upload information.
	// Returns upload instructions including the upload ID and storage location.
	CacheCreate(ctx context.Context, registry string, req CacheCreateReq) (CacheCreateResp, error)

	// CacheCommit marks a cache entry as committed after successful upload.
	// The upload ID from CacheCreate must be provided.
	CacheCommit(ctx context.Context, registry string, req CacheCommitReq) (CacheCommitResp, error)

	// CacheRetrieve retrieves download information for a cache entry.
	// Returns the cache metadata, a boolean indicating if found (true if exists), and any error.
	// When the cache entry is not found, returns (resp, false, nil) with resp.Message set.
	// The response may indicate a fallback key was used via resp.Fallback.
	CacheRetrieve(ctx context.Context, registry string, req CacheRetrieveReq) (CacheRetrieveResp, bool, error)
}

CacheClient defines the interface for cache API operations. This interface is implemented by Client and can be mocked for testing.

type CacheCommitReq

type CacheCommitReq struct {
	UploadID string `json:"upload_id"`
}

type CacheCommitResp

type CacheCommitResp struct {
	Message string `json:"message"`
}

type CacheCreateReq

type CacheCreateReq struct {
	Store        string   `json:"store"` // The store used for the cache entry
	Key          string   `json:"key"`
	FallbackKeys []string `json:"fallback_keys"`
	Compression  string   `json:"compression"`
	FileSize     int      `json:"file_size"`
	Digest       string   `json:"digest"`
	Paths        []string `json:"paths"`
	Platform     string   `json:"platform"`
	Pipeline     string   `json:"pipeline"`
	Branch       string   `json:"branch"`
	Organization string   `json:"owner"`
}

type CacheCreateResp

type CacheCreateResp struct {
	UploadID           string   `json:"upload_id"` // the identifier used to write the key in blob storage
	StoreObjectName    string   `json:"store_object_name"`
	Multipart          bool     `json:"multipart"`
	UploadInstructions []string `json:"upload_instructions"`
	Message            string   `json:"message"`
}

type CachePeekReq

type CachePeekReq struct {
	Key    string `url:"key"`
	Branch string `url:"branch"`
}

type CachePeekResp

type CachePeekResp struct {
	Store        string    `json:"store"` // The store used for the cache entry
	Digest       string    `json:"digest"`
	ExpiresAt    time.Time `json:"expires_at"`
	Compression  string    `json:"compression"`
	Message      string    `json:"message"`
	FileSize     int       `json:"file_size"`
	Paths        []string  `json:"paths"`
	Pipeline     string    `json:"pipeline"`
	Branch       string    `json:"branch"`
	Owner        string    `json:"owner"`
	Platform     string    `json:"platform"`
	Key          string    `json:"key"`
	FallbackKeys []string  `json:"fallback_keys"`
	CreatedAt    time.Time `json:"created_at"`
	AgentID      string    `json:"agent_id"`
	JobID        string    `json:"job_id"`
	BuildID      string    `json:"build_id"`
}

func (CachePeekResp) GetMessage

func (r CachePeekResp) GetMessage() string

GetMessage returns the message for CachePeekResp

type CacheRegistryResp

type CacheRegistryResp struct {
	UUID  string `json:"uuid"`
	Name  string `json:"name"`
	Store string `json:"store"` // The store used for the cache registry
}

type CacheRetrieveReq

type CacheRetrieveReq struct {
	Key          string `url:"key"`
	Branch       string `url:"branch"`
	FallbackKeys string `url:"fallback_keys"`
}

type CacheRetrieveResp

type CacheRetrieveResp struct {
	Store                string    `json:"store"`             // The store used for the cache entry
	Key                  string    `json:"key"`               // The key of the cache entry, we MUST use this in rest of the restore process to cater for fallbacks
	Fallback             bool      `json:"fallback"`          // Indicates if this is a fallback cache entry
	StoreObjectName      string    `json:"store_object_name"` // the identifier used to read the key in blob storage
	ExpiresAt            time.Time `json:"expires_at"`
	CompressionType      string    `json:"compression_type"`
	Multipart            bool      `json:"multipart"`
	DownloadInstructions []string  `json:"download_instructions"`
	Message              string    `json:"message"`
}

func (CacheRetrieveResp) GetMessage

func (r CacheRetrieveResp) GetMessage() string

GetMessage returns the message for CacheRetrieveResp

type Client

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

func NewClient

func NewClient(ctx context.Context, version, endpoint, token string) Client

func (Client) CacheCommit

func (c Client) CacheCommit(ctx context.Context, registry string, commit CacheCommitReq) (CacheCommitResp, error)

func (Client) CacheCreate

func (c Client) CacheCreate(ctx context.Context, registry string, create CacheCreateReq) (CacheCreateResp, error)

func (Client) CachePeekExists

func (c Client) CachePeekExists(ctx context.Context, registry string, create CachePeekReq) (CachePeekResp, bool, error)

func (Client) CacheRegistry

func (c Client) CacheRegistry(ctx context.Context, registry string) (CacheRegistryResp, error)

func (Client) CacheRetrieve

func (c Client) CacheRetrieve(ctx context.Context, registry string, retrieve CacheRetrieveReq) (CacheRetrieveResp, bool, error)

func (Client) Do

func (c Client) Do(req *http.Request) (*http.Response, error)

type MessageGetter

type MessageGetter interface {
	GetMessage() string
}

MessageGetter interface for types that have a Message field

Jump to

Keyboard shortcuts

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