Skip to content

Commit

Permalink
fix: allow finch commands to run using default config (#1109)
Browse files Browse the repository at this point in the history
* fix: allow finch commands to run using default config

Signed-off-by: Justin Alvarez <[email protected]>

* update warning

Signed-off-by: Justin Alvarez <[email protected]>

---------

Signed-off-by: Justin Alvarez <[email protected]>
  • Loading branch information
pendo324 authored Sep 24, 2024
1 parent 839221c commit 4b57a00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmd/finch/main_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
package main

import (
"errors"
"fmt"
"io"
"os"

"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,7 +43,11 @@ func xmain(logger flog.Logger,
ecc,
)
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
if errors.Is(err, os.ErrPermission) {
logger.Warnf("Failed to load config, using default values. You may need to be root or use sudo. (%s)", err)
} else {
return fmt.Errorf("failed to load config: %w", err)
}
}

return newApp(
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Load(
return nil, fmt.Errorf("failed to ensure %q directory: %w", cfgPath, err)
}
if err := writeConfig(defCfg, fs, cfgPath); err != nil {
return nil, err
log.Warnf("Could not save default values to %q: %w", cfgPath, err)
}
return defCfg, nil
}
Expand Down

0 comments on commit 4b57a00

Please sign in to comment.