Skip to content

Commit

Permalink
Add Contact Points
Browse files Browse the repository at this point in the history
  • Loading branch information
safaci2000 committed Oct 14, 2024
1 parent fdf53c5 commit c164284
Show file tree
Hide file tree
Showing 12 changed files with 841 additions and 22 deletions.
34 changes: 34 additions & 0 deletions cli/backup/alerting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package backup

import (
"context"

"github.com/bep/simplecobra"
"github.com/esnet/gdg/cli/support"
"github.com/spf13/cobra"
)

func newAlertingCommand() simplecobra.Commander {
description := "Manage Alerting resources"
return &support.SimpleCommand{
NameP: "alerting",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"alert"}
// connections := cmd
// connections.PersistentFlags().StringP("connection", "", "", "filter by connection slug")
},
CommandsList: []simplecobra.Commander{
newAlertingContactCommand(),
// newClearConnectionsCmd(),
// newUploadConnectionsCmd(),
// newDownloadConnectionsCmd(),
// newListConnectionsCmd(),
// newConnectionsPermissionCmd(),
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
return cd.CobraCommand.Help()
},

Check warning on line 32 in cli/backup/alerting.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting.go#L30-L32

Added lines #L30 - L32 were not covered by tests
}
}
148 changes: 148 additions & 0 deletions cli/backup/alerting_contacts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package backup

import (
"context"
"encoding/json"
"log/slog"

"github.com/bep/simplecobra"
"github.com/esnet/gdg/cli/support"
"github.com/esnet/gdg/internal/service"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
)

func newAlertingContactCommand() simplecobra.Commander {
description := "Manage Alerting ContactPoints "
return &support.SimpleCommand{
NameP: "contactpoint",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"contact", "contacts", "contactpoints"}
},
CommandsList: []simplecobra.Commander{
newListContactPointsCmd(),
newClearContactPointsCmd(),
newUploadContactPointsCmd(),
newDownloadContactPointsCmd(),
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
return cd.CobraCommand.Help()
},

Check warning on line 32 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L30-L32

Added lines #L30 - L32 were not covered by tests
}
}

func newListContactPointsCmd() simplecobra.Commander {
description := "List all contact points for the given Organization"
return &support.SimpleCommand{
NameP: "list",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"l"}
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
rootCmd.TableObj.AppendHeader(table.Row{"uid", "name", "slug", "type", "provenance", "settings"})
contactPoints := rootCmd.GrafanaSvc().ListContactPoints()
slog.Info("Listing contact points for context",
slog.String("Organization", GetOrganizationName()),
slog.String("context", GetContext()))
if len(contactPoints) == 0 {
slog.Info("No contact points found")
} else {
for _, link := range contactPoints {
rawBytes, err := json.Marshal(link.Settings)
if err != nil {
slog.Warn("unable to marshall settings to valid JSON")

Check warning on line 57 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L45-L57

Added lines #L45 - L57 were not covered by tests
}
rootCmd.TableObj.AppendRow(table.Row{link.UID, link.Name, service.GetSlug(link.Name), link.Type, link.Provenance, string(rawBytes)})

Check warning on line 59 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L59

Added line #L59 was not covered by tests
}
rootCmd.Render(cd.CobraCommand, contactPoints)

Check warning on line 61 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L61

Added line #L61 was not covered by tests
}
return nil

Check warning on line 63 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L63

Added line #L63 was not covered by tests
},
}
}

func newDownloadContactPointsCmd() simplecobra.Commander {
description := "Download all contact points for the given Organization"
return &support.SimpleCommand{
NameP: "download",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"d"}
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
file, err := rootCmd.GrafanaSvc().DownloadContactPoints()
slog.Info("Download contact points for context",
slog.String("Organization", GetOrganizationName()),
slog.String("context", GetContext()))
if err != nil {
slog.Error("unable to contact point")
} else {
slog.Info("contact points successfully downloaded", slog.Any("file", file))

Check warning on line 85 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L77-L85

Added lines #L77 - L85 were not covered by tests
}
return nil

Check warning on line 87 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L87

Added line #L87 was not covered by tests
},
}
}

