diff options
| author | Shulhan <ms@kilabit.info> | 2023-08-08 00:22:57 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-08-08 00:22:57 +0700 |
| commit | 7f3201843a65693de3c7bfbea129867088abcfca (patch) | |
| tree | b7fecf334f6352b68c09165b3a587404e554f856 /lib/ssh | |
| parent | 9fcf5f502961256fae928eccb0bc6fcb8a606fa0 (diff) | |
| download | pakakeh.go-7f3201843a65693de3c7bfbea129867088abcfca.tar.xz | |
ssh/config: export the function to create new Section
The NewSection function are required to test NewClientInteractive later.
Diffstat (limited to 'lib/ssh')
| -rw-r--r-- | lib/ssh/config/config.go | 2 | ||||
| -rw-r--r-- | lib/ssh/config/config_test.go | 2 | ||||
| -rw-r--r-- | lib/ssh/config/section.go | 6 | ||||
| -rw-r--r-- | lib/ssh/config/section_match.go | 2 | ||||
| -rw-r--r-- | lib/ssh/config/section_test.go | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/lib/ssh/config/config.go b/lib/ssh/config/config.go index c95c45be..f8c92ea8 100644 --- a/lib/ssh/config/config.go +++ b/lib/ssh/config/config.go @@ -117,7 +117,7 @@ func Load(file string) (cfg *Config, err error) { // If no Host or Match found, it still return non-nil Section but with empty // fields. func (cfg *Config) Get(s string) (section *Section) { - section = newSection(s) + section = NewSection(s) for _, hostMatch := range cfg.sections { if hostMatch.isMatch(s) { section.mergeField(hostMatch) diff --git a/lib/ssh/config/config_test.go b/lib/ssh/config/config_test.go index 60882ed8..51f4c032 100644 --- a/lib/ssh/config/config_test.go +++ b/lib/ssh/config/config_test.go @@ -14,7 +14,7 @@ import ( ) var ( - testDefaultSection = newSection(``) + testDefaultSection = NewSection(``) testParser *parser ) diff --git a/lib/ssh/config/section.go b/lib/ssh/config/section.go index 7d81a2d2..99075cd9 100644 --- a/lib/ssh/config/section.go +++ b/lib/ssh/config/section.go @@ -225,8 +225,8 @@ type Section struct { useCriteria bool } -// newSection create new Host or Match with default values. -func newSection(name string) *Section { +// NewSection create new Host or Match with default values. +func NewSection(name string) *Section { return &Section{ Field: map[string]string{ KeyChallengeResponseAuthentication: ValueYes, @@ -243,7 +243,7 @@ func newSection(name string) *Section { func newSectionHost(rawPattern string) (host *Section) { patterns := strings.Fields(rawPattern) - host = newSection(rawPattern) + host = NewSection(rawPattern) host.patterns = make([]*pattern, 0, len(patterns)) for _, pattern := range patterns { diff --git a/lib/ssh/config/section_match.go b/lib/ssh/config/section_match.go index 700e6f60..c9d1eeee 100644 --- a/lib/ssh/config/section_match.go +++ b/lib/ssh/config/section_match.go @@ -29,7 +29,7 @@ func newSectionMatch(rawPattern string) (match *Section, err error) { criteria *matchCriteria ) - match = newSection(rawPattern) + match = NewSection(rawPattern) match.criteria = make([]*matchCriteria, 0) match.useCriteria = true diff --git a/lib/ssh/config/section_test.go b/lib/ssh/config/section_test.go index 72c02af6..a5c9c5b8 100644 --- a/lib/ssh/config/section_test.go +++ b/lib/ssh/config/section_test.go @@ -167,7 +167,7 @@ func TestSection_UserKnownHostsFile(t *testing.T) { }} var ( - section = newSection(`test`) + section = NewSection(`test`) c testCase err error |
