use the workspace as the plan module

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-07-02 18:28:03 +02:00
parent 919d5576d0
commit 6e215b194e
7 changed files with 95 additions and 73 deletions

View File

@@ -9,7 +9,7 @@ type State struct {
Workspace string `yaml:"-"`
// Plan
Plan Plan `yaml:"plan"`
Plan Plan `yaml:"plan,omitempty"`
// Human-friendly environment name.
// A environment may have more than one name.
@@ -23,17 +23,21 @@ type State struct {
Computed string `yaml:"-"`
}
// Cue module containing the environment plan
func (s *State) Source() Input {
w := s.Workspace
// FIXME: backward compatibility
if mod := s.Plan.Module; mod != "" {
w = mod
}
return DirInput(w, []string{}, []string{})
}
type Plan struct {
Module string `yaml:"module,omitempty"`
Package string `yaml:"package,omitempty"`
}
// Cue module containing the environment plan
// The input's top-level artifact is used as a module directory.
func (p *Plan) Source() Input {
return DirInput(p.Module, []string{}, []string{})
}
func (s *State) SetInput(key string, value Input) error {
if s.Inputs == nil {
s.Inputs = make(map[string]Input)