diff --git a/pkg/composer/run.go b/pkg/composer/run.go index 6368d27d638..d88ec688b3c 100644 --- a/pkg/composer/run.go +++ b/pkg/composer/run.go @@ -127,7 +127,7 @@ func (c *Composer) Run(ctx context.Context, ro RunOptions) error { if ro.User != "" { targetSvc.User = ro.User } - if ro.Volume != nil && len(ro.Volume) > 0 { + if len(ro.Volume) > 0 { for _, v := range ro.Volume { vc, err := loader.ParseVolume(v) if err != nil { @@ -136,15 +136,15 @@ func (c *Composer) Run(ctx context.Context, ro RunOptions) error { targetSvc.Volumes = append(targetSvc.Volumes, vc) } } - if ro.Entrypoint != nil && len(ro.Entrypoint) > 0 { + if len(ro.Entrypoint) > 0 { targetSvc.Entrypoint = make([]string, len(ro.Entrypoint)) copy(targetSvc.Entrypoint, ro.Entrypoint) } - if ro.Env != nil && len(ro.Env) > 0 { + if len(ro.Env) > 0 { envs := types.NewMappingWithEquals(ro.Env) targetSvc.Environment.OverrideBy(envs) } - if ro.Label != nil && len(ro.Label) > 0 { + if len(ro.Label) > 0 { label := types.NewMappingWithEquals(ro.Label) for k, v := range label { if v != nil { @@ -161,7 +161,7 @@ func (c *Composer) Run(ctx context.Context, ro RunOptions) error { for k := range svcs { svcs[k].Ports = []types.ServicePortConfig{} } - if ro.Publish != nil && len(ro.Publish) > 0 { + if len(ro.Publish) > 0 { for _, p := range ro.Publish { pc, err := types.ParsePortConfig(p) if err != nil { diff --git a/pkg/containerutil/container_network_manager.go b/pkg/containerutil/container_network_manager.go index 67a49f2dd88..b86870a4eee 100644 --- a/pkg/containerutil/container_network_manager.go +++ b/pkg/containerutil/container_network_manager.go @@ -195,7 +195,7 @@ func (m *containerNetworkManager) VerifyNetworkOptions(_ context.Context) error return errors.New("container networking mode is currently only supported on Linux") } - if m.netOpts.NetworkSlice != nil && len(m.netOpts.NetworkSlice) > 1 { + if len(m.netOpts.NetworkSlice) > 1 { return errors.New("conflicting options: only one network specification is allowed when using '--network=container:'") }