Skip to content

Commit d638e2d

Browse files
committed
fix: fixed bootstrap 'dbname' check
1 parent 950ac9d commit d638e2d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

mamonsu/tools/bootstrap/start.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,15 @@ def __init__(self):
7676
parser.add_option_group(group)
7777
parser.add_option_group(bootstrap_group)
7878
self.args, commands = parser.parse_args()
79-
if len(commands) > 0:
80-
if len(commands) == 1:
81-
self.args.dbname = commands[0]
82-
else:
83-
parser.print_help()
84-
sys.exit(1)
8579
if self.args.dbname is None:
8680
try:
8781
cfg = Config(self.args.config)
8882
self.args.dbname = cfg.fetch('postgres', 'database')
83+
# apply dbname env
84+
os.environ['PGDATABASE'] = self.args.dbname
8985
except Exception as e:
86+
# apply dbname env
87+
os.environ['PGDATABASE'] = self.args.username
9088
sys.stderr.write("ERROR: Database for mamonsu is not specified\n")
9189
sys.stderr.write("{0}\n".format(e))
9290
parser.print_bootstrap_help()
@@ -97,7 +95,6 @@ def __init__(self):
9795
os.environ['PGPASSWORD'] = self.args.password
9896
os.environ['PGHOST'] = self.args.hostname
9997
os.environ['PGPORT'] = str(self.args.port)
100-
os.environ['PGDATABASE'] = self.args.username if self.args.dbname is None else self.args.dbname
10198
os.environ['PGAPPNAME'] = 'mamonsu deploy'
10299

103100
def try_configure_connect_to_pg(self):

0 commit comments

Comments
 (0)