Skip to content

Commit

Permalink
sort arguments in CheckCommand (#364)
Browse files Browse the repository at this point in the history
* sorts arguments in CheckCommand

* fixed

* fixed
  • Loading branch information
Mir Shahriar authored and tamalsaha committed May 16, 2018
1 parent 2a7eda3 commit 0f28cab
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/examples/plugins/check-command/ca-cert.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ object CheckCommand "ca-cert" {
command = [ PluginDir + "/hyperalert", "check_ca_cert"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--warning" = "$warning$"
"--critical" = "$critical$"
"--icinga.checkInterval" = "$service.check_interval$"
"--v" = "$host.vars.verbosity$"
"--warning" = "$warning$"
}
}
10 changes: 5 additions & 5 deletions docs/examples/plugins/check-command/cert.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ object CheckCommand "cert" {
command = [ PluginDir + "/hyperalert", "check_cert"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--selector" = "$selector$"
"--secretName" = "$secretName$"
"--secretKey" = "$secretKey$"
"--warning" = "$warning$"
"--critical" = "$critical$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--secretKey" = "$secretKey$"
"--secretName" = "$secretName$"
"--selector" = "$selector$"
"--v" = "$host.vars.verbosity$"
"--warning" = "$warning$"
}
}
2 changes: 1 addition & 1 deletion docs/examples/plugins/check-command/component-status.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ object CheckCommand "component-status" {
command = [ PluginDir + "/hyperalert", "check_component_status"]

arguments = {
"--componentName" = "$componentName$"
"--icinga.checkInterval" = "$service.check_interval$"
"--selector" = "$selector$"
"--componentName" = "$componentName$"
"--v" = "$host.vars.verbosity$"
}
}
6 changes: 3 additions & 3 deletions docs/examples/plugins/check-command/event.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ object CheckCommand "event" {
command = [ PluginDir + "/hyperalert", "check_event"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--clockSkew" = "$clockSkew$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--involvedObjectKind" = "$involvedObjectKind$"
"--involvedObjectName" = "$involvedObjectName$"
"--involvedObjectNamespace" = "$involvedObjectNamespace$"
"--involvedObjectKind" = "$involvedObjectKind$"
"--involvedObjectUID" = "$involvedObjectUID$"
"--v" = "$host.vars.verbosity$"
"--host" = "$host.name$"
}
}
8 changes: 4 additions & 4 deletions docs/examples/plugins/check-command/json-path.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ object CheckCommand "json-path" {
command = [ PluginDir + "/hyperalert", "check_json_path"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--url" = "$url$"
"--secretName" = "$secretName$"
"--warning" = "$warning$"
"--critical" = "$critical$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--secretName" = "$secretName$"
"--url" = "$url$"
"--v" = "$host.vars.verbosity$"
"--warning" = "$warning$"
}
}
4 changes: 2 additions & 2 deletions docs/examples/plugins/check-command/node-exists.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ object CheckCommand "node-exists" {
command = [ PluginDir + "/hyperalert", "check_node_exists"]

arguments = {
"--count" = "$count$"
"--icinga.checkInterval" = "$service.check_interval$"
"--selector" = "$selector$"
"--nodeName" = "$nodeName$"
"--count" = "$count$"
"--selector" = "$selector$"
"--v" = "$host.vars.verbosity$"
}
}
2 changes: 1 addition & 1 deletion docs/examples/plugins/check-command/node-status.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ object CheckCommand "node-status" {
command = [ PluginDir + "/hyperalert", "check_node_status"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--v" = "$host.vars.verbosity$"
}
}
6 changes: 3 additions & 3 deletions docs/examples/plugins/check-command/node-volume.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ object CheckCommand "node-volume" {
command = [ PluginDir + "/hyperalert", "check_volume"]

arguments = {
"--critical" = "$critical$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--mountPoint" = "$mountPoint$"
"--secretName" = "$secretName$"
"--warning" = "$warning$"
"--critical" = "$critical$"
"--host" = "$host.name$"
"--v" = "$host.vars.verbosity$"
"--warning" = "$warning$"
}
}
6 changes: 3 additions & 3 deletions docs/examples/plugins/check-command/pod-exec.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ object CheckCommand "pod-exec" {
command = [ PluginDir + "/hyperalert", "check_pod_exec"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--argv" = "$argv$"
"--container" = "$container$"
"--cmd" = "$cmd$"
"--v" = "$host.vars.verbosity$"
"--container" = "$container$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--v" = "$host.vars.verbosity$"
}
}
4 changes: 2 additions & 2 deletions docs/examples/plugins/check-command/pod-exists.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ object CheckCommand "pod-exists" {
command = [ PluginDir + "/hyperalert", "check_pod_exists"]

arguments = {
"--count" = "$count$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--podName" = "$podName$"
"--count" = "$count$"
"--selector" = "$selector$"
"--host" = "$host.name$"
"--v" = "$host.vars.verbosity$"
}
}
2 changes: 1 addition & 1 deletion docs/examples/plugins/check-command/pod-status.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ object CheckCommand "pod-status" {
command = [ PluginDir + "/hyperalert", "check_pod_status"]

arguments = {
"--icinga.checkInterval" = "$service.check_interval$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--v" = "$host.vars.verbosity$"
}
}
8 changes: 4 additions & 4 deletions docs/examples/plugins/check-command/pod-volume.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ object CheckCommand "pod-volume" {
command = [ PluginDir + "/hyperalert", "check_volume"]

arguments = {
"--critical" = "$critical$"
"--host" = "$host.name$"
"--icinga.checkInterval" = "$service.check_interval$"
"--volumeName" = "$volumeName$"
"--secretName" = "$secretName$"
"--warning" = "$warning$"
"--critical" = "$critical$"
"--v" = "$host.vars.verbosity$"
"--host" = "$host.name$"
"--volumeName" = "$volumeName$"
"--warning" = "$warning$"
}
}
5 changes: 5 additions & 0 deletions pkg/plugin/check_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package plugin

import (
"fmt"
"sort"
"strings"

api "github.com/appscode/searchlight/apis/monitoring/v1alpha1"
Expand Down Expand Up @@ -58,6 +59,10 @@ func GenerateCheckCommand(plugin *api.SearchlightPlugin) string {
})
}

sort.Slice(args, func(i, j int) bool {
return args[i].key < args[j].key
})

flagList := make([]string, 0)

if webhook == nil {
Expand Down

0 comments on commit 0f28cab

Please sign in to comment.