@@ -45,21 +45,27 @@ def stop() -> None:
4545 @staticmethod
4646 def import_data (path : str ) -> None :
4747 subprocess .run (
48- f"topaz import -i -d { path } " ,
48+ f"topaz ds import -i -d { path } " ,
4949 shell = True ,
5050 capture_output = True ,
5151 check = True ,
5252 )
5353
54- def set_manifest (self , manifest_path : str ) -> None :
55- with open (manifest_path , "r" ) as f :
56- manifest = f .read ()
57- resp = requests .post (
58- f"https://{ self .directory_gw .address } /api/v3/directory/manifest" ,
59- data = manifest ,
60- verify = self .directory_gw .ca_cert_path ,
54+ @staticmethod
55+ def set_manifest (manifest_path : str ) -> None :
56+ subprocess .run (
57+ f"topaz ds delete manifest --force" ,
58+ shell = True ,
59+ capture_output = True ,
60+ check = True ,
61+ )
62+
63+ subprocess .run (
64+ f"topaz ds set manifest { manifest_path } " ,
65+ shell = True ,
66+ capture_output = True ,
67+ check = True ,
6168 )
62- resp .raise_for_status ()
6369
6470 def wait_for_ready (self ) -> None :
6571 t0 = datetime .now ()
@@ -93,27 +99,21 @@ def topaz():
9399
94100 time .sleep (1 )
95101
96- subprocess .run (
97- "rm ~/.config/topaz/db/directory.db" ,
98- shell = True ,
99- capture_output = True ,
100- check = True ,
101- )
102-
103102 if os .path .exists (f"{ topaz_db_dir } /directory.bak" ):
104103 os .rename (f"{ topaz_db_dir } /directory.bak" , f"{ topaz_db_dir } /directory.db" )
105104
106105
107106def topaz_configure () -> Topaz :
108107 subprocess .run (
109- "topaz configure -r ghcr.io/aserto-policies/policy-todo:3 -n todo -d -f --enable-v2 " ,
108+ "topaz config new -r ghcr.io/aserto-policies/policy-todo:3 -n todo -d -f" ,
110109 shell = True ,
111110 capture_output = True ,
112111 check = True ,
113112 )
114113
115- ca_cert_path_grpc = os .path .expanduser ("~/.config/topaz/certs/grpc-ca.crt" )
116- ca_cert_path_gw = os .path .expanduser ("~/.config/topaz/certs/gateway-ca.crt" )
114+ cert_path = topaz_cert_path ()
115+ ca_cert_path_grpc = os .path .join (cert_path , "grpc-ca.crt" )
116+ ca_cert_path_gw = os .path .join (cert_path , "gateway-ca.crt" )
117117
118118 return Topaz (
119119 authorizer = Service ("localhost:8282" , ca_cert_path = ca_cert_path_grpc ),
@@ -122,6 +122,16 @@ def topaz_configure() -> Topaz:
122122 )
123123
124124
125+ def topaz_cert_path () -> str :
126+ proc = subprocess .run (
127+ "topaz config info | jq .config.topaz_certs_dir -r" ,
128+ shell = True ,
129+ check = True ,
130+ capture_output = True ,
131+ )
132+ return proc .stdout .decode ().strip ()
133+
134+
125135def connect (svc : Service ) -> grpc .Channel :
126136 return grpc .secure_channel (
127137 target = svc .address , credentials = grpc .ssl_channel_credentials (read_cert (svc .ca_cert_path ))
0 commit comments