Skip to content

Commit 0db4052

Browse files
authored
feat(scalyr): add project_id (#822)
* build: bump go-fastly to 9.2.0 * refactor(scalyr): remove code comment * feat(scalyr): add project_id * doc(scalyr): regenerate
1 parent 68a13e8 commit 0db4052

File tree

12 files changed

+82
-15
lines changed

12 files changed

+82
-15
lines changed

docs/resources/service_compute.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ Required:
567567

568568
Optional:
569569

570+
- `project_id` (String) The name of the logfile field sent to Scalyr
570571
- `region` (String) The region that log data will be sent to. One of `US` or `EU`. Defaults to `US` if undefined
571572

572573

docs/resources/service_vcl.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ Optional:
10091009
- `format` (String) Apache style log formatting.
10101010
- `format_version` (Number) The version of the custom logging format used for the configured endpoint. Can be either 1 or 2. (default: 2).
10111011
- `placement` (String) Where in the generated VCL the logging call should be placed.
1012+
- `project_id` (String) The name of the logfile field sent to Scalyr
10121013
- `region` (String) The region that log data will be sent to. One of `US` or `EU`. Defaults to `US` if undefined
10131014
- `response_condition` (String) The name of an existing condition in the configured endpoint, or leave blank to always execute.
10141015

fastly/block_fastly_service_logging_scalyr.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func (h *ScalyrServiceAttributeHandler) GetSchema() *schema.Schema {
3737
Required: true,
3838
Description: "The unique name of the Scalyr logging endpoint. It is important to note that changing this attribute will delete and recreate the resource",
3939
},
40+
"project_id": {
41+
Type: schema.TypeString,
42+
Optional: true,
43+
Description: "The name of the logfile field sent to Scalyr",
44+
},
4045
"region": {
4146
Type: schema.TypeString,
4247
Optional: true,
@@ -151,6 +156,9 @@ func (h *ScalyrServiceAttributeHandler) Update(_ context.Context, d *schema.Reso
151156
if v, ok := modified["placement"]; ok {
152157
opts.Placement = gofastly.ToPointer(v.(string))
153158
}
159+
if v, ok := modified["project_id"]; ok {
160+
opts.ProjectID = gofastly.ToPointer(v.(string))
161+
}
154162

155163
log.Printf("[DEBUG] Update Scalyr Opts: %#v", opts)
156164
_, err := conn.UpdateScalyr(&opts)
@@ -216,6 +224,9 @@ func flattenScalyr(remoteState []*gofastly.Scalyr) []map[string]any {
216224
if resource.FormatVersion != nil {
217225
data["format_version"] = *resource.FormatVersion
218226
}
227+
if resource.ProjectID != nil {
228+
data["project_id"] = *resource.ProjectID
229+
}
219230

220231
// Prune any empty values that come from the default string value in structs.
221232
for k, v := range data {
@@ -244,12 +255,13 @@ func (h *ScalyrServiceAttributeHandler) buildCreate(scalyrMap any, serviceID str
244255
Token: gofastly.ToPointer(resource["token"].(string)),
245256
}
246257

258+
if v := resource["project_id"].(string); v != "" {
259+
opts.ProjectID = gofastly.ToPointer(v)
260+
}
261+
247262
// WARNING: The following fields shouldn't have an empty string passed.
248263
// As it will cause the Fastly API to return an error.
249264
// This is because go-fastly v7+ will not 'omitempty' due to pointer type.
250-
// if vla.placement != "" {
251-
// opts.Placement = gofastly.ToPointer(vla.placement)
252-
// }
253265
if vla.placement != "" {
254266
opts.Placement = gofastly.ToPointer(vla.placement)
255267
}

fastly/block_fastly_service_logging_scalyr_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func TestResourceFastlyFlattenScalyr(t *testing.T) {
2828
Format: gofastly.ToPointer(`%a %l %u %t %m %U%q %H %>s %b %T`),
2929
FormatVersion: gofastly.ToPointer(2),
3030
Placement: gofastly.ToPointer("none"),
31+
ProjectID: gofastly.ToPointer("example-project"),
3132
},
3233
},
3334
local: []map[string]any{
@@ -39,6 +40,7 @@ func TestResourceFastlyFlattenScalyr(t *testing.T) {
3940
"format": `%a %l %u %t %m %U%q %H %>s %b %T`,
4041
"placement": "none",
4142
"format_version": 2,
43+
"project_id": "example-project",
4244
},
4345
},
4446
},
@@ -77,6 +79,7 @@ func TestAccFastlyServiceVCL_scalyrlogging_basic(t *testing.T) {
7779
ResponseCondition: gofastly.ToPointer("response_condition_test"),
7880
ServiceVersion: gofastly.ToPointer(1),
7981
Token: gofastly.ToPointer("newtkn"),
82+
ProjectID: gofastly.ToPointer("example-project"),
8083
}
8184

8285
log2 := gofastly.Scalyr{
@@ -307,6 +310,7 @@ resource "fastly_service_vcl" "foo" {
307310
format_version = 2
308311
response_condition = "response_condition_test"
309312
placement = "waf_debug"
313+
project_id = "example-project"
310314
}
311315
312316
logging_scalyr {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/bflad/tfproviderlint v0.29.0
7-
github.com/fastly/go-fastly/v9 v9.0.0
7+
github.com/fastly/go-fastly/v9 v9.2.0
88
github.com/google/go-cmp v0.6.0
99
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1010
github.com/hashicorp/terraform-plugin-docs v0.16.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
3333
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3434
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
3535
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
36-
github.com/fastly/go-fastly/v9 v9.0.0 h1:KQIqimmw0SJikXCEE+0kDzvYgCIaO8+upl7y9Sfo2fc=
37-
github.com/fastly/go-fastly/v9 v9.0.0/go.mod h1:iGGitrzwWXtwFVkESHsTNENc/BZTY9z2IfyFxN2FJjw=
36+
github.com/fastly/go-fastly/v9 v9.2.0 h1:+tCE/5LV0fa9bMuIBKx5Xtc4N/dTlRjB02b3bSddRv4=
37+
github.com/fastly/go-fastly/v9 v9.2.0/go.mod h1:5w2jgJBZqQEebOwM/rRg7wutAcpDTziiMYWb/6qdM7U=
3838
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
3939
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
4040
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=

vendor/github.com/fastly/go-fastly/v9/fastly/client.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fastly/go-fastly/v9/fastly/config_store.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fastly/go-fastly/v9/fastly/kv_store.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/fastly/go-fastly/v9/fastly/logging_scalyr.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)