Skip to content

Commit

Permalink
Merge pull request #171 from SaaShup/fix_container_nonexisting_ports
Browse files Browse the repository at this point in the history
🐛 fix container update on non-existing ports
  • Loading branch information
dzove855 authored Dec 23, 2024
2 parents 5724540 + 09ae07e commit acf4764
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions flows.json
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"host\": msg.config.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"state\": msg.result.State.Status,\t \"operation\": \"none\",\t \"restart_policy\": msg.result.HostConfig.RestartPolicy.Name = \"\" ? \"no\" : msg.result.HostConfig.RestartPolicy.Name,\t \"image\": {\t \"host\": msg.config.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"cap_add\": msg.result.HostConfig.CapAdd,\t \"cap_drop\": msg.result.HostConfig.CapDrop,\t \"extra_hosts\": msg.result.HostConfig.ExtraHosts,\t \"pid_mode\": msg.result.HostConfig.PidMode,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"host\": msg.config.id, \"name\": $k } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"devices\": msg.result.HostConfig.Devices\t ? [\t $map(\t msg.result.HostConfig.Devices,\t function($v, $k) {\t {\t \"container_path\": $v.PathInContainer,\t \"host_path\": $v.PathOnHost\t }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $not($v.RW)\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $not($v.RW)\t }\t }\t )\t ]\t}",
"to": "{\t \"host\": msg.config.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"state\": msg.result.State.Status,\t \"operation\": \"none\",\t \"restart_policy\": msg.result.HostConfig.RestartPolicy.Name = \"\" ? \"no\" : msg.result.HostConfig.RestartPolicy.Name,\t \"image\": {\t \"host\": msg.config.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"cap_add\": msg.result.HostConfig.CapAdd,\t \"cap_drop\": msg.result.HostConfig.CapDrop,\t \"extra_hosts\": msg.result.HostConfig.ExtraHosts,\t \"pid_mode\": msg.result.HostConfig.PidMode,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"host\": msg.config.id, \"name\": $k } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : msg.result.HostConfig.PortBindings ? [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ] : [],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"devices\": msg.result.HostConfig.Devices\t ? [\t $map(\t msg.result.HostConfig.Devices,\t function($v, $k) {\t {\t \"container_path\": $v.PathInContainer,\t \"host_path\": $v.PathOnHost\t }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $not($v.RW)\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $not($v.RW)\t }\t }\t )\t ]\t}",
"tot": "jsonata"
}
],
Expand Down Expand Up @@ -4219,7 +4219,7 @@
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[{\t \"id\": msg.input.data.id,\t \"host\": msg.input.data.host.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"state\": \"created\",\t \"operation\": \"none\",\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"image\": {\t \"host\": msg.input.data.host.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"name\": $k, \"host\": msg.config.id } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : [\t $each(\t msg.result.Config.ExposedPorts,\t function($v, $k) {\t $not($exists($lookup($v,'IP'))) or $lookup($v,'IP') = \"0.0.0.0\"\t ? {\t \"public_port\": $v.PublicPort ? $v.PublicPort : \"0\",\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $v.ReadOnly\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $v.ReadOnly\t }\t }\t )\t ]\t}]",
"to": "[{\t \"id\": msg.input.data.id,\t \"host\": msg.input.data.host.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"state\": \"created\",\t \"operation\": \"none\",\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"image\": {\t \"host\": msg.input.data.host.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"name\": $k, \"host\": msg.config.id } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : msg.result.Config.ExposedPorts ? [\t $each(\t msg.result.Config.ExposedPorts,\t function($v, $k) {\t $not($exists($lookup($v,'IP'))) or $lookup($v,'IP') = \"0.0.0.0\"\t ? {\t \"public_port\": $v.PublicPort ? $v.PublicPort : \"0\",\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ] : [],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $v.ReadOnly\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $v.ReadOnly\t }\t }\t )\t ]\t}]",
"tot": "jsonata"
},
{
Expand Down Expand Up @@ -6242,7 +6242,7 @@
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[{\t \"id\": msg.input.data.id,\t \"host\": msg.input.data.host.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"operation\": \"none\",\t \"state\": msg.result.State.Status,\t \"extra_hosts\": msg.result.HostConfig.ExtraHosts,\t \"restart_policy\": msg.result.HostConfig.RestartPolicy.Name = \"\" ? \"no\" : msg.result.HostConfig.RestartPolicy.Name,\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"image\": {\t \"host\": msg.input.data.host.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"name\": $k, \"host\": msg.config.id } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $not($v.RW)\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $not($v.RW)\t }\t }\t )\t ]\t}]",
"to": "[{\t \"id\": msg.input.data.id,\t \"host\": msg.input.data.host.id,\t \"name\": $replace(msg.result.Name,\"/\",\"\"),\t \"hostname\": msg.result.Config.Hostname,\t \"operation\": \"none\",\t \"state\": msg.result.State.Status,\t \"extra_hosts\": msg.result.HostConfig.ExtraHosts,\t \"restart_policy\": msg.result.HostConfig.RestartPolicy.Name = \"\" ? \"no\" : msg.result.HostConfig.RestartPolicy.Name,\t \"status\": msg.result.State.Status = \"running\"\t ? \"running \" & $ceil(($toMillis($now()) - $toMillis(msg.result.State.StartedAt)) / 1000 / 60 / 60 / 24) & \"d\"\t : \"na\",\t \"image\": {\t \"host\": msg.input.data.host.id,\t \"ImageID\": msg.result.Image\t },\t \"ContainerID\": msg.result.Id,\t \"network_settings\": [\t $each(\t msg.result.NetworkSettings.Networks,\t function($v, $k) {\t { \"network\": { \"name\": $k, \"host\": msg.config.id } }\t }\t )\t ],\t \"ports\": msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ]\t : msg.result.HostConfig.PortBindings ? [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $v[0] = null ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ] : [],\t \"env\": [\t $map(\t msg.result.Config.Env,\t function($v, $k) {\t {\t \"var_name\": $substringBefore($v, \"=\"),\t \"value\": $substringAfter($v, \"=\")\t }\t }\t )\t ],\t \"labels\": [\t $each(\t msg.result.Config.Labels,\t function($v, $k) {\t { \"key\": $k, \"value\": $v }\t }\t )\t ],\t \"mounts\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"volume\"\t ? {\t \"source\": $v.Destination,\t \"volume\": { \"name\": $v.Name, \"host\": msg.config.id },\t \"read_only\": $not($v.RW)\t }\t }\t )\t ],\t \"binds\": [\t $map(\t msg.result.Mounts,\t function($v, $k) {\t $v.Type = \"bind\"\t ? {\t \"host_path\": $v.Source,\t \"container_path\": $v.Destination,\t \"read_only\": $not($v.RW)\t }\t }\t )\t ]\t}]",
"tot": "jsonata"
}
],
Expand Down
Loading

0 comments on commit acf4764

Please sign in to comment.