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
- func Download(sourcePackageLister v1alpha1lister.SourcePackageLister, ...) (io.ReadCloser, error)
- func ExtractImage(targetPath, sourcePath string, image v1.Image) error
- func ExtractTar(targetPath, sourcePath string, tarReader *tar.Reader) error
- func IsSubPath(path, prefix string) bool
- func Keychain() authn.Keychain
- func ListTar(w io.Writer, reader *tar.Reader) error
- func PackageFile(path string) (v1.Image, error)
- func PackageSourceDirectory(sourcePath string, filter FileFilter) (v1.Image, error)
- func PackageSourceTar(dest io.Writer, sourcePath string, filter FileFilter) error
- func PushImage(imageName string, image v1.Image, retryOnErr bool) (name.Reference, error)
- func TrimPathPrefix(path, prefix string) string
- type FakeSourcePackageLister
- type FakeSourcePackageListerMockRecorder
- type FakeSourcePackageNamespaceLister
- type FakeSourcePackageNamespaceListerMockRecorder
- type FakeSpaceLister
- type FakeSpaceListerMockRecorder
- type FileFilter
- type ImageUploader
- type Uploader
Constants ¶
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 ¶
ExtractImage extracts the files and directories from the given sourcePath in image to targetPath on the current system.
func ExtractTar ¶
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 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 PackageFile ¶
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 ¶
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 ¶
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 ¶
func (m *FakeSourcePackageLister) EXPECT() *FakeSourcePackageListerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*FakeSourcePackageLister) List ¶
func (m *FakeSourcePackageLister) List(arg0 labels.Selector) ([]*v1alpha1.SourcePackage, error)
List mocks base method.
func (*FakeSourcePackageLister) SourcePackages ¶
func (m *FakeSourcePackageLister) SourcePackages(arg0 string) v1alpha10.SourcePackageNamespaceLister
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 ¶
func (m *FakeSourcePackageNamespaceLister) EXPECT() *FakeSourcePackageNamespaceListerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*FakeSourcePackageNamespaceLister) Get ¶
func (m *FakeSourcePackageNamespaceLister) Get(arg0 string) (*v1alpha1.SourcePackage, error)
Get mocks base method.
func (*FakeSourcePackageNamespaceLister) List ¶
func (m *FakeSourcePackageNamespaceLister) List(arg0 labels.Selector) ([]*v1alpha1.SourcePackage, error)
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 ¶
func (m *FakeSpaceLister) EXPECT() *FakeSpaceListerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
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 ¶
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.
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.