feat(observability): Add missing support for OpsGenie priority level (#931)
relates to STACKITCDN-879 Co-authored-by: Ruben Hoenle <Ruben.Hoenle@stackit.cloud>
This commit is contained in:
parent
4b670ee73f
commit
971cd27e4b
7 changed files with 47 additions and 24 deletions
|
|
@ -110,6 +110,7 @@ Read-Only:
|
||||||
|
|
||||||
- `api_key` (String) The API key for OpsGenie.
|
- `api_key` (String) The API key for OpsGenie.
|
||||||
- `api_url` (String) The host to send OpsGenie API requests to. Must be a valid URL
|
- `api_url` (String) The host to send OpsGenie API requests to. Must be a valid URL
|
||||||
|
- `priority` (String) Priority of the alert. Possible values are: `P1`, `P2`, `P3`, `P4`, `P5`.
|
||||||
- `tags` (String) Comma separated list of tags attached to the notifications.
|
- `tags` (String) Comma separated list of tags attached to the notifications.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ Optional:
|
||||||
|
|
||||||
- `api_key` (String) The API key for OpsGenie.
|
- `api_key` (String) The API key for OpsGenie.
|
||||||
- `api_url` (String) The host to send OpsGenie API requests to. Must be a valid URL
|
- `api_url` (String) The host to send OpsGenie API requests to. Must be a valid URL
|
||||||
|
- `priority` (String) Priority of the alert. Possible values are: `P1`, `P2`, `P3`, `P4`, `P5`.
|
||||||
- `tags` (String) Comma separated list of tags attached to the notifications.
|
- `tags` (String) Comma separated list of tags attached to the notifications.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,10 @@ func (d *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
||||||
Description: "Comma separated list of tags attached to the notifications.",
|
Description: "Comma separated list of tags attached to the notifications.",
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"priority": schema.StringAttribute{
|
||||||
|
Description: "Priority of the alert. " + utils.FormatPossibleValues([]string{"P1", "P2", "P3", "P4", "P5"}...),
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -187,15 +187,17 @@ var emailConfigsTypes = map[string]attr.Type{
|
||||||
|
|
||||||
// Struct corresponding to Model.AlertConfig.receivers.opsGenieConfigs
|
// Struct corresponding to Model.AlertConfig.receivers.opsGenieConfigs
|
||||||
type opsgenieConfigsModel struct {
|
type opsgenieConfigsModel struct {
|
||||||
ApiKey types.String `tfsdk:"api_key"`
|
ApiKey types.String `tfsdk:"api_key"`
|
||||||
ApiUrl types.String `tfsdk:"api_url"`
|
ApiUrl types.String `tfsdk:"api_url"`
|
||||||
Tags types.String `tfsdk:"tags"`
|
Tags types.String `tfsdk:"tags"`
|
||||||
|
Priority types.String `tfsdk:"priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var opsgenieConfigsTypes = map[string]attr.Type{
|
var opsgenieConfigsTypes = map[string]attr.Type{
|
||||||
"api_key": types.StringType,
|
"api_key": types.StringType,
|
||||||
"api_url": types.StringType,
|
"api_url": types.StringType,
|
||||||
"tags": types.StringType,
|
"tags": types.StringType,
|
||||||
|
"priority": types.StringType,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Struct corresponding to Model.AlertConfig.receivers.webHooksConfigs
|
// Struct corresponding to Model.AlertConfig.receivers.webHooksConfigs
|
||||||
|
|
@ -629,6 +631,10 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
|
||||||
Description: "Comma separated list of tags attached to the notifications.",
|
Description: "Comma separated list of tags attached to the notifications.",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
"priority": schema.StringAttribute{
|
||||||
|
Description: "Priority of the alert. " + utils.FormatPossibleValues("P1", "P2", "P3", "P4", "P5"),
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -1665,9 +1671,10 @@ func mapReceiversToAttributes(ctx context.Context, respReceivers *[]observabilit
|
||||||
if receiver.OpsgenieConfigs != nil {
|
if receiver.OpsgenieConfigs != nil {
|
||||||
for _, opsgenieConfig := range *receiver.OpsgenieConfigs {
|
for _, opsgenieConfig := range *receiver.OpsgenieConfigs {
|
||||||
opsGenieConfigMap := map[string]attr.Value{
|
opsGenieConfigMap := map[string]attr.Value{
|
||||||
"api_key": types.StringPointerValue(opsgenieConfig.ApiKey),
|
"api_key": types.StringPointerValue(opsgenieConfig.ApiKey),
|
||||||
"api_url": types.StringPointerValue(opsgenieConfig.ApiUrl),
|
"api_url": types.StringPointerValue(opsgenieConfig.ApiUrl),
|
||||||
"tags": types.StringPointerValue(opsgenieConfig.Tags),
|
"tags": types.StringPointerValue(opsgenieConfig.Tags),
|
||||||
|
"priority": types.StringPointerValue(opsgenieConfig.Priority),
|
||||||
}
|
}
|
||||||
opsGenieConfigModel, diags := types.ObjectValue(opsgenieConfigsTypes, opsGenieConfigMap)
|
opsGenieConfigModel, diags := types.ObjectValue(opsgenieConfigsTypes, opsGenieConfigMap)
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
|
|
@ -2014,9 +2021,10 @@ func toReceiverPayload(ctx context.Context, model *alertConfigModel) (*[]observa
|
||||||
for i := range opsgenieConfigs {
|
for i := range opsgenieConfigs {
|
||||||
opsgenieConfig := opsgenieConfigs[i]
|
opsgenieConfig := opsgenieConfigs[i]
|
||||||
payloadOpsGenieConfigs = append(payloadOpsGenieConfigs, observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner{
|
payloadOpsGenieConfigs = append(payloadOpsGenieConfigs, observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner{
|
||||||
ApiKey: conversion.StringValueToPointer(opsgenieConfig.ApiKey),
|
ApiKey: conversion.StringValueToPointer(opsgenieConfig.ApiKey),
|
||||||
ApiUrl: conversion.StringValueToPointer(opsgenieConfig.ApiUrl),
|
ApiUrl: conversion.StringValueToPointer(opsgenieConfig.ApiUrl),
|
||||||
Tags: conversion.StringValueToPointer(opsgenieConfig.Tags),
|
Tags: conversion.StringValueToPointer(opsgenieConfig.Tags),
|
||||||
|
Priority: conversion.StringValueToPointer(opsgenieConfig.Priority),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
receiverPayload.OpsgenieConfigs = &payloadOpsGenieConfigs
|
receiverPayload.OpsgenieConfigs = &payloadOpsGenieConfigs
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,10 @@ func fixtureEmailConfigsModel() basetypes.ListValue {
|
||||||
func fixtureOpsGenieConfigsModel() basetypes.ListValue {
|
func fixtureOpsGenieConfigsModel() basetypes.ListValue {
|
||||||
return types.ListValueMust(types.ObjectType{AttrTypes: opsgenieConfigsTypes}, []attr.Value{
|
return types.ListValueMust(types.ObjectType{AttrTypes: opsgenieConfigsTypes}, []attr.Value{
|
||||||
types.ObjectValueMust(opsgenieConfigsTypes, map[string]attr.Value{
|
types.ObjectValueMust(opsgenieConfigsTypes, map[string]attr.Value{
|
||||||
"api_key": types.StringValue("key"),
|
"api_key": types.StringValue("key"),
|
||||||
"tags": types.StringValue("tag"),
|
"tags": types.StringValue("tag"),
|
||||||
"api_url": types.StringValue("ops.example.com"),
|
"api_url": types.StringValue("ops.example.com"),
|
||||||
|
"priority": types.StringValue("P3"),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -140,9 +141,10 @@ func fixtureEmailConfigsPayload() observability.CreateAlertConfigReceiverPayload
|
||||||
|
|
||||||
func fixtureOpsGenieConfigsPayload() observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner {
|
func fixtureOpsGenieConfigsPayload() observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner {
|
||||||
return observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner{
|
return observability.CreateAlertConfigReceiverPayloadOpsgenieConfigsInner{
|
||||||
ApiKey: utils.Ptr("key"),
|
ApiKey: utils.Ptr("key"),
|
||||||
Tags: utils.Ptr("tag"),
|
Tags: utils.Ptr("tag"),
|
||||||
ApiUrl: utils.Ptr("ops.example.com"),
|
ApiUrl: utils.Ptr("ops.example.com"),
|
||||||
|
Priority: utils.Ptr("P3"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,9 +222,10 @@ func fixtureEmailConfigsResponse() observability.EmailConfig {
|
||||||
|
|
||||||
func fixtureOpsGenieConfigsResponse() observability.OpsgenieConfig {
|
func fixtureOpsGenieConfigsResponse() observability.OpsgenieConfig {
|
||||||
return observability.OpsgenieConfig{
|
return observability.OpsgenieConfig{
|
||||||
ApiKey: utils.Ptr("key"),
|
ApiKey: utils.Ptr("key"),
|
||||||
Tags: utils.Ptr("tag"),
|
Tags: utils.Ptr("tag"),
|
||||||
ApiUrl: utils.Ptr("ops.example.com"),
|
ApiUrl: utils.Ptr("ops.example.com"),
|
||||||
|
Priority: utils.Ptr("P3"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ var testConfigVarsMax = config.Variables{
|
||||||
"opsgenie_api_key": config.StringVariable("example-api-key"),
|
"opsgenie_api_key": config.StringVariable("example-api-key"),
|
||||||
"opsgenie_api_tags": config.StringVariable("observability-alert"),
|
"opsgenie_api_tags": config.StringVariable("observability-alert"),
|
||||||
"opsgenie_api_url": config.StringVariable("https://api.eu.opsgenie.com"),
|
"opsgenie_api_url": config.StringVariable("https://api.eu.opsgenie.com"),
|
||||||
|
"opsgenie_priority": config.StringVariable("P3"),
|
||||||
"webhook_configs_url": config.StringVariable("https://example.com"),
|
"webhook_configs_url": config.StringVariable("https://example.com"),
|
||||||
"ms_teams": config.StringVariable("true"),
|
"ms_teams": config.StringVariable("true"),
|
||||||
"group_by": config.StringVariable("alertname"),
|
"group_by": config.StringVariable("alertname"),
|
||||||
|
|
@ -505,6 +506,7 @@ func TestAccResourceMax(t *testing.T) {
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
||||||
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.priority", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_priority"])),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
||||||
|
|
@ -666,6 +668,7 @@ func TestAccResourceMax(t *testing.T) {
|
||||||
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
||||||
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
||||||
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
||||||
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.priority", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_priority"])),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
||||||
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
resource.TestCheckResourceAttr("data.stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
||||||
|
|
@ -888,6 +891,7 @@ func TestAccResourceMax(t *testing.T) {
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_key", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_key"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.tags", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_tags"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.api_url", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_api_url"])),
|
||||||
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.opsgenie_configs.0.priority", testutil.ConvertConfigVariable(testConfigVarsMax["opsgenie_priority"])),
|
||||||
|
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.url", testutil.ConvertConfigVariable(testConfigVarsMax["webhook_configs_url"])),
|
||||||
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.receivers.0.webhooks_configs.0.ms_teams", testutil.ConvertConfigVariable(testConfigVarsMax["ms_teams"])),
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ variable "email_to" {}
|
||||||
variable "opsgenie_api_key" {}
|
variable "opsgenie_api_key" {}
|
||||||
variable "opsgenie_api_tags" {}
|
variable "opsgenie_api_tags" {}
|
||||||
variable "opsgenie_api_url" {}
|
variable "opsgenie_api_url" {}
|
||||||
|
variable "opsgenie_priority" {}
|
||||||
variable "webhook_configs_url" {}
|
variable "webhook_configs_url" {}
|
||||||
variable "ms_teams" {}
|
variable "ms_teams" {}
|
||||||
variable "group_by" {}
|
variable "group_by" {}
|
||||||
|
|
@ -114,9 +115,10 @@ resource "stackit_observability_instance" "instance" {
|
||||||
]
|
]
|
||||||
opsgenie_configs = [
|
opsgenie_configs = [
|
||||||
{
|
{
|
||||||
api_key = var.opsgenie_api_key
|
api_key = var.opsgenie_api_key
|
||||||
tags = var.opsgenie_api_tags
|
tags = var.opsgenie_api_tags
|
||||||
api_url = var.opsgenie_api_url
|
api_url = var.opsgenie_api_url
|
||||||
|
priority = var.opsgenie_priority
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
webhooks_configs = [
|
webhooks_configs = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue