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
This commit is part of merge request !7. Comments created here will be created in the context of that merge request.
...@@ -29,7 +29,7 @@ export evaluate_return_code, ...@@ -29,7 +29,7 @@ export evaluate_return_code,
CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage
# Exports from module Utility # Exports from module Utility
export get_env_var export get_env_fallback
# Export from module Connection # Export from module Connection
export connect, connect_manually export connect, connect_manually
......
...@@ -364,13 +364,13 @@ function connect_manually(; ...@@ -364,13 +364,13 @@ function connect_manually(;
if host == "" if host == ""
host = CaosDB.Utility.get_env_var("CAOSDB_SERVER_HOST", "localhost") host = CaosDB.Utility.get_env_fallback("CAOSDB_SERVER_HOST", "localhost")
end end
if port_str == "undefined" 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 end
...@@ -378,19 +378,19 @@ function connect_manually(; ...@@ -378,19 +378,19 @@ function connect_manually(;
if cacert == "" if cacert == ""
cacert = CaosDB.Utility.get_env_var("CAOSDB_SERVER_CERT") cacert = CaosDB.Utility.get_env_fallback("CAOSDB_SERVER_CERT")
end end
if username == "" if username == ""
username = CaosDB.Utility.get_env_var("CAOSDB_USER", "admin") username = CaosDB.Utility.get_env_fallback("CAOSDB_USER", "admin")
end end
if password == "undefined" if password == "undefined"
password = CaosDB.Utility.get_env_var("CAOSDB_PASSWORD", "caosdb") password = CaosDB.Utility.get_env_fallback("CAOSDB_PASSWORD", "caosdb")
end end
......
...@@ -22,21 +22,21 @@ ...@@ -22,21 +22,21 @@
# #
module Utility module Utility
export get_env_var export get_env_fallback
using ..CaosDB using ..CaosDB
""" """
get_env_var(var[, default]) get_env_fallback(var[, default])
Return the environmental variable `var` if it exists, `default` Return the environmental variable `var` if it exists, `default`
otherwise. If no `default` is given an empty string is returned otherwise. If no `default` is given an empty string is returned
instead. instead.
""" """
function get_env_var(var::AbstractString, default::AbstractString = "") function get_env_fallback(var::AbstractString, default::AbstractString = "")
ret = ccall( ret = ccall(
(:caosdb_utility_get_env_var, CaosDB.library_name), (:caosdb_utility_get_env_fallback, CaosDB.library_name),
Cstring, Cstring,
(Cstring, Cstring), (Cstring, Cstring),
var, var,
......
...@@ -30,7 +30,7 @@ using CaosDB ...@@ -30,7 +30,7 @@ using CaosDB
else else
shell_var = "default" shell_var = "default"
end end
@test CaosDB.Utility.get_env_var("SHELL", "default") == shell_var @test CaosDB.Utility.get_env_fallback("SHELL", "default") == shell_var
end end
@testset "TestExceptions" begin @testset "TestExceptions" begin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment