-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure appsignals processor on EKS with cluster name (#980)
- Loading branch information
Showing
30 changed files
with
463 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package config | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/aws/amazon-cloudwatch-agent/plugins/processors/awsappsignals/rules" | ||
) | ||
|
||
type Config struct { | ||
Resolvers []Resolver `mapstructure:"resolvers"` | ||
Rules []rules.Rule `mapstructure:"rules"` | ||
} | ||
|
||
func (cfg *Config) Validate() error { | ||
if len(cfg.Resolvers) == 0 { | ||
return errors.New("resolvers must not be empty") | ||
} | ||
for _, resolver := range cfg.Resolvers { | ||
switch resolver.Platform { | ||
case PlatformEKS: | ||
if resolver.Name == "" { | ||
return errors.New("name must not be empty for eks resolver") | ||
} | ||
case PlatformGeneric: | ||
default: | ||
return errors.New("unknown resolver") | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidatePassed(t *testing.T) { | ||
config := Config{ | ||
Resolvers: []Resolver{NewEKSResolver("test"), NewGenericResolver("")}, | ||
Rules: nil, | ||
} | ||
assert.Nil(t, config.Validate()) | ||
} | ||
|
||
func TestValidateFailedOnEmptyResolver(t *testing.T) { | ||
config := Config{ | ||
Resolvers: []Resolver{}, | ||
Rules: nil, | ||
} | ||
assert.NotNil(t, config.Validate()) | ||
} | ||
|
||
func TestValidateFailedOnEmptyClusterName(t *testing.T) { | ||
config := Config{ | ||
Resolvers: []Resolver{NewEKSResolver("")}, | ||
Rules: nil, | ||
} | ||
assert.NotNil(t, config.Validate()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package config | ||
|
||
const ( | ||
// PlatformGeneric Platforms other than Amazon EKS | ||
PlatformGeneric = "generic" | ||
// PlatformEKS Amazon EKS platform | ||
PlatformEKS = "eks" | ||
) | ||
|
||
type Resolver struct { | ||
Name string `mapstructure:"name"` | ||
Platform string `mapstructure:"platform"` | ||
} | ||
|
||
func NewEKSResolver(name string) Resolver { | ||
return Resolver{ | ||
Name: name, | ||
Platform: PlatformEKS, | ||
} | ||
} | ||
|
||
func NewGenericResolver(name string) Resolver { | ||
return Resolver{ | ||
Name: name, | ||
Platform: PlatformGeneric, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewEKSResolver(t *testing.T) { | ||
resolver := NewEKSResolver("test") | ||
assert.Equal(t, "eks", resolver.Platform) | ||
} | ||
|
||
func TestNewGenericResolver(t *testing.T) { | ||
resolver := NewGenericResolver("") | ||
assert.Equal(t, "generic", resolver.Platform) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.