/
instanceutil.go
41 lines (35 loc) · 1.1 KB
/
instanceutil.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT
package util
import (
"fmt"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/metrics/config"
)
const Resource_Key = "resources"
const Asterisk_Key = "*"
const Mapped_Instance_Key_Windows = "Instances"
const Disabled_Instance_Val_Windows = "------"
// If the input map contain instance_key, but the vale is not a string list
// A panic will be thrown
func ContainAsterisk(input interface{}, fieldKey string) bool {
if val, ok := input.(map[string]interface{}); ok {
if instanceValue, ok := val[fieldKey]; ok {
return checkListContainsAsterisk(instanceValue.([]interface{}))
}
} else {
fmt.Printf("Invalid input type, ignore field")
}
return false
}
// This method is checking string type only
func checkListContainsAsterisk(inputList []interface{}) bool {
for _, resource := range inputList {
if resource.(string) == Asterisk_Key {
return true
}
}
return false
}
func InstanceDisabled(pluginName string) bool {
return ListContains(config.Instances_disabled_plugins, pluginName)
}