-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
source
a .conf file with skywire-cli config gen
#1558
Conversation
… tp setup node configuration
source
a .conf file with skywire-cli config gen
[WIP]source
a .conf file with skywire-cli config gen
|
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.
I will have to do a review in multiple parts.
pkg/visor/visorconfig/values.go
Outdated
func MustPKs(pks string) []cipher.PubKey { | ||
var sPKs cipher.PubKeys | ||
if err := sPKs.Set(pks); err != nil { | ||
fmt.Printf("invalid public key or keys: %s", pks) |
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.
I see that this package uses fmt
consistently. Is there a reason we are using fmt
here instead of the logging pacakge we use typically?
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.
There is no logging package already used in this particular file, but fmt was already imported
i was replacing a panic with an actual error before the panic because at one point i was hitting that panic and it was very unhelpful.
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.
@0pcom we use the logging package liberally throughout the project. I dont see a reason we should avoid importing it here unless you see an explicit reason.
pkg/visor/visorconfig/values.go
Outdated
panic(err) | ||
} | ||
|
||
return sPK | ||
} | ||
|
||
// MustPKs unmarshals comma separated list of string PKs to []cipher.PubKey. It panics if unmarshaling fails. | ||
func MustPKs(pks string) []cipher.PubKey { |
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.
Can we name this more explicitly like MustParsePKs
?
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.
If we want to rename the one above it to match as MustParsePK
if err != nil { | ||
log.WithError(err).Fatal("Failed to create http request\n") | ||
} | ||
req.Header.Add("Cache-Control", "no-cache") |
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.
Where is the cache supposed to come from? I dont think we are currently caching the conf service responses.
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.
I cannot say, this was existing code I just moved
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.
I will have to do a review in multiple parts.
gHiddenFlags = append(gHiddenFlags, "binpath") | ||
// genConfigCmd.Flags().StringVar(&addSkysocksClientSrv, "proxyclientpk", scriptExecString("${PROXYCLIENTPK}"), "set server public key for proxy client") |
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.
Still dead code here.
if err != nil { | ||
//silence errors for stdout | ||
if !isStdout { | ||
log.WithError(err).Error("Failed to fetch servers\n") | ||
log.Warn("Falling back on hardcoded servers") | ||
} | ||
} else { | ||
// nil error from client.Do(req) | ||
// nil error from client.Get |
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.
Can we move all of this code to inside the else clause outside the else clause? Resp body should be closed even if there is an error I believe. Also, can we set the log level to panic
or something equivalent and remove all these checks for !stdout
?
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.
valid points, will make the changes
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.
I've outdented the code as requested, but in terms of getting rid of 'all these checks for !isStdout
' it's not just as straightforward as changing the log level because the behavior is also changed by the stdout flag to not create or read files and I already have the -w flag as an override for showing the errors, so it's something I would like to revisit after this PR is merged.
We are talking about code that currently works and is on develop in any case
I've gone ahead and implemented the dead code which was functionality from config update also updated the env file
|
skywire-cli config gen
has a lot of flags, but still lacks the granularity of configuration which may be desired to persist or set initially for config generation.This PR introduces a comment-able, human-editable standard .conf template which can be specified as an environmental variable to
config gen
andsourced
(or the windows / powershell equivalent)Here is the WIP version for linux
This will be extended to allow for or include
Invocation
to generate a json skywire config using such a template, the path to the .conf file should be specified as an env to
skywire-cli config gen
as followsThe values override the defaults of the flags, viewable with
config gen --all
as demonstrated in the following screenshots:no env file specified or file not detected
Here I have
Usage
The use of the env file and flags will be to a large extent mutually exclusive with flags, as using the same flagset (for boolean values) as envs specified in the .config will cancel each other out. Some flags will not be made available to set in the env file; specifically the following flags
-n
stdout-x
retain hypervisors-r
regenerate config or retain keysadditionally, more flags need to be added to achieve the desired level of granularity of configuration.
Non-linux implementations
(.)
command on windows (powershell) is the equivalent of thesource
command on linux.$
in front of variable declarations