Documentation
¶
Overview ¶
Copyright 2021 NDD.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func Build(ctx context.Context, b parser.Backend, p parser.Parser, l parser.Linter) (v1.Image, error)
- func BuildMetaScheme() (*runtime.Scheme, error)
- func BuildObjectScheme() (*runtime.Scheme, error)
- func BuildPath(path, name string) string
- func FindNddpkgInDir(fs afero.Fs, root string) (string, error)
- func FriendlyID(name, hash string) string
- func IsCRD(o runtime.Object) error
- func IsIntent(o runtime.Object) error
- func IsProvider(o runtime.Object) error
- func NewIntentLinter() parser.Linter
- func NewProviderLinter() parser.Linter
- func OneMeta(pkg *parser.Package) error
- func PackageNddCompatible(v version.Operations) parser.ObjectLinterFn
- func PackageValidSemver(o runtime.Object) error
- func ParseKindFromMeta(fs afero.Fs, path string) (string, error)
- func ParseNameFromMeta(fs afero.Fs, path string) (string, error)
- func ParsePackageSourceFromReference(ref name.Reference) string
- func ToDNSLabel(s string) string
- func TryConvert(obj runtime.Object, candidates ...conversion.Hub) (runtime.Object, bool)
- func TryConvertToPkg(obj runtime.Object, candidates ...conversion.Hub) (pkgmetav1.Pkg, bool)
- type Cache
- type Fetcher
- type ImageCache
- type K8sFetcher
- func (i *K8sFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
- func (i *K8sFetcher) Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error)
- func (i *K8sFetcher) Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error)
- type NopCache
- type NopFetcher
- func (n *NopFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
- func (n *NopFetcher) Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error)
- func (n *NopFetcher) Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error)
Constants ¶
const ( // MetaFile is the name of a Ndd package metadata file. MetaFile string = "ndd.yaml" // StreamFile is the name of the file in a ndd package image that // contains its YAML stream. StreamFile string = "package.yaml" // StreamFileMode determines the permissions on the stream file. StreamFileMode os.FileMode = 0o644 // NddpkgExtension is the extension for compiled ndd packages. NddpkgExtension string = ".nddpkg" // NddpkgMatchPattern is the match pattern for identifying compiled ndd packages. NddpkgMatchPattern string = "*" + NddpkgExtension )
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(ctx context.Context, b parser.Backend, p parser.Parser, l parser.Linter) (v1.Image, error)
Build compiles a Ndd package from an on-disk package.
func BuildMetaScheme ¶
BuildMetaScheme builds the default scheme used for identifying metadata in a Ndd package.
func BuildObjectScheme ¶
BuildObjectScheme builds the default scheme used for identifying objects in a Ndd package.
func BuildPath ¶
BuildPath builds a path for a compiled Ndd package. If file name has extension it will be replaced.
func FindNddpkgInDir ¶
FindNddpkgInDir finds compiled Ndd packages in a directory.
func FriendlyID ¶
FriendlyID builds a valid DNS label string made up of the name of a package and its image digest.
func IsProvider ¶
IsProvider checks that an object is a Provider meta type.
func NewIntentLinter ¶ added in v0.1.3
NewIntentLinter is a convenience function for creating a package linter for intents.
func NewProviderLinter ¶
NewProviderLinter is a convenience function for creating a package linter for providers.
func PackageNddCompatible ¶
func PackageNddCompatible(v version.Operations) parser.ObjectLinterFn
PackageNddCompatible checks that the current Ndd version is compatible with the package constraints.
func PackageValidSemver ¶
PackageValidSemver checks that the package uses valid semver ranges.
func ParseKindFromMeta ¶ added in v0.1.3
ParseKindFromMeta extracts the package kind from its meta file.
func ParseNameFromMeta ¶
ParseNameFromMeta extracts the package name from its meta file.
func ParsePackageSourceFromReference ¶
ParsePackageSourceFromReference parses a package source from an OCI image reference. A source is defined as an OCI image reference with the identifier (tag or digest) stripped and no other changes to the original reference source. This is necessary because go-containerregistry will convert docker.io to index.docker.io for backwards compatibility before pulling an image. We do not want to do that in cases where we are not pulling an image because it breaks comparison with dependencies defined in a Configuration manifest.
func ToDNSLabel ¶
ToDNSLabel converts the string to a valid DNS label.
func TryConvert ¶
TryConvert converts the supplied object to the first supplied candidate that does not return an error. Returns the converted object and true when conversion succeeds, or the original object and false if it does not.
func TryConvertToPkg ¶
TryConvertToPkg converts the supplied object to a pkgmeta.Pkg, if possible.
Types ¶
type Cache ¶
type Cache interface { Get(tag string, id string) (v1.Image, error) Store(tag string, id string, img v1.Image) error Delete(id string) error }
A Cache caches OCI images.
type Fetcher ¶
type Fetcher interface { Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error) Head(ctx context.Context, ref name.Reference, secrets ...string) (*v1.Descriptor, error) Tags(ctx context.Context, ref name.Reference, secrets ...string) ([]string, error) }
Fetcher fetches package images.
type ImageCache ¶
type ImageCache struct {
// contains filtered or unexported fields
}
ImageCache stores and retrieves OCI images in a filesystem-backed cache in a thread-safe manner.
func NewImageCache ¶
func NewImageCache(dir string, fs afero.Fs) *ImageCache
NewImageCache creates a new ImageCache.
func (*ImageCache) Delete ¶
func (c *ImageCache) Delete(id string) error
Delete removes an image from the ImageCache.
type K8sFetcher ¶
type K8sFetcher struct {
// contains filtered or unexported fields
}
K8sFetcher uses kubernetes credentials to fetch package images.
func NewK8sFetcher ¶
func NewK8sFetcher(client kubernetes.Interface, namespace string) *K8sFetcher
NewK8sFetcher creates a new K8sFetcher.
func (*K8sFetcher) Fetch ¶
func (i *K8sFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
Fetch fetches a package image.
type NopCache ¶
type NopCache struct{}
NopCache is a cache implementation that does not store anything and always returns an error on get.
type NopFetcher ¶
type NopFetcher struct{}
NopFetcher always returns an empty image and never returns error.
func (*NopFetcher) Fetch ¶
func (n *NopFetcher) Fetch(ctx context.Context, ref name.Reference, secrets ...string) (v1.Image, error)
Fetch fetches an empty image and does not return error.