From ae33d765b5d6f7f21dfd285e63ef0a5a58566500 Mon Sep 17 00:00:00 2001 From: Gerrit Date: Thu, 15 Feb 2024 09:57:36 +0100 Subject: [PATCH] Default firewall rule protocols as promised. (#502) --- cmd/metal-api/internal/service/machine-service.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/metal-api/internal/service/machine-service.go b/cmd/metal-api/internal/service/machine-service.go index 7e7ab5e86..be1faa0e2 100644 --- a/cmd/metal-api/internal/service/machine-service.go +++ b/cmd/metal-api/internal/service/machine-service.go @@ -1046,6 +1046,10 @@ func createMachineAllocationSpec(ds *datastore.RethinkStore, machineRequest v1.M for _, ruleSpec := range firewallRequest.FirewallRules.Egress { ruleSpec := ruleSpec + if ruleSpec.Protocol == "" { + ruleSpec.Protocol = string(metal.ProtocolTCP) + } + protocol, err := metal.ProtocolFromString(ruleSpec.Protocol) if err != nil { return nil, err @@ -1068,6 +1072,10 @@ func createMachineAllocationSpec(ds *datastore.RethinkStore, machineRequest v1.M for _, ruleSpec := range firewallRequest.FirewallRules.Ingress { ruleSpec := ruleSpec + if ruleSpec.Protocol == "" { + ruleSpec.Protocol = string(metal.ProtocolTCP) + } + protocol, err := metal.ProtocolFromString(ruleSpec.Protocol) if err != nil { return nil, err