Skip to content

Commit

Permalink
refactor(agent): ♻️ move prefs lookup from global to local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Jan 11, 2024
1 parent 177c24a commit 8cbe821
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions internal/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,20 @@ type pref struct {
viper string
}

var prefs = map[string]pref{
"PrefAPIURL": {fyne: "ApiURL", viper: "hass.apiurl"},
"PrefWebsocketURL": {fyne: "WebSocketURL", viper: "hass.websocketurl"},
"PrefCloudhookURL": {fyne: "CloudhookURL", viper: "hass.cloudhookurl"},
"PrefRemoteUIURL": {fyne: "RemoteUIURL", viper: "hass.remoteuiurl"},
"PrefToken": {fyne: "Token", viper: "hass.token"},
"PrefWebhookID": {fyne: "WebhookID", viper: "hass.webhookid"},
"PrefSecret": {fyne: "secret", viper: "hass.secret"},
"PrefHost": {fyne: "Host", viper: "hass.host"},
"PrefVersion": {fyne: "Version", viper: "agent.version"},
"PrefDeviceName": {fyne: "DeviceName", viper: "device.name"},
"PrefDeviceID": {fyne: "DeviceID", viper: "device.id"},
}

func viperToFyne(configPath string) error {
prefs := map[string]pref{
"PrefAPIURL": {fyne: "ApiURL", viper: "hass.apiurl"},
"PrefWebsocketURL": {fyne: "WebSocketURL", viper: "hass.websocketurl"},
"PrefCloudhookURL": {fyne: "CloudhookURL", viper: "hass.cloudhookurl"},
"PrefRemoteUIURL": {fyne: "RemoteUIURL", viper: "hass.remoteuiurl"},
"PrefToken": {fyne: "Token", viper: "hass.token"},
"PrefWebhookID": {fyne: "WebhookID", viper: "hass.webhookid"},
"PrefSecret": {fyne: "secret", viper: "hass.secret"},
"PrefHost": {fyne: "Host", viper: "hass.host"},
"PrefVersion": {fyne: "Version", viper: "agent.version"},
"PrefDeviceName": {fyne: "DeviceName", viper: "device.name"},
"PrefDeviceID": {fyne: "DeviceID", viper: "device.id"},
}
var err error
fs, err := os.Stat(filepath.Join(configPath, "go-hass-agent.toml"))
if fs != nil && err == nil {
Expand Down

0 comments on commit 8cbe821

Please sign in to comment.