Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion cloudfoundry_client/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
from pathlib import Path
import json
from http import HTTPStatus
Expand Down Expand Up @@ -247,7 +248,21 @@ def _get_info(self, target_endpoint: str, proxy: dict | None = None, verify: boo

@staticmethod
def build_from_cf_config(config_path: str | None = None, **kwargs) -> 'CloudFoundryClient':
config = Path(config_path) if config_path else Path.home() / '.cf/config.json'
cf_home = "CF_HOME"
config_file = "config.json"
config_dir = ".cf"
# handles config path provided or defaults to CF_HOME or HOME
if config_path is not None:
config = Path(config_path)
if config.is_dir():
if config.name == config_dir:
config = config / config_file
else:
config = config / config_dir / config_file
elif os.environ.get(cf_home):
config = Path(os.environ.get(cf_home)) / config_dir / config_file
else:
config = Path.home() / config_dir / config_file
try:
with open(config) as f:
cf_config = json.load(f)
Expand Down
Loading