Skip to content

Commit

Permalink
fix: hcloud network config changes
Browse files Browse the repository at this point in the history
The format of network config has changed.
Now it similar nocloud.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
(cherry picked from commit 97d64d1)
  • Loading branch information
sergelogvinov authored and Unix4ever committed Nov 2, 2021
1 parent 7cb9813 commit 2226a99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
Expand Up @@ -90,6 +90,10 @@ func (h *Hcloud) ConfigurationNetwork(metadataNetworkConfig []byte, confProvider
}

for _, network := range unmarshalledNetworkConfig.Config {
if network.Type != "physical" {
continue
}

iface := v1alpha1.Device{
DeviceInterface: network.Interfaces,
DeviceDHCP: false,
Expand Down Expand Up @@ -184,12 +188,14 @@ func (h *Hcloud) ExternalIPs(ctx context.Context) (addrs []net.IP, err error) {
download.WithErrorOnNotFound(errors.ErrNoExternalIPs),
download.WithErrorOnEmptyResponse(errors.ErrNoExternalIPs))
if err != nil {
return addrs, err
return nil, err
}

addrs = append(addrs, net.ParseIP(string(exIP)))
if ip := net.ParseIP(string(exIP)); ip != nil {
addrs = append(addrs, ip)
}

return addrs, err
return addrs, nil
}

// KernelArgs implements the runtime.Platform interface.
Expand Down
Expand Up @@ -23,17 +23,18 @@ config:
- mac_address: 96:00:00:1:2:3
name: eth0
subnets:
- dns_nameservers:
- 213.133.100.100
- 213.133.99.99
- 213.133.98.98
ipv4: true
- ipv4: true
type: dhcp
- address: 2a01:4f8:1:2::1/64
gateway: fe80::1
ipv6: true
type: static
type: physical
- address:
- 185.12.64.2
- 185.12.64.1
interface: eth0
type: nameserver
version: 1
`)
p := &hcloud.Hcloud{}
Expand Down Expand Up @@ -70,21 +71,3 @@ version: 1
func TestConfigSuite(t *testing.T) {
suite.Run(t, new(ConfigSuite))
}

// http://169.254.169.254/hetzner/v1/metadata/network-config
// config:
// - mac_address: 96:00:00:72:a3:19
// name: eth0
// subnets:
// - dns_nameservers:
// - 213.133.100.100
// - 213.133.99.99
// - 213.133.98.98
// ipv4: true
// type: dhcp
// - address: 2a01:4f8:1:2::1/64
// gateway: fe80::1
// ipv6: true
// type: static
// type: physical
// version: 1

0 comments on commit 2226a99

Please sign in to comment.