Skip to content

Commit

Permalink
add support for SECURE logging level
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Aug 21, 2023
1 parent 7363e1b commit bff6520
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 10 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ require (
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

replace github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20230820021429-370ebe039763
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/heimweh/go-pagerduty v0.0.0-20230615223713-346f1359a346 h1:ZPq/T5o8a6jcIJMPtjwadbXvbU/jc4b0DsVZlZ6iQNA=
github.com/heimweh/go-pagerduty v0.0.0-20230615223713-346f1359a346/go.mod h1:t9vftsO1IjYHGdgJXeemZtomCWnxi2SRgu0PRcRb2oY=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
Expand All @@ -679,6 +677,8 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/imjaroiswebdev/go-pagerduty v0.0.0-20230820021429-370ebe039763 h1:JcEMNSPERTTNp/suOToXzOql2RXKvhWuHB/nZ+kNFyA=
github.com/imjaroiswebdev/go-pagerduty v0.0.0-20230820021429-370ebe039763/go.mod h1:t9vftsO1IjYHGdgJXeemZtomCWnxi2SRgu0PRcRb2oY=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
Expand Down
20 changes: 13 additions & 7 deletions vendor/github.com/heimweh/go-pagerduty/pagerduty/pagerduty.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions vendor/github.com/heimweh/go-pagerduty/pagerduty/secure_logger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ github.com/hashicorp/terraform-svchost
# github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
## explicit
github.com/hashicorp/yamux
# github.com/heimweh/go-pagerduty v0.0.0-20230615223713-346f1359a346
# github.com/heimweh/go-pagerduty v0.0.0-20230615223713-346f1359a346 => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20230820021429-370ebe039763
## explicit; go 1.17
github.com/heimweh/go-pagerduty/pagerduty
# github.com/klauspost/compress v1.15.9
Expand Down Expand Up @@ -445,3 +445,4 @@ google.golang.org/protobuf/types/known/anypb
google.golang.org/protobuf/types/known/durationpb
google.golang.org/protobuf/types/known/emptypb
google.golang.org/protobuf/types/known/timestamppb
# github.com/heimweh/go-pagerduty => github.com/imjaroiswebdev/go-pagerduty v0.0.0-20230820021429-370ebe039763
19 changes: 19 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ The following arguments are supported:
* `skip_credentials_validation` - (Optional) Skip validation of the token against the PagerDuty API.
* `service_region` - (Optional) The PagerDuty service region to use. Default to empty (uses US region). Supported value: `eu`.
* `api_url_override` - (Optional) It can be used to set a custom proxy endpoint as PagerDuty client api url overriding `service_region` setup.

## Debugging Provider Output Using Logs

In addition to the [log levels provided by Terraform](https://developer.hashicorp.com/terraform/internals/debugging), namely `TRACE`, `DEBUG`, `INFO`, `WARN`, and `ERROR` (in descending order of verbosity), the PagerDuty Provider introduces an extra level called `SECURE`. This level offers verbosity similar to Terraform's debug logging level, specifically for the output of API calls and HTTP request/response logs. The key difference is that API keys within the request's Authorization header will be obfuscated, revealing only the last four characters. An example is provided below:

```sh
---[ REQUEST ]---------------------------------------
GET /teams/DER8RFS HTTP/1.1
Accept: application/vnd.pagerduty+json;version=2
Authorization: <OBSCURED>kCjQ
Content-Type: application/json
User-Agent: (darwin arm64) Terraform/1.5.1
```

To enable the `SECURE` log level, you must set two environment variables:

* `TF_LOG=INFO`
* `TF_LOG_PROVIDER_PAGERDUTY=SECURE`

0 comments on commit bff6520

Please sign in to comment.