Documentation ¶
Index ¶
- Constants
- Variables
- func FindConfigFile() (path string, err error)
- func IsValidInstanceId(id string) bool
- func IsValidPackageName(name string) bool
- func IsValidRefName(v string) bool
- func IsValidTagName(v string) bool
- func IsValidTagValue(v string) bool
- func MakeArchive(dst io.Writer, fs fs.FS) (id string, err error)
- func NewConfigLoadError(err error, path string) error
- func NewConfigSaveError(err error, path string) error
- func SaveConfig(cfg Config, path string) (err error)
- type Config
- type ConfigLoadError
- type ConfigSaveError
- type Cursor
- type Entry
- type ErrorCursor
- type FileFS
- func (f FileFS) Create(ctx context.Context, path string) (io.WriteCloser, error)
- func (f FileFS) Exists(ctx context.Context, path string) (ok bool, err error)
- func (f FileFS) ListDir(ctx context.Context, path string) Cursor[Entry]
- func (f FileFS) MakeDir(ctx context.Context, path string) error
- func (f FileFS) Open(ctx context.Context, path string) (io.ReadCloser, error)
- func (f FileFS) Read(ctx context.Context, path string) ([]byte, error)
- func (f FileFS) Remove(ctx context.Context, path string) error
- func (f FileFS) Write(ctx context.Context, path string, data []byte) error
- type HTTPAccessConfig
- type Instance
- type Package
- type PackageOrPrefix
- type PackageTag
- type PackageTagValue
- type Reference
- type Registry
- type RegistryConfig
- type RegistryImpl
- func (c *RegistryImpl) DeletePackageInstanceInfo(ctx context.Context, instance Instance) error
- func (c *RegistryImpl) DeletePackageInstanceTag(ctx context.Context, tag Tag) error
- func (c *RegistryImpl) DeletePackageReference(ctx context.Context, ref Reference) error
- func (c *RegistryImpl) GetConfig() RegistryConfig
- func (c *RegistryImpl) GetManifest(ctx context.Context) (manifest *RegistryManifest, err error)
- func (c *RegistryImpl) GetPackage(ctx context.Context, name string) (manifest *Package, err error)
- func (c *RegistryImpl) GetPackageInstanceInfo(ctx context.Context, name, id string) (instance *Instance, err error)
- func (c *RegistryImpl) GetPackageReference(ctx context.Context, pkg, name string) (ref *Reference, err error)
- func (c *RegistryImpl) Initialize(ctx context.Context, name string) error
- func (c *RegistryImpl) ListPackageInstanceTags(ctx context.Context, instance Instance) Cursor[Tag]
- func (c *RegistryImpl) ListPackageInstances(ctx context.Context, name string) Cursor[Instance]
- func (c *RegistryImpl) ListPackageInstancesByTag(ctx context.Context, tag PackageTagValue) Cursor[Tag]
- func (c *RegistryImpl) ListPackageReferences(ctx context.Context, name string) Cursor[Reference]
- func (c *RegistryImpl) ListPackageTagValues(ctx context.Context, tag PackageTag) Cursor[PackageTagValue]
- func (c *RegistryImpl) ListPackageTags(ctx context.Context, name string) Cursor[PackageTag]
- func (c *RegistryImpl) ListPackages(ctx context.Context, prefix string) Cursor[PackageOrPrefix]
- func (c *RegistryImpl) PutManifest(ctx context.Context, manifest RegistryManifest) error
- func (c *RegistryImpl) PutPackage(ctx context.Context, pkg Package) error
- func (c *RegistryImpl) PutPackageInstanceInfo(ctx context.Context, instance Instance) error
- func (c *RegistryImpl) PutPackageInstanceTag(ctx context.Context, tag Tag) error
- func (c *RegistryImpl) PutPackageReference(ctx context.Context, ref Reference) error
- func (c *RegistryImpl) UploadPackageInstance(ctx context.Context, name, id string, reader io.Reader) (*Instance, error)
- type RegistryManifest
- type Repository
- type RepositoryConfig
- type RepositoryFS
- type RepositoryManifest
- type S3AccessConfig
- type SliceCursor
- type Tag
- type TeeWriter
- type UnixTimestamp
Constants ¶
View Source
const ( LatestVersion = "1.0.0" RegistryManifestKey = "shop.json" RegistryPackagesPrefix = "/packages/" RegistryPackageManifestKey = "package.json" RegistryPackageReferencesPrefix = "/refs/" RegistryPackageInstancesPrefix = "/instances/" RegistryPackageInstanceManifestKey = "instance.json" RegistryPackageTagsPrefix = "/tags/" RegistryPackageInstanceTagsPrefix = "/tags/" RegistryPackageInstanceIdLen = sha1.Size * 2 RegistryCASPrefix = "/cas/" RegistryCASArchiveExtension = ".tgz" )
View Source
const (
DefaultRegistryName = "default"
)
View Source
const (
RepositoryManifestKey = "shop-repository.json"
)
Variables ¶
View Source
var ( ErrRegistryConfigExists = errors.New("Registry already exists in configuration") ErrRegistryConfigNotExists = errors.New("Registry does not exist in configuration") )
View Source
var ( ErrUnimplemented = errors.New("Unimplemented") ErrRegistryAdminIsNotAllowed = errors.New("Admin action on the registry is not enabled in configuration") ErrRegistryWriteIsNotAllowed = errors.New("Write action on the registry is not enabled in configuration") ErrUnknownRepo = errors.New("Registry does not have repo") ErrInvalidPackageName = errors.New("Invalid package name") ErrInvalidInstanceId = errors.New("Invalid instance id") ErrInvalidReferenceName = errors.New("Invalid reference name") ErrInvalidTagName = errors.New("Invalid tag name") ErrInvalidTagValue = errors.New("Invalid tag value") )
View Source
var ( RepositoryFactories = map[string]func(context.Context, RepositoryConfig) (RepositoryFS, error){} ErrRepoWriteIsNotAllowed = errors.New("Write to the repository is not enabled in configuration") ErrRepoAdminIsNotAllowed = errors.New("Admin action on the repository is not enabled in configuration") )
Functions ¶
func FindConfigFile ¶
Find location of the config file. Should be $XDG_CONFIG_HOME/shop/config.toml
func IsValidInstanceId ¶
func IsValidPackageName ¶
func IsValidRefName ¶
func IsValidTagName ¶
func IsValidTagValue ¶
func NewConfigLoadError ¶
func NewConfigSaveError ¶
func SaveConfig ¶
Types ¶
type Config ¶
type Config struct { DefaultRegistry string `toml:"default_registry,omitempty" comment:"Default registry to use."` Cache string `toml:"cache,omitempty" comment:"Path to the local file cache."` Registries map[string]RegistryConfig `toml:"registry,omitempty"` }
func LoadConfig ¶
Load config from file at path. Returns empty config if file does not exist.
func (*Config) AddRegistry ¶
func (c *Config) AddRegistry(name string, registryCfg RegistryConfig) error
func (*Config) UpdateRegistry ¶
func (c *Config) UpdateRegistry(name string, registryCfg RegistryConfig) error
type ConfigLoadError ¶
type ConfigLoadError struct { Path string // contains filtered or unexported fields }
func (ConfigLoadError) Error ¶
func (e ConfigLoadError) Error() string
type ConfigSaveError ¶
type ConfigSaveError struct { Path string // contains filtered or unexported fields }
func (ConfigSaveError) Error ¶
func (e ConfigSaveError) Error() string
type ErrorCursor ¶
type ErrorCursor[T any] struct { // contains filtered or unexported fields }
type FileFS ¶
type FileFS struct {
// contains filtered or unexported fields
}
type HTTPAccessConfig ¶
type Instance ¶
type Instance struct { ApiVersion string `json:"api_version"` Package string `json:"package"` Id string `json:"id"` UploadedAt UnixTimestamp `json:"uploaded_at"` UpdatedAt UnixTimestamp `json:"updated_at"` }
func NewInstance ¶
type Package ¶
type Package struct { ApiVersion string `json:"api_version"` Name string `json:"name"` Description string `json:"description,omitempty"` Repo string `json:"repo,omitempty"` UpdatedAt UnixTimestamp `json:"package"` }
func NewPackage ¶
type PackageOrPrefix ¶
type PackageTag ¶
type PackageTagValue ¶
type PackageTagValue struct { PackageTag Value string }
type Reference ¶
type Reference struct { ApiVersion string `json:"api_version"` Package string `json:"package"` Name string `json:"name"` Id string `json:"id"` UpdatedAt UnixTimestamp `json:"updated_at"` }
func NewReference ¶
type Registry ¶
type Registry interface { GetConfig() RegistryConfig Initialize(ctx context.Context, name string) error GetManifest(ctx context.Context) (*RegistryManifest, error) PutManifest(context.Context, RegistryManifest) error GetPackage(ctx context.Context, name string) (*Package, error) ListPackages(ctx context.Context, prefix string) Cursor[PackageOrPrefix] PutPackage(ctx context.Context, pkg Package) error UploadPackageInstance(ctx context.Context, name, id string, reader io.Reader) (*Instance, error) ListPackageInstances(ctx context.Context, name string) Cursor[Instance] GetPackageInstanceInfo(ctx context.Context, name, id string) (*Instance, error) PutPackageInstanceInfo(ctx context.Context, instance Instance) error DeletePackageInstanceInfo(ctx context.Context, instance Instance) error ListPackageInstanceTags(ctx context.Context, instance Instance) Cursor[Tag] ListPackageReferences(ctx context.Context, name string) Cursor[Reference] GetPackageReference(ctx context.Context, pkg, name string) (*Reference, error) PutPackageReference(ctx context.Context, ref Reference) error DeletePackageReference(ctx context.Context, ref Reference) error ListPackageTags(ctx context.Context, names string) Cursor[PackageTag] ListPackageTagValues(ctx context.Context, tag PackageTag) Cursor[PackageTagValue] ListPackageInstancesByTag(ctx context.Context, tag PackageTagValue) Cursor[Tag] PutPackageInstanceTag(ctx context.Context, tag Tag) error DeletePackageInstanceTag(ctx context.Context, tag Tag) error }
func NewRegistry ¶
func NewRegistry(ctx context.Context, cfg RegistryConfig) (Registry, error)
type RegistryConfig ¶
type RegistryConfig struct { URL string `toml:"url" comment:"Manifest url."` RootRepo RepositoryConfig `toml:"root_repository" comment:"Main repository settings."` Repos map[string]RepositoryConfig `toml:"repo,omitempty" comment:"Secondar repositories settings."` // Local tool configuration Admin bool `toml:"admin,omitempty" comment:"Enable admin commands for this registry."` Write bool `toml:"write,omitempty" comment:"Enable write commands for this registry."` }
type RegistryImpl ¶
type RegistryImpl struct {
// contains filtered or unexported fields
}
func (*RegistryImpl) DeletePackageInstanceInfo ¶
func (c *RegistryImpl) DeletePackageInstanceInfo(ctx context.Context, instance Instance) error
func (*RegistryImpl) DeletePackageInstanceTag ¶
func (c *RegistryImpl) DeletePackageInstanceTag(ctx context.Context, tag Tag) error
func (*RegistryImpl) DeletePackageReference ¶
func (c *RegistryImpl) DeletePackageReference(ctx context.Context, ref Reference) error
func (*RegistryImpl) GetConfig ¶
func (c *RegistryImpl) GetConfig() RegistryConfig
func (*RegistryImpl) GetManifest ¶
func (c *RegistryImpl) GetManifest(ctx context.Context) (manifest *RegistryManifest, err error)
func (*RegistryImpl) GetPackage ¶
func (*RegistryImpl) GetPackageInstanceInfo ¶
func (*RegistryImpl) GetPackageReference ¶
func (*RegistryImpl) Initialize ¶
func (c *RegistryImpl) Initialize(ctx context.Context, name string) error
func (*RegistryImpl) ListPackageInstanceTags ¶
func (*RegistryImpl) ListPackageInstances ¶
func (*RegistryImpl) ListPackageInstancesByTag ¶
func (c *RegistryImpl) ListPackageInstancesByTag(ctx context.Context, tag PackageTagValue) Cursor[Tag]
func (*RegistryImpl) ListPackageReferences ¶
func (*RegistryImpl) ListPackageTagValues ¶
func (c *RegistryImpl) ListPackageTagValues(ctx context.Context, tag PackageTag) Cursor[PackageTagValue]
func (*RegistryImpl) ListPackageTags ¶
func (c *RegistryImpl) ListPackageTags(ctx context.Context, name string) Cursor[PackageTag]
func (*RegistryImpl) ListPackages ¶
func (c *RegistryImpl) ListPackages(ctx context.Context, prefix string) Cursor[PackageOrPrefix]
func (*RegistryImpl) PutManifest ¶
func (c *RegistryImpl) PutManifest(ctx context.Context, manifest RegistryManifest) error
func (*RegistryImpl) PutPackage ¶
func (c *RegistryImpl) PutPackage(ctx context.Context, pkg Package) error
func (*RegistryImpl) PutPackageInstanceInfo ¶
func (c *RegistryImpl) PutPackageInstanceInfo(ctx context.Context, instance Instance) error
func (*RegistryImpl) PutPackageInstanceTag ¶
func (c *RegistryImpl) PutPackageInstanceTag(ctx context.Context, tag Tag) error
func (*RegistryImpl) PutPackageReference ¶
func (c *RegistryImpl) PutPackageReference(ctx context.Context, ref Reference) error
func (*RegistryImpl) UploadPackageInstance ¶
type RegistryManifest ¶
type RegistryManifest struct { ApiVersion string `json:"api_version"` Name string `json:"name"` RootRepo RepositoryManifest `json:"root_repo"` Repos map[string]RepositoryManifest `json:"repos"` UpdatedAt UnixTimestamp `json:"updated_at"` }
type Repository ¶
type Repository interface { GetConfig() RepositoryConfig Get(ctx context.Context, key string) (io.ReadCloser, error) Put(ctx context.Context, key string, body io.Reader) error GetJSON(ctx context.Context, key string, output any) error PutJSON(ctx context.Context, key string, input any) error List(ctx context.Context, prefix string) Cursor[Entry] EnsurePrefix(ctx context.Context, key string) error Delete(ctx context.Context, key string) error GetManifest(ctx context.Context) (RepositoryManifest, error) PutManifest(ctx context.Context, manifest RepositoryManifest) error ResourceExists(ctx context.Context, key string) (bool, error) }
func NewRepository ¶
func NewRepository(ctx context.Context, cfg RepositoryConfig) (repository Repository, err error)
type RepositoryConfig ¶
type RepositoryFS ¶
type RepositoryFS interface { Read(context.Context, string) ([]byte, error) Write(context.Context, string, []byte) error Open(context.Context, string) (io.ReadCloser, error) Create(context.Context, string) (io.WriteCloser, error) MakeDir(context.Context, string) error ListDir(context.Context, string) Cursor[Entry] Remove(context.Context, string) error Exists(context.Context, string) (bool, error) }
func NewFileFS ¶
func NewFileFS(ctx context.Context, cfg RepositoryConfig) (RepositoryFS, error)
type RepositoryManifest ¶
type RepositoryManifest struct { ApiVersion string `json:"api_version"` URL string `json:"url"` Name string `json:"name"` ReadOnlyURL string `json:"readonly_url,omitempty"` UpdatedAt UnixTimestamp `json:"updated_at"` }
type S3AccessConfig ¶
type S3AccessConfig struct { // S3 Bucket settings. EndpointURL string `toml:"endpoint_url,omitempty" comment:"S3 Endpoint url."` Region string `toml:"region" comment:"AWS region."` Bucket string `toml:"bucket" comment:"S3 Bucket name."` // S3 Auth information. AWSProfile string `toml:"aws_profile,omitempty" comment:"AWS profile name."` AccessKeyId string `toml:"access_key_id,omitempty" comment:"AWS Access Key ID."` SecretAccessKey string `toml:"secret_access_key,omitempty" comment:"AWS Secret Access Key."` }
type SliceCursor ¶
type SliceCursor[T any] struct { // contains filtered or unexported fields }
type Tag ¶
type UnixTimestamp ¶
func (UnixTimestamp) MarshalJSON ¶
func (ut UnixTimestamp) MarshalJSON() ([]byte, error)
func (*UnixTimestamp) UnmarshalJSON ¶
func (ut *UnixTimestamp) UnmarshalJSON(d []byte) (err error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.