mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
547ef5b55d
Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
//go:build !release
|
|
// +build !release
|
|
|
|
package cnbutils
|
|
|
|
import (
|
|
"io"
|
|
"path/filepath"
|
|
|
|
pkgutil "github.com/GoogleContainerTools/container-diff/pkg/util"
|
|
"github.com/SAP/jenkins-library/pkg/mock"
|
|
"github.com/SAP/jenkins-library/pkg/piperutils"
|
|
v1 "github.com/google/go-containerregistry/pkg/v1"
|
|
fakeImage "github.com/google/go-containerregistry/pkg/v1/fake"
|
|
)
|
|
|
|
type MockUtils struct {
|
|
*mock.ExecMockRunner
|
|
*mock.FilesMock
|
|
}
|
|
|
|
func (c *MockUtils) GetFileUtils() piperutils.FileUtils {
|
|
return c.FilesMock
|
|
}
|
|
|
|
func (c *MockUtils) DownloadImageToPath(bpack, filePath string) (pkgutil.Image, error) {
|
|
fakeImage := fakeImage.FakeImage{}
|
|
fakeImage.ConfigFileReturns(&v1.ConfigFile{
|
|
Config: v1.Config{
|
|
Labels: map[string]string{
|
|
"io.buildpacks.buildpackage.metadata": "{\"id\": \"testbuildpack\", \"version\": \"0.0.1\"}",
|
|
},
|
|
},
|
|
}, nil)
|
|
|
|
c.AddDir(filepath.Join(filePath, "cnb/buildpacks", bpack))
|
|
c.AddDir(filepath.Join(filePath, "cnb/buildpacks", bpack, "0.0.1"))
|
|
img := pkgutil.Image{
|
|
Image: &fakeImage,
|
|
}
|
|
return img, nil
|
|
}
|
|
|
|
func (c *MockUtils) GetImageSource() (string, error) {
|
|
return "imageSource", nil
|
|
}
|
|
|
|
func (c *MockUtils) TarImage(writer io.Writer, image pkgutil.Image) error {
|
|
return nil
|
|
}
|