feat: attach vector container to additional docker networks

Adds a new global `vector-networks` property on the logs plugin that takes a comma-separated list of Docker networks. When set, the rendered compose file declares each network plus `bridge` as external and joins them on the vector service, so `docker compose up` reconciles attachments on every `logs:vector-start`. When unset, the existing `network_mode: bridge` template is preserved unchanged. The value is validated against `docker network inspect` at set time, rejects the reserved `bridge` entry, and is surfaced in `dokku logs:report` via `--logs-vector-global-networks`.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-12 22:05:50 -04:00
parent b096d0f131
commit d00a7d741a
7 changed files with 262 additions and 10 deletions

View File

@@ -4,6 +4,9 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
func validateSetValue(appName string, key string, value string) error {
@@ -11,6 +14,10 @@ func validateSetValue(appName string, key string, value string) error {
return validateMaxSize(appName, value)
}
if key == "vector-networks" {
return validateVectorNetworks(appName, value)
}
if key == "vector-sink" {
return validateVectorSink(appName, value)
}
@@ -56,3 +63,30 @@ func validateVectorSink(appName string, value string) error {
return nil
}
func validateVectorNetworks(appName string, value string) error {
if value == "" {
return nil
}
for _, name := range strings.Split(value, ",") {
name = strings.TrimSpace(name)
if name == "" {
return errors.New("Invalid vector-networks value, empty entry in comma-separated list")
}
if name == "bridge" {
return errors.New("Invalid vector-networks value, \"bridge\" is attached by default and must not be listed")
}
result, err := common.CallExecCommand(common.ExecCommandInput{
Command: common.DockerBin(),
Args: []string{"network", "inspect", name},
})
if err != nil || result.ExitCode != 0 {
return fmt.Errorf("Network %q does not exist", name)
}
}
return nil
}