Migrate dagger.#Secret and dagger.#Stream to new format
- Refactored to keep every transformation of built-in types (e.g. FS, Secret, etc) to/from CUE in the same place (plancontext) - dagger.#Service and dagger.#Secret are now following the new FS-like format (e.g. `_service: id: string`) - Backward compatibility - dagger.#Stream is now an alias for dagger.#Service Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -5,41 +5,16 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type LocalDir struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
type localDirContext struct {
|
||||
l sync.RWMutex
|
||||
store map[ContextKey]*LocalDir
|
||||
store []string
|
||||
}
|
||||
|
||||
func (c *localDirContext) Register(directory *LocalDir) ContextKey {
|
||||
func (c *localDirContext) Add(dir string) {
|
||||
c.l.Lock()
|
||||
defer c.l.Unlock()
|
||||
|
||||
id := hashID(directory)
|
||||
c.store[id] = directory
|
||||
return id
|
||||
}
|
||||
|
||||
func (c *localDirContext) Get(id ContextKey) *LocalDir {
|
||||
c.l.RLock()
|
||||
defer c.l.RUnlock()
|
||||
|
||||
return c.store[id]
|
||||
}
|
||||
|
||||
func (c *localDirContext) List() []*LocalDir {
|
||||
c.l.RLock()
|
||||
defer c.l.RUnlock()
|
||||
|
||||
directories := make([]*LocalDir, 0, len(c.store))
|
||||
for _, d := range c.store {
|
||||
directories = append(directories, d)
|
||||
}
|
||||
|
||||
return directories
|
||||
c.store = append(c.store, dir)
|
||||
}
|
||||
|
||||
func (c *localDirContext) Paths() (map[string]string, error) {
|
||||
@@ -48,12 +23,12 @@ func (c *localDirContext) Paths() (map[string]string, error) {
|
||||
|
||||
directories := make(map[string]string)
|
||||
for _, d := range c.store {
|
||||
abs, err := filepath.Abs(d.Path)
|
||||
abs, err := filepath.Abs(d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
directories[d.Path] = abs
|
||||
directories[d] = abs
|
||||
}
|
||||
|
||||
return directories, nil
|
||||
|
Reference in New Issue
Block a user