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>
46 lines
822 B
Go
46 lines
822 B
Go
package plancontext
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"fmt"
|
|
)
|
|
|
|
// Context holds the execution context for a plan.
|
|
type Context struct {
|
|
Platform *platformContext
|
|
FS *fsContext
|
|
LocalDirs *localDirContext
|
|
Secrets *secretContext
|
|
Services *serviceContext
|
|
}
|
|
|
|
func New() *Context {
|
|
return &Context{
|
|
Platform: &platformContext{
|
|
platform: defaultPlatform,
|
|
},
|
|
FS: &fsContext{
|
|
store: make(map[string]*FS),
|
|
},
|
|
LocalDirs: &localDirContext{
|
|
store: []string{},
|
|
},
|
|
Secrets: &secretContext{
|
|
store: make(map[string]*Secret),
|
|
},
|
|
Services: &serviceContext{
|
|
store: make(map[string]*Service),
|
|
},
|
|
}
|
|
}
|
|
|
|
func hashID(values ...string) string {
|
|
hash := sha256.New()
|
|
for _, v := range values {
|
|
if _, err := hash.Write([]byte(v)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
return fmt.Sprintf("%x", hash)
|
|
}
|