mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
1f750af16d
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com> Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
//go:build !release
|
|
// +build !release
|
|
|
|
package cnbutils
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"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) DownloadImageContent(bpack, targetDir string) (v1.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(targetDir, "cnb/buildpacks", bpack))
|
|
c.AddDir(filepath.Join(targetDir, "cnb/buildpacks", bpack, "0.0.1"))
|
|
return &fakeImage, nil
|
|
}
|
|
|
|
func (c *MockUtils) DownloadImage(src, dst string) (v1.Image, error) {
|
|
return nil, fmt.Errorf("not implemented")
|
|
}
|
|
|
|
func (c *MockUtils) GetImageSource() (string, error) {
|
|
return "imageSource", nil
|
|
}
|
|
|
|
func (c *MockUtils) GetRemoteImageInfo(imageSource string) (v1.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)
|
|
fakeImage.DigestReturns(v1.Hash{}, nil)
|
|
|
|
return &fakeImage, nil
|
|
}
|