Skip to content
Snippets Groups Projects
Commit 71f1b13d authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: rename get_env_var to get_env_fallback

parent 0e070706
No related branches found
No related tags found
1 merge request!7ENH: Implement queries and entity retrieval
Pipeline #12552 failed
......@@ -29,7 +29,7 @@ export evaluate_return_code,
CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage
# Exports from module Utility
export get_env_var
export get_env_fallback
# Export from module Connection
export connect, connect_manually
......
......@@ -364,13 +364,13 @@ function connect_manually(;
if host == ""
host = CaosDB.Utility.get_env_var("CAOSDB_SERVER_HOST", "localhost")
host = CaosDB.Utility.get_env_fallback("CAOSDB_SERVER_HOST", "localhost")
end
if port_str == "undefined"
port_str = CaosDB.Utility.get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443")
port_str = CaosDB.Utility.get_env_fallback("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443")
end
......@@ -378,19 +378,19 @@ function connect_manually(;
if cacert == ""
cacert = CaosDB.Utility.get_env_var("CAOSDB_SERVER_CERT")
cacert = CaosDB.Utility.get_env_fallback("CAOSDB_SERVER_CERT")
end
if username == ""
username = CaosDB.Utility.get_env_var("CAOSDB_USER", "admin")
username = CaosDB.Utility.get_env_fallback("CAOSDB_USER", "admin")
end
if password == "undefined"
password = CaosDB.Utility.get_env_var("CAOSDB_PASSWORD", "caosdb")
password = CaosDB.Utility.get_env_fallback("CAOSDB_PASSWORD", "caosdb")
end
......
......@@ -22,21 +22,21 @@
#
module Utility
export get_env_var
export get_env_fallback
using ..CaosDB
"""
get_env_var(var[, default])
get_env_fallback(var[, default])
Return the environmental variable `var` if it exists, `default`
otherwise. If no `default` is given an empty string is returned
instead.
"""
function get_env_var(var::AbstractString, default::AbstractString = "")
function get_env_fallback(var::AbstractString, default::AbstractString = "")
ret = ccall(
(:caosdb_utility_get_env_var, CaosDB.library_name),
(:caosdb_utility_get_env_fallback, CaosDB.library_name),
Cstring,
(Cstring, Cstring),
var,
......
......@@ -30,7 +30,7 @@ using CaosDB
else
shell_var = "default"
end
@test CaosDB.Utility.get_env_var("SHELL", "default") == shell_var
@test CaosDB.Utility.get_env_fallback("SHELL", "default") == shell_var
end
@testset "TestExceptions" begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment