fix envvar handling
This commit is contained in:
parent
daf452a180
commit
d949b6c8ef
@ -34,10 +34,10 @@ development = true
|
||||
|
||||
- You can also specify a URL, together with a sha256 checksum to avoid downloading from
|
||||
github.
|
||||
- You can also specify an EnvVar, to provide the path dynamically at runtime.
|
||||
- You can also specify an environment variable (`LOTUS_BUILTIN_ACTORS_VX_BUNDLE`), to provide the path dynamically at runtime.
|
||||
|
||||
The precedence for bundle fetching/loading is as folllows:
|
||||
- Check the EnvVar; use the bundle specified by it.
|
||||
- Check the environment variable `LOTUS_BUILTIN_ACTORS_VX_BUNDLE` for version X bundle; use it if set.
|
||||
- Check the Path; use the bundle specified by it.
|
||||
- Check the URL; use the bundle specified by it, and verify the checksum which must be present.
|
||||
- Otherwise, use the release tag and download from github.
|
||||
|
@ -20,8 +20,6 @@ type Bundle struct {
|
||||
Version actors.Version
|
||||
// Release is the release id
|
||||
Release string
|
||||
// EnvVar is the (optional) env var specifying the bundle path; takes precdence over path
|
||||
EnvVar string
|
||||
// Path is the (optional) bundle path; takes precedence over url
|
||||
Path string
|
||||
// URL is the (optional) bundle URL; takes precdence over github release
|
||||
|
@ -2,6 +2,7 @@ package bundle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@ -86,13 +87,11 @@ func FetchAndLoadBundles(ctx context.Context, bs blockstore.Blockstore, bar map[
|
||||
}
|
||||
|
||||
for av, bd := range bar {
|
||||
envvar := fmt.Sprintf("LOGUS_BUILTIN_ACTORS_V%d_BUNDLE", av)
|
||||
switch {
|
||||
case bd.EnvVar != "":
|
||||
case os.Getenv(envvar) != "":
|
||||
// this is a local bundle, specified by an env var to load from the filesystem
|
||||
path := os.Getenv(bd.EnvVar)
|
||||
if path == "" {
|
||||
return xerrors.Errorf("bundle envvar is empty: %s", bd.EnvVar)
|
||||
}
|
||||
path := os.Getenv(envvar)
|
||||
|
||||
if _, err := LoadBundle(ctx, bs, path, av); err != nil {
|
||||
return err
|
||||
|
@ -68,14 +68,11 @@ func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRe
|
||||
}
|
||||
|
||||
// we haven't recorded it in the datastore, so we need to load it
|
||||
envvar := fmt.Sprintf("LOGUS_BUILTIN_ACTORS_V%d_BUNDLE", av)
|
||||
var mfCid cid.Cid
|
||||
switch {
|
||||
case bd.EnvVar != "":
|
||||
// this is a local bundle, specified by an env var to load from the filesystem
|
||||
path := os.Getenv(bd.EnvVar)
|
||||
if path == "" {
|
||||
return result, xerrors.Errorf("bundle envvar is empty: %s", bd.EnvVar)
|
||||
}
|
||||
case os.Getenv(envvar) != "":
|
||||
path := os.Getenv(envvar)
|
||||
|
||||
mfCid, err = bundle.LoadBundle(ctx, bs, path, av)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user