proxy

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 17 Imported by: 0

README

Proxy

Runs a local server on WarpBuild Runners. Serves the following use-cases:

  • /_apis/artifactcache: A local cache proxy server that is able to take requests from Buildkit's Remote Cache GHA backend and proxy them to work with WarpCache.

Documentation

Index

Constants

View Source
const PROXY_SERVER_OPTIONS_CONTEXT_KEY = "proxy_server_options"

Variables

This section is empty.

Functions

func CommitCacheHandler

func CommitCacheHandler(c *fiber.Ctx) error

func GetCacheEntryHandler

func GetCacheEntryHandler(c *fiber.Ctx) error

func ReserveCacheHandler

func ReserveCacheHandler(c *fiber.Ctx) error

func StartProxyServer

func StartProxyServer(ctx context.Context, opts *ProxyServerOptions) error

func UploadCacheHandler

func UploadCacheHandler(c *fiber.Ctx) error

Types

type AuthMethod

type AuthMethod string
const (
	MethodShortLivedToken AuthMethod = "short_lived_token"
	MethodPresignedURL    AuthMethod = "presigned_url"
)

type AzureBlobCommitCacheResponse added in v0.7.0

type AzureBlobCommitCacheResponse struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type AzureBlobDeleteCacheResponse added in v0.7.0

type AzureBlobDeleteCacheResponse struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type AzureBlobGetCacheResponse added in v0.7.0

type AzureBlobGetCacheResponse struct {
	PreSignedURL string `json:"pre_signed_url"`
	CacheKey     string `json:"cache_key"`
	CacheVersion string `json:"cache_version"`
	BucketName   string `json:"bucket_name"`
}

type AzureBlobReserveCacheResponse added in v0.7.0

type AzureBlobReserveCacheResponse struct {
	PreSignedURL  string `json:"pre_signed_url"`
	ContainerName string `json:"container_name"`
	BlobName      string `json:"blob_name"`
}

type CacheBackendInfo

type CacheBackendInfo struct {
	HostURL   string `json:"hostURL"`
	AuthToken string `json:"authToken"`
}

type CacheEntry

type CacheEntry struct {
	ID                     string             `json:"id"`
	CreatedAt              time.Time          `json:"created_at"`
	UpdatedAt              time.Time          `json:"updated_at"`
	StorageBackendId       string             `json:"storage_backend_id"`
	StorageBackendLocation string             `json:"storage_backend_location"`
	CacheKey               string             `json:"cache_key"`
	CacheUserGivenKey      string             `json:"cache_user_given_key"`
	CacheVersion           string             `json:"cache_version"`
	VCSOrganizationName    string             `json:"vcs_organization_name"`
	VCSRepositoryName      string             `json:"vcs_repository_name"`
	VCSRef                 string             `json:"vcs_ref"`
	OrganizationID         string             `json:"organization_id"`
	Provider               Provider           `json:"provider" enum:"gcs,s3,azure_blob"`
	Metadata               CacheEntryMetadata `json:"metadata"`
}

type CacheEntryData

type CacheEntryData struct {
	BackendReserveResponse ReserveCacheResponse
	S3Parts                []S3CompletedPart
	CacheKey               string
	CacheVersion           string
	Chunks                 map[int64]ChunkData
	Mutex                  sync.Mutex // Mutex to protect access to chunks
}

type CacheEntryMetadata

type CacheEntryMetadata struct {
	StackId           string `json:"stack_id"`
	StackName         string `json:"stack_name"`
	CloudConnectionId string `json:"cloud_connection_id"`
}

type ChunkData added in v0.5.4

type ChunkData struct {
	StartOffset int64
	EndOffset   int64
	Content     []byte
}

type CommitCacheRequest

type CommitCacheRequest struct {
	CacheKey     string            `json:"cache_key" validate:"required"`
	CacheVersion string            `json:"cache_version" validate:"required"`
	UploadKey    string            `json:"upload_key"`
	UploadID     string            `json:"upload_id"`
	Parts        []S3CompletedPart `json:"parts" validate:"required"`
	VCSType      string            `json:"vcs_type" validate:"required"`
	Provider     Provider          `json:"provider" enum:"gcs,s3"`
}

