ociinstaller

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: AGPL-3.0 Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultImageTag  = "latest"
	DefaultImageOrg  = "turbot"
	DefaultImageType = "plugins"
)
View Source
const DefaultConfigSchema string = "2020-11-18"

Variables

This section is empty.

Functions

func FileExists

func FileExists(filePath string) bool

func FindLayersForMediaType

func FindLayersForMediaType(layers []ocispec.Descriptor, mediaType string) []ocispec.Descriptor

func MediaTypeConfig

func MediaTypeConfig() string

func MediaTypePluginConfig

func MediaTypePluginConfig() string

deprecate this....

func MediaTypePluginDocsLayer

func MediaTypePluginDocsLayer() string

func MediaTypePluginLicenseLayer

func MediaTypePluginLicenseLayer() string

func MediaTypePluginSpcLayer

func MediaTypePluginSpcLayer() string

func MoveFileWithinPartition

func MoveFileWithinPartition(sourcePath, destPath string) error

MoveFileWithinPartition moves a file within an fs partition. panics if movement is attempted between partitions this is done separately to achieve performance benefits of os.Rename over reading and writing content

func MoveFolderWithinPartition

func MoveFolderWithinPartition(sourcePath, destPath string) error

MoveFolderWithinPartition moves a folder within an fs partition. panics if movement is attempted between partitions this is done separately to achieve performance benefits of os.Rename over reading and writing content

func NewTempDir

func NewTempDir(parent string) *tempDir

NewTempDir creates a directory under the given parent directory.

func Ungzip

func Ungzip(sourceFile string, destDir string, opts ...UngzipOption) (string, error)

Types

type ImageProvider

type ImageProvider[I OciImageData, C OciImageConfig] interface {
	GetImageData(layers []ocispec.Descriptor) (I, error)
	EmptyConfig() C
}

type ImageRef

type ImageRef struct {
	RequestedRef string
}

ImageRef a struct encapsulating a ref to an OCI image

func NewImageRef

func NewImageRef(ref string) *ImageRef

NewImageRef creates and returns a New ImageRef

func (*ImageRef) ActualImageRef

func (r *ImageRef) ActualImageRef() string

ActualImageRef returns the actual, physical full image ref (ghcr.io/turbot/steampipe/plugins/turbot/aws:1.0.0)

func (*ImageRef) DisplayImageRef

func (r *ImageRef) DisplayImageRef() string

DisplayImageRef returns the "friendly" user-facing full image ref (hub.steampipe.io/plugins/turbot/aws@1.0.0)

func (*ImageRef) DisplayImageRefConstraintOverride

func (r *ImageRef) DisplayImageRefConstraintOverride(constraint string) string

DisplayImageRefConstraintOverride returns a "friendly" user-facing version of the image ref but with the version replaced by provided constraint (hub.steampipe.io/plugins/turbot/aws@^1.0)

func (*ImageRef) GetFriendlyName

func (r *ImageRef) GetFriendlyName() string

GetFriendlyName returns the minimum friendly name so that the original name can be rebuilt using preset defaults: hub.steampipe.io/plugins/turbot/aws@1.0.0 => aws@1.0.0 hub.steampipe.io/plugins/turbot/aws@latest => aws hub.steampipe.io/plugins/otherOrg/aws@latest => otherOrg/aws hub.steampipe.io/plugins/otherOrg/aws@1.0.0 => otherOrg/aws@1.0.0 differentRegistry.com/otherOrg/aws@latest => differentRegistry.com/otherOrg/aws@latest differentRegistry.com/otherOrg/aws@1.0.0 => differentRegistry.com/otherOrg/aws@1.0.0

func (*ImageRef) GetOrgNameAndStream

func (r *ImageRef) GetOrgNameAndStream() (org, name, stream string)

GetOrgNameAndStream splits the full image reference into (org, name, constraint) Constraint will be either a SemVer version (1.2.3) or a SemVer constraint (^0.4)

func (*ImageRef) IsFromTurbotHub

func (r *ImageRef) IsFromTurbotHub() bool

type ImageType

