dagger.#FS support
- Implement dagger.#FS support - Migrate `context.imports` to dagger.#FS - Backward compat: dagger.#FS can be passed in lieu of a dagger.#Artifact - For instance, an import (`dagger.#FS`) can be passed to the current `yarn.#Package` implementation Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
32
plancontext/fs.go
Normal file
32
plancontext/fs.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package plancontext
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
bkgw "github.com/moby/buildkit/frontend/gateway/client"
|
||||
)
|
||||
|
||||
type FS struct {
|
||||
Result bkgw.Reference
|
||||
}
|
||||
|
||||
type fsContext struct {
|
||||
l sync.RWMutex
|
||||
store map[ContextKey]*FS
|
||||
}
|
||||
|
||||
func (c *fsContext) Register(fs *FS) ContextKey {
|
||||
c.l.Lock()
|
||||
defer c.l.Unlock()
|
||||
|
||||
id := hashID(fs)
|
||||
c.store[id] = fs
|
||||
return id
|
||||
}
|
||||
|
||||
func (c *fsContext) Get(id ContextKey) *FS {
|
||||
c.l.RLock()
|
||||
defer c.l.RUnlock()
|
||||
|
||||
return c.store[id]
|
||||
}
|
Reference in New Issue
Block a user