Skip to content

Commit fa35150

Browse files
authored
website: Logging navigation adjustments, minor HTTP Transport page fixes (#1016)
This adjusts the side navigation so Logging and Testing are more prominent and close to Debugging, which are similar in nature.
1 parent 92520a9 commit fa35150

File tree

2 files changed

+63
-60
lines changed

2 files changed

+63
-60
lines changed

Diff for: website/data/plugin-sdk-nav-data.json

+62-54
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,68 @@
4040
}
4141
]
4242
},
43+
{
44+
"title": "Logging",
45+
"routes": [
46+
{
47+
"title": "Overview",
48+
"path": "logging"
49+
},
50+
{
51+
"title": "Writing Logs",
52+
"href": "/plugin/log/writing"
53+
},
54+
{
55+
"title": "Filtering Logs",
56+
"href": "/plugin/log/filtering"
57+
},
58+
{
59+
"title": "HTTP Transport",
60+
"path": "logging/http-transport"
61+
}
62+
]
63+
},
64+
{
65+
"title": "Testing",
66+
"routes": [
67+
{ "title": "Overview", "path": "testing" },
68+
{
69+
"title": "Acceptance Testing",
70+
"routes": [
71+
{
72+
"title": "Overview",
73+
"path": "testing/acceptance-tests"
74+
},
75+
{
76+
"title": "Test Cases",
77+
"path": "testing/acceptance-tests/testcase"
78+
},
79+
{
80+
"title": "Test Steps",
81+
"path": "testing/acceptance-tests/teststep"
82+
},
83+
{
84+
"title": "Sweepers",
85+
"path": "testing/acceptance-tests/sweepers"
86+
}
87+
]
88+
},
89+
{
90+
"title": "Testing API",
91+
"path": "testing/testing-api",
92+
"hidden": true
93+
},
94+
{
95+
"title": "Testing Patterns",
96+
"path": "testing/testing-patterns",
97+
"hidden": true
98+
},
99+
{
100+
"title": "Unit Testing",
101+
"path": "testing/unit-testing"
102+
}
103+
]
104+
},
43105
{ "title": "Debugging Providers", "path": "debugging" },
44106
{
45107
"title": "Upgrade Guides",
@@ -95,59 +157,5 @@
95157
"path": "best-practices/other-languages"
96158
}
97159
]
98-
},
99-
{
100-
"title": "Logging",
101-
"routes": [
102-
{
103-
"title": "Overview",
104-
"path": "logging"
105-
},
106-
{
107-
"title": "HTTP Transport",
108-
"path": "logging/http-transport"
109-
}
110-
]
111-
},
112-
{
113-
"title": "Testing",
114-
"routes": [
115-
{ "title": "Overview", "path": "testing" },
116-
{
117-
"title": "Acceptance Testing",
118-
"routes": [
119-
{
120-
"title": "Overview",
121-
"path": "testing/acceptance-tests"
122-
},
123-
{
124-
"title": "Test Cases",
125-
"path": "testing/acceptance-tests/testcase"
126-
},
127-
{
128-
"title": "Test Steps",
129-
"path": "testing/acceptance-tests/teststep"
130-
},
131-
{
132-
"title": "Sweepers",
133-
"path": "testing/acceptance-tests/sweepers"
134-
}
135-
]
136-
},
137-
{
138-
"title": "Testing API",
139-
"path": "testing/testing-api",
140-
"hidden": true
141-
},
142-
{
143-
"title": "Testing Patterns",
144-
"path": "testing/testing-patterns",
145-
"hidden": true
146-
},
147-
{
148-
"title": "Unit Testing",
149-
"path": "testing/unit-testing"
150-
}
151-
]
152160
}
153161
]

Diff for: website/docs/plugin/sdkv2/logging/http-transport.mdx

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ We do not recommend using this original helper because it is designed to log the
1212

1313
Instead, we recommend using the [terraform-plugin-log](https://www.terraform.io/plugin/log) library to produce logs for your provider. This library does not present the same security concerns and provides [log filtering](https://www.terraform.io/plugin/log/filtering) functionality. This page explains how to set up the new `RoundTripper()` helper to log HTTP Transactions with `terraform-plugin-log`.
1414

15-
1615
# Setting Up Logging for HTTP Transactions
1716

1817
The recommended logging helper for SDK is built on top of [terraform-plugin-log](https://www.terraform.io/plugin/log). This lets you leverage the features from our structured logging framework without having to write an entire implementation of `http.RoundTripper`.
@@ -24,7 +23,6 @@ There are two functions inside `helper/logging` that target a specific logging s
2423

2524
To set up HTTP transport, you must create the HTTP Client to use the new transport and then add logging configuration to the HTTP request context.
2625

27-
2826
### Creating the HTTP Client
2927

3028
After you create the transport , you must use it to set up the `http.Client` for the provider. The following example sets up the client in `schema.Provider` `ConfigureContextFunc`. The client is identical to the default Golang `http.Client`, except it uses the new logging transport.
@@ -47,7 +45,7 @@ func New() (*schema.Provider, error) {
4745
}
4846
}
4947
}
50-
48+
```
5149

5250
## Adding Context to HTTP Requests
5351

@@ -71,7 +69,6 @@ defer res.Body.Close()
7169

7270
Use the [`(http.Request).WithContext()` method](https://pkg.go.dev/net/http#Request.WithContext) to set the context for the `http.Request` if the request is generated separately from where the `context.Context` is available.
7371

74-
7572
## HTTP Transaction Log Format
7673

7774
The logging transport produces two log entries for each HTTP transaction: one for the request and one for the response.
@@ -176,7 +173,6 @@ Each log contains the following information, which is represented as [fields](ht
176173
| `tf_http_res_version` | Response HTTP version | Ex. `"HTTP/2.0"` | Response |
177174
| (Other fields) | Request / Response headers. One field per header. If the header contains a single value, the log field value is set to that value. Otherwise, the field value is a slice of strings. | | Request / Response |
178175

179-
180176
## Filtering Sensitive Data
181177

182178
To [filter logs](https://www.terraform.io/plugin/log/filtering), you must configure the `context.Context` before before it is added to the `http.Request`.
@@ -200,7 +196,6 @@ if err != nil {
200196
defer res.Body.Close()
201197
```
202198

203-
204199
# Links
205200

206201
* [Plugin Development - Logging](https://www.terraform.io/plugin/log) - Learn more about the logging framework

0 commit comments

Comments
 (0)