LoadFromReader reads the configuration data given and sets up the auth config information with given directory and populates the receiver object
(configData io.Reader)
| 125 | // LoadFromReader reads the configuration data given and sets up the auth config |
| 126 | // information with given directory and populates the receiver object |
| 127 | func (c *ConfigFile) LoadFromReader(configData io.Reader) error { |
| 128 | if err := json.NewDecoder(configData).Decode(c); err != nil && !errors.Is(err, io.EOF) { |
| 129 | return err |
| 130 | } |
| 131 | var err error |
| 132 | for addr, ac := range c.AuthConfigs { |
| 133 | if ac.Auth != "" { |
| 134 | ac.Username, ac.Password, err = decodeAuth(ac.Auth) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | } |
| 139 | ac.Auth = "" |
| 140 | ac.ServerAddress = addr |
| 141 | c.AuthConfigs[addr] = ac |
| 142 | } |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // ContainsAuth returns whether there is authentication configured |
| 147 | // in this file or not. |