go.mod: github.com/docker/docker, docker/cli v25.0.5 · jesseduffield/lazydocker@0232610 (original) (raw)

`@@ -16,7 +16,7 @@ import (

`

16

16

` cliconfig "github.com/docker/cli/cli/config"

`

17

17

` ddocker "github.com/docker/cli/cli/context/docker"

`

18

18

` ctxstore "github.com/docker/cli/cli/context/store"

`

19

``

`-

dockerTypes "github.com/docker/docker/api/types"

`

``

19

`+

"github.com/docker/docker/api/types/container"

`

20

20

`"github.com/docker/docker/client"

`

21

21

`"github.com/imdario/mergo"

`

22

22

`"github.com/jesseduffield/lazydocker/pkg/commands/ssh"

`

`@@ -200,9 +200,9 @@ func (c *DockerCommand) RefreshContainersAndServices(currentServices []*Service,

`

200

200

`func (c *DockerCommand) assignContainersToServices(containers []*Container, services []*Service) {

`

201

201

`L:

`

202

202

`for _, service := range services {

`

203

``

`-

for _, container := range containers {

`

204

``

`-

if !container.OneOff && container.ServiceName == service.Name {

`

205

``

`-

service.Container = container

`

``

203

`+

for _, ctr := range containers {

`

``

204

`+

if !ctr.OneOff && ctr.ServiceName == service.Name {

`

``

205

`+

service.Container = ctr

`

206

206

`continue L

`

207

207

` }

`

208

208

` }

`

`@@ -215,19 +215,19 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta

`

215

215

`c.ContainerMutex.Lock()

`

216

216

`defer c.ContainerMutex.Unlock()

`

217

217

``

218

``

`-

containers, err := c.Client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{All: true})

`

``

218

`+

containers, err := c.Client.ContainerList(context.Background(), container.ListOptions{All: true})

`

219

219

`if err != nil {

`

220

220

`return nil, err

`

221

221

` }

`

222

222

``

223

223

`ownContainers := make([]*Container, len(containers))

`

224

224

``

225

``

`-

for i, container := range containers {

`

``

225

`+

for i, ctr := range containers {

`

226

226

`var newContainer *Container

`

227

227

``

228

228

`// check if we already have data stored against the container

`

229

229

`for _, existingContainer := range existingContainers {

`

230

``

`-

if existingContainer.ID == container.ID {

`

``

230

`+

if existingContainer.ID == ctr.ID {

`

231

231

`newContainer = existingContainer

`

232

232

`break

`

233

233

` }

`

`@@ -236,7 +236,7 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta

`

236

236

`// initialise the container if it's completely new

`

237

237

`if newContainer == nil {

`

238

238

`newContainer = &Container{

`

239

``

`-

ID: container.ID,

`

``

239

`+

ID: ctr.ID,

`

240

240

`Client: c.Client,

`

241

241

`OSCommand: c.OSCommand,

`

242

242

`Log: c.Log,

`

`@@ -245,17 +245,17 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta

`

245

245

` }

`

246

246

` }

`

247

247

``

248

``

`-

newContainer.Container = container

`

``

248

`+

newContainer.Container = ctr

`

249

249

`// if the container is made with a name label we will use that

`

250

``

`-

if name, ok := container.Labels["name"]; ok {

`

``

250

`+

if name, ok := ctr.Labels["name"]; ok {

`

251

251

`newContainer.Name = name

`

252

252

` } else {

`

253

``

`-

newContainer.Name = strings.TrimLeft(container.Names[0], "/")

`

``

253

`+

newContainer.Name = strings.TrimLeft(ctr.Names[0], "/")

`

254

254

` }

`

255

``

`-

newContainer.ServiceName = container.Labels["com.docker.compose.service"]

`

256

``

`-

newContainer.ProjectName = container.Labels["com.docker.compose.project"]

`

257

``

`-

newContainer.ContainerNumber = container.Labels["com.docker.compose.container"]

`

258

``

`-

newContainer.OneOff = container.Labels["com.docker.compose.oneoff"] == "True"

`

``

255

`+

newContainer.ServiceName = ctr.Labels["com.docker.compose.service"]

`

``

256

`+

newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]

`

``

257

`+

newContainer.ContainerNumber = ctr.Labels["com.docker.compose.container"]

`

``

258

`+

newContainer.OneOff = ctr.Labels["com.docker.compose.oneoff"] == "True"

`

259

259

``

260

260

`ownContainers[i] = newContainer

`

261

261

` }

`

`@@ -309,15 +309,15 @@ func (c *DockerCommand) RefreshContainerDetails(containers []*Container) error {

`

309

309

`// this contains a bit more info than what you get from the go-docker client

`

310

310

`func (c *DockerCommand) SetContainerDetails(containers []*Container) {

`

311

311

`wg := sync.WaitGroup{}

`

312

``

`-

for _, container := range containers {

`

313

``

`-

container := container

`

``

312

`+

for _, ctr := range containers {

`

``

313

`+

ctr := ctr

`

314

314

`wg.Add(1)

`

315

315

`go func() {

`

316

``

`-

details, err := c.Client.ContainerInspect(context.Background(), container.ID)

`

``

316

`+

details, err := c.Client.ContainerInspect(context.Background(), ctr.ID)

`

317

317

`if err != nil {

`

318

318

`c.Log.Error(err)

`

319

319

` } else {

`

320

``

`-

container.Details = details

`

``

320

`+

ctr.Details = details

`

321

321

` }

`

322

322

`wg.Done()

`

323

323

` }()

`