Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Feb 6, 2024
1 parent e3d6526 commit dd35380
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,51 +1039,53 @@ func createMachineAllocationSpec(ds *datastore.RethinkStore, machineRequest v1.M
role = metal.RoleMachine
)

if firewallRequest != nil && firewallRequest.FirewallRules != nil {
if firewallRequest != nil {
role = metal.RoleFirewall

for _, ruleSpec := range firewallRequest.FirewallRules.Egress {
ruleSpec := ruleSpec
if firewallRequest.FirewallRules != nil {
for _, ruleSpec := range firewallRequest.FirewallRules.Egress {
ruleSpec := ruleSpec

protocol, err := metal.ProtocolFromString(ruleSpec.Protocol)
if err != nil {
return nil, err
}
protocol, err := metal.ProtocolFromString(ruleSpec.Protocol)
if err != nil {
return nil, err
}

rule := metal.EgressRule{
Protocol: protocol,
Ports: ruleSpec.Ports,
ToCIDRs: ruleSpec.ToCIDRs,
Comment: ruleSpec.Comment,
}
rule := metal.EgressRule{
Protocol: protocol,
Ports: ruleSpec.Ports,
ToCIDRs: ruleSpec.ToCIDRs,
Comment: ruleSpec.Comment,
}

if err := rule.Validate(); err != nil {
return nil, err
}

if err := rule.Validate(); err != nil {
return nil, err
egress = append(egress, rule)
}

egress = append(egress, rule)
}
for _, ruleSpec := range firewallRequest.FirewallRules.Ingress {
ruleSpec := ruleSpec

for _, ruleSpec := range firewallRequest.FirewallRules.Ingress {
ruleSpec := ruleSpec
protocol, err := metal.ProtocolFromString(ruleSpec.Protocol)
if err != nil {
return nil, err
}

protocol, err := metal.ProtocolFromString(ruleSpec.Protocol)
if err != nil {
return nil, err
}
rule := metal.IngressRule{
Protocol: protocol,
Ports: ruleSpec.Ports,
FromCIDRs: ruleSpec.FromCIDRs,
Comment: ruleSpec.Comment,
}

rule := metal.IngressRule{
Protocol: protocol,
Ports: ruleSpec.Ports,
FromCIDRs: ruleSpec.FromCIDRs,
Comment: ruleSpec.Comment,
}
if err := rule.Validate(); err != nil {
return nil, err
}

if err := rule.Validate(); err != nil {
return nil, err
ingress = append(ingress, rule)
}

ingress = append(ingress, rule)
}
}

Expand Down

0 comments on commit dd35380

Please sign in to comment.