Add export and load for dagger images
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
@@ -10,6 +10,7 @@ type Context struct {
|
||||
Platform *platformContext
|
||||
FS *fsContext
|
||||
LocalDirs *localDirContext
|
||||
TempDirs *tempDirContext
|
||||
Secrets *secretContext
|
||||
Services *serviceContext
|
||||
}
|
||||
@@ -25,6 +26,9 @@ func New() *Context {
|
||||
LocalDirs: &localDirContext{
|
||||
store: []string{},
|
||||
},
|
||||
TempDirs: &tempDirContext{
|
||||
store: make(map[string]string),
|
||||
},
|
||||
Secrets: &secretContext{
|
||||
store: make(map[string]*Secret),
|
||||
},
|
||||
|
34
plancontext/tempdir.go
Normal file
34
plancontext/tempdir.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package plancontext
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type tempDirContext struct {
|
||||
l sync.RWMutex
|
||||
store map[string]string
|
||||
}
|
||||
|
||||
func (c *tempDirContext) Add(dir, key string) {
|
||||
c.l.Lock()
|
||||
defer c.l.Unlock()
|
||||
|
||||
c.store[key] = dir
|
||||
}
|
||||
|
||||
func (c *tempDirContext) Get(key string) string {
|
||||
c.l.RLock()
|
||||
defer c.l.RUnlock()
|
||||
|
||||
return c.store[key]
|
||||
}
|
||||
|
||||
func (c *tempDirContext) Clean() {
|
||||
c.l.RLock()
|
||||
defer c.l.RUnlock()
|
||||
|
||||
for _, s := range c.store {
|
||||
defer os.RemoveAll(s)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user