func newUploadContactPointsCmd() simplecobra.Commander {
description := "Upload all contact points for the given Organization"
return &support.SimpleCommand{
NameP: "upload",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"u"}
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
removedItems, err := rootCmd.GrafanaSvc().UploadContactPoints()
slog.Info("Upload contact points for context",
slog.String("Organization", GetOrganizationName()),
slog.String("context", GetContext()))
if err != nil {
slog.Error("unable to upload contact points", slog.Any("err", err))
} else {
slog.Info("contact points successfully uploaded")
rootCmd.TableObj.AppendHeader(table.Row{"name"})
for _, item := range removedItems {
rootCmd.TableObj.AppendRow(table.Row{item})

Check warning on line 112 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L101-L112

Added lines #L101 - L112 were not covered by tests
}

rootCmd.Render(cd.CobraCommand, removedItems)

Check warning on line 115 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L115

Added line #L115 was not covered by tests
}
return nil

Check warning on line 117 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L117

Added line #L117 was not covered by tests
},
}
}

func newClearContactPointsCmd() simplecobra.Commander {
description := "Clear all contact points for the given Organization"
return &support.SimpleCommand{
NameP: "clear",
Short: description,
Long: description,
WithCFunc: func(cmd *cobra.Command, r *support.RootCommand) {
cmd.Aliases = []string{"l"}
},
RunFunc: func(ctx context.Context, cd *simplecobra.Commandeer, rootCmd *support.RootCommand, args []string) error {
removedItems, err := rootCmd.GrafanaSvc().ClearContactPoints()
slog.Info("Clear contact points for context",
slog.String("Organization", GetOrganizationName()),
slog.String("context", GetContext()))
if err != nil {
slog.Error("unable to contact point")
} else {
slog.Info("contact points successfully removed")
rootCmd.TableObj.AppendHeader(table.Row{"name"})
for _, item := range removedItems {
rootCmd.TableObj.AppendRow(table.Row{item})

Check warning on line 142 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L131-L142

Added lines #L131 - L142 were not covered by tests
}
}
return nil

Check warning on line 145 in cli/backup/alerting_contacts.go

View check run for this annotation

Codecov / codecov/patch

cli/backup/alerting_contacts.go#L145

Added line #L145 was not covered by tests
},
}
}
1 change: 1 addition & 0 deletions cli/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ limited to clear/delete, list, download and upload. Any other functionality wil
newOrganizationsCommand(),
newTeamsCommand(),
newUsersCommand(),
newAlertingCommand(),
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ require (
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.9.4 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.2.0 // indirect
cloud.google.com/go/compute/metadata v0.5.1 // indirect
cloud.google.com/go/iam v1.2.1 // indirect
cloud.google.com/go/storage v1.43.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
Expand Down Expand Up @@ -173,8 +173,8 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.mongodb.org/mongo-driver v1.16.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
Expand Down
13 changes: 9 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ cloud.google.com/go/auth/oauth2adapt v0.2.4 h1:0GWE/FUsXhf6C+jAkWgYm7X9tK8cuEIfy
cloud.google.com/go/auth/oauth2adapt v0.2.4/go.mod h1:jC/jOpwFP6JBxhB3P5Rr0a9HLMC/Pe3eaL4NmdvqPtc=
cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
cloud.google.com/go/compute/metadata v0.5.1 h1:NM6oZeZNlYjiwYje+sYFjEpP0Q0zCan1bmQW/KmIrGs=
cloud.google.com/go/compute/metadata v0.5.1/go.mod h1:C66sj2AluDcIqakBq/M8lw8/ybHgOZqin2obFxa/E5k=
cloud.google.com/go/iam v1.2.0 h1:kZKMKVNk/IsSSc/udOb83K0hL/Yh/Gcqpz+oAkoIFN8=
cloud.google.com/go/iam v1.2.0/go.mod h1:zITGuWgsLZxd8OwAlX+eMFgZDXzBm7icj1PVTYG766Q=
cloud.google.com/go/iam v1.2.1 h1:QFct02HRb7H12J/3utj0qf5tobFh9V4vR6h9eX5EBRU=
cloud.google.com/go/iam v1.2.1/go.mod h1:3VUIJDPpwT6p/amXRC5GY8fCCh70lxPygguVtI0Z4/g=
cloud.google.com/go/longrunning v0.6.0 h1:mM1ZmaNsQsnb+5n1DNPeL0KwQd9jQRqSqSDEkBZr+aI=
cloud.google.com/go/longrunning v0.6.0/go.mod h1:uHzSZqW89h7/pasCWNYdUpwGz3PcVWhrWupreVPYLts=
cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs=
Expand Down Expand Up @@ -430,10 +434,10 @@ go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0 h1:hCq2hNMwsegUvPzI7sPOvtO9cqyy5GbWt/Ybp2xrx8Q=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0/go.mod h1:LqaApwGx/oUmzsbqxkzuBvyoPpkxk3JQWnqfVrJ3wCA=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0 h1:ZIg3ZT/aQ7AfKqdwp7ECpOK6vHqquXXuyTjIO8ZdmPs=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0/go.mod h1:DQAwmETtZV00skUwgD6+0U89g80NKsJE3DCKeLLPQMI=
go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts=
go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY=
Expand All @@ -444,6 +448,7 @@ go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4Q
go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ=
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo=
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
Expand Down
2 changes: 2 additions & 0 deletions internal/config/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
UserResource ResourceType = "users"
TemplatesResource ResourceType = "templates"
SecureSecretsResource ResourceType = "secure"
AlertingResource ResourceType = "alerting"
)

