Skip to content

Commit f9b00a8

Browse files
committed
🐛 Fix container's capabilities values and event
The version 1.5.2 introduce some BC break * Capabilities is now prefixed by "CAP_" on a docker inspect * Event data structure change
1 parent fd31ad3 commit f9b00a8

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

flows.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@
12601260
"t": "set",
12611261
"p": "url",
12621262
"pt": "msg",
1263-
"to": "\"http://localhost/containers/\" & msg.payload.id & \"/json -H 'content-type: application/json'\"",
1263+
"to": "\"http://localhost/containers/\" & (msg.payload.id ? msg.payload.id : msg.payload.Actor.ID) & \"/json -H 'content-type: application/json'\"",
12641264
"tot": "jsonata"
12651265
}
12661266
],
@@ -2219,7 +2219,7 @@
22192219
"t": "set",
22202220
"p": "payload",
22212221
"pt": "msg",
2222-
"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(\t (\t $toMillis($now()) - $toMillis(msg.result.State.StartedAt)\t ) / 1000 / 60 / 60 / 24\t ) & \"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 \"HealthCheck\": msg.result.Config.Healthcheck,\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 {\t \"network\": { \"host\": msg.config.id, \"name\": $k } \t }\t }\t )\t ],\t \"ports\":msg.result.HostConfig.PortBindings ? [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $count($v) = 0 or $v[0] = null or $length($v[0].HostPort) = 0 ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ] : msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": -1,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\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\": {\t \"name\": $v.Name,\t \"host\": msg.config.id \t },\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 \"log_driver\": msg.result.HostConfig.LogConfig.Type,\t \"log_driver_options\": [\t $each(\t msg.result.HostConfig.LogConfig.Config,\t function($v, $k) {\t {\t \"option_name\": $k,\t \"value\": $v\t }\t }\t )\t ],\t \"cmd\": msg.result.Config.Cmd\t}",
2222+
"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(\t (\t $toMillis($now()) - $toMillis(msg.result.State.StartedAt)\t ) / 1000 / 60 / 60 / 24\t ) & \"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 \"HealthCheck\": msg.result.Config.Healthcheck,\t \"ContainerID\": msg.result.Id,\t \"cap_add\": msg.result.HostConfig.CapAdd != null ? msg.result.HostConfig.CapAdd.$replace(\"CAP_\", \"\")[] : msg.result.HostConfig.CapAdd,\t \"cap_drop\": msg.result.HostConfig.CapDrop != null ? msg.result.HostConfig.CapDrop.$replace(\"CAP_\", \"\")[] : 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 {\t \"network\": { \"host\": msg.config.id, \"name\": $k } \t }\t }\t )\t ],\t \"ports\":msg.result.HostConfig.PortBindings ? [\t $each(\t msg.result.HostConfig.PortBindings,\t function($v, $k) {\t {\t \"public_port\": $count($v) = 0 or $v[0] = null or $length($v[0].HostPort) = 0 ? 0 : $v[0].HostPort,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\t }\t )\t ] : msg.result.NetworkSettings.Ports\t ? [\t $each(\t msg.result.NetworkSettings.Ports,\t function($v, $k) {\t {\t \"public_port\": -1,\t \"private_port\": $split($k,\"/\")[0],\t \"type\": $split($k,\"/\")[1]\t }\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\": {\t \"name\": $v.Name,\t \"host\": msg.config.id \t },\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 \"log_driver\": msg.result.HostConfig.LogConfig.Type,\t \"log_driver_options\": [\t $each(\t msg.result.HostConfig.LogConfig.Config,\t function($v, $k) {\t {\t \"option_name\": $k,\t \"value\": $v\t }\t }\t )\t ],\t \"cmd\": msg.result.Config.Cmd\t}",
22232223
"tot": "jsonata"
22242224
}
22252225
],

package-lock.json

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netbox-docker-agent",
3-
"version": "1.19.1",
3+
"version": "1.19.2",
44
"description": "Saashup agent for netbox manager",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)