Documentation
¶
Index ¶
- Constants
- func AppendRef(name, ref string) string
- func DefaultCachePath() string
- func EscapePackName(name string) string
- func EscapeRef(ref string) string
- func UnescapePackName(escaped string) (string, error)
- func UnescapeRef(escaped string) string
- func VerifyPackExists(cfg *PackConfig, errCtx *errors.UIErrorContext, logger logging.Logger) (err error)
- type AddOpts
- type Cache
- type CacheConfig
- type DeleteOpts
- func (opts *DeleteOpts) AtRef() string
- func (opts *DeleteOpts) ForPackName() string
- func (opts *DeleteOpts) IsLatest() bool
- func (opts *DeleteOpts) IsTarget(dirEntry os.DirEntry) bool
- func (opts *DeleteOpts) PackDir() string
- func (opts *DeleteOpts) PackPath() (packPath string)
- func (opts *DeleteOpts) RegistryPath() string
- type GetOpts
- type Pack
- type PackConfig
- type Registry
Constants ¶
const ( DefaultRegistryName = "default" DefaultRef = "latest" DevRegistryName = "<<local folder>>" DevRef = "<<none>>" DefaultDirPerms = 0700 )
Variables ¶
This section is empty.
Functions ¶
func DefaultCachePath ¶
func DefaultCachePath() string
DefaultCachePath returns the default cache path.
func EscapePackName ¶
EscapePackName escapes a pack name for safe use as a filesystem path component. Each uppercase letter is replaced by an exclamation mark followed by the lowercase equivalent, mirroring the Go module cache convention. This ensures producing distinct directory names even on case-insensitive filesystems
Examples:
"donutdns" -> "donutdns" (no uppercase, unchanged) "donutDNS" -> "donut!d!n!s" "MyPack" -> "!my!pack"
func EscapeRef ¶
EscapeRef makes a git ref safe for use as a filesystem path component by replacing forward slashes with the escape sequence "!_". Slashes in refs (e.g. namespaced tags like "pack-name/v1.0.0") would otherwise be interpreted as directory separators by path.Join and friends.
func UnescapePackName ¶
UnescapePackName reverses the escaping applied by EscapePackName. It returns an error when the escaped string is malformed (e.g. a trailing '!' or an '!' followed by a non-lowercase-ASCII letter).
func UnescapeRef ¶
UnescapeRef reverses the escaping applied by EscapeRef, converting "!_" back to "/".
func VerifyPackExists ¶
func VerifyPackExists(cfg *PackConfig, errCtx *errors.UIErrorContext, logger logging.Logger) (err error)
VerifyPackExists verifies that a pack exists at the specified path.
Types ¶
type AddOpts ¶
type AddOpts struct {
// Required name for the registry. Used when managing a registry by a user defined name.
RegistryName string
// The well known location of a registry. Used when adding a registry. URL
// or file directory currently supported.
Source string
// Optional target pack. Used when managing a specific pack within a registry.
PackName string
// Optional ref of pack or registry at which to add. Ignored if not
// specifying a git source. Defaults to latest.
Ref string
// Optional username for basic auth to a registry that requires authentication.
Username string
// Optional password for basic auth to a registry that requires authentication.
Password string
// contains filtered or unexported fields
}
AddOpts are the arguments that are required to add a registry or pack to the cache.
func (*AddOpts) ForPackName ¶
ForPackName fulfills the cacheOperationProvider interface for AddOpts
func (*AddOpts) RegistryPath ¶
RegistryPath fulfills the cacheOperationProvider interface for AddOpts
type Cache ¶
type Cache struct {
// ErrorContext stores any errors that were encountered along the way so that
// error handling can be dealt with in one place.
ErrorContext *errors.ErrorContext
// contains filtered or unexported fields
}
Cache encapsulates the state and functionality of a Cache of registries
func NewCache ¶
func NewCache(cfg *CacheConfig) (cache *Cache, err error)
NewCache instantiates a new cache instance with the specified config. If no config is provided, the cache is initialized with default configuration.
func (*Cache) Delete ¶
func (c *Cache) Delete(opts *DeleteOpts) (err error)
Delete deletes a registry from the specified global cache directory. If the name includes a @ref component, only packs matching that ref will be deleted. If a target is specified, only packs matching that target will be deleted. Ref and target are additive.
func (*Cache) Load ¶
Load loads a list of registries from a cache path. It assumes each directory in the specified path cache is a registry.
func (*Cache) Registries ¶
Registries is an accessor for the cached registries contain within the cache instance.
type CacheConfig ¶
CacheConfig encapsulates the configuration options for a cache instance.
type DeleteOpts ¶
type DeleteOpts struct {
// Name or alias of the registry the delete operation will be performed against.
RegistryName string
// Optional pack name to delete when deleting a specific pack from the cache.
PackName string
// Optional ref of pack or registry at which to delete. Ignored it not
// specifying a git source. Defaults to latest.
Ref string
// contains filtered or unexported fields
}
DeleteOpts are the arguments that are required to delete a registry or pack from the cache.
func (*DeleteOpts) AtRef ¶
func (opts *DeleteOpts) AtRef() string
AtRef fulfills the cacheOperationProvider interface for DeleteOpts. Returns the filesystem-safe (escaped) form of the ref so that callers that use it in path.Join operations handle slashes in git refs correctly.
func (*DeleteOpts) ForPackName ¶
func (opts *DeleteOpts) ForPackName() string
ForPackName fulfills the cacheOperationProvider interface for DeleteOpts
func (*DeleteOpts) IsLatest ¶
func (opts *DeleteOpts) IsLatest() bool
IsLatest fulfills the RegistryOptsProviderInterface for DeleteOpts
func (*DeleteOpts) IsTarget ¶
func (opts *DeleteOpts) IsTarget(dirEntry os.DirEntry) bool
IsTarget fulfills the RegistryOptsProviderInterface for DeleteOpts
func (*DeleteOpts) PackDir ¶
func (opts *DeleteOpts) PackDir() string
PackDir fulfills the cacheOperationProvider interface for DeleteOpts
func (*DeleteOpts) PackPath ¶
func (opts *DeleteOpts) PackPath() (packPath string)
PackPath fulfills the cacheOperationProvider interface for DeleteOpts
func (*DeleteOpts) RegistryPath ¶
func (opts *DeleteOpts) RegistryPath() string
RegistryPath fulfills the cacheOperationProvider interface for DeleteOpts
type GetOpts ¶
type GetOpts struct {
// Optional Name or alias of the registry the get operation will be performed
// against.
RegistryName string
// Optional name of pack to get from cache
PackName string
// Optional ref ov pack or registry to get from the cache.
Ref string
// contains filtered or unexported fields
}
GetOpts are the arguments are required to get a registry or pack from the cache.
func (*GetOpts) ForPackName ¶
ForPackName fulfills the cacheOperationProvider interface for GetOpts
func (*GetOpts) RegistryPath ¶
RegistryPath fulfills the cacheOperationProvider interface for GetOpts
type Pack ¶
Pack wraps a pack.Pack add adds the local cache ref. Useful for showing the registry in the global cache differentiated from the pack metadata.
type PackConfig ¶
PackConfig represents the common configuration required by all packs. Used primarily by the cli package but should
func (*PackConfig) Init ¶
func (cfg *PackConfig) Init()
type Registry ¶
type Registry struct {
// Name as defined by the user
Name string `json:"name,omitempty"`
// Source URL of the registry
Source string `json:"source,omitempty"`
// Ref is a reference of the registry as specified by the user (may be "latest"
// or an actual git ref)
Ref string `json:"ref,omitempty"`
// LocalRef is a reference to the git SHA that we have available locally
LocalRef string `json:"local_ref,omitempty"`
Packs []*Pack `json:"-"`
}
Registry represents a registry definition from the global cache.