Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gracewehner committed Jan 27, 2021
1 parent 49336fa commit 79e0e71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions plugins/inputs/prometheus/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (p *Prometheus) watch(ctx context.Context, client *k8s.Client) error {

func (p *Prometheus) cAdvisor(ctx context.Context, client *k8s.Client) error {
p.Log.Infof("Using monitor pods version 2 to get pod list using cAdvisor.")

nodeIP := os.Getenv("NODE_IP")
if nodeIP == "" {
return errors.New("The environment variable NODE_IP is not set. Cannot get pod list for monitor_kubernetes_pods using version 2.")
Expand Down Expand Up @@ -204,7 +204,7 @@ func (p *Prometheus) cAdvisor(ctx context.Context, client *k8s.Client) error {
}

func updateCadvisorPodList(ctx context.Context, p *Prometheus, client *k8s.Client, req *http.Request,
labelSelector labels.Selector, fieldSelector fields.Selector) error {
labelSelector labels.Selector, fieldSelector fields.Selector) error {

resp, err := client.Client.Do(req)
if err != nil {
Expand Down Expand Up @@ -232,7 +232,7 @@ func updateCadvisorPodList(ctx context.Context, p *Prometheus, client *k8s.Clien
podHasMatchingNamespace(pod, p) &&
podHasMatchingLabelSelector(pod, labelSelector) &&
podHasMatchingFieldSelector(pod, fieldSelector) {
registerPod(pod, p)
registerPod(pod, p)
}

}
Expand All @@ -243,14 +243,14 @@ func updateCadvisorPodList(ctx context.Context, p *Prometheus, client *k8s.Clien
}

func fieldSelectorIsSupported(fieldSelector fields.Selector) bool {
supportedFieldsToSelect := map[string]bool {
"spec.nodeName" : true,
"spec.restartPolicy" : true,
"spec.schedulerName" : true,
"spec.serviceAccountName" : true,
"status.phase" : true,
"status.podIP" : true,
"status.nominatedNodeName" : true,
supportedFieldsToSelect := map[string]bool{
"spec.nodeName": true,
"spec.restartPolicy": true,
"spec.schedulerName": true,
"spec.serviceAccountName": true,
"status.phase": true,
"status.podIP": true,
"status.nominatedNodeName": true,
}

for _, requirement := range fieldSelector.Requirements() {
Expand Down Expand Up @@ -289,7 +289,7 @@ func podHasMatchingFieldSelector(pod *corev1.Pod, fieldSelector fields.Selector)

// Spec and Status shouldn't be nil.
// Error handling just in case something goes wrong but won't crash telegraf
if (podSpec == nil || podStatus == nil) {
if podSpec == nil || podStatus == nil {
return false
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/prometheus/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

v1 "github.com/ericchiang/k8s/apis/core/v1"
metav1 "github.com/ericchiang/k8s/apis/meta/v1"

"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
)
Expand Down

0 comments on commit 79e0e71

Please sign in to comment.