registry

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ISO8601 for time format.
	ISO8601 = "20060102T150405Z0700"
)

Variables

View Source
var (
	// TestArch overrides runtime.GOARCH when set (for testing).
	TestArch string
	// TestOS overrides runtime.GOOS when set (for testing).
	TestOS string
)
View Source
var (
	SemVerRegexWithoutPreRelease = regexp.MustCompile(`^v?(\d+)\.(\d+)\.(\d+)$`)
	SemVerRegex                  = regexp.MustCompile(`^(v)?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$`)
)

Functions

func MatchArtifactByPlatform added in v0.15.0

func MatchArtifactByPlatform(artifactNames []string) (string, bool)

MatchArtifactByPlatform finds the first artifact name that matches current OS and architecture.

Types

type ArtifactNotFoundError added in v0.14.0

type ArtifactNotFoundError struct {
	ArtifactName string
	ReleaseTime  *time.Time
	Message      string
}

ArtifactNotFoundError wraps artifact not found errors with release information.

func (*ArtifactNotFoundError) Error added in v0.14.0

func (e *ArtifactNotFoundError) Error() string

func (*ArtifactNotFoundError) IsWithinGracePeriod added in v0.14.0

func (e *ArtifactNotFoundError) IsWithinGracePeriod(gracePeriod time.Duration) bool

IsWithinGracePeriod checks if the error occurred within the grace period. This helps prevent false alerts during CI/CD builds where artifacts may not be immediately available after release creation.

type CurrentResponse

type CurrentResponse struct {
	// ID uniquely identifies the response.
	ID string
	// Tag uniquely identifies the artifact concerned.
	Tag string
	// ArtifactURL is the URL to download the artifact.
	// The URL is not only "https://"
	ArtifactURL string
	// CreatedAt is the creation time of the release
	CreatedAt *time.Time
}

CurrentResponse is the response to get the current artifact.

type GHR

type GHR struct {
	Owner                 string `schema:"-"`
	Repo                  string `schema:"-"`
	Artifact              string `schema:"artifact"`
	PreRelease            bool   `schema:"pre-release"`
	DisableRecordShipping bool   // FIXME: For testing. Remove this.
	// contains filtered or unexported fields
}

GHR struct.

func NewGHR

func NewGHR(ctx context.Context, u string, log *logging.Logger) (*GHR, error)

New returns GHR.

func (*GHR) Current

func (g *GHR) Current(ctx context.Context) (*CurrentResponse, error)

Current returns current artifact.

func (*GHR) Report

func (g *GHR) Report(ctx context.Context, req *ReportRequest) error

Report report shipping.

func (*GHR) String

func (g *GHR) String() string

String to string.

type GRPC

type GRPC struct {
	Target   string `schema:"-"`
	NoTLS    bool   `schema:"no-tls"`
	Artifact string `schema:"artifact"`
	// contains filtered or unexported fields
}

func NewGRPC

func NewGRPC(ctx context.Context, u string) (*GRPC, error)

func (*GRPC) Current

func (c *GRPC) Current(ctx context.Context) (*CurrentResponse, error)

Current returns current artifact.

func (*GRPC) Dial

func (c *GRPC) Dial(ctx context.Context, target string) error

Dial returns GRPC.

func (*GRPC) Report

func (c *GRPC) Report(ctx context.Context, req *ReportRequest) error

Report report shipping.

type GS added in v0.18.0

type GS struct {
	Bucket     string `schema:"-"`
	Prefix     string `schema:"-"`
	Artifact   string `schema:"artifact"`
	PreRelease bool   `schema:"pre-release"`
	// contains filtered or unexported fields
}

GS struct.

func NewGS added in v0.18.0

func NewGS(ctx context.Context, u string, log *logging.Logger) (*GS, error)

NewGS returns GS.

func NewGSWithClient added in v0.18.0

func NewGSWithClient(ctx context.Context, u string, log *logging.Logger, client GSClient) (*GS, error)

NewGSWithClient returns GS with custom client (for testing).

func (*GS) Current added in v0.18.0

func (g *GS) Current(ctx context.Context) (*CurrentResponse, error)

Current returns current artifact.

func (*GS) LatestVersion added in v0.18.0

func (g *GS) LatestVersion(ctx context.Context) (string, *SemVer, error)

func (*GS) Report added in v0.18.0

func (g *GS) Report(ctx context.Context, req *ReportRequest) error

Report report shipping.

type GSClient added in v0.18.0

type GSClient interface {
	Bucket(name string) *storage.BucketHandle
	Close() error
}

type ListObjectsV2Pager

type ListObjectsV2Pager interface {
	HasMorePages() bool
	NextPage(context.Context, ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
}

type Registry

type Registry interface {
	// Current returns the current artifact.
	Current(context.Context) (*CurrentResponse, error)
	// Report reports the result of deploying the artifact.
	Report(context.Context, *ReportRequest) error
}

func New

func New(ctx context.Context, url string, log *logging.Logger) (Registry, error)

type ReportRequest

type ReportRequest struct {
	// ID is the ID of the response.
	ID string
	// Tag is the current tag of deployed artifact.
	Tag string
	// Command is the command that was used for deployment (server or assets).
	Command string
	// Err is the error that occurred during deployment. If Err is nil, the deployment is considered successful.
	Err error
}

ReportRequest is the request to report the result of deploying the artifact.

type S3

type S3 struct {
	Bucket     string `schema:"-"`
	Prefix     string `schema:"-"`
	Region     string `schema:"region"`
	Endpoint   string `schema:"endpoint"`
	Artifact   string `schema:"artifact"`
	PreRelease bool   `schema:"pre-release"`
	// contains filtered or unexported fields
}

S3 struct.

func NewS3

func NewS3(ctx context.Context, u string, log *logging.Logger) (*S3, error)

NewS3 returns S3.

func (*S3) Current

func (s *S3) Current(ctx context.Context) (*CurrentResponse, error)

Current returns current artifact.

func (*S3) LatestVersion

func (s *S3) LatestVersion(ctx context.Context) (string, *SemVer, error)

func (*S3) ListObjects

func (s *S3) ListObjects(ctx context.Context, prefix string) ([]types.Object, error)

func (*S3) PutTextObject

func (s *S3) PutTextObject(ctx context.Context, key, content string) error

func (*S3) Report

func (s *S3) Report(ctx context.Context, req *ReportRequest) error

Report report shipping.

type S3Client

type S3Client interface {
	PutObject(ctx context.Context, input *s3.PutObjectInput, opts ...func(*s3.Options)) (*s3.PutObjectOutput, error)
	ListObjectsV2(context.Context, *s3.ListObjectsV2Input, ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
}

type SemVer

type SemVer struct {
	V          string
	Major      int
	Minor      int
	Patch      int
	PreRelease string
}

func FindLatestSemVer added in v0.15.0

func FindLatestSemVer(versionNames []string, allowPreRelease bool) (*SemVer, string, error)

FindLatestSemVer finds the latest semantic version from a list of version strings.

func ParseSemVer added in v0.12.0

func ParseSemVer(version string) *SemVer

func (*SemVer) Compare

func (v *SemVer) Compare(other *SemVer) int

func (*SemVer) String

func (v *SemVer) String() string

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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