Update module github.com/kevinburke/ssh_config to v1.4.0

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2025-08-20 00:34:25 +00:00
committed by GitHub
parent bb18ae6ee3
commit 40cd207437
10 changed files with 73 additions and 27 deletions

2
go.mod
View File

@ -39,7 +39,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-multierror v1.1.1
github.com/hugelgupf/p9 v0.3.1-0.20250420164440-abc96d20b308 github.com/hugelgupf/p9 v0.3.1-0.20250420164440-abc96d20b308
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12
github.com/kevinburke/ssh_config v1.2.0 github.com/kevinburke/ssh_config v1.4.0
github.com/klauspost/pgzip v1.2.6 github.com/klauspost/pgzip v1.2.6
github.com/linuxkit/virtsock v0.0.0-20241009230534-cb6a20cc0422 github.com/linuxkit/virtsock v0.0.0-20241009230534-cb6a20cc0422
github.com/mattn/go-shellwords v1.0.12 github.com/mattn/go-shellwords v1.0.12

4
go.sum
View File

@ -246,8 +246,8 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.4.0 h1:6xxtP5bZ2E4NF5tuQulISpTO2z8XbtH8cg1PWkxoFkQ=
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kevinburke/ssh_config v1.4.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=

View File

@ -1 +0,0 @@
testdata/dos-lines eol=crlf

View File

@ -5,5 +5,6 @@ Kevin Burke <kevin@burke.dev>
Mark Nevill <nev@improbable.io> Mark Nevill <nev@improbable.io>
Scott Lessans <slessans@gmail.com> Scott Lessans <slessans@gmail.com>
Sergey Lukjanov <me@slukjanov.name> Sergey Lukjanov <me@slukjanov.name>
Simon Josefsson <simon@josefsson.org>
Wayne Ashley Berry <wayneashleyberry@gmail.com> Wayne Ashley Berry <wayneashleyberry@gmail.com>
santosh653 <70637961+santosh653@users.noreply.github.com> santosh653 <70637961+santosh653@users.noreply.github.com>

View File

@ -1,5 +1,18 @@
# Changes # Changes
## Version 1.4 (released August 2025)
- Remove .gitattributes file (which was used to test different line endings, and
caused issues in some build environments).
## Version 1.3 (released February 2025)
- Add go.mod file (although this project has no dependencies).
- Various updates to CI and build environment
- config: add UserSettings.ConfigFinder
## Version 1.2 ## Version 1.2
Previously, if a Host declaration or a value had trailing whitespace, that Previously, if a Host declaration or a value had trailing whitespace, that

View File

@ -1,19 +1,15 @@
BUMP_VERSION := $(GOPATH)/bin/bump_version BUMP_VERSION := $(GOPATH)/bin/bump_version
STATICCHECK := $(GOPATH)/bin/staticcheck
WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap
$(STATICCHECK): lint:
go get honnef.co/go/tools/cmd/staticcheck
lint: $(STATICCHECK)
go vet ./... go vet ./...
$(STATICCHECK) go run honnef.co/go/tools/cmd/staticcheck@latest ./...
test: lint test:
@# the timeout helps guard against infinite recursion @# the timeout helps guard against infinite recursion
go test -timeout=250ms ./... go test -timeout=250ms ./...
race-test: lint race-test:
go test -timeout=500ms -race ./... go test -timeout=500ms -race ./...
$(BUMP_VERSION): $(BUMP_VERSION):

View File

@ -82,11 +82,11 @@ file format.
[blog]: https://kev.inburke.com/kevin/more-comment-preserving-configuration-parsers/ [blog]: https://kev.inburke.com/kevin/more-comment-preserving-configuration-parsers/
[hostsfile]: https://github.com/kevinburke/hostsfile [hostsfile]: https://github.com/kevinburke/hostsfile
## Donating ## Sponsorships
I don't get paid to maintain this project. Donations free up time to make Thank you very much to Tailscale and Indeed for sponsoring development of this
improvements to the library, and respond to bug reports. You can send donations library. [Sponsors][sponsors] will get their names featured in the README.
via Paypal's "Send Money" feature to kev@inburke.com. Donations are not tax
deductible in the USA.
You can also reach out about a consulting engagement: https://burke.services You can also reach out about a consulting engagement: https://burke.services
[sponsors]: https://github.com/sponsors/kevinburke

View File

