func networkMapping()

in projects/aws/bottlerocket-bootstrap/pkg/providers/snow/system/network.go [97:128]


func networkMapping() ([]NetworkMapping, error) {
	dniList, err := dniList()
	if err != nil {
		return nil, errors.Wrap(err, "error getting DNI list")
	}

	network, err := parseNetworkFile()
	if err != nil {
		return nil, errors.Wrap(err, "error parsing network file")
	}

	if len(dniList) != network.DniCount {
		return nil, errors.Wrap(err, "the number of DNI found does not match the dniCount in the network file")
	}

	if len(network.Static) > 0 && len(network.Static) < network.DniCount {
		return nil, errors.Wrap(err, "mix of using DHCP and static IP is not supported")
	}

	m := make([]NetworkMapping, 0, network.DniCount)
	for i, dni := range dniList {
		n := NetworkMapping{
			DNI: dni,
		}
		if len(network.Static) > 0 {
			n.StaticIP = &network.Static[i]
		}
		m = append(m, n)
	}

	return m, nil
}