-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/catalyst: boot from a temporary mist config file
- Loading branch information
Showing
5 changed files
with
110 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cli | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
downloaderCli "github.com/livepeer/catalyst/cmd/downloader/cli" | ||
"github.com/livepeer/catalyst/cmd/downloader/constants" | ||
"github.com/livepeer/catalyst/cmd/downloader/types" | ||
"github.com/peterbourgon/ff/v3" | ||
) | ||
|
||
// GetCliFlags reads command-line arguments and generates a struct | ||
// with useful values set after parsing the same. | ||
func GetCliFlags(buildFlags types.BuildFlags) (types.CliFlags, error) { | ||
cliFlags := types.CliFlags{} | ||
flag.Set("logtostderr", "true") | ||
vFlag := flag.Lookup("v") | ||
fs := flag.NewFlagSet(constants.AppName, flag.ExitOnError) | ||
|
||
downloaderCli.AddDownloaderFlags(fs, &cliFlags) | ||
|
||
fs.StringVar(&cliFlags.MistController, "mist-controller", "MistController", "Path to MistController binary to exec when done") | ||
fs.StringVar(&cliFlags.ConfigStack, "config", "/etc/livepeer/catalyst.yaml", "Path to multiple Catalyst config files to use. Can contain multiple entries e.g. /conf1:/conf2") | ||
|
||
version := fs.Bool("version", false, "Get version information") | ||
|
||
if *version { | ||
fmt.Printf("catalyst version: %s\n", buildFlags.Version) | ||
os.Exit(0) | ||
} | ||
|
||
ff.Parse( | ||
fs, os.Args[1:], | ||
ff.WithConfigFileParser(ff.PlainParser), | ||
ff.WithEnvVarPrefix("CATALYST"), | ||
ff.WithEnvVarSplit(","), | ||
) | ||
flag.CommandLine.Parse(nil) | ||
vFlag.Value.Set(cliFlags.Verbosity) | ||
|
||
err := downloaderCli.ValidateFlags(&cliFlags) | ||
if err != nil { | ||
return cliFlags, err | ||
} | ||
return cliFlags, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters