fix: use correct struct field names when building check protobufs (#121)
check_type_config was returning `config: {:http, ...}` but the
Check struct has no :config field — it has :http, :tcp, :dns, :ssl
directly. This caused a KeyError crash in build_and_push_check_jobs.
Reviewed-on: graham/towerops-web#121
This commit is contained in:
parent
3282c664dc
commit
e0a74e2f77
1 changed files with 25 additions and 33 deletions
|
|
@ -910,54 +910,46 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
|
||||
defp check_type_config("http", config) do
|
||||
[
|
||||
config:
|
||||
{:http,
|
||||
%HttpCheckConfig{
|
||||
url: config["url"] || "",
|
||||
method: config["method"] || "GET",
|
||||
expected_status: config["expected_status"] || 200,
|
||||
verify_ssl: config["verify_ssl"] != false,
|
||||
regex: config["regex"] || "",
|
||||
follow_redirects: config["follow_redirects"] != false
|
||||
}}
|
||||
http: %HttpCheckConfig{
|
||||
url: config["url"] || "",
|
||||
method: config["method"] || "GET",
|
||||
expected_status: config["expected_status"] || 200,
|
||||
verify_ssl: config["verify_ssl"] != false,
|
||||
regex: config["regex"] || "",
|
||||
follow_redirects: config["follow_redirects"] != false
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
defp check_type_config("tcp", config) do
|
||||
[
|
||||
config:
|
||||
{:tcp,
|
||||
%TcpCheckConfig{
|
||||
host: config["host"] || "",
|
||||
port: config["port"] || 0,
|
||||
send: config["send"] || "",
|
||||
expect: config["expect"] || ""
|
||||
}}
|
||||
tcp: %TcpCheckConfig{
|
||||
host: config["host"] || "",
|
||||
port: config["port"] || 0,
|
||||
send: config["send"] || "",
|
||||
expect: config["expect"] || ""
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
defp check_type_config("dns", config) do
|
||||
[
|
||||
config:
|
||||
{:dns,
|
||||
%DnsCheckConfig{
|
||||
hostname: config["hostname"] || "",
|
||||
server: config["server"] || "",
|
||||
record_type: config["record_type"] || "A",
|
||||
expected: config["expected"] || ""
|
||||
}}
|
||||
dns: %DnsCheckConfig{
|
||||
hostname: config["hostname"] || "",
|
||||
server: config["server"] || "",
|
||||
record_type: config["record_type"] || "A",
|
||||
expected: config["expected"] || ""
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
defp check_type_config("ssl", config) do
|
||||
[
|
||||
config:
|
||||
{:ssl,
|
||||
%SslCheckConfig{
|
||||
host: config["host"] || "",
|
||||
port: config["port"] || 443,
|
||||
warning_days: config["warning_days"] || 30
|
||||
}}
|
||||
ssl: %SslCheckConfig{
|
||||
host: config["host"] || "",
|
||||
port: config["port"] || 443,
|
||||
warning_days: config["warning_days"] || 30
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue