|
@@ -232,15 +232,16 @@ func validateProtocol(proto, propName string) (err error) {
|
|
|
}
|
|
|
|
|
|
func SaveAuthToken(configPath, authtoken string) (err error) {
|
|
|
+ // empty configuration by default for the case that we can't read it
|
|
|
+ c := new(Configuration)
|
|
|
+
|
|
|
// read the configuration
|
|
|
oldConfigBytes, err := ioutil.ReadFile(configPath)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- c := new(Configuration)
|
|
|
- if err = goyaml.Unmarshal(oldConfigBytes, c); err != nil {
|
|
|
- return
|
|
|
+ if err == nil {
|
|
|
+ // unmarshal if we successfully read the configuration file
|
|
|
+ if err = goyaml.Unmarshal(oldConfigBytes, c); err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// no need to save, the authtoken is already the correct value
|