Skip to content

Commit

Permalink
Feature/gometalinter (#71)
Browse files Browse the repository at this point in the history
* non contentious changes

* minor code changes, should be zero impact
  • Loading branch information
damianoneill authored and nemith committed Sep 1, 2018
1 parent ecb6058 commit 4d8ffce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
13 changes: 9 additions & 4 deletions examples/juniper/get_system_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
agent = flag.Bool("agent", false, "Use SSH agent for public key authentication")
)

// SystemInformation provides a representation of the system-information container
type SystemInformation struct {
HardwareModel string `xml:"system-information>hardware-model"`
OsName string `xml:"system-information>os-name"`
Expand All @@ -38,10 +39,11 @@ type SystemInformation struct {
HostName string `xml:"system-information>host-name"`
}

// BuildConfig captures information from the console to build a SSH Client Config
func BuildConfig() *ssh.ClientConfig {
var config *ssh.ClientConfig
var pass string
if *pubkey == true {
if *pubkey {
if *agent {
var err error
config, err = netconf.SSHConfigPubKeyAgent(*username)
Expand All @@ -58,7 +60,7 @@ func BuildConfig() *ssh.ClientConfig {
var readpass []byte
var err error
fmt.Printf("Enter Passphrase for %s: ", *key)
readpass, err = terminal.ReadPassword(int(syscall.Stdin))
readpass, err = terminal.ReadPassword(syscall.Stdin)
if err != nil {
log.Fatal(err)
}
Expand All @@ -74,7 +76,7 @@ func BuildConfig() *ssh.ClientConfig {
}
} else {
fmt.Printf("Enter Password: ")
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
bytePassword, err := terminal.ReadPassword(syscall.Stdin)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -109,7 +111,10 @@ func main() {
}
var q SystemInformation

xml.Unmarshal([]byte(reply.RawReply), &q)
err = xml.Unmarshal([]byte(reply.RawReply), &q)
if err != nil {
log.Fatal(err)
}
fmt.Printf("hostname: %s\n", q.HostName)
fmt.Printf("model: %s\n", q.HardwareModel)
fmt.Printf("version: %s\n", q.OsVersion)
Expand Down
2 changes: 1 addition & 1 deletion netconf/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestUUIDChar(t *testing.T) {
u := uuid()

for _, v := range u {
if valid(int(v)) == false {
if !valid(int(v)) {
t.Errorf("invalid char %s", string(v))

}
Expand Down
2 changes: 1 addition & 1 deletion netconf/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// license that can be found in the LICENSE file.

/*
This library is a simple NETCONF client based on RFC6241 and RFC6242
Package netconf provides support for a a simple NETCONF client based on RFC6241 and RFC6242
(although not fully compliant yet).
*/
package netconf
Expand Down
3 changes: 1 addition & 2 deletions netconf/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type Transport interface {

type transportBasicIO struct {
io.ReadWriteCloser
chunkedFraming bool
}

// Sends a well formated NETCONF rpc message as a slice of bytes adding on the
Expand Down Expand Up @@ -83,7 +82,7 @@ func (t *transportBasicIO) ReceiveHello() (*HelloMessage, error) {
return hello, err
}

err = xml.Unmarshal([]byte(val), hello)
err = xml.Unmarshal(val, hello)
return hello, err
}

Expand Down
9 changes: 2 additions & 7 deletions netconf/transport_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ func (t *TransportSSH) Dial(target string, config *ssh.ClientConfig) error {
}

err = t.setupSession()
if err != nil {
return err
}

return nil
return err
}

func (t *TransportSSH) setupSession() error {
Expand Down Expand Up @@ -177,8 +173,7 @@ func SSHConfigPubKeyFile(user string, file string, passphrase string) (*ssh.Clie
}

if x509.IsEncryptedPEMBlock(block) {
b := block.Bytes
b, err = x509.DecryptPEMBlock(block, []byte(passphrase))
b, err := x509.DecryptPEMBlock(block, []byte(passphrase))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4d8ffce

Please sign in to comment.