Skip to content

Commit 32cbdcd

Browse files
committed
git: make Source struct public
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 78a6eb8 commit 32cbdcd

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

source/git/source.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Opt struct {
4242
CacheAccessor cache.Accessor
4343
}
4444

45-
type gitSource struct {
45+
type Source struct {
4646
cache cache.Accessor
4747
locker *locker.Locker
4848
}
@@ -55,19 +55,19 @@ func Supported() error {
5555
return nil
5656
}
5757

58-
func NewSource(opt Opt) (source.Source, error) {
59-
gs := &gitSource{
58+
func NewSource(opt Opt) (*Source, error) {
59+
gs := &Source{
6060
cache: opt.CacheAccessor,
6161
locker: locker.New(),
6262
}
6363
return gs, nil
6464
}
6565

66-
func (gs *gitSource) Schemes() []string {
66+
func (gs *Source) Schemes() []string {
6767
return []string{srctypes.GitScheme}
6868
}
6969

70-
func (gs *gitSource) Identifier(scheme, ref string, attrs map[string]string, platform *pb.Platform) (source.Identifier, error) {
70+
func (gs *Source) Identifier(scheme, ref string, attrs map[string]string, platform *pb.Platform) (source.Identifier, error) {
7171
id, err := NewGitIdentifier(ref)
7272
if err != nil {
7373
return nil, err
@@ -105,7 +105,7 @@ func (gs *gitSource) Identifier(scheme, ref string, attrs map[string]string, pla
105105
}
106106

107107
// needs to be called with repo lock
108-
func (gs *gitSource) mountRemote(ctx context.Context, remote string, authArgs []string, sha256 bool, reset bool, g session.Group) (target string, release func() error, retErr error) {
108+
func (gs *Source) mountRemote(ctx context.Context, remote string, authArgs []string, sha256 bool, reset bool, g session.Group) (target string, release func() error, retErr error) {
109109
sis, err := searchGitRemote(ctx, gs.cache, remote)
110110
if err != nil {
111111
return "", nil, errors.Wrapf(err, "failed to search metadata for %s", urlutil.RedactCredentials(remote))
@@ -205,7 +205,7 @@ func (gs *gitSource) mountRemote(ctx context.Context, remote string, authArgs []
205205
}
206206

207207
type gitSourceHandler struct {
208-
*gitSource
208+
*Source
209209
src GitIdentifier
210210
cacheKey string
211211
cacheCommit string
@@ -231,16 +231,16 @@ func (gs *gitSourceHandler) shaToCacheKey(sha, ref string) string {
231231
return key
232232
}
233233

234-
func (gs *gitSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) {
234+
func (gs *Source) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) {
235235
gitIdentifier, ok := id.(*GitIdentifier)
236236
if !ok {
237237
return nil, errors.Errorf("invalid git identifier %v", id)
238238
}
239239

240240
return &gitSourceHandler{
241-
src: *gitIdentifier,
242-
gitSource: gs,
243-
sm: sm,
241+
src: *gitIdentifier,
242+
Source: gs,
243+
sm: sm,
244244
}, nil
245245
}
246246

worker/base/worker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type Worker struct {
9595
imageWriter *imageexporter.ImageWriter
9696
ImageSource *containerimage.Source
9797
OCILayoutSource *containerimage.Source
98+
GitSource *git.Source
9899
}
99100

100101
// NewWorker instantiates a local worker
@@ -141,6 +142,7 @@ func NewWorker(ctx context.Context, opt WorkerOpt) (*Worker, error) {
141142

142143
sm.Register(is)
143144

145+
var gitSource *git.Source
144146
if err := git.Supported(); err == nil {
145147
gs, err := git.NewSource(git.Opt{
146148
CacheAccessor: cm,
@@ -149,6 +151,7 @@ func NewWorker(ctx context.Context, opt WorkerOpt) (*Worker, error) {
149151
return nil, err
150152
}
151153
sm.Register(gs)
154+
gitSource = gs
152155
} else {
153156
bklog.G(ctx).Warnf("git source cannot be enabled: %v", err)
154157
}
@@ -210,6 +213,7 @@ func NewWorker(ctx context.Context, opt WorkerOpt) (*Worker, error) {
210213
imageWriter: iw,
211214
ImageSource: is,
212215
OCILayoutSource: os,
216+
GitSource: gitSource,
213217
}, nil
214218
}
215219

0 commit comments

Comments
 (0)