From 3fd55c5ceede90b3d57bc1bde41bba5e5325e345 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Thu, 14 Jan 2021 17:09:31 -0500 Subject: [PATCH] tofu: Add KnownHosts.Load function --- tofu/tofu.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tofu/tofu.go b/tofu/tofu.go index 9954734..0fd7d26 100644 --- a/tofu/tofu.go +++ b/tofu/tofu.go @@ -67,6 +67,17 @@ func (k *KnownHosts) WriteTo(w io.Writer) (int64, error) { return int64(written), bw.Flush() } +// Load loads the known hosts entries from the provided path. +func (k *KnownHosts) Load(path string) error { + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + + return k.Parse(f) +} + // Parse parses the provided io.Reader and adds the parsed hosts to the list. // Invalid entries are ignored. //