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

feat(url): Add skip_verify param #22

Merged
merged 1 commit into from
Dec 29, 2024
Merged

Conversation

jouir
Copy link
Contributor

@jouir jouir commented Dec 29, 2024

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.68%. Comparing base (c4248d4) to head (3699397).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #22   +/-   ##
=======================================
  Coverage   94.68%   94.68%           
=======================================
  Files          92       92           
  Lines       39096    39106   +10     
=======================================
+ Hits        37019    37029   +10     
  Misses       1763     1763           
  Partials      314      314           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

url.go Outdated
Comment on lines 93 to 102
if q.Get("skip_verify") == "" {
opt.TLSConfig.InsecureSkipVerify = true
} else {
skipVerify, err := strconv.ParseBool(q.Get("skip_verify"))
if err != nil {
return opt, fmt.Errorf("valkey: invalid skip verify: %q", q.Get("skip_verify"))
}
opt.TLSConfig.InsecureSkipVerify = skipVerify
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if q.Get("skip_verify") == "" {
opt.TLSConfig.InsecureSkipVerify = true
} else {
skipVerify, err := strconv.ParseBool(q.Get("skip_verify"))
if err != nil {
return opt, fmt.Errorf("valkey: invalid skip verify: %q", q.Get("skip_verify"))
}
opt.TLSConfig.InsecureSkipVerify = skipVerify
}
if v := q.Get("skip_verify"); v == "" {
opt.TLSConfig.InsecureSkipVerify = true
} else {
skipVerify, err := strconv.ParseBool(v)
if err != nil {
return opt, fmt.Errorf("valkey: invalid skip verify: %q", v)
}
opt.TLSConfig.InsecureSkipVerify = skipVerify
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM mostly, but the indention on line 97 is wrong, and one minor improvement is you can store the result of q.Get() into a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions applied

Add `skip_verify` or `skip_verify=true` to disable TLS certificate
verification. Default is false.

Inspired by various Go drivers:
- ClickHouse: https://github.com/ClickHouse/clickhouse-go/blob/v2.30.0/clickhouse_options.go#L259
- MongoDB: https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/x/mongo/driver/connstring/connstring.go#L609
- MySQL: https://github.com/go-sql-driver/mysql/blob/v1.8.1/dsn.go#L175

Signed-off-by: Julien Riou <[email protected]>
@rueian rueian merged commit b4b3c96 into valkey-io:main Dec 29, 2024
29 checks passed
rueian pushed a commit that referenced this pull request Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants