Skip to content

Commit

Permalink
Exclude test flags from the public API
Browse files Browse the repository at this point in the history
  • Loading branch information
jtyr committed Mar 21, 2018
1 parent 83c6ad4 commit 2f2c5ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 8 additions & 6 deletions plugins/inputs/ssl_cert/ssl_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ type SSLCert struct {
Servers []string `toml:"servers"`
Files []string `toml:"files"`
Timeout time.Duration `toml:"timeout"`

// For tests
CloseConn bool
UnsetCerts bool
}

// For tests
var (
closeConn bool
unsetCerts bool
)

// Description returns description of the plugin.
func (sc *SSLCert) Description() string {
return description
Expand All @@ -45,7 +47,7 @@ func (sc *SSLCert) SampleConfig() string {
return sampleConfig
}

func getRemoteCert(server string, timeout time.Duration, closeConn bool, unsetCerts bool) (*x509.Certificate, error) {
func getRemoteCert(server string, timeout time.Duration) (*x509.Certificate, error) {
tlsCfg := &tls.Config{
InsecureSkipVerify: true,
}
Expand Down Expand Up @@ -121,7 +123,7 @@ func (sc *SSLCert) Gather(acc telegraf.Accumulator) error {
now := time.Now()

for _, server := range sc.Servers {
cert, err := getRemoteCert(server, sc.Timeout*time.Second, sc.CloseConn, sc.UnsetCerts)
cert, err := getRemoteCert(server, sc.Timeout*time.Second)
if err != nil {
return fmt.Errorf("cannot get remote SSL cert '%s': %s", server, err)
}
Expand Down
9 changes: 5 additions & 4 deletions plugins/inputs/ssl_cert/ssl_cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ func TestGatherRemote(t *testing.T) {
}

sc := SSLCert{
Servers: []string{test.server},
Timeout: test.timeout,
CloseConn: test.close,
UnsetCerts: test.unset,
Servers: []string{test.server},
Timeout: test.timeout,
}

closeConn = test.close
unsetCerts = test.unset

error := false

acc := testutil.Accumulator{}
Expand Down

0 comments on commit 2f2c5ff

Please sign in to comment.