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 9898 build : yarn build --target aarch64-apple-darwin
9999 - host : ubuntu-latest
100100 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
102104 name : stable - ${{ matrix.settings.target }} - node@22
103105 runs-on : ${{ matrix.settings.host }}
104106 steps :
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ crate-type = ["cdylib"]
1010
1111[dependencies ]
1212anyhow = " 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 " }
1414bollard = " 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 "
1717semver = " 1.0.26"
1818
1919[build-dependencies ]
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ test('smoke test', async (t) => {
4141 let getDeployment = await client . getDeployment ( createDeploymentOptions . name )
4242 t . is ( getDeployment . name , createDeploymentOptions . name )
4343
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+
4450 // Count deployments after creation
4551 let after_create_deployment_count = ( await client . listDeployments ( ) ) . length
4652 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 = [
3838# they are connected to another crate in the graph that hasn't been pruned,
3939# so it should be used with care. The identifiers are [Package ID Specifications]
4040# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
41- # exclude = []
41+ exclude = [" mongodb " ]
4242# If true, metadata will be collected with `--all-features`. Note that this can't
4343# be toggled off if true, if you want to conditionally enable `--all-features` it
4444# 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 {
66 listDeployments ( ) : Promise < Array < Deployment > >
77 deleteDeployment ( deploymentName : string ) : Promise < void >
88 getDeployment ( deploymentName : string ) : Promise < Deployment >
9+ getConnectionString ( options : GetConnectionStringOptions ) : Promise < string >
910}
1011
1112export declare const enum BindingType {
@@ -66,6 +67,12 @@ export interface Deployment {
6667 telemetryBaseUrl ?: string
6768}
6869
70+ export interface GetConnectionStringOptions {
71+ containerIdOrName : string
72+ dbUsername ?: string
73+ dbPassword ?: string
74+ }
75+
6976export interface MongoDbPortBinding {
7077 type : BindingType
7178 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 {
6969 . context ( "get deployment" )
7070 . map ( |d| d. into ( ) )
7171 }
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+ }
7285}
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 11pub mod create_deployment;
2+ pub mod get_connection_string;
23pub mod list_deployments;
You can’t perform that action at this time.
0 commit comments