sourceimage

package
v2.11.27 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package sourceimage includes utilities to pack and unpack source code from OCI containers so a normal container registry can be used as a source management system.

Package sourceimage is a generated GoMock package.

Index

Constants

View Source
const (
	// DefaultSourcePath contains the path to the source code inside the image.
	DefaultSourcePath = "/var/run/kontext"
)

Variables

This section is empty.

Functions

func Download

func Download(sourcePackageLister v1alpha1lister.SourcePackageLister, namespace, sourcePackageName string) (io.ReadCloser, error)

Download returns the extracted image from the specified SourcePackage.

func ExtractImage

func ExtractImage(targetPath, sourcePath string, image v1.Image) (int, error)

ExtractImage extracts the files and directories from the given sourcePath in image to targetPath on the current system.

func ExtractTar

func ExtractTar(targetPath, sourcePath string, tarReader *tar.Reader) (int, error)

ExtractTar extracts the files and directories from the given sourcePath in the tarReader to the targetPath on the current system.

Special files are skipped, and all files are converted to their absolute path equivalents to avoid traversal attacks.

func IsSubPath

func IsSubPath(path, prefix string) bool

IsSubPath returns whether or not the path is a child of the given path.

func Keychain

func Keychain() authn.Keychain

Keychain returns a Keychain that is used to push an image to a remote registry. It will first attempt to use the local docker configuration (found in $HOME/.docker/config.json). If that fails, it will defer to the Google Keychain which uses gcloud to fetch a token (used for GCR and AR).

func ListTar

func ListTar(w io.Writer, reader *tar.Reader) error

ListTar writes a ls -la style listing of the tar to the given writer.

func PackageFile

func PackageFile(path string) (v1.Image, error)

PackageFile converts the tar file into a container image.

func PackageSourceDirectory

func PackageSourceDirectory(sourcePath string, filter FileFilter) (v1.Image, error)

PackageSourceDirectory converts all the source code in sourcePath into a container image.

func PackageSourceTar

func PackageSourceTar(dest io.Writer, sourcePath string, filter FileFilter) error

PackageSourceTar recurses through sourcePath and writes source files to dest that match the given filter.

NOTE: file permissions in the created TAR are fixed to 0755 to prevent issues in the build system or Windows and files in the TAR will ALWAYS have forward-slashed paths.

func PushImage

func PushImage(imageName string, image v1.Image, retryOnErr bool) (name.Reference, error)

PushImage uploads the given v1.Image to a registry incorporating the provided string into the image's repository name. Returns the digest of the published image.

func TrimPathPrefix

func TrimPathPrefix(path, prefix string) string

TrimPathPrefix removes the full prefix from the given path if it is a sub path.

Types

type FakeSourcePackageLister

type FakeSourcePackageLister struct {
	// contains filtered or unexported fields
}

FakeSourcePackageLister is a mock of SourcePackageLister interface.

func NewFakeSourcePackageLister

func NewFakeSourcePackageLister(ctrl *gomock.Controller) *FakeSourcePackageLister

NewFakeSourcePackageLister creates a new mock instance.

func (*FakeSourcePackageLister) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*FakeSourcePackageLister) List

List mocks base method.

func (*FakeSourcePackageLister) SourcePackages

SourcePackages mocks base method.

type FakeSourcePackageListerMockRecorder

type FakeSourcePackageListerMockRecorder struct {
	// contains filtered or unexported fields
}

FakeSourcePackageListerMockRecorder is the mock recorder for FakeSourcePackageLister.

func (*FakeSourcePackageListerMockRecorder) List

func (mr *FakeSourcePackageListerMockRecorder) List(arg0 interface{}) *gomock.Call

List indicates an expected call of List.

func (*FakeSourcePackageListerMockRecorder) SourcePackages

func (mr *FakeSourcePackageListerMockRecorder) SourcePackages(arg0 interface{}) *gomock.Call

SourcePackages indicates an expected call of SourcePackages.

type FakeSourcePackageNamespaceLister

type FakeSourcePackageNamespaceLister struct {
	// contains filtered or unexported fields
}

FakeSourcePackageNamespaceLister is a mock of SourcePackageNamespaceLister interface.

func NewFakeSourcePackageNamespaceLister

func NewFakeSourcePackageNamespaceLister(ctrl *gomock.Controller) *FakeSourcePackageNamespaceLister

NewFakeSourcePackageNamespaceLister creates a new mock instance.

func (*FakeSourcePackageNamespaceLister) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*FakeSourcePackageNamespaceLister) Get

Get mocks base method.

func (*FakeSourcePackageNamespaceLister) List

List mocks base method.

type FakeSourcePackageNamespaceListerMockRecorder

type FakeSourcePackageNamespaceListerMockRecorder struct {
	// contains filtered or unexported fields
}

FakeSourcePackageNamespaceListerMockRecorder is the mock recorder for FakeSourcePackageNamespaceLister.

func (*FakeSourcePackageNamespaceListerMockRecorder) Get

func (mr *FakeSourcePackageNamespaceListerMockRecorder) Get(arg0 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*FakeSourcePackageNamespaceListerMockRecorder) List

func (mr *FakeSourcePackageNamespaceListerMockRecorder) List(arg0 interface{}) *gomock.Call

List indicates an expected call of List.

type FakeSpaceLister

type FakeSpaceLister struct {
	// contains filtered or unexported fields
}

FakeSpaceLister is a mock of SpaceLister interface.

func NewFakeSpaceLister

func NewFakeSpaceLister(ctrl *gomock.Controller) *FakeSpaceLister

NewFakeSpaceLister creates a new mock instance.

func (*FakeSpaceLister) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*FakeSpaceLister) Get

func (m *FakeSpaceLister) Get(arg0 string) (*v1alpha1.Space, error)

Get mocks base method.

func (*FakeSpaceLister) List

func (m *FakeSpaceLister) List(arg0 labels.Selector) ([]*v1alpha1.Space, error)

List mocks base method.

type FakeSpaceListerMockRecorder

type FakeSpaceListerMockRecorder struct {
	// contains filtered or unexported fields
}

FakeSpaceListerMockRecorder is the mock recorder for FakeSpaceLister.

func (*FakeSpaceListerMockRecorder) Get

func (mr *FakeSpaceListerMockRecorder) Get(arg0 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*FakeSpaceListerMockRecorder) List

func (mr *FakeSpaceListerMockRecorder) List(arg0 interface{}) *gomock.Call

List indicates an expected call of List.

type FileFilter

type FileFilter func(path string) bool

FileFilter returns true if the file should be included in the result and false otherwise.

func BuildIgnoreFilter

func BuildIgnoreFilter(srcPath string) (FileFilter, error)

BuildIgnoreFilter returns a FileFilter that ignores files similar to CF.

type ImageUploader

type ImageUploader struct {
	// contains filtered or unexported fields
}

ImageUploader is the logic for the service API for data.builds.appdevexperience.dev. It composes a container image and publishes it for the given tar data.

func NewImageUploader

func NewImageUploader(
	cfg *config.Defaults,
	buildLister v1alpha1lister.BuildLister,
	spaceLister v1alpha1lister.SpaceLister,
	imagePusher func(path, imageName string) (name.Reference, error),
) *ImageUploader

NewImageUploader returns a new ImageUploader.

func (*ImageUploader) Upload

func (u *ImageUploader) Upload(
	ctx context.Context,
	namespace string,
	name string,
	r io.Reader,
) (name.Reference, error)

Upload composes a container image and publishes the given data. It will publish to the configured container registry.

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader is the logic for the service API for upload.kf.dev. It composes a container image and publishes it for the given data.

func NewUploader

func NewUploader(
	spaceLister v1alpha1lister.SpaceLister,
	sourcePackageLister v1alpha1lister.SourcePackageLister,
	imagePusher func(path, imageName string) (name.Reference, error),
	statusUpdater func(s *v1alpha1.SourcePackage) error,
) *Uploader

NewUploader returns a new Uploader.

func (*Uploader) Upload

func (u *Uploader) Upload(
	ctx context.Context,
	spaceName string,
	sourcePackageName string,
	r io.Reader,
) (name.Reference, error)

Upload composes a container image and publishes the given data. It will publish to the configured container registry found in the Space.

Jump to

Keyboard shortcuts

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