var orgNamespacedResource = map[ResourceType]bool{
Expand All @@ -34,6 +35,7 @@ var orgNamespacedResource = map[ResourceType]bool{
FolderResource: true,
LibraryElementResource: true,
TeamResource: true,
AlertingResource: true,
}

// isNamespaced returns true if the resource type is namespaced
Expand Down
133 changes: 133 additions & 0 deletions internal/service/alerting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package service

import (
"encoding/json"
"fmt"
"log"
"log/slog"

"github.com/esnet/gdg/internal/config"
"github.com/esnet/gdg/internal/tools"
"github.com/grafana/grafana-openapi-client-go/client/provisioning"
"github.com/grafana/grafana-openapi-client-go/models"
)

func (s *DashNGoImpl) ListContactPoints() []*models.EmbeddedContactPoint {
p := provisioning.NewGetContactpointsParams()
result, err := s.GetClient().Provisioning.GetContactpoints(p)
if err != nil {
log.Fatalf("unable to retrieve contact points, err:%s", err.Error())

Check warning on line 19 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L15-L19

Added lines #L15 - L19 were not covered by tests
}
return result.GetPayload()

Check warning on line 21 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L21

Added line #L21 was not covered by tests
}

func (s *DashNGoImpl) DownloadContactPoints() (string, error) {
var (
dsPacked []byte
err error
)
p := provisioning.NewGetContactpointsExportParams()
p.Download = tools.PtrOf(true)
p.Decrypt = tools.PtrOf(true)
p.Format = tools.PtrOf("json")
data, err := s.GetClient().Provisioning.GetContactpointsExport(p)
if err != nil {
log.Fatalf("unable to retrieve Contact Points, err: %s", err.Error())

Check warning on line 35 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L24-L35

Added lines #L24 - L35 were not covered by tests
}

dsPath := buildResourcePath("contacts", config.AlertingResource)
if dsPacked, err = json.MarshalIndent(data.GetPayload(), "", " "); err != nil {
return "", fmt.Errorf("unable to serialize data to JSON. %w", err)

Check warning on line 40 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L38-L40

Added lines #L38 - L40 were not covered by tests
}
if err = s.storage.WriteFile(dsPath, dsPacked); err != nil {
return "", fmt.Errorf("unable to write file. %w", err)

Check warning on line 43 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L42-L43

Added lines #L42 - L43 were not covered by tests
}

return dsPath, nil

Check warning on line 46 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L46

Added line #L46 was not covered by tests
}

func (s *DashNGoImpl) UploadContactPoints() ([]string, error) {
var (
err error
rawDS []byte
result []string
)
data := new(models.AlertingFileExport)
currentContacts := s.ListContactPoints()
m := make(map[string]*models.EmbeddedContactPoint)
for ndx, i := range currentContacts {
m[i.UID] = currentContacts[ndx]

Check warning on line 59 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L49-L59

Added lines #L49 - L59 were not covered by tests
}

fileLocation := buildResourcePath("contacts", config.AlertingResource)
if rawDS, err = s.storage.ReadFile(fileLocation); err != nil {
return nil, fmt.Errorf("failed to read file. file: %s, err: %w", fileLocation, err)

Check warning on line 64 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L62-L64

Added lines #L62 - L64 were not covered by tests
}
if err = json.Unmarshal(rawDS, data); err != nil {
return nil, fmt.Errorf("failed to unmarshall file, file:%s, err: %w", fileLocation, err)

Check warning on line 67 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L66-L67

Added lines #L66 - L67 were not covered by tests
}
for _, i := range data.ContactPoints {
for _, r := range i.Receivers {
if _, ok := m[r.UID]; ok {

Check warning on line 71 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L69-L71

Added lines #L69 - L71 were not covered by tests
// do update
p := provisioning.NewPutContactpointParams()
p.UID = r.UID
p.Body = &models.EmbeddedContactPoint{
DisableResolveMessage: false,
Name: i.Name,
Provenance: "",
Settings: r.Settings,
Type: tools.PtrOf(r.Type),
UID: r.UID,

Check warning on line 81 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L73-L81

Added lines #L73 - L81 were not covered by tests
}
_, err := s.GetClient().Provisioning.PutContactpoint(p)
if err != nil {
slog.Error("failed to update contact point", slog.Any("uid", r.UID))
continue

Check warning on line 86 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L83-L86

Added lines #L83 - L86 were not covered by tests
}
result = append(result, i.Name)

Check warning on line 88 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L88

Added line #L88 was not covered by tests

} else {
p := provisioning.NewPostContactpointsParams()
p.Body = &models.EmbeddedContactPoint{
DisableResolveMessage: false,
Name: i.Name,
UID: r.UID,
Provenance: "",
Settings: r.Settings,
Type: tools.PtrOf(r.Type),

Check warning on line 98 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L90-L98

Added lines #L90 - L98 were not covered by tests
}
_, err := s.GetClient().Provisioning.PostContactpoints(p)
if err != nil {
slog.Error("failed to create contact point", slog.Any("uid", r.UID))
continue

Check warning on line 103 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L100-L103

Added lines #L100 - L103 were not covered by tests
}

result = append(result, i.Name)

Check warning on line 106 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L106

Added line #L106 was not covered by tests
}
}
}

return result, nil

Check warning on line 111 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L111

Added line #L111 was not covered by tests
}

func (s *DashNGoImpl) ClearContactPoints() ([]string, error) {
var (
err error
results []string
)
contacts := s.ListContactPoints()
for _, contact := range contacts {
_, err = s.GetClient().Provisioning.DeleteContactpoints(contact.UID)
if err != nil {
slog.Error("unable to delete contact point",
slog.Any("name", contact.Name),
slog.Any("uid", contact.UID),
)
continue

Check warning on line 127 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L114-L127

Added lines #L114 - L127 were not covered by tests
}
results = append(results, contact.Name)

Check warning on line 129 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L129

Added line #L129 was not covered by tests
}

return results, nil

Check warning on line 132 in internal/service/alerting.go

View check run for this annotation

Codecov / codecov/patch

internal/service/alerting.go#L132

Added line #L132 was not covered by tests
}
Loading

0 comments on commit c164284

Please sign in to comment.