universe vendoring

Rather than injecting universe at runtime, this change will vendor
alpha.dagger.io in `cue.mod` directly.

Fixes #700

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-07-01 19:42:52 +02:00
parent bf6a9f3588
commit f58ee5811b
17 changed files with 170 additions and 59 deletions

View File

@@ -1,5 +1,10 @@
package state
import (
"context"
"path"
)
// Contents of an environment serialized to a file
type State struct {
// State path
@@ -28,11 +33,26 @@ func (s *State) Source() Input {
w := s.Workspace
// FIXME: backward compatibility
if mod := s.Plan.Module; mod != "" {
w = mod
w = path.Join(w, mod)
}
return DirInput(w, []string{}, []string{})
}
// VendorUniverse vendors the latest (built-in) version of the universe into the
// environment's `cue.mod`.
// FIXME: This has nothing to do in `State` and should be tied to a `Workspace`.
// However, since environments could point to different modules before, we have
// to handle vendoring on a per environment basis.
func (s *State) VendorUniverse(ctx context.Context) error {
w := s.Workspace
// FIXME: backward compatibility
if mod := s.Plan.Module; mod != "" {
w = path.Join(w, mod)
}
return vendorUniverse(ctx, w)
}
type Plan struct {
Module string `yaml:"module,omitempty"`
Package string `yaml:"package,omitempty"`