From a4c675dd5015d13182ae46d93d3bfba441628e82 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Thu, 5 May 2016 14:19:54 -0500 Subject: [PATCH] Use internal.Duration for CacheTTL and go fmt --- internal/config/aws/credentials.go | 14 +++++++------- plugins/inputs/cloudwatch/cloudwatch.go | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/config/aws/credentials.go b/internal/config/aws/credentials.go index 5a89d8bff..c22e7fae9 100644 --- a/internal/config/aws/credentials.go +++ b/internal/config/aws/credentials.go @@ -9,13 +9,13 @@ import ( ) type AwsCredentials struct { - Region string `toml:"region"` // AWS Region - AccessKey string `toml:"access_key"` // Explicit AWS Access Key ID - SecretKey string `toml:"secret_key"` // Explicit AWS Secret Access Key - RoleArn string `toml:"role_arn"` // Role ARN to assume - Profile string `toml:"profile"` // the shared profile to use - SharedCredentialFile string `toml:"shared_credential_file"` // location of shared credential file - Token string `toml:"token"` // STS session token + Region string `toml:"region"` // AWS Region + AccessKey string `toml:"access_key"` // Explicit AWS Access Key ID + SecretKey string `toml:"secret_key"` // Explicit AWS Secret Access Key + RoleArn string `toml:"role_arn"` // Role ARN to assume + Profile string `toml:"profile"` // the shared profile to use + SharedCredentialFile string `toml:"shared_credential_file"` // location of shared credential file + Token string `toml:"token"` // STS session token } func (c *AwsCredentials) Credentials() client.ConfigProvider { diff --git a/plugins/inputs/cloudwatch/cloudwatch.go b/plugins/inputs/cloudwatch/cloudwatch.go index 8530ee656..9325b3987 100644 --- a/plugins/inputs/cloudwatch/cloudwatch.go +++ b/plugins/inputs/cloudwatch/cloudwatch.go @@ -22,7 +22,7 @@ type ( Delay internal.Duration `toml:"delay"` Namespace string `toml:"namespace"` Metrics []*Metric `toml:"metrics"` - CacheTTL string `toml:"cache_ttl"` + CacheTTL internal.Duration `toml:"cache_ttl"` client cloudwatchClient metricCache *MetricCache } @@ -135,7 +135,7 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error { for _, metric := range allMetrics { if isSelected(metric, m.Dimensions) { metrics = append(metrics, &cloudwatch.Metric{ - Namespace: aws.String(c.Namespace), + Namespace: aws.String(c.Namespace), MetricName: aws.String(name), Dimensions: metric.Dimensions, }) @@ -177,8 +177,9 @@ func (c *CloudWatch) Gather(acc telegraf.Accumulator) error { func init() { inputs.Add("cloudwatch", func() telegraf.Input { + ttl, _ := time.ParseDuration("1hr") return &CloudWatch{ - CacheTTL: "1hr", + CacheTTL: internal.Duration{Duration: ttl}, } }) } @@ -224,11 +225,10 @@ func (c *CloudWatch) fetchNamespaceMetrics() (metrics []*cloudwatch.Metric, err more = token != nil } - cacheTTL, _ := time.ParseDuration(c.CacheTTL) c.metricCache = &MetricCache{ Metrics: metrics, Fetched: time.Now(), - TTL: cacheTTL, + TTL: c.CacheTTL.Duration, } return