Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TLS struct keys and adjust field tags to match field names #27

Merged
merged 9 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/param/param.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const endpoint = __ENV.ENDPOINT || "otel-collector:4317"
const client = new tracing.Client({
endpoint,
exporter: tracing.EXPORTER_OTLP,
insecure: true,
tls: {
insecure: true,
}
});

export default function () {
Expand Down Expand Up @@ -45,4 +47,4 @@ export default function () {

export function teardown() {
client.shutdown();
}
}
4 changes: 3 additions & 1 deletion examples/template/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const orgid = __ENV.TEMPO_X_SCOPE_ORGID || "k6-test"
const client = new tracing.Client({
endpoint,
exporter: tracing.EXPORTER_OTLP,
insecure: true,
tls: {
insecure: true,
},
headers: {
"X-Scope-Orgid": orgid
}
Expand Down
26 changes: 18 additions & 8 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,24 @@ func (ct *TracingModule) newTemplatedGenerator(g goja.ConstructorCall, rt *goja.
return rt.ToValue(generator).ToObject(rt)
}

type TLSClientConfig struct {
Insecure bool `js:"insecure"`
InsecureSkipVerify bool `js:"insecure_skip_verify"`
ServerName string `js:"server_name"`
CAFile string `js:"ca_file"`
CertFile string `js:"cert_file"`
KeyFile string `js:"key_file"`
}

type ClientConfig struct {
Exporter exporterType `json:"type"`
Endpoint string `json:"url"`
TLS configtls.TLSClientSetting `json:"tls"`
Exporter exporterType `js:"exporter"`
Endpoint string `js:"endpoint"`
TLS TLSClientConfig `js:"tls"`
Authentication struct {
User string `json:"user"`
Password string `json:"password"`
User string `js:"user"`
Password string `js:"password"`
}
Headers map[string]configopaque.String `json:"headers"`
Headers map[string]configopaque.String `js:"headers"`
}

type Client struct {
Expand All @@ -170,8 +179,9 @@ func NewClient(cfg *ClientConfig, vu modules.VU) (*Client, error) {
)

tlsConfig := configtls.TLSClientSetting{
Insecure: cfg.TLS.Insecure,
ServerName: cfg.TLS.ServerName,
Insecure: cfg.TLS.Insecure,
InsecureSkipVerify: cfg.TLS.InsecureSkipVerify,
ServerName: cfg.TLS.ServerName,
TLSSetting: configtls.TLSSetting{
CAFile: cfg.TLS.CAFile,
CertFile: cfg.TLS.CertFile,
Expand Down
Loading