package cli

import (
	"strings"

	"banger/internal/guest"
	"banger/internal/model"
)

func removeUserKnownHosts(vm model.VMRecord) error {
	knownHostsPath, err := bangerKnownHostsPath()
	if err != nil {
		return err
	}
	var hosts []string
	if ip := strings.TrimSpace(vm.Runtime.GuestIP); ip != "" {
		hosts = append(hosts, ip)
	}
	if dns := strings.TrimSpace(vm.Runtime.DNSName); dns != "" {
		hosts = append(hosts, dns)
	}
	if len(hosts) == 0 {
		return nil
	}
	return guest.RemoveKnownHosts(knownHostsPath, hosts...)
}
