...

Source file src/go.mongodb.org/mongo-driver/mongo/integration/mtest/setup_options.go

Documentation: go.mongodb.org/mongo-driver/mongo/integration/mtest

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package mtest
     8  
     9  // SetupOptions is the type used to configure mtest setup
    10  type SetupOptions struct {
    11  	// Specifies the URI to connect to. Defaults to URI based on the environment variables MONGODB_URI,
    12  	// MONGO_GO_DRIVER_CA_FILE, and MONGO_GO_DRIVER_COMPRESSOR
    13  	URI *string
    14  }
    15  
    16  // NewSetupOptions creates an empty SetupOptions struct
    17  func NewSetupOptions() *SetupOptions {
    18  	return &SetupOptions{}
    19  }
    20  
    21  // SetURI sets the uri to connect to
    22  func (so *SetupOptions) SetURI(uri string) *SetupOptions {
    23  	so.URI = &uri
    24  	return so
    25  }
    26  
    27  // MergeSetupOptions combines the given *SetupOptions into a single *Options in a last one wins fashion.
    28  //
    29  // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a
    30  // single options struct instead.
    31  func MergeSetupOptions(opts ...*SetupOptions) *SetupOptions {
    32  	op := NewSetupOptions()
    33  	for _, opt := range opts {
    34  		if opt == nil {
    35  			continue
    36  		}
    37  		if opt.URI != nil {
    38  			op.URI = opt.URI
    39  		}
    40  	}
    41  	return op
    42  }
    43  

View as plain text