From a8ce9a90f52dd81281fca78b077435229bdbafaf Mon Sep 17 00:00:00 2001 From: Salim Afiune Date: Mon, 20 Jul 2020 17:03:45 -0600 Subject: [PATCH] fix(cli): missing fields for Slack integrations (#170) Contributes to https://github.com/lacework/go-sdk/issues/169 Signed-off-by: Salim Afiune Maya --- api/integrations_slack_channel.go | 6 +++--- cli/cmd/integration.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api/integrations_slack_channel.go b/api/integrations_slack_channel.go index f293700e6..bbade8279 100644 --- a/api/integrations_slack_channel.go +++ b/api/integrations_slack_channel.go @@ -124,7 +124,7 @@ type SlackChanIntegration struct { } type SlackChannelData struct { - IssueGrouping string `json:"ISSUE_GROUPING,omitempty"` - SlackUrl string `json:"SLACK_URL"` - MinAlertSeverity SlackAlertLevel `json:"MIN_ALERT_SEVERITY"` + IssueGrouping string `json:"ISSUE_GROUPING,omitempty" mapstructure:"ISSUE_GROUPING"` + SlackUrl string `json:"SLACK_URL" mapstructure:"SLACK_URL"` + MinAlertSeverity SlackAlertLevel `json:"MIN_ALERT_SEVERITY" mapstructure:"MIN_ALERT_SEVERITY"` } diff --git a/cli/cmd/integration.go b/cli/cmd/integration.go index 59a596362..e9ab4c936 100644 --- a/cli/cmd/integration.go +++ b/cli/cmd/integration.go @@ -373,6 +373,26 @@ func reflectIntegrationData(raw api.RawIntegration) [][]string { } return out + case api.SlackChannelIntegration.String(): + + var iData api.SlackChannelData + err := mapstructure.Decode(raw.Data, &iData) + if err != nil { + cli.Log.Debugw("unable to decode integration data", + "integration_type", raw.Type, + "raw_data", raw.Data, + "error", err, + ) + break + } + out := [][]string{ + []string{"SLACK URL", iData.SlackUrl}, + []string{"ISSUE GROUPING", iData.IssueGrouping}, + []string{"ALERT ON SEVERITY", iData.MinAlertSeverity.String()}, + } + + return out + default: out := [][]string{} for key, value := range deepKeyValueExtract(raw.Data) {