Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
crosbymichael committed Feb 10, 2016
1 parent a16f671 commit f190f0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
log "github.com/Sirupsen/logrus"
)

type SshConfigFileSection struct {
type SSHConfigFileSection struct {
Host string
ForwardAgent string
User string
HostName string
Port string
}

// parseSshConfigFileSection parses a section from the ~/.ssh/config file
func parseSshConfigFileSection(content string) *SshConfigFileSection {
section := &SshConfigFileSection{}
// parseSSHConfigFileSection parses a section from the ~/.ssh/config file
func parseSSHConfigFileSection(content string) *SSHConfigFileSection {
section := &SSHConfigFileSection{}

for n, line := range strings.Split(content, "\n") {
line = strings.TrimSpace(line)
Expand All @@ -42,10 +42,10 @@ func parseSshConfigFileSection(content string) *SshConfigFileSection {
return section
}

// parseSshConfigFile parses the ~/.ssh/config file and build a list of section
func parseSshConfigFile(path string) (map[string]*SshConfigFileSection, error) {
// parseSSHConfigFile parses the ~/.ssh/config file and build a list of section
func parseSSHConfigFile(path string) (map[string]*SSHConfigFileSection, error) {

sections := make(map[string]*SshConfigFileSection)
sections := make(map[string]*SSHConfigFileSection)

log.Debugf("parsing ssh config file: %s", path)
content, err := ioutil.ReadFile(path)
Expand All @@ -63,7 +63,7 @@ func parseSshConfigFile(path string) (map[string]*SshConfigFileSection, error) {
continue
}

section := parseSshConfigFileSection(split)
section := parseSSHConfigFileSection(split)
sections[section.Host] = section
}

Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func multiplexAction(context *cli.Context) {
log.Fatal(err)
}

sections, err := parseSshConfigFile(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
sections, err := parseSSHConfigFile(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
if err != nil {
log.Fatal(err)
}
Expand All @@ -74,7 +74,7 @@ func multiplexAction(context *cli.Context) {
log.Debugf("finished executing %s on all hosts", c)
}

func executeCommand(c command, host string, section *SshConfigFileSection, agentForwarding, quiet bool, group *sync.WaitGroup) {
func executeCommand(c command, host string, section *SSHConfigFileSection, agentForwarding, quiet bool, group *sync.WaitGroup) {
defer group.Done()
var (
err error
Expand All @@ -92,8 +92,8 @@ func executeCommand(c command, host string, section *SshConfigFileSection, agent
}

// runSSH executes the given command on the given host
func runSSH(c command, host string, section *SshConfigFileSection, agentForwarding, quiet bool) error {
config, err := newSshClientConfig(host, section, c.User, c.Identity, agentForwarding)
func runSSH(c command, host string, section *SSHConfigFileSection, agentForwarding, quiet bool) error {
config, err := newSSHClientConfig(host, section, c.User, c.Identity, agentForwarding)
if err != nil {
return err
}
Expand Down
22 changes: 11 additions & 11 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ type sshClientConfig struct {
*ssh.ClientConfig
}

// updateFromSshConfigFile updates the host, username and agentforwarding parameters
// updateFromSSHConfigFile updates the host, username and agentforwarding parameters
// from the ~/.ssh/config if there is a matching section
func updateFromSshConfigFile(section *SshConfigFileSection, host, userName *string, agentForwarding *bool) {
func updateFromSSHConfigFile(section *SSHConfigFileSection, host, userName *string, agentForwarding *bool) {
hostName, port, err := net.SplitHostPort(*host)
if err != nil {
return
Expand All @@ -63,22 +63,22 @@ func updateFromSshConfigFile(section *SshConfigFileSection, host, userName *stri
*host = net.JoinHostPort(hostName, port)
}

// newSshClientConfig initializes the ssh configuration.
// newSSHClientConfig initializes the ssh configuration.
// It connects with the ssh agent when agent forwarding is enabled.
func newSshClientConfig(host string, section *SshConfigFileSection, userName, identity string, agentForwarding bool) (*sshClientConfig, error) {
func newSSHClientConfig(host string, section *SSHConfigFileSection, userName, identity string, agentForwarding bool) (*sshClientConfig, error) {
var (
config *sshClientConfig
err error
)

if section != nil {
updateFromSshConfigFile(section, &host, &userName, &agentForwarding)
updateFromSSHConfigFile(section, &host, &userName, &agentForwarding)
}

if agentForwarding {
config, err = newSshAgentConfig(userName)
config, err = newSSHAgentConfig(userName)
} else {
config, err = newSshDefaultConfig(userName, identity)
config, err = newSSHDefaultConfig(userName, identity)
}

if config != nil {
Expand All @@ -87,8 +87,8 @@ func newSshClientConfig(host string, section *SshConfigFileSection, userName, id
return config, err
}

// newSshAgentConfig initializes the configuration to talk with an ssh agent.
func newSshAgentConfig(userName string) (*sshClientConfig, error) {
// newSSHAgentConfig initializes the configuration to talk with an ssh agent.
func newSSHAgentConfig(userName string) (*sshClientConfig, error) {
agent, err := newAgent()
if err != nil {
return nil, err
Expand All @@ -105,8 +105,8 @@ func newSshAgentConfig(userName string) (*sshClientConfig, error) {
}, nil
}

// newSshDefaultConfig initializes the configuration to use an ideitity file.
func newSshDefaultConfig(userName, identity string) (*sshClientConfig, error) {
// newSSHDefaultConfig initializes the configuration to use an ideitity file.
func newSSHDefaultConfig(userName, identity string) (*sshClientConfig, error) {
config, err := sshDefaultConfig(userName, identity)
if err != nil {
return nil, err
Expand Down

0 comments on commit f190f0f

Please sign in to comment.