type CommitCacheResponse

type CommitCacheResponse struct {
	CacheEntry *CacheEntry                   `json:"cache_entry"`
	Provider   Provider                      `json:"provider" enum:"gcs,s3"`
	GCS        *GCSCommitCacheResponse       `json:"gcs,omitempty"`
	S3         *S3CommitCacheResponse        `json:"s3,omitempty"`
	AzureBlob  *AzureBlobCommitCacheResponse `json:"azure_blob,omitempty"`
}

type DeleteCacheRequest

type DeleteCacheRequest struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type DeleteCacheResponse

type DeleteCacheResponse struct {
	CacheEntry *CacheEntry                   `json:"cache_entry"`
	Provider   Provider                      `json:"provider" enum:"gcs,s3,azure_blob"`
	GCS        *GCSDeleteCacheResponse       `json:"gcs,omitempty"`
	S3         *S3DeleteCacheResponse        `json:"s3,omitempty"`
	AzureBlob  *AzureBlobDeleteCacheResponse `json:"azure_blob,omitempty"`
}

type DockerGHACommitCacheRequest

type DockerGHACommitCacheRequest struct {
	CacheID int   `json:"cacheID"`
	Size    int64 `json:"size"`
	CacheBackendInfo
}

type DockerGHACommitCacheResponse

type DockerGHACommitCacheResponse struct{}

type DockerGHAGetCacheRequest

type DockerGHAGetCacheRequest struct {
	Keys    []string `json:"keys"`
	Version string   `json:"version"`
	CacheBackendInfo
}

type DockerGHAGetCacheResponse

type DockerGHAGetCacheResponse struct {
	CacheKey        string `json:"cacheKey"`
	ArchiveLocation string `json:"archiveLocation"`
}

type DockerGHAReserveCacheRequest

type DockerGHAReserveCacheRequest struct {
	Key     string `json:"key"`
	Version string `json:"version"`
	CacheBackendInfo
}

type DockerGHAReserveCacheResponse

type DockerGHAReserveCacheResponse struct {
	CacheID int `json:"cacheID"`
}

type DockerGHAUploadCacheRequest

type DockerGHAUploadCacheRequest struct {
	CacheID      int    `json:"cacheID"`
	Content      []byte `json:"content"`
	ContentRange string `json:"contentRange"`
	CacheBackendInfo
}

type DockerGHAUploadCacheResponse

type DockerGHAUploadCacheResponse struct{}

type GCSCommitCacheResponse

type GCSCommitCacheResponse struct {
	Method          AuthMethod       `json:"method" enum:"short_lived_token"`
	ShortLivedToken *ShortLivedToken `json:"short_lived_token,omitempty"`
	BucketName      string           `json:"bucket_name"`
	ProjectID       string           `json:"project_id"`
	CacheKey        string           `json:"cache_key" validate:"required"`
}

type GCSDeleteCacheResponse

type GCSDeleteCacheResponse struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type GCSGetCacheResponse

type GCSGetCacheResponse struct {
	Method          AuthMethod       `json:"method" enum:"short_lived_token"`
	ShortLivedToken *ShortLivedToken `json:"short_lived_token,omitempty"`
	PreSignedURL    string           `json:"pre_signed_url"`
	BucketName      string           `json:"bucket_name"`
	ProjectID       string           `json:"project_id"`
	CacheKey        string           `json:"cache_key"`
	CacheVersion    string           `json:"cache_version"`
}

type GCSReserveCacheResponse

type GCSReserveCacheResponse struct {
	Method          AuthMethod       `json:"method" enum:"short_lived_token"`
	ShortLivedToken *ShortLivedToken `json:"short_lived_token,omitempty"`
	BucketName      string           `json:"bucket_name"`
	ProjectID       string           `json:"project_id"`
	CacheKey        string           `json:"cache_key" validate:"required"`
}

