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
|
- You can also specify a URL, together with a sha256 checksum to avoid downloading from
|
||||||
github.
|
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:
|
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 Path; use the bundle specified by it.
|
||||||
- Check the URL; use the bundle specified by it, and verify the checksum which must be present.
|
- 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.
|
- Otherwise, use the release tag and download from github.
|
||||||
|
@ -20,8 +20,6 @@ type Bundle struct {
|
|||||||
Version actors.Version
|
Version actors.Version
|
||||||
// Release is the release id
|
// Release is the release id
|
||||||
Release string
|
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 is the (optional) bundle path; takes precedence over url
|
||||||
Path string
|
Path string
|
||||||
// URL is the (optional) bundle URL; takes precdence over github release
|
// URL is the (optional) bundle URL; takes precdence over github release
|
||||||
|
@ -2,6 +2,7 @@ package bundle
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -86,13 +87,11 @@ func FetchAndLoadBundles(ctx context.Context, bs blockstore.Blockstore, bar map[
|
|||||||
}
|
}
|
||||||
|
|
||||||
for av, bd := range bar {
|
for av, bd := range bar {
|
||||||
|
envvar := fmt.Sprintf("LOGUS_BUILTIN_ACTORS_V%d_BUNDLE", av)
|
||||||
switch {
|
switch {
|
||||||
case bd.EnvVar != "":
|
case os.Getenv(envvar) != "":
|
||||||
// this is a local bundle, specified by an env var to load from the filesystem
|
// this is a local bundle, specified by an env var to load from the filesystem
|
||||||
path := os.Getenv(bd.EnvVar)
|
path := os.Getenv(envvar)
|
||||||
if path == "" {
|
|
||||||
return xerrors.Errorf("bundle envvar is empty: %s", bd.EnvVar)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := LoadBundle(ctx, bs, path, av); err != nil {
|
if _, err := LoadBundle(ctx, bs, path, av); err != nil {
|
||||||
return err
|
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
|
// 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
|
var mfCid cid.Cid
|
||||||
switch {
|
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(envvar)
|
||||||
path := os.Getenv(bd.EnvVar)
|
|
||||||
if path == "" {
|
|
||||||
return result, xerrors.Errorf("bundle envvar is empty: %s", bd.EnvVar)
|
|
||||||
}
|
|
||||||
|
|
||||||
mfCid, err = bundle.LoadBundle(ctx, bs, path, av)
|
mfCid, err = bundle.LoadBundle(ctx, bs, path, av)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user