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

[MongoDB] Adding an option to disable TLS #459

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Artie Reader reads from databases to perform historical snapshots and also reads

## Supports:

| | Snapshot | Streaming |
|------------|----------|-----------------|
| DynamoDB | ✅ | ✅ |
| MongoDB | ✅ | 🚧 Experimental |
| MySQL | ✅ | ❌ |
| PostgreSQL | ✅ | ❌ |
| SQL Server | ✅ | ❌ |
| | Snapshot | Streaming |
|------------|----------|-----------|
| DynamoDB | ✅ | ✅ |
| MongoDB | ✅ | |
| MySQL | ✅ | ❌ |
| PostgreSQL | ✅ | ❌ |
| SQL Server | ✅ | ❌ |


## Running
Expand Down
1 change: 1 addition & 0 deletions config/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type MongoDB struct {
Database string `yaml:"database"`
Collections []Collection `yaml:"collections"`
StreamingSettings StreamingSettings `yaml:"streamingSettings,omitempty"`
DisableTLS bool `yaml:"disableTLS"`
}

type Collection struct {
Expand Down
6 changes: 5 additions & 1 deletion sources/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ func Load(cfg config.MongoDB) (*Source, bool, error) {
Password: cfg.Password,
}

opts := options.Client().ApplyURI(cfg.Host).SetAuth(creds).SetTLSConfig(&tls.Config{})
opts := options.Client().ApplyURI(cfg.Host).SetAuth(creds)
if !cfg.DisableTLS {
opts.SetTLSConfig(&tls.Config{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need to be opts := opts.SetTLSConfig(&tls.Config{})?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, but we can add it for more clarity

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

func (c *ClientOptions) SetTLSConfig(cfg *tls.Config) *ClientOptions {
	c.TLSConfig = cfg
	return c
}

}

ctx := context.Background()
client, err := mongo.Connect(ctx, opts)
if err != nil {
Expand Down