fix: validate IP address returned as HTTP response in platform code

If provider returns empty response, it is parsed as `nil` IP address and
included in the response which leads to `<nil>` entries in the machine
configuration after applying dynamic config.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
Andrey Smirnov 2021-08-26 00:03:12 +03:00
parent c9af8f7ff1
commit 80b5f0e7f7
No known key found for this signature in database
GPG Key ID: 7B26396447AB6DFD
3 changed files with 9 additions and 3 deletions

View File

@ -202,7 +202,9 @@ func (a *AWS) ExternalIPs(ctx context.Context) (addrs []net.IP, err error) {
return return
} }
addrs = append(addrs, net.ParseIP(string(body))) if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}
return addrs, err return addrs, err
} }

View File

@ -99,7 +99,9 @@ func (d *DigitalOcean) ExternalIPs(ctx context.Context) (addrs []net.IP, err err
return return
} }
addrs = append(addrs, net.ParseIP(string(body))) if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}
return addrs, err return addrs, err
} }

View File

@ -101,7 +101,9 @@ func (a *Openstack) ExternalIPs(ctx context.Context) (addrs []net.IP, err error)
return return
} }
addrs = append(addrs, net.ParseIP(string(body))) if addr := net.ParseIP(string(body)); addr != nil {
addrs = append(addrs, addr)
}
return addrs, err return addrs, err
} }