From 226ff2dee2ab9828b5fa74316b7cb3669fa2a348 Mon Sep 17 00:00:00 2001 From: Pete Davids Date: Wed, 21 Feb 2024 18:11:37 -0500 Subject: [PATCH 1/3] fix event query update --- .go-version | 2 +- client/event_query.go | 2 +- lightstep/resource_event_query_test.go | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.go-version b/.go-version index 8a78acff..038051d7 100644 --- a/.go-version +++ b/.go-version @@ -1,2 +1,2 @@ -1.91.1 +1.91.2 diff --git a/client/event_query.go b/client/event_query.go index 2614c074..0d85e166 100644 --- a/client/event_query.go +++ b/client/event_query.go @@ -65,7 +65,7 @@ func (c *Client) UpdateEventQuery(ctx context.Context, projectName string, event return event, err } if err := c.CallAPI(ctx, "PUT", - fmt.Sprintf("projects/%v/event_queries/%v", eventQueryID, projectName), bytes, &resp); err != nil { + fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), bytes, &resp); err != nil { return nil, err } err = json.Unmarshal(resp.Data, &event) diff --git a/lightstep/resource_event_query_test.go b/lightstep/resource_event_query_test.go index aa6bf410..c6249236 100644 --- a/lightstep/resource_event_query_test.go +++ b/lightstep/resource_event_query_test.go @@ -20,6 +20,16 @@ resource "lightstep_event_query" "terraform" { source = "test-source" query_string = "logs" } +` + + updatedEventQueryConfig := ` +resource "lightstep_event_query" "terraform" { + project_name = "` + testProject + `" + name = "updated name" + type = "test-type" + source = "test-source" + query_string = "logs" +} ` resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -36,6 +46,13 @@ resource "lightstep_event_query" "terraform" { resource.TestCheckResourceAttr("lightstep_event_query.terraform", "query_string", "logs"), ), }, + { + Config: updatedEventQueryConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckEventQueryExists("lightstep_event_query.terraform", &eventQuery), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "name", "updated name"), + ), + }, }, }) From ebea3930bdb567c46354e598407370bc82f15dfe Mon Sep 17 00:00:00 2001 From: Pete Davids Date: Wed, 21 Feb 2024 18:15:43 -0500 Subject: [PATCH 2/3] why am i like this --- lightstep/resource_event_query_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lightstep/resource_event_query_test.go b/lightstep/resource_event_query_test.go index c6249236..85358e35 100644 --- a/lightstep/resource_event_query_test.go +++ b/lightstep/resource_event_query_test.go @@ -28,7 +28,7 @@ resource "lightstep_event_query" "terraform" { name = "updated name" type = "test-type" source = "test-source" - query_string = "logs" + query_string = "logs | filter foo == bar" } ` resource.Test(t, resource.TestCase{ @@ -51,6 +51,9 @@ resource "lightstep_event_query" "terraform" { Check: resource.ComposeTestCheckFunc( testAccCheckEventQueryExists("lightstep_event_query.terraform", &eventQuery), resource.TestCheckResourceAttr("lightstep_event_query.terraform", "name", "updated name"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "type", "test-type"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "source", "test-source"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "query_string", "logs | filter foo == bar"), ), }, }, From 1c5b4295b247956be149d7335c576a3660753e8b Mon Sep 17 00:00:00 2001 From: Pete Davids Date: Wed, 21 Feb 2024 18:21:21 -0500 Subject: [PATCH 3/3] wrap --- client/event_query.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/event_query.go b/client/event_query.go index 0d85e166..04792a4d 100644 --- a/client/event_query.go +++ b/client/event_query.go @@ -60,12 +60,13 @@ func (c *Client) UpdateEventQuery(ctx context.Context, projectName string, event resp Envelope ) - bytes, err := json.Marshal(attributes) + body := WireEventQueryAttributes{Attributes: attributes} + bytes, err := json.Marshal(body) if err != nil { return event, err } if err := c.CallAPI(ctx, "PUT", - fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), bytes, &resp); err != nil { + fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), Envelope{Data: bytes}, &resp); err != nil { return nil, err } err = json.Unmarshal(resp.Data, &event)