store: support multiple deployments per path

- Add support for multiple deployments per path in the Store
- Add a bunch of tests
- Change the Lookup deployment API
- Add disambiguation in the CLI commands

Fixes #231

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-04-02 16:38:27 -07:00
parent 540f373993
commit 33a7770459
3 changed files with 77 additions and 26 deletions

View File

@@ -38,7 +38,26 @@ func GetCurrentDeploymentState(ctx context.Context, store *dagger.Store) *dagger
Str("deploymentPath", wd).
Msg("failed to lookup deployment by path")
}
return st
if len(st) == 0 {
lg.
Fatal().
Err(err).
Str("deploymentPath", wd).
Msg("no deployments match the current directory")
}
if len(st) > 1 {
deployments := []string{}
for _, s := range st {
deployments = append(deployments, s.Name)
}
lg.
Fatal().
Err(err).
Str("deploymentPath", wd).
Strs("deployments", deployments).
Msg("multiple deployments match the current directory, select one with `--deployment`")
}
return st[0]
}
// Re-compute a deployment (equivalent to `dagger up`).