Rename silence API Delete() -> Expire() (#1319)

Within alertmanager, expire is the term used,
since silences still "exist" but aren't in effect.

Signed-off-by: Stuart Nelson <stuartnelson3@gmail.com>
This commit is contained in:
stuart nelson 2018-04-11 12:30:18 +02:00 committed by GitHub
parent c92ed69ce8
commit 360dba6d9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -32,7 +32,7 @@ func expire(element *kingpin.ParseElement, ctx *kingpin.ParseContext) error {
silenceAPI := client.NewSilenceAPI(c) silenceAPI := client.NewSilenceAPI(c)
for _, id := range *expireIds { for _, id := range *expireIds {
err := silenceAPI.Delete(context.Background(), id) err := silenceAPI.Expire(context.Background(), id)
if err != nil { if err != nil {
return err return err
} }

View File

@ -237,8 +237,8 @@ type SilenceAPI interface {
Get(ctx context.Context, id string) (*types.Silence, error) Get(ctx context.Context, id string) (*types.Silence, error)
// Set updates or creates the given silence and returns its ID. // Set updates or creates the given silence and returns its ID.
Set(ctx context.Context, sil types.Silence) (string, error) Set(ctx context.Context, sil types.Silence) (string, error)
// Delete deletes the silence with the given ID. // Expire expires the silence with the given ID.
Delete(ctx context.Context, id string) error Expire(ctx context.Context, id string) error
// List returns silences matching the given filter. // List returns silences matching the given filter.
List(ctx context.Context, filter string) ([]*types.Silence, error) List(ctx context.Context, filter string) ([]*types.Silence, error)
} }
@ -270,7 +270,7 @@ func (h *httpSilenceAPI) Get(ctx context.Context, id string) (*types.Silence, er
return &sil, err return &sil, err
} }
func (h *httpSilenceAPI) Delete(ctx context.Context, id string) error { func (h *httpSilenceAPI) Expire(ctx context.Context, id string) error {
u := h.client.URL(epSilence, map[string]string{ u := h.client.URL(epSilence, map[string]string{
"id": id, "id": id,
}) })

View File

@ -155,10 +155,10 @@ func TestAPI(t *testing.T) {
return api.Set(context.Background(), sil) return api.Set(context.Background(), sil)
} }
} }
doSilenceDelete := func(id string) func() (interface{}, error) { doSilenceExpire := func(id string) func() (interface{}, error) {
return func() (interface{}, error) { return func() (interface{}, error) {
api := httpSilenceAPI{client: client} api := httpSilenceAPI{client: client}
return nil, api.Delete(context.Background(), id) return nil, api.Expire(context.Background(), id)
} }
} }
doSilenceList := func() (interface{}, error) { doSilenceList := func() (interface{}, error) {
@ -258,14 +258,14 @@ func TestAPI(t *testing.T) {
err: fmt.Errorf("some error"), err: fmt.Errorf("some error"),
}, },
{ {
do: doSilenceDelete("abc"), do: doSilenceExpire("abc"),
apiRes: fakeAPIResponse{ apiRes: fakeAPIResponse{
path: "/api/v1/silence/abc", path: "/api/v1/silence/abc",
method: http.MethodDelete, method: http.MethodDelete,
}, },
}, },
{ {
do: doSilenceDelete("abc"), do: doSilenceExpire("abc"),
apiRes: fakeAPIResponse{ apiRes: fakeAPIResponse{
err: fmt.Errorf("some error"), err: fmt.Errorf("some error"),
path: "/api/v1/silence/abc", path: "/api/v1/silence/abc",