File tree Expand file tree Collapse file tree 9 files changed +278
-36
lines changed Expand file tree Collapse file tree 9 files changed +278
-36
lines changed Original file line number Diff line number Diff line change 98
98
build : yarn build --target aarch64-apple-darwin
99
99
- host : ubuntu-latest
100
100
target : aarch64-unknown-linux-gnu
101
- build : yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
101
+ build : |
102
+ export CFLAGS_aarch64_unknown_linux_gnu="-D__ARM_ARCH=8"
103
+ yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
102
104
name : stable - ${{ matrix.settings.target }} - node@22
103
105
runs-on : ${{ matrix.settings.host }}
104
106
steps :
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ crate-type = ["cdylib"]
10
10
11
11
[dependencies ]
12
12
anyhow = " 1.0.99"
13
- atlas-local = { git = " https://github.com/mongodb/atlas-local-lib.git" , rev = " 7d8de1e2b9b865fafeb4120c765b1223d500bbc1 " }
13
+ atlas-local = { git = " https://github.com/mongodb/atlas-local-lib.git" , rev = " df190245295e6675949fb5c63a164fadc0007dab " }
14
14
bollard = " 0.19.2"
15
- napi = { version = " 3.0 .0" , features = [" async" , " anyhow" ] }
16
- napi-derive = " 3.0.0 "
15
+ napi = { version = " ^3.3 .0" , features = [" async" , " anyhow" ] }
16
+ napi-derive = " ^3.2.5 "
17
17
semver = " 1.0.26"
18
18
19
19
[build-dependencies ]
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ test('smoke test', async (t) => {
41
41
let getDeployment = await client . getDeployment ( createDeploymentOptions . name )
42
42
t . is ( getDeployment . name , createDeploymentOptions . name )
43
43
44
+ let getConnectionStringOptions = {
45
+ containerIdOrName : createDeploymentOptions . name ,
46
+ }
47
+ let connString = await client . getConnectionString ( getConnectionStringOptions )
48
+ t . assert ( connString === `mongodb://127.0.0.1:${ getDeployment . portBindings . port } /?directConnection=true` )
49
+
44
50
// Count deployments after creation
45
51
let after_create_deployment_count = ( await client . listDeployments ( ) ) . length
46
52
t . assert ( after_create_deployment_count - start_deployments_count === 1 )
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ targets = [
38
38
# they are connected to another crate in the graph that hasn't been pruned,
39
39
# so it should be used with care. The identifiers are [Package ID Specifications]
40
40
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
41
- # exclude = []
41
+ exclude = [" mongodb " ]
42
42
# If true, metadata will be collected with `--all-features`. Note that this can't
43
43
# be toggled off if true, if you want to conditionally enable `--all-features` it
44
44
# is recommended to pass `--all-features` on the cmd line instead
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export declare class Client {
6
6
listDeployments ( ) : Promise < Array < Deployment > >
7
7
deleteDeployment ( deploymentName : string ) : Promise < void >
8
8
getDeployment ( deploymentName : string ) : Promise < Deployment >
9
+ getConnectionString ( options : GetConnectionStringOptions ) : Promise < string >
9
10
}
10
11
11
12
export declare const enum BindingType {
@@ -66,6 +67,12 @@ export interface Deployment {
66
67
telemetryBaseUrl ?: string
67
68
}
68
69
70
+ export interface GetConnectionStringOptions {
71
+ containerIdOrName : string
72
+ dbUsername ?: string
73
+ dbPassword ?: string
74
+ }
75
+
69
76
export interface MongoDbPortBinding {
70
77
type : BindingType
71
78
ip : string
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -69,4 +69,17 @@ impl Client {
69
69
. context ( "get deployment" )
70
70
. map ( |d| d. into ( ) )
71
71
}
72
+
73
+ #[ napi]
74
+ pub async fn get_connection_string (
75
+ & self ,
76
+ options : crate :: models:: get_connection_string:: GetConnectionStringOptions ,
77
+ ) -> Result < String > {
78
+ let options: atlas_local:: models:: GetConnectionStringOptions = options. into ( ) ;
79
+ self
80
+ . client
81
+ . get_connection_string ( options)
82
+ . await
83
+ . context ( "get connection string" )
84
+ }
72
85
}
Original file line number Diff line number Diff line change
1
+ use napi_derive:: napi;
2
+
3
+ #[ napi( object) ]
4
+ pub struct GetConnectionStringOptions {
5
+ pub container_id_or_name : String ,
6
+ pub db_username : Option < String > ,
7
+ pub db_password : Option < String > ,
8
+ }
9
+
10
+ impl From < GetConnectionStringOptions > for atlas_local:: models:: GetConnectionStringOptions {
11
+ fn from ( source : GetConnectionStringOptions ) -> Self {
12
+ Self {
13
+ container_id_or_name : source. container_id_or_name ,
14
+ db_username : source. db_username ,
15
+ db_password : source. db_password ,
16
+ }
17
+ }
18
+ }
19
+
20
+ // test
21
+ #[ cfg( test) ]
22
+ mod tests {
23
+ use super :: * ;
24
+
25
+ #[ test]
26
+ fn test_get_connection_string_options ( ) {
27
+ let options = GetConnectionStringOptions {
28
+ container_id_or_name : "test_container" . into ( ) ,
29
+ db_username : Some ( "test_user" . into ( ) ) ,
30
+ db_password : Some ( "test_pass" . into ( ) ) ,
31
+ } ;
32
+
33
+ let get_connection_string_options: atlas_local:: models:: GetConnectionStringOptions =
34
+ options. into ( ) ;
35
+
36
+ assert_eq ! (
37
+ get_connection_string_options. container_id_or_name,
38
+ "test_container"
39
+ ) ;
40
+ assert_eq ! (
41
+ get_connection_string_options. db_username,
42
+ Some ( "test_user" . into( ) )
43
+ ) ;
44
+ assert_eq ! (
45
+ get_connection_string_options. db_password,
46
+ Some ( "test_pass" . into( ) )
47
+ ) ;
48
+ }
49
+ }
Original file line number Diff line number Diff line change 1
1
pub mod create_deployment;
2
+ pub mod get_connection_string;
2
3
pub mod list_deployments;
You can’t perform that action at this time.
0 commit comments