This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/plancontext/context.go
Marcos Lilljedahl 34c7a2ff12 Automatically set target platform based on client architecture
Set the default platform based on the client's OS and architecture. This
function is the same one that buildkit uses (https://github.com/moby/buildkit/blob/master/frontend/dockerfile/builder/build.go#L100-L102) to set the default build target platform

Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
2022-04-05 15:30:11 -03:00

48 lines
885 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
TempDirs *tempDirContext
Secrets *secretContext
Services *serviceContext
}
func New() *Context {
return &Context{
Platform: &platformContext{},
FS: &fsContext{
store: make(map[string]*FS),
},
LocalDirs: &localDirContext{
store: []string{},
},
TempDirs: &tempDirContext{
store: make(map[string]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)
}