Documentation ¶
Index ¶
- Constants
- func CacheDependency(a app.App, checker InstalledChecker, d pkg.Descriptor, customName string, ...) (*app.LibraryConfig, error)
- func DefaultYAMLData(r Registry) ([]byte, error)
- type Fs
- func (fs *Fs) CacheRoot(name, path string) (string, error)
- func (fs *Fs) FetchRegistrySpec() (*Spec, error)
- func (fs *Fs) MakeRegistryConfig() *app.RegistryConfig
- func (fs *Fs) Name() string
- func (fs *Fs) Protocol() Protocol
- func (fs *Fs) RegistrySpecDir() string
- func (fs *Fs) RegistrySpecFilePath() string
- func (fs *Fs) ResolveLibrary(partName, partAlias, libRefSpec string, onFile ResolveFile, ...) (*parts.Spec, *app.LibraryConfig, error)
- func (fs *Fs) ResolveLibrarySpec(partName, libRefSpec string) (*parts.Spec, error)
- func (fs *Fs) SetURI(uri string) error
- func (fs *Fs) URI() string
- func (fs *Fs) ValidateURI(uri string) (bool, error)
- type FsRemoveAller
- type GarbageCollector
- type GitHub
- func (gh *GitHub) CacheRoot(name, path string) (string, error)
- func (gh *GitHub) FetchRegistrySpec() (*Spec, error)
- func (gh *GitHub) MakeRegistryConfig() *app.RegistryConfig
- func (gh *GitHub) Name() string
- func (gh *GitHub) Protocol() Protocol
- func (gh *GitHub) RegistrySpecDir() string
- func (gh *GitHub) RegistrySpecFilePath() string
- func (gh *GitHub) ResolveLibrary(partName, partAlias, libRefSpec string, onFile ResolveFile, ...) (*parts.Spec, *app.LibraryConfig, error)
- func (gh *GitHub) ResolveLibrarySpec(partName, libRefSpec string) (*parts.Spec, error)
- func (gh *GitHub) SetURI(uri string) error
- func (gh *GitHub) URI() string
- func (gh *GitHub) ValidateURI(uri string) (bool, error)
- type GitHubOpt
- type Helm
- func (h *Helm) CacheRoot(name string, relPath string) (string, error)
- func (h *Helm) FetchRegistrySpec() (*Spec, error)
- func (h *Helm) MakeRegistryConfig() *app.RegistryConfig
- func (h *Helm) Name() string
- func (h *Helm) Protocol() Protocol
- func (h *Helm) RegistrySpecDir() string
- func (h *Helm) RegistrySpecFilePath() string
- func (h *Helm) ResolveLibrary(partName string, partAlias string, version string, onFile ResolveFile, ...) (*parts.Spec, *app.LibraryConfig, error)
- func (h *Helm) ResolveLibrarySpec(partName, version string) (*parts.Spec, error)
- func (h *Helm) SetURI(uri string) error
- func (h *Helm) URI() string
- func (h *Helm) Update(version string) (string, error)
- func (h *Helm) ValidateURI(uri string) (bool, error)
- type InstalledChecker
- type LibraryConfig
- type LibraryConfigs
- type LibraryResolver
- type LibrarySpecResolver
- type PackageManager
- type PackageManagerOpt
- type Protocol
- type Registry
- type ResolveDirectory
- type ResolveFile
- type Setter
- type Spec
- type SpecFetcher
- type Specs
- type Validator
Constants ¶
const ( // DefaultAPIVersion is the default version of the registry API. DefaultAPIVersion = "0.2.0" // DefaultKind is the default kind of the registry API. DefaultKind = "ksonnet.io/registry" )
Variables ¶
This section is empty.
Functions ¶
func CacheDependency ¶
func CacheDependency(a app.App, checker InstalledChecker, d pkg.Descriptor, customName string, force bool, httpClient *http.Client) (*app.LibraryConfig, error)
CacheDependency vendors registry dependencies. TODO: create unit tests for this once mocks for this package are worked out.
func DefaultYAMLData ¶
DefaultYAMLData generates the contents for a registry's spec.
Types ¶
type Fs ¶
type Fs struct {
// contains filtered or unexported fields
}
Fs is a registry based on a local filesystem.
func NewFs ¶
NewFs creates an instance of Fs. Assign a name to the RegistryConfig if you want the Fs to know it's name.
func (*Fs) FetchRegistrySpec ¶
FetchRegistrySpec fetches the registry spec.
func (*Fs) MakeRegistryConfig ¶ added in v0.12.0
func (fs *Fs) MakeRegistryConfig() *app.RegistryConfig
MakeRegistryConfig returns an app registry ref spec.
func (*Fs) RegistrySpecDir ¶
RegistrySpecDir is the registry directory.
func (*Fs) RegistrySpecFilePath ¶
RegistrySpecFilePath is the path for the registry.yaml
func (*Fs) ResolveLibrary ¶
func (fs *Fs) ResolveLibrary(partName, partAlias, libRefSpec string, onFile ResolveFile, onDir ResolveDirectory) (*parts.Spec, *app.LibraryConfig, error)
ResolveLibrary fetches the part and creates a parts spec and library ref spec.
func (*Fs) ResolveLibrarySpec ¶
ResolveLibrarySpec returns a resolved spec for a part. `libRefSpec` is ignored.
type FsRemoveAller ¶ added in v0.13.0
type FsRemoveAller interface { // RemoveAll removes a directory path and any children it contains. It // does not fail if the path does not exist (return nil). RemoveAll(path string) error }
FsRemoveAller Subset of afero.Fs - just remove a directory
type GarbageCollector ¶ added in v0.13.0
type GarbageCollector struct {
// contains filtered or unexported fields
}
GarbageCollector removes vendored packages that are no longer needed
func NewGarbageCollector ¶ added in v0.13.0
func NewGarbageCollector(fs afero.Fs, pm vendorPathResolver, root string) GarbageCollector
NewGarbageCollector constructs a GarbageCollector
func (GarbageCollector) RemoveOrphans ¶ added in v0.13.0
func (gc GarbageCollector) RemoveOrphans(d pkg.Descriptor) error
RemoveOrphans removes vendored packages that have been orphaned
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
GitHub is a Github Registry
func (*GitHub) CacheRoot ¶
CacheRoot returns the root for caching - it removes any leading path segments from a provided path, leaving just the relative path under the registry name. Example:
uri: github.com/ksonnet/parts/tree/master/long/path/incubator path: long/path/incubator/parts.yaml output: incubator/parts.yaml
func (*GitHub) FetchRegistrySpec ¶
FetchRegistrySpec fetches the registry spec (registry.yaml, inventory of packages) This inventory may have been previously cached on disk. If the cache is not stale, it will be used. Otherwise, the spec is fetched from the remote repository.
func (*GitHub) MakeRegistryConfig ¶ added in v0.12.0
func (gh *GitHub) MakeRegistryConfig() *app.RegistryConfig
MakeRegistryConfig returns an app registry ref spec.
func (*GitHub) RegistrySpecDir ¶
RegistrySpecDir is the registry directory.
func (*GitHub) RegistrySpecFilePath ¶
RegistrySpecFilePath is the path for the registry.yaml
func (*GitHub) ResolveLibrary ¶
func (gh *GitHub) ResolveLibrary(partName, partAlias, libRefSpec string, onFile ResolveFile, onDir ResolveDirectory) (*parts.Spec, *app.LibraryConfig, error)
ResolveLibrary fetches the part and creates a parts spec and library ref spec.
func (*GitHub) ResolveLibrarySpec ¶
ResolveLibrarySpec returns a resolved spec for a part.
func (*GitHub) SetURI ¶ added in v0.12.0
SetURI implements registry.Setter. It sets the URI for the registry.
func (*GitHub) ValidateURI ¶ added in v0.12.0
ValidateURI implements registry.Validator. A URI is valid if:
- It is a valid URI (RFC 3986)
- It points to GitHub (Enterprise not supported at this time)
- It points to a valid tree in a GitHub repository
- That tree contains a `registry.yaml` file
- It currently exists (a HEAD request is sent over the network)
type GitHubOpt ¶
type GitHubOpt func(*GitHub)
GitHubOpt is an option for configuring GitHub.
func GitHubClient ¶
GitHubClient is an option for the setting a github client.
type Helm ¶ added in v0.12.0
type Helm struct {
// contains filtered or unexported fields
}
Helm is a Helm repository.
func NewHelm ¶ added in v0.12.0
func NewHelm(a app.App, registryRef *app.RegistryConfig, rc helm.RepositoryClient, ua archive.Unarchiver) (*Helm, error)
NewHelm creates an instance of Helm.
func (*Helm) CacheRoot ¶ added in v0.12.0
CacheRoot returns the root for caching by combining the path with the registry name.
func (*Helm) FetchRegistrySpec ¶ added in v0.12.0
FetchRegistrySpec fetches the registry spec. This method returns an unmarshalled version of registry.yaml
func (*Helm) MakeRegistryConfig ¶ added in v0.12.0
func (h *Helm) MakeRegistryConfig() *app.RegistryConfig
MakeRegistryConfig returns app registry ref spec.
func (*Helm) RegistrySpecDir ¶ added in v0.12.0
RegistrySpecDir is the registry directory.
func (*Helm) RegistrySpecFilePath ¶ added in v0.12.0
RegistrySpecFilePath is the path for the registry.yaml NOTE: this function appears to be github registry specific and may not need to be a part of the interface.
func (*Helm) ResolveLibrary ¶ added in v0.12.0
func (h *Helm) ResolveLibrary(partName string, partAlias string, version string, onFile ResolveFile, onDir ResolveDirectory) (*parts.Spec, *app.LibraryConfig, error)
ResolveLibrary fetches the part and creates a parts spec and library ref spec.
func (*Helm) ResolveLibrarySpec ¶ added in v0.12.0
ResolveLibrarySpec returns a resolved spec for a part.
func (*Helm) SetURI ¶ added in v0.12.0
SetURI implements registry.Setter. It sets the URI for the registry.
type InstalledChecker ¶ added in v0.12.0
type InstalledChecker interface { // IsInstalled checks whether a package is installed. // Supports fuzzy searches: Name, Name/Version, Registry/Name/Version, Registry/Version IsInstalled(d pkg.Descriptor) (bool, error) }
InstalledChecker checks if a package is installed, based on app config.
type LibraryConfig ¶ added in v0.12.0
LibraryConfig is library reference.
type LibraryConfigs ¶ added in v0.12.0
type LibraryConfigs map[string]*LibraryConfig
LibraryConfigs maps LibraryConfigs to a name.
type LibraryResolver ¶ added in v0.12.0
type LibraryResolver interface {
ResolveLibrary(libID, libAlias, version string, onFile ResolveFile, onDir ResolveDirectory) (*parts.Spec, *app.LibraryConfig, error)
}
LibraryResolver fetches library (package) contents from a registry
type LibrarySpecResolver ¶ added in v0.12.0
type LibrarySpecResolver interface {
ResolveLibrarySpec(libID, libRefSpec string) (*parts.Spec, error)
}
LibrarySpecResolver fetches metadata for a library.
type PackageManager ¶ added in v0.12.0
type PackageManager interface { InstalledChecker // Find finds a package by name. Package names have the format `<registry>/<library>@<version>`. // Remote registries may be consulted if the package is not installed locally. Find(pkg.Descriptor) (pkg.Package, error) // Packages lists packages. Packages() ([]pkg.Package, error) // PackagesForEnv returns a list of Packages defined in the application, from the context // of the specified environment. PackagesForEnv(e *app.EnvironmentConfig) ([]pkg.Package, error) // RemotePackages returns a list of remote packages. RemotePackages() ([]pkg.Package, error) // Prototypes lists prototypes. Prototypes() (prototype.Prototypes, error) // PackageEnvironments returns a list of environments a package is installed in. PackageEnvironments(pkg pkg.Package) ([]*app.EnvironmentConfig, error) // VendorPath returns the local path a package would be vendored at VendorPath(pkg.Descriptor) (string, error) }
PackageManager is a package manager.
func NewPackageManager ¶ added in v0.12.0
func NewPackageManager(a app.App, opts ...PackageManagerOpt) PackageManager
NewPackageManager creates an instance of PackageManager.
type PackageManagerOpt ¶ added in v0.13.0
type PackageManagerOpt func(*packageManager)
PackageManagerOpt configures a package mangager
func HTTPClientOpt ¶ added in v0.13.0
func HTTPClientOpt(httpClient *http.Client) PackageManagerOpt
HTTPClientOpt configures a packageManager with an http.Client
type Protocol ¶
type Protocol string
Protocol is the protocol for a registry.
const ( // ProtocolFilesystem is the protocol for file system based registries. ProtocolFilesystem Protocol = "fs" // ProtocolGitHub is the protocol for GitHub based registries. ProtocolGitHub Protocol = "github" // ProtocolHelm is the protocol for Helm based registries. ProtocolHelm Protocol = "helm" // ProtocolInvalid is an invalid protocol. ProtocolInvalid Protocol = "invalid" )
type Registry ¶
type Registry interface { RegistrySpecDir() string RegistrySpecFilePath() string LibrarySpecResolver LibraryResolver Name() string Protocol() Protocol URI() string CacheRoot(name, relPath string) (string, error) Validator Setter }
Registry is a Registry
type ResolveDirectory ¶
ResolveDirectory resolves directories when searching a part.
type ResolveFile ¶
ResolveFile resolves files found when searching a part.
type Setter ¶ added in v0.12.0
type Setter interface { SetURI(uri string) (err error) MakeRegistryConfig() *app.RegistryConfig SpecFetcher }
Setter is an interface for updating an existing registry
type Spec ¶
type Spec struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Version string `json:"version"` Libraries LibraryConfigs `json:"libraries"` }
Spec describes how a registry is stored.
func Add ¶
func Add(a app.App, protocol Protocol, name string, uri string, isOverride bool, httpClient *http.Client) (*Spec, error)
Add adds a registry with `name`, `protocol`, and `uri` to the current ksonnet application.
func (*Spec) UnmarshalJSON ¶ added in v0.12.0
UnmarshalJSON implements the json.Unmarshaler interface. We implement some compatibility conversions.
type SpecFetcher ¶ added in v0.12.0
type SpecFetcher interface { // FetchRegistrySpec fetches the registry spec (registry.yaml, inventory of packages) FetchRegistrySpec() (*Spec, error) }
SpecFetcher fetches registry metadata