Documentation ¶
Overview ¶
Copyright © 2020 Joseph Saylor <doug@saylorsolutions.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Joseph Saylor <doug@saylorsolutions.com>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func DefaultSSHKeyPath() string
- func LoadKey(path string) (ssh.AuthMethod, error)
- func NewSpecTemplate(config *SpecTemplateConfig) (string, error)
- type ClientFilePair
- type ConfigFileData
- type ConsolidatedWriter
- type HostSpec
- type KeySpec
- type SpecData
- type SpecTemplateConfig
- type TailChannelWriter
- type TailSession
Constants ¶
const DEFAULT_SSH_PORT int = 22
Variables ¶
This section is empty.
Functions ¶
func DefaultSSHKeyPath ¶
func DefaultSSHKeyPath() string
DefaultSSHKeyPath returns the config specified value or the default path of ~/.ssh/id_rsa
func NewSpecTemplate ¶
func NewSpecTemplate(config *SpecTemplateConfig) (string, error)
NewSpecTemplate creates a new spec template with the given configuration parameters.
Types ¶
type ClientFilePair ¶
ClientFilePair associates a Client connection with a host tag and file
type ConfigFileData ¶
type ConfigFileData struct {
DefaultKey KeySpec `json:"defaultKey" yaml:"defaultKey"`
}
ConfigFileData is the format for the home config file.
func ConfigFile ¶
func ConfigFile() (*ConfigFileData, error)
ConfigFile reads the default config from the active user's home directory.
type ConsolidatedWriter ¶
type ConsolidatedWriter struct {
// contains filtered or unexported fields
}
ConsolidatedWriter receives messages from all of its tail session instances and writes them to its output stream.
func NewConsolidatedWriter ¶
func NewConsolidatedWriter(specData *SpecData, out *os.File) (*ConsolidatedWriter, error)
NewConsolidatedWriter creates tail sessions that are ready to start and write to the provided writer.
func (*ConsolidatedWriter) AddOutputFile ¶
func (c *ConsolidatedWriter) AddOutputFile(file *os.File) error
AddOutputFile adds a file to the list of files that should have output appended to them.
func (*ConsolidatedWriter) Close ¶
func (c *ConsolidatedWriter) Close() error
Close closes all tail sessions as well as the connected clients.
func (*ConsolidatedWriter) Start ¶
func (c *ConsolidatedWriter) Start() error
Start starts all tail sessions. In the event of an error, all already opened sessions are closed and an error is returned.
type HostSpec ¶
type HostSpec struct { Hostname string `json:"hostname" yaml:"hostname"` Username string `json:"username" yaml:"username"` File string `json:"file" yaml:"file"` Port int `json:"port" yaml:"port"` }
HostSpec identifies the hostname and port to connect to, as well as the file to tail.
type KeySpec ¶
type KeySpec struct {
Path string `json:"path" yaml:"path"`
}
KeySpec specifies the path to the SSH key to be used for the host named by the SpecData.Keys map key.
type SpecData ¶
type SpecData struct { Hosts map[string]*HostSpec `json:"hosts" yaml:"hosts"` Keys map[string]*KeySpec `json:"keys" yaml:"keys"` }
SpecData encapsulates runtime parameters for SSH tailing.
func ReadSpecFile ¶
ReadSpecFile attempts to read SpecData from the specified file.
type SpecTemplateConfig ¶
SpecTemplateConfig config
type TailChannelWriter ¶
type TailChannelWriter struct {
// contains filtered or unexported fields
}
type TailSession ¶
type TailSession struct {
// contains filtered or unexported fields
}
TailSession represents
func NewTailSession ¶
func NewTailSession(client *ClientFilePair) (ts *TailSession, err error)
NewTailSession creates a new TailSession instance that is ready to be started.
func (*TailSession) Close ¶
func (s *TailSession) Close() (err error)
Close stops the running tail session and disconnects the client.
func (*TailSession) Closed ¶
func (s *TailSession) Closed() bool
Closed returns whether the tail session has been previously closed. A closed tail session cannot be restarted.
func (*TailSession) Started ¶
func (s *TailSession) Started() bool
Started returns whether the tail session has already been started.