fix(err): No port with depends_on

As #182 were not clear, the `depends_on` from a compose file needs, at
this time, to check the port of the dependent service. If the port is
not declared (ports or with label), we need to "fail", not to "warn.

Fixes #182
This commit is contained in:
2026-03-08 22:52:24 +01:00
parent 61896baad8
commit 269717eb1c

View File

@@ -268,13 +268,12 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error {
for _, container := range to.Spec.Template.Spec.Containers { for _, container := range to.Spec.Template.Spec.Containers {
commands := []string{} commands := []string{}
if len(container.Ports) == 0 { if len(container.Ports) == 0 {
logger.Warn("No ports found for service ", logger.Fatal("No ports found for service ",
servicename, servicename,
". You should declare a port in the service or use "+ ". You should declare a port in the service or use "+
labels.LabelPorts+ labels.LabelPorts+
" label.", " label.",
) )
os.Exit(1)
} }
for _, port := range container.Ports { for _, port := range container.Ports {
command := fmt.Sprintf("until nc -z %s %d; do\n sleep 1;\ndone", to.Name, port.ContainerPort) command := fmt.Sprintf("until nc -z %s %d; do\n sleep 1;\ndone", to.Name, port.ContainerPort)