Skip to content

Commit a190c15

Browse files
fix(build): panic: assignment to entry in nil map
panic: assignment to entry in nil map goroutine 13229 [running]: github.com/werf/werf/v2/pkg/build/stage.(*ImageSpecStage).PrepareImage(0xc000e99660, {0x4ead678, 0xc003309980}, {0x10?, 0x2c?}, {0x30?, 0x30?}, 0xc001d454c0?, 0xc0072c25a0, {0x0, ...}) /git/pkg/build/stage/image_spec.go:67 +0x6d5 Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent aca070a commit a190c15

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/build/stage/image_spec.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ func (s *ImageSpecStage) PrepareImage(ctx context.Context, _ Conveyor, _ contain
6363
newConfig.Env = modifyEnv(ctx, imageInfo.Env, s.imageSpec.RemoveEnv, s.imageSpec.Env)
6464
newConfig.Volumes = modifyVolumes(ctx, imageInfo.Volumes, s.imageSpec.RemoveVolumes, s.imageSpec.Volumes)
6565

66-
for _, expose := range s.imageSpec.Expose {
67-
newConfig.ExposedPorts[expose] = struct{}{}
66+
if s.imageSpec.Expose != nil {
67+
newConfig.ExposedPorts = make(map[string]struct{}, len(s.imageSpec.Expose))
68+
for _, expose := range s.imageSpec.Expose {
69+
newConfig.ExposedPorts[expose] = struct{}{}
70+
}
6871
}
6972

7073
if s.imageSpec.Healthcheck != nil {

0 commit comments

Comments
 (0)