@ -8,7 +8,7 @@
// the host name to match on ("example.com"), and the second argument is the key // the host name to match on ("example.com"), and the second argument is the key
// you want to retrieve ("Port"). The keywords are case insensitive. // you want to retrieve ("Port"). The keywords are case insensitive.
// //
// port := ssh_config.Get("myhost", "Port") // port := ssh_config.Get("myhost", "Port")
// //
// You can also manipulate an SSH config file and then print it or write it back // You can also manipulate an SSH config file and then print it or write it back
// to disk. // to disk.
@ -43,7 +43,7 @@ import (
"sync" "sync"
) )
const version = "1.2" const version = "1.4.0"
var _ = version var _ = version
@ -53,6 +53,8 @@ type configFinder func() string
// files are parsed and cached the first time Get() or GetStrict() is called. // files are parsed and cached the first time Get() or GetStrict() is called.
type UserSettings struct { type UserSettings struct {
IgnoreErrors bool IgnoreErrors bool
customConfig *Config
customConfigFinder configFinder
systemConfig *Config systemConfig *Config
systemConfigFinder configFinder systemConfigFinder configFinder
userConfig *Config userConfig *Config
@ -203,6 +205,13 @@ func (u *UserSettings) GetStrict(alias, key string) (string, error) {
if u.onceErr != nil && u.IgnoreErrors == false { if u.onceErr != nil && u.IgnoreErrors == false {
return "", u.onceErr return "", u.onceErr
} }
// TODO this is getting repetitive
if u.customConfig != nil {
val, err := findVal(u.customConfig, alias, key)
if err != nil || val != "" {
return val, err
}
}
val, err := findVal(u.userConfig, alias, key) val, err := findVal(u.userConfig, alias, key)
if err != nil || val != "" { if err != nil || val != "" {
return val, err return val, err
@ -228,6 +237,12 @@ func (u *UserSettings) GetAllStrict(alias, key string) ([]string, error) {
if u.onceErr != nil && u.IgnoreErrors == false { if u.onceErr != nil && u.IgnoreErrors == false {
return nil, u.onceErr return nil, u.onceErr
} }
if u.customConfig != nil {
val, err := findAll(u.customConfig, alias, key)
if err != nil || val != nil {
return val, err
}
}
val, err := findAll(u.userConfig, alias, key) val, err := findAll(u.userConfig, alias, key)
if err != nil || val != nil { if err != nil || val != nil {
return val, err return val, err
@ -243,16 +258,38 @@ func (u *UserSettings) GetAllStrict(alias, key string) ([]string, error) {
return []string{}, nil return []string{}, nil
} }
// ConfigFinder will invoke f to try to find a ssh config file in a custom
// location on disk, instead of in /etc/ssh or $HOME/.ssh. f should return the
// name of a file containing SSH configuration.
//
// ConfigFinder must be invoked before any calls to Get or GetStrict and panics
// if f is nil. Most users should not need to use this function.
func (u *UserSettings) ConfigFinder(f func() string) {
if f == nil {
panic("cannot call ConfigFinder with nil function")
}
u.customConfigFinder = f
}
func (u *UserSettings) doLoadConfigs() { func (u *UserSettings) doLoadConfigs() {
u.loadConfigs.Do(func() { u.loadConfigs.Do(func() {
// can't parse user file, that's ok.
var filename string var filename string
var err error
if u.customConfigFinder != nil {
filename = u.customConfigFinder()
u.customConfig, err = parseFile(filename)
// IsNotExist should be returned because a user specified this
// function - not existing likely means they made an error
if err != nil {
u.onceErr = err
}
return
}
if u.userConfigFinder == nil { if u.userConfigFinder == nil {
filename = userConfigFinder() filename = userConfigFinder()
} else { } else {
filename = u.userConfigFinder() filename = u.userConfigFinder()
} }
var err error
u.userConfig, err = parseFile(filename) u.userConfig, err = parseFile(filename)
//lint:ignore S1002 I prefer it this way //lint:ignore S1002 I prefer it this way
if err != nil && os.IsNotExist(err) == false { if err != nil && os.IsNotExist(err) == false {

View File

@ -21,9 +21,9 @@ type sshParser struct {
type sshParserStateFn func() sshParserStateFn type sshParserStateFn func() sshParserStateFn
// Formats and panics an error message based on a token // Formats and panics an error message based on a token
func (p *sshParser) raiseErrorf(tok *token, msg string, args ...interface{}) { func (p *sshParser) raiseErrorf(tok *token, msg string) {
// TODO this format is ugly // TODO this format is ugly
panic(tok.Position.String() + ": " + fmt.Sprintf(msg, args...)) panic(tok.Position.String() + ": " + msg)
} }
func (p *sshParser) raiseError(tok *token, err error) { func (p *sshParser) raiseError(tok *token, err error) {
@ -118,7 +118,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
} }
pat, err := NewPattern(strPatterns[i]) pat, err := NewPattern(strPatterns[i])
if err != nil { if err != nil {
p.raiseErrorf(val, "Invalid host pattern: %v", err) p.raiseErrorf(val, fmt.Sprintf("Invalid host pattern: %v", err))
return nil return nil
} }
patterns = append(patterns, pat) patterns = append(patterns, pat)
@ -144,7 +144,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
return nil return nil
} }
if err != nil { if err != nil {
p.raiseErrorf(val, "Error parsing Include directive: %v", err) p.raiseErrorf(val, fmt.Sprintf("Error parsing Include directive: %v", err))
return nil return nil
} }
lastHost.Nodes = append(lastHost.Nodes, inc) lastHost.Nodes = append(lastHost.Nodes, inc)

4
vendor/modules.txt vendored
View File

@ -594,8 +594,8 @@ github.com/jinzhu/copier
# github.com/json-iterator/go v1.1.12 # github.com/json-iterator/go v1.1.12
## explicit; go 1.12 ## explicit; go 1.12
github.com/json-iterator/go github.com/json-iterator/go
# github.com/kevinburke/ssh_config v1.2.0 # github.com/kevinburke/ssh_config v1.4.0
## explicit ## explicit; go 1.18
github.com/kevinburke/ssh_config github.com/kevinburke/ssh_config
# github.com/klauspost/compress v1.18.0 # github.com/klauspost/compress v1.18.0
## explicit; go 1.22 ## explicit; go 1.22