type GetCacheRequest

type GetCacheRequest struct {
	CacheKey     string   `json:"cache_key" validate:"required"`
	CacheVersion string   `json:"cache_version" validate:"required"`
	RestoreKeys  []string `json:"restore_keys"`
}

type GetCacheResponse

type GetCacheResponse struct {
	Provider   Provider                   `json:"provider" enum:"gcs,s3"`
	GCS        *GCSGetCacheResponse       `json:"gcs,omitempty"`
	S3         *S3GetCacheResponse        `json:"s3,omitempty"`
	AzureBlob  *AzureBlobGetCacheResponse `json:"azure_blob,omitempty"`
	CacheEntry *CacheEntry                `json:"cache_entry"`
}

type GithubAPIError

type GithubAPIError struct {
	Message   string `json:"message"`
	TypeName  string `json:"typeName"`
	TypeKey   string `json:"typeKey"`
	ErrorCode int    `json:"errorCode"`
}

type Provider

type Provider string

WarpCache DTO

const (
	ProviderGCS       Provider = "gcs"
	ProviderS3        Provider = "s3"
	ProviderAzureBlob Provider = "azure_blob"
)

type ProxyServerOptions

type ProxyServerOptions struct {
	CacheProxyPort                   string
	CacheBackendHost                 string
	WarpBuildRunnerVerificationToken string
}

type ReserveCacheRequest

type ReserveCacheRequest struct {
	CacheKey       string `json:"cache_key" validate:"required"`
	CacheVersion   string `json:"cache_version" validate:"required"`
	NumberOfChunks uint   `json:"number_of_chunks"`
	ContentType    string `json:"content_type"`
}

type ReserveCacheResponse

type ReserveCacheResponse struct {
	Provider  Provider                       `json:"provider" enum:"gcs,s3"`
	GCS       *GCSReserveCacheResponse       `json:"gcs,omitempty"`
	S3        *S3ReserveCacheResponse        `json:"s3,omitempty"`
	AzureBlob *AzureBlobReserveCacheResponse `json:"azure_blob,omitempty"`
}

type S3CommitCacheResponse

type S3CommitCacheResponse struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type S3CompletedPart

type S3CompletedPart struct {

	// Entity tag returned when the part was uploaded.
	ETag *string

	// Part number that identifies the part. This is a positive integer between 1 and
	// 10,000.
	//
	//   - General purpose buckets - In CompleteMultipartUpload , when a additional
	//   checksum (including x-amz-checksum-crc32 , x-amz-checksum-crc32c ,
	//   x-amz-checksum-sha1 , or x-amz-checksum-sha256 ) is applied to each part, the
	//   PartNumber must start at 1 and the part numbers must be consecutive.
	//   Otherwise, Amazon S3 generates an HTTP 400 Bad Request status code and an
	//   InvalidPartOrder error code.
	//
	//   - Directory buckets - In CompleteMultipartUpload , the PartNumber must start
	//   at 1 and the part numbers must be consecutive.
	PartNumber *int32
}

Taken from s3 v2 sdk

type S3DeleteCacheResponse

type S3DeleteCacheResponse struct {
	CacheKey     string `json:"cache_key" validate:"required"`
	CacheVersion string `json:"cache_version" validate:"required"`
}

type S3GetCacheResponse

type S3GetCacheResponse struct {
	CacheKey     string `json:"cache_key"`
	CacheVersion string `json:"cache_version"`
	PreSignedURL string `json:"pre_signed_url"`
}

type S3ReserveCacheResponse

type S3ReserveCacheResponse struct {
	PreSignedURLs []string `json:"pre_signed_urls"`
	UploadKey     string   `json:"upload_key"`
	UploadID      string   `json:"upload_id"`
}

type ShortLivedToken

type ShortLivedToken struct {
	AccessToken string    `json:"access_token"`
	ExpiresAt   time.Time `json:"expires_at"`
}

Jump to

Keyboard shortcuts

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