5b7b1cab79
- 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>
36 lines
532 B
Go
36 lines
532 B
Go
package plancontext
|
|
|
|
import (
|
|
"path/filepath"
|
|
"sync"
|
|
)
|
|
|
|
type localDirContext struct {
|
|
l sync.RWMutex
|
|
store []string
|
|
}
|
|
|
|
func (c *localDirContext) Add(dir string) {
|
|
c.l.Lock()
|
|
defer c.l.Unlock()
|
|
|
|
c.store = append(c.store, dir)
|
|
}
|
|
|
|
func (c *localDirContext) Paths() (map[string]string, error) {
|
|
c.l.RLock()
|
|
defer c.l.RUnlock()
|
|
|
|
directories := make(map[string]string)
|
|
for _, d := range c.store {
|
|
abs, err := filepath.Abs(d)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
directories[d] = abs
|
|
}
|
|
|
|
return directories, nil
|
|
}
|