func()

in google_guest_agent/network/manager/netplan_linux.go [477:510]


func (n *netplan) SetupVlanInterface(ctx context.Context, config *cfg.Sections, nics *Interfaces) error {
	var reload1, reload2, reload3 bool
	var err error

	toRemove, err := n.findVlanDiff(nics)
	if err != nil {
		return fmt.Errorf("unable to detect vlan nics to delete: %w", err)
	}

	if toRemove != nil {
		reload1, err = n.rollbackVlanNics(ctx, toRemove)
		if err != nil {
			return fmt.Errorf("unable to remove vlan interfaces (%+v): %w", toRemove, err)
		}
	}

	reload2, err = n.writeNetplanVLANDropin(nics)
	if err != nil {
		return fmt.Errorf("unable to write netplan VLAN dropin: %w", err)
	}

	reload3, err = n.writeNetworkdVLANDropin(nics)
	if err != nil {
		return fmt.Errorf("unable to write netplan networkd VLAN dropin: %w", err)
	}

	if reload1 || reload2 || reload3 {
		if err = n.reloadConfigs(ctx); err != nil {
			return fmt.Errorf("error applying vlan interface configs: %w", err)
		}
	}

	return nil
}