@@ -48,12 +48,11 @@ type options struct {
48
48
}
49
49
50
50
type tmplOptions struct {
51
- Opts options
52
- URL string
53
- IncludePath string
54
- Dir string
55
- UserAgent string
56
- ForceUserAgent bool // DOUBT: This is the only way to ensure all the requests have the same User-Agent. Do we want to force it?
51
+ Opts options
52
+ URL string
53
+ IncludePath string
54
+ Dir string
55
+ UserAgent string
57
56
}
58
57
59
58
const configTemplate = `
63
62
urls: [ "{{ .URL }}" ]
64
63
includePaths: [ "{{ .IncludePath }}" ]
65
64
jobs:
66
- {{ if .ForceUserAgent }}
67
- - type: script
68
- parameters:
69
- name: set-user-agent
70
- type: httpsender
71
- action: add
72
- engine: "ECMAScript : Graal.js"
73
- inline: |-
74
- function sendingRequest(msg, initiator, helper) {
75
- msg.getRequestHeader().setHeader("User-Agent", "{{ .UserAgent }}");
76
- }
77
- function responseReceived(msg, initiator, helper) {}
78
- {{ end }}
79
65
{{ if .Opts.OpenapiUrl }}
80
66
- type: openapi
81
67
parameters:
@@ -188,7 +174,7 @@ var portPool *pool = createPortPool(13000, 5)
188
174
189
175
func main () {
190
176
run := func (ctx context.Context , target , assetType , optJSON string , state checkstate.State ) (err error ) {
191
- logger := check .NewCheckLog ( checkName )
177
+ logger := check .NewCheckLogFromContext ( ctx , checkName )
192
178
var opt options
193
179
if optJSON != "" {
194
180
if err = json .Unmarshal ([]byte (optJSON ), & opt ); err != nil {
@@ -229,12 +215,11 @@ func main() {
229
215
}
230
216
sb := new (strings.Builder )
231
217
err = tmpl .Execute (sb , tmplOptions {
232
- Opts : opt ,
233
- URL : targetURL .String (),
234
- Dir : tempDir ,
235
- IncludePath : includePathRegex ,
236
- UserAgent : userAgent ,
237
- ForceUserAgent : false ,
218
+ Opts : opt ,
219
+ URL : targetURL .String (),
220
+ Dir : tempDir ,
221
+ IncludePath : includePathRegex ,
222
+ UserAgent : userAgent ,
238
223
})
239
224
if err != nil {
240
225
return fmt .Errorf ("unable to execute template: %w" , err )
0 commit comments