18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/modal/config.rb', line 18
def self.get_profile(profile_name = nil)
config = read_config_file
profile_name ||= ENV["MODAL_PROFILE"]
unless profile_name
config.each do |name, data|
if data["active"]
profile_name = name
break
end
end
end
if profile_name && !config.key?(profile_name)
raise "Profile \"#{profile_name}\" not found in .modal.toml. Please set the MODAL_PROFILE environment variable or specify a valid profile." unless config.empty?
end
profile_data = profile_name ? (config[profile_name] || {}) : {}
server_url = ENV["MODAL_SERVER_URL"] || profile_data["server_url"] || "https://api.modal.com"
token_id = ENV["MODAL_TOKEN_ID"] || profile_data["token_id"]
token_secret = ENV["MODAL_TOKEN_SECRET"] || profile_data["token_secret"]
environment = ENV["MODAL_ENVIRONMENT"] || profile_data["environment"]
image_builder_version = ENV["MODAL_IMAGE_BUILDER_VERSION"] || profile_data["image_builder_version"] || "2024.10"
unless token_id && token_secret
raise "Profile \"#{profile_name}\" is missing token_id or token_secret. Please set them in .modal.toml or as environment variables."
end
{
server_url: server_url,
token_id: token_id,
token_secret: token_secret,
environment: environment,
image_builder_version: image_builder_version
}
end
|