chore: OpenVPN user and password as nullable

- Username and password can be the empty string for custom provider
This commit is contained in:
Quentin McGaw
2022-08-13 16:44:38 +00:00
parent 8e101d49a1
commit 1ab74e6bb3
9 changed files with 50 additions and 46 deletions

View File

@@ -72,14 +72,25 @@ func (r *Reader) readOpenVPN() (
return openVPN, nil
}
func (r *Reader) readOpenVPNUser() (user string) {
_, user = r.getEnvWithRetro("OPENVPN_USER", "USER")
func (r *Reader) readOpenVPNUser() (user *string) {
user = new(string)
_, *user = r.getEnvWithRetro("OPENVPN_USER", "USER")
if *user == "" {
return nil
}
// Remove spaces in user ID to simplify user's life, thanks @JeordyR
return strings.ReplaceAll(user, " ", "")
*user = strings.ReplaceAll(*user, " ", "")
return user
}
func (r *Reader) readOpenVPNPassword() (password string) {
_, password = r.getEnvWithRetro("OPENVPN_PASSWORD", "PASSWORD")
func (r *Reader) readOpenVPNPassword() (password *string) {
password = new(string)
_, *password = r.getEnvWithRetro("OPENVPN_PASSWORD", "PASSWORD")
if *password == "" {
return nil
}
return password
}