File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,8 @@ type Api struct {
3737
3838func NewApi (opts ... func (* ApiOptions )) * Api {
3939 var options = & ApiOptions {}
40- if opts != nil {
41- for _ , opt := range opts {
42- opt (options )
43- }
40+ for _ , opt := range opts {
41+ opt (options )
4442 }
4543
4644 tr := & http.Transport {}
@@ -60,7 +58,7 @@ func (a *Api) saveSession(host string, session *Session) {
6058}
6159
6260func (a * Api ) getSession (host string ) * Session {
63- session , _ := a .sessions [host ]
61+ session := a .sessions [host ]
6462 return session
6563}
6664
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ func newConfig() *Config {
2626
2727var Cfg * Config
2828
29- func init () {
29+ func Load () error {
3030 Cfg = newConfig ()
31- Cfg .Load ()
31+ return Cfg .Load ()
3232}
3333
3434func (c * Config ) AddProfile (profile * Profile ) {
Original file line number Diff line number Diff line change 66 "os"
77
88 "github.com/MrZoidberg/megarac/cmd"
9+ "github.com/MrZoidberg/megarac/config"
910 "github.com/MrZoidberg/megarac/lgr"
1011 "github.com/urfave/cli/v2"
1112)
@@ -15,13 +16,16 @@ var revision = "latest"
1516func main () {
1617
1718 lgr .SetupLog ()
19+ err := config .Load ()
20+ if err != nil {
21+ log .Fatalf ("Failed to load configuration: %v" , err )
22+ }
1823
1924 app := & cli.App {
2025 Name : "megarac" ,
2126 Usage : "cli tool for managing MegaRAC BMCs" ,
2227 Action : func (cCtx * cli.Context ) error {
23- cli .ShowAppHelp (cCtx )
24- return nil
28+ return cli .ShowAppHelp (cCtx )
2529 },
2630 Commands : []* cli.Command {
2731 {
You can’t perform that action at this time.
0 commit comments