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
|
defp check_type_config("http", config) do
|
||||||
[
|
[
|
||||||
config:
|
http: %HttpCheckConfig{
|
||||||
{:http,
|
url: config["url"] || "",
|
||||||
%HttpCheckConfig{
|
method: config["method"] || "GET",
|
||||||
url: config["url"] || "",
|
expected_status: config["expected_status"] || 200,
|
||||||
method: config["method"] || "GET",
|
verify_ssl: config["verify_ssl"] != false,
|
||||||
expected_status: config["expected_status"] || 200,
|
regex: config["regex"] || "",
|
||||||
verify_ssl: config["verify_ssl"] != false,
|
follow_redirects: config["follow_redirects"] != false
|
||||||
regex: config["regex"] || "",
|
}
|
||||||
follow_redirects: config["follow_redirects"] != false
|
|
||||||
}}
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_type_config("tcp", config) do
|
defp check_type_config("tcp", config) do
|
||||||
[
|
[
|
||||||
config:
|
tcp: %TcpCheckConfig{
|
||||||
{:tcp,
|
host: config["host"] || "",
|
||||||
%TcpCheckConfig{
|
port: config["port"] || 0,
|
||||||
host: config["host"] || "",
|
send: config["send"] || "",
|
||||||
port: config["port"] || 0,
|
expect: config["expect"] || ""
|
||||||
send: config["send"] || "",
|
}
|
||||||
expect: config["expect"] || ""
|
|
||||||
}}
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_type_config("dns", config) do
|
defp check_type_config("dns", config) do
|
||||||
[
|
[
|
||||||
config:
|
dns: %DnsCheckConfig{
|
||||||
{:dns,
|
hostname: config["hostname"] || "",
|
||||||
%DnsCheckConfig{
|
server: config["server"] || "",
|
||||||
hostname: config["hostname"] || "",
|
record_type: config["record_type"] || "A",
|
||||||
server: config["server"] || "",
|
expected: config["expected"] || ""
|
||||||
record_type: config["record_type"] || "A",
|
}
|
||||||
expected: config["expected"] || ""
|
|
||||||
}}
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_type_config("ssl", config) do
|
defp check_type_config("ssl", config) do
|
||||||
[
|
[
|
||||||
config:
|
ssl: %SslCheckConfig{
|
||||||
{:ssl,
|
host: config["host"] || "",
|
||||||
%SslCheckConfig{
|
port: config["port"] || 443,
|
||||||
host: config["host"] || "",
|
warning_days: config["warning_days"] || 30
|
||||||
port: config["port"] || 443,
|
}
|
||||||
warning_days: config["warning_days"] || 30
|
|
||||||
}}
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue