I am trying to call a specific function when invoking this python script, i,e i have multiple functions within this script.
I tried using globals but not dough.
#!/usr/bin/python3
"""
This module is used to access the service account key stored in the secret manager secret
"""
import sys
import argparse
import json
import datetime
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(description='Service account key credential', formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-p', '--project_name',
metavar='<project_name>',
help='GCP project name to retrieve the service account key credential stored in secret manager secret',
required=True)
parser.add_argument('-n', '--secret_name',
metavar='<secret_name>',
help='name of the secret where service account credential is stored',
required=True)
parser.add_argument('-e', '--email_id',
metavar='<email_id>',
help='name of the secret where service account credential is stored',
required=False)
parsers = parser.parse_args()
return parsers
def sa_credentials():
"""
This is the main method to retrieve the secret manager secret which consists of the service account credential
"""
options = parse_arguments()
print(options)
project_name = options.project_name
secret_name = options.secret_name
print("It worked")
if __name__ == "__main__":
globals()[sys.argv[1]]
This is how i am running it, but nothing happens
# ./test.py sa_credentials -p the-webbing-330212 -n my-secret