tofu: Rename KnownHost to Host
This commit is contained in:
parent
95aff9c573
commit
4b8bb16a3d
94
tofu/tofu.go
94
tofu/tofu.go
@ -16,41 +16,41 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KnownHostsFile represents a list of known hosts optionally loaded from a file.
|
// HostsFile represents a list of known hosts optionally loaded from a file.
|
||||||
// The zero value for KnownHostsFile represents an empty list ready to use.
|
// The zero value for HostsFile represents an empty list ready to use.
|
||||||
//
|
//
|
||||||
// KnownHostsFile is safe for concurrent use by multiple goroutines.
|
// HostsFile is safe for concurrent use by multiple goroutines.
|
||||||
type KnownHostsFile struct {
|
type HostsFile struct {
|
||||||
hosts map[string]KnownHost
|
hosts map[string]Host
|
||||||
out *bufio.Writer
|
writer *bufio.Writer
|
||||||
closer io.Closer
|
closer io.Closer
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetOutput sets the output to which new known hosts will be written to.
|
// SetOutput sets the output to which new known hosts will be written to.
|
||||||
func (k *KnownHostsFile) SetOutput(w io.WriteCloser) error {
|
func (k *HostsFile) SetOutput(w io.WriteCloser) error {
|
||||||
k.mu.Lock()
|
k.mu.Lock()
|
||||||
defer k.mu.Unlock()
|
defer k.mu.Unlock()
|
||||||
|
|
||||||
if k.out != nil {
|
if k.writer != nil {
|
||||||
err := k.closer.Close()
|
err := k.closer.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to close previous output: %w", err)
|
return fmt.Errorf("failed to close previous output: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k.out = bufio.NewWriter(w)
|
k.writer = bufio.NewWriter(w)
|
||||||
k.closer = w
|
k.closer = w
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the output.
|
// Close closes the output.
|
||||||
func (k *KnownHostsFile) Close() error {
|
func (k *HostsFile) Close() error {
|
||||||
k.mu.Lock()
|
k.mu.Lock()
|
||||||
defer k.mu.Unlock()
|
defer k.mu.Unlock()
|
||||||
|
|
||||||
if k.out == nil {
|
if k.writer == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||