1313import crossplane .function .logging
1414import crossplane .function .proto .v1 .run_function_pb2_grpc as grpcv1
1515import grpc
16- import pip ._internal .cli .main
1716
1817from . import function
1918
@@ -24,7 +23,7 @@ def main():
2423
2524class Main :
2625 async def main (self ):
27- parser = argparse .ArgumentParser ('Forta Crossplane Function' )
26+ parser = argparse .ArgumentParser ('Crossplane Function Pythonic ' )
2827 parser .add_argument (
2928 '--debug' , '-d' ,
3029 action = 'store_true' ,
@@ -40,18 +39,18 @@ async def main(self):
4039 parser .add_argument (
4140 '--address' ,
4241 default = '0.0.0.0:9443' ,
43- help = 'Address at which to listen for gRPC connections, default: 0.0.0.0:9443' ,
42+ help = 'Address to listen on for gRPC connections, default: 0.0.0.0:9443' ,
4443 )
4544 parser .add_argument (
4645 '--tls-certs-dir' ,
4746 default = os .getenv ('TLS_SERVER_CERTS_DIR' ),
4847 metavar = 'DIRECTORY' ,
49- help = 'Serve using mTLS certificates.' ,
48+ help = 'Serve using TLS certificates.' ,
5049 )
5150 parser .add_argument (
5251 '--insecure' ,
5352 action = 'store_true' ,
54- help = 'Run without mTLS credentials. If you supply this flag --tls-certs-dir will be ignored.' ,
53+ help = 'Run without mTLS credentials, --tls-certs-dir will be ignored.' ,
5554 )
5655 parser .add_argument (
5756 '--packages' ,
@@ -97,7 +96,8 @@ async def main(self):
9796 self .configure_logging (args )
9897
9998 if args .pip_install :
100- pip ._internal .cli .main .main (['install' , * shlex .split (args .pip_install )])
99+ import pip ._internal .cli .main
100+ pip ._internal .cli .main .main (['install' , '--user' , * shlex .split (args .pip_install )])
101101
102102 # enables read only volumes or mismatched uid volumes
103103 sys .dont_write_bytecode = True
@@ -128,7 +128,8 @@ async def main(self):
128128 )
129129 else :
130130 if not args .insecure :
131- raise ValueError ('Either --tls-certs-dir or --insecure must be specified' )
131+ print ('Either --tls-certs-dir or --insecure must be specified' , file = sys .stderr )
132+ sys .exit (1 )
132133 grpc_server .add_insecure_port (args .address )
133134 await grpc_server .start ()
134135
0 commit comments