type ImageType string
const (
	ImageTypePlugin ImageType = "plugin"
)

type MediaTypeProvider

type MediaTypeProvider interface {
	MediaTypeForPlatform(imageType ImageType) ([]string, error)
	SharedMediaTypes(imageType ImageType) []string
	ConfigMediaTypes() []string
}

type OciConfigBase

type OciConfigBase struct {
	SchemaVersion string `json:"schemaVersion"`
}

func (*OciConfigBase) GetSchemaVersion

func (c *OciConfigBase) GetSchemaVersion() string

func (*OciConfigBase) SetSchemaVersion

func (c *OciConfigBase) SetSchemaVersion(version string)

type OciDownloader

type OciDownloader[I OciImageData, C OciImageConfig] struct {
	Images []*OciImage[I, C]

	MediaTypesProvider MediaTypeProvider
	ImageProvider      ImageProvider[I, C]
	// contains filtered or unexported fields
}

func NewOciDownloader

func NewOciDownloader[I OciImageData, C OciImageConfig](baseImageRef string, mediaTypesProvider MediaTypeProvider, imageProvider ImageProvider[I, C]) *OciDownloader[I, C]

NewOciDownloader creates and returns a OciDownloader instance

func (*OciDownloader[I, C]) Download

func (o *OciDownloader[I, C]) Download(ctx context.Context, ref *ImageRef, imageType ImageType, destDir string) (*OciImage[I, C], error)

func (*OciDownloader[I, C]) Pull

func (o *OciDownloader[I, C]) Pull(ctx context.Context, ref string, mediaTypes []string, destDir string) (*ocispec.Descriptor, *ocispec.Descriptor, []byte, []ocispec.Descriptor, error)

Pull downloads the image from the given `ref` to the supplied `destDir`

Returns

imageDescription, configDescription, config, imageLayers, error

type OciImage

type OciImage[I OciImageData, C OciImageConfig] struct {
	OCIDescriptor *ocispec.Descriptor
	ImageRef      *ImageRef
	Config        C
	Data          I
	// contains filtered or unexported fields
}

func InstallPlugin

func InstallPlugin(ctx context.Context, imageRef string, constraint string, sub chan struct{}, baseImageRef string, mediaTypesProvider MediaTypeProvider, opts ...PluginInstallOption) (*OciImage[*PluginImage, *PluginImageConfig], error)

InstallPlugin installs a plugin from an OCI Image

type OciImageConfig

type OciImageConfig interface {
	GetSchemaVersion() string
	SetSchemaVersion(string)
}

type OciImageData

type OciImageData interface {
	Type() ImageType
}

type PluginImage

type PluginImage struct {
	BinaryFile         string
	BinaryDigest       string
	BinaryArchitecture string
	DocsDir            string
	ConfigFileDir      string
	LicenseFile        string
}

func (*PluginImage) Type

func (s *PluginImage) Type() ImageType

type PluginImageConfig

type PluginImageConfig struct {
	OciConfigBase
	Plugin struct {
		Name         string `json:"name,omitempty"`
		Organization string `json:"organization,omitempty"`
		Version      string `json:"version"`
	}
}

type PluginInstallOption

type PluginInstallOption = func(config *pluginInstallConfig)

func WithSkipConfig

func WithSkipConfig(skipConfigFile bool) PluginInstallOption

type PluginOciDownloader

type PluginOciDownloader struct {
	OciDownloader[*PluginImage, *PluginImageConfig]
}

func NewPluginOciDownloader

func NewPluginOciDownloader(baseImageRef string, mediaTypesProvider MediaTypeProvider) *PluginOciDownloader

func (*PluginOciDownloader) EmptyConfig

func (p *PluginOciDownloader) EmptyConfig() *PluginImageConfig

func (*PluginOciDownloader) GetImageData

func (p *PluginOciDownloader) GetImageData(layers []ocispec.Descriptor) (*PluginImage, error)

type UngzipOption

type UngzipOption func(*gzipConfig)

func WithMaxDecompressedSize

func WithMaxDecompressedSize(size int64) UngzipOption

Jump to

Keyboard shortcuts

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