Skip to content

Commit

Permalink
fix: avoid potential nil reference in nested map (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
agaffney authored Mar 31, 2024
1 parent 48cea3e commit 620c37c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkgmgr/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (p Package) install(cfg Config, context string, opts map[string]bool) (stri
}
for _, svc := range tmpServices {
shortContainerName := strings.TrimPrefix(svc.ContainerName, pkgName+`-`)
tmpPorts[shortContainerName] = make(map[string]string)
tmpPortsContainer := make(map[string]string)
for _, port := range svc.Ports {
var containerPort, hostPort string
portParts := strings.Split(port, ":")
Expand All @@ -205,8 +205,9 @@ func (p Package) install(cfg Config, context string, opts map[string]bool) (stri
containerPort = portParts[2]
hostPort = portParts[1]
}
tmpPorts[shortContainerName][containerPort] = hostPort
tmpPortsContainer[containerPort] = hostPort
}
tmpPorts[shortContainerName] = tmpPortsContainer
}
cfg.Template = cfg.Template.WithVars(
map[string]any{
Expand Down

0 comments on commit 620c37c

Please sign in to comment.