From ae192244f390109844aa383350a61570765b9827 Mon Sep 17 00:00:00 2001 From: Tim Heckman Date: Sat, 17 Apr 2021 19:12:08 -0700 Subject: [PATCH] Add missing context.Context support and propagation While looking at something I discovered that I had accidentally missed adding full `context.Context` support in two places. In particular, in `service_dependency.go` the context for `AssociateServiceDependenciesWithContext` wasn't being used. Second, I missed adding context support to `AssignTags()` completely. --- service_dependency.go | 2 +- tag.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/service_dependency.go b/service_dependency.go index 67b33b6d..b760b436 100644 --- a/service_dependency.go +++ b/service_dependency.go @@ -89,7 +89,7 @@ func (c *Client) AssociateServiceDependenciesWithContext(ctx context.Context, de } func (c *Client) associateServiceDependenciesWithContext(ctx context.Context, dependencies *ListServiceDependencies) (*ListServiceDependencies, *http.Response, error) { - resp, err := c.post(context.TODO(), "/service_dependencies/associate", dependencies, nil) + resp, err := c.post(ctx, "/service_dependencies/associate", dependencies, nil) if err != nil { return nil, nil, err } diff --git a/tag.go b/tag.go index 8d7d47be..011ab1f5 100644 --- a/tag.go +++ b/tag.go @@ -122,9 +122,15 @@ func (c *Client) GetTagWithContext(ctx context.Context, id string) (*Tag, *http. return getTagFromResponse(c, resp, err) } -// AssignTags adds and removes tag assignments with entities +// AssignTags adds and removes tag assignments with entities. It's recommended +// to use AssignTagsWithContext instead. func (c *Client) AssignTags(e, eid string, a *TagAssignments) (*http.Response, error) { - resp, err := c.post(context.TODO(), "/"+e+"/"+eid+"/change_tags", a, nil) + return c.AssignTagsWithContext(context.Background(), e, eid, a) +} + +// AssignTagsWithContext adds and removes tag assignments with entities. +func (c *Client) AssignTagsWithContext(ctx context.Context, e, eid string, a *TagAssignments) (*http.Response, error) { + resp, err := c.post(ctx, "/"+e+"/"+eid+"/change_tags", a, nil) if err != nil { return nil, err }