Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions internal/common/config/icinga2Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ func GenerateIcinga2Config(cmd *cobra.Command, commandName, executableName strin

ccaFlags = make([]icingadsl.CheckCommandArgument, 0)

flags.VisitAll(func(foo *pflag.Flag) {
_ = GenerateIcinga2CheckCommandArgument(foo, &ccaFlags)
flags.VisitAll(func(flag *pflag.Flag) {
if flag.Name != "help" && flag.Name != "debug" {
_ = GenerateIcinga2CheckCommandArgument(flag, &ccaFlags)
}
})

parentArgs := make([]icingadsl.CheckCommandArgument, len(ccaFlags))
Expand All @@ -41,6 +43,11 @@ func GenerateIcinga2Config(cmd *cobra.Command, commandName, executableName strin
checkCommands = append(checkCommands, parentDefinition)

for _, command := range cmd.Commands() {
// Ignore the magical cobra command "no-help"
if command.Name() == "no-help" {
continue
}

ccaFlags = make([]icingadsl.CheckCommandArgument, 0)

// This triggers a side effect to get inherited flags
Expand All @@ -49,7 +56,9 @@ func GenerateIcinga2Config(cmd *cobra.Command, commandName, executableName strin

scFlags := command.Flags()
scFlags.VisitAll(func(foo *pflag.Flag) {
_ = GenerateIcinga2CheckCommandArgument(foo, &ccaFlags)
if foo.Name != "help" && foo.Name != "debug" {
_ = GenerateIcinga2CheckCommandArgument(foo, &ccaFlags)
}
})

cc := icingadsl.CheckCommand{}
Expand Down
Loading