Skip to content
Draft
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions cmd/humioctl/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,37 @@
package main

import (
"github.com/humio/cli/internal/api"
"github.com/spf13/cobra"
)

// getActionLabels extracts labels from an action based on its type
func getActionLabels(action api.Action) []string {
switch action.Type {
case "EmailAction":
return action.EmailAction.Labels
case "HumioRepoAction":
return action.HumioRepoAction.Labels
case "OpsGenieAction":
return action.OpsGenieAction.Labels
case "PagerDutyAction":
return action.PagerDutyAction.Labels
case "SlackAction":
return action.SlackAction.Labels
case "SlackPostMessageAction":
return action.SlackPostMessageAction.Labels
case "VictorOpsAction":
return action.VictorOpsAction.Labels
case "UploadFileAction":
return action.UploadFileAction.Labels
case "WebhookAction":
return action.WebhookAction.Labels
case "S3Action":
return action.S3Action.Labels
}
return nil
}

func newActionsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "actions",
Expand Down
11 changes: 9 additions & 2 deletions cmd/humioctl/actions_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package main

import (
"strings"

"github.com/humio/cli/internal/format"
"github.com/spf13/cobra"
)
Expand All @@ -34,10 +36,15 @@ func newActionsListCmd() *cobra.Command {
var rows [][]format.Value
for i := 0; i < len(actions); i++ {
action := actions[i]
rows = append(rows, []format.Value{format.String(action.Name), format.String(action.Type)})

rows = append(rows, []format.Value{
format.String(action.Name),
format.String(action.Type),
format.String(strings.Join(action.GetLabels(), ",")),
})
}

printOverviewTable(cmd, []string{"Name", "Type"}, rows)
printOverviewTable(cmd, []string{"Name", "Type", "Labels"}, rows)
},
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/humioctl/actions_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package main

import (
"strings"

"github.com/humio/cli/internal/format"
"github.com/spf13/cobra"
)
Expand All @@ -36,6 +38,7 @@ func newActionsShowCmd() *cobra.Command {
{format.String("Name"), format.String(action.Name)},
{format.String("Type"), format.String(action.Type)},
{format.String("ID"), format.String(action.ID)},
{format.String("Labels"), format.String(strings.Join(action.GetLabels(), ","))},
}

printDetailsTable(cmd, details)
Expand Down
1 change: 0 additions & 1 deletion cmd/humioctl/alerts_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func newAlertsShowCmd() *cobra.Command {
{format.String("Query String"), format.String(alert.QueryString)},
{format.String("Labels"), format.String(strings.Join(alert.Labels, ", "))},
{format.String("Throttle Time Millis"), format.Int(alert.ThrottleTimeMillis)},
{format.String("Is Starred"), format.Bool(alert.IsStarred)},
{format.String("Last Error"), format.StringPtr(alert.LastError)},
{format.String("Throttle Field"), format.StringPtr(alert.ThrottleField)},
{format.String("Time Of Last Trigger"), format.Int64Ptr(alert.TimeOfLastTrigger)},
Expand Down
Loading