-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix issue 2304: ux improvements #2317
Changes from all commits
5b9baba
b2f94e4
ce0f992
973de32
5dfb8c9
14ec9a2
5cc4f81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,13 +72,25 @@ func flagForRepo(t repo.RepoType) string { | |
case repo.FullNode: | ||
return "repo" | ||
case repo.StorageMiner: | ||
return "storagerepo" | ||
return "miner-repo" | ||
default: | ||
panic(fmt.Sprintf("Unknown repo type: %v", t)) | ||
} | ||
} | ||
|
||
func envForRepo(t repo.RepoType) string { | ||
switch t { | ||
case repo.FullNode: | ||
return "FULLNODE_API_INFO" | ||
case repo.StorageMiner: | ||
return "MINER_API_INFO" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fully support deprecation we'd need to figure out how to handle this stuff as well. This only returns the used value (which is fine), but we would need to handle both in the @magik6k might have some ideas where, but an off the cuff solution would be to change both of these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes, that sound like a better idea |
||
default: | ||
panic(fmt.Sprintf("Unknown repo type: %v", t)) | ||
} | ||
} | ||
|
||
// TODO remove after deprecation period | ||
func envForRepoDeprecation(t repo.RepoType) string { | ||
switch t { | ||
case repo.FullNode: | ||
return "FULLNODE_API_INFO" | ||
|
@@ -90,14 +102,24 @@ func envForRepo(t repo.RepoType) string { | |
} | ||
|
||
func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) { | ||
if env, ok := os.LookupEnv(envForRepo(t)); ok { | ||
envKey := envForRepo(t) | ||
env, ok := os.LookupEnv(envKey) | ||
if !ok { | ||
// TODO remove after deprecation period | ||
envKey = envForRepoDeprecation(t) | ||
env, ok = os.LookupEnv(envKey) | ||
if ok { | ||
log.Warnf("Use deprecation env(%s) value, please use env(%s) instead.", envKey, envForRepo(t)) | ||
} | ||
} | ||
if ok { | ||
sp := strings.SplitN(env, ":", 2) | ||
if len(sp) != 2 { | ||
log.Warnf("invalid env(%s) value, missing token or address", envForRepo(t)) | ||
log.Warnf("invalid env(%s) value, missing token or address", envKey) | ||
} else { | ||
ma, err := multiaddr.NewMultiaddr(sp[1]) | ||
if err != nil { | ||
return APIInfo{}, xerrors.Errorf("could not parse multiaddr from env(%s): %w", envForRepo(t), err) | ||
return APIInfo{}, xerrors.Errorf("could not parse multiaddr from env(%s): %w", envKey, err) | ||
} | ||
return APIInfo{ | ||
Addr: ma, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for
EnvironmentFile=-/etc/lotus/chainwatch.env
inlotus-chainwatch.service
.