Skip to content

Commit

Permalink
Changelog update (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyanakiev authored Apr 17, 2024
1 parent 5632aa9 commit c791070
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.1.5] - 2024-04-18

## Fixed

- Fixing issue where vaulty will error if no config file is provided.

## [0.1.4] - 2024-04-17

## Fixed
Expand Down
25 changes: 4 additions & 21 deletions internal/config/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,33 @@ type Config struct {
VaultyRefreshRate int `yaml:"vaulty_refresh_rate"`
}

func checkForVaultAddress() {
if os.Getenv("VAULT_ADDR") == "" {
fmt.Println("VAULT_ADDR is not set. Please set it and try again.")
os.Exit(1)
}

if os.Getenv("VAULT_TOKEN") == "" {
fmt.Println("VAULT_TOKEN is not set. Please set it and try again.")
os.Exit(1)
}

}

func LoadConfig(cfgFile string) Config {
var config Config
// Load the config from the YAML file
home, err := os.UserHomeDir()
if err != nil {
fmt.Println("Error getting user home directory")
os.Exit(1)
}

var data []byte
if cfgFile == "" {
fmt.Println("No config file specified, using default")
fmt.Println("No config file specified")
yamlFilePath := filepath.Join(home, ".vaul7y.yaml")
data, err = ioutil.ReadFile(yamlFilePath)
data, err = os.ReadFile(yamlFilePath)
if err != nil {
fmt.Printf("Error reading YAML file: %v\n", err)
os.Exit(1)
}
} else {
fmt.Println("Using config file: ", cfgFile)
data, err = ioutil.ReadFile(cfgFile)
data, err = os.ReadFile(cfgFile)
if err != nil {
fmt.Printf("Error reading YAML file: %v\n", err)
os.Exit(1)
}
}

var config Config
err = yaml.Unmarshal(data, &config)
if err != nil {
fmt.Printf("Error parsing YAML file: %v\n", err)
os.Exit(1)
}

// Overwrite with environment variables if they are set
Expand Down

0 comments on commit c791070

Please sign in to comment.