Skip to content

Commit

Permalink
Fix server struct access in config read, bind expanded path to variable
Browse files Browse the repository at this point in the history
Saves a `Path.expanduser` in the `LakectlConfig.read()`.
  • Loading branch information
nicholasjng committed Aug 30, 2023
1 parent 0214a5f commit e2da0c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lakefs_spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def read(cls, path: str | Path) -> "LakectlConfig":
except ModuleNotFoundError:
return cls()

obj: dict[str, Any] = yaml.safe_load(Path(path).expanduser())
obj: dict[str, Any] = yaml.safe_load(path)

# config struct schema (Golang backend code):
# https://github.com/treeverse/lakeFS/blob/master/cmd/lakectl/cmd/root.go
creds: dict[str, str] = obj.get("credentials", {})
server: dict[str, str] = obj.get("server")
server: dict[str, str] = obj.get("server", {})
username = creds.get("access_key_id")
password = creds.get("secret_access_key")
host = server.get("endpoint_url")
Expand Down Expand Up @@ -219,8 +219,8 @@ def __init__(
"""
super().__init__()

if Path(configfile).expanduser().exists():
lakectl_config = LakectlConfig.read(configfile)
if (p := Path(configfile).expanduser()).exists():
lakectl_config = LakectlConfig.read(p)
else:
# empty config.
lakectl_config = LakectlConfig()
Expand Down

0 comments on commit e2da0c4

Please sign in to comment.