Skip to content

Commit b474e6f

Browse files
aauschclaude
authored andcommitted
fix(ollama): correct local process Inspect and test type mismatches
Three issues from the moby migration in the ollama local process: 1. Inspect() populated Networks with a "bridge" entry, but the old code used an empty map (bridge info was in the deprecated NetworkSettingsBase.Bridge field). Restored empty map. 2. Tests compared port.Proto() (network.IPProtocol) to "tcp" (string). The old nat.Port.Proto() returned string; the new network.Port.Proto() returns network.IPProtocol. Fixed to compare against network.TCP. 3. Tests compared port[0].HostIP (netip.Addr) to "127.0.0.1" (string). The old PortBinding.HostIP was string; the new one is netip.Addr. Fixed to compare against netip.MustParseAddr(testHost). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3bd2ae2 commit b474e6f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

modules/ollama/local.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,7 @@ func (c *localProcess) Inspect(ctx context.Context) (*container.InspectResponse,
490490
Entrypoint: []string{c.binary, localServeArg},
491491
},
492492
NetworkSettings: &container.NetworkSettings{
493-
Networks: map[string]*network.EndpointSettings{
494-
"bridge": {
495-
IPAddress: cIP,
496-
},
497-
},
493+
Networks: map[string]*network.EndpointSettings{},
498494
Ports: network.PortMap{
499495
port: []network.PortBinding{{
500496
HostIP: cIP,

modules/ollama/local_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"io"
77
"io/fs"
8+
"net/netip"
89
"os"
910
"os/exec"
1011
"path/filepath"
@@ -154,7 +155,7 @@ func TestRun_local(t *testing.T) {
154155
port, exists := ports[testNatPort]
155156
require.True(t, exists)
156157
require.Len(t, port, 1)
157-
require.Equal(t, testHost, port[0].HostIP)
158+
require.Equal(t, netip.MustParseAddr(testHost), port[0].HostIP)
158159
require.NotEmpty(t, port[0].HostPort)
159160
})
160161

@@ -180,7 +181,7 @@ func TestRun_local(t *testing.T) {
180181
port, err := ollamaContainer.MappedPort(ctx, testNatPort.String())
181182
require.NoError(t, err)
182183
require.NotEmpty(t, port.Port())
183-
require.Equal(t, "tcp", port.Proto())
184+
require.Equal(t, network.TCP, port.Proto())
184185
})
185186

186187
t.Run("networks", func(t *testing.T) {
@@ -405,7 +406,7 @@ func testRunLocalWithCustomHost(ctx context.Context, t *testing.T, ollamaContain
405406
port, exists := ports[testNatPort]
406407
require.True(t, exists)
407408
require.Len(t, port, 1)
408-
require.Equal(t, testHost, port[0].HostIP)
409+
require.Equal(t, netip.MustParseAddr(testHost), port[0].HostIP)
409410
require.Equal(t, "1234", port[0].HostPort)
410411
})
411412

@@ -426,7 +427,7 @@ func testRunLocalWithCustomHost(ctx context.Context, t *testing.T, ollamaContain
426427
port, err := ollamaContainer.MappedPort(ctx, testNatPort.String())
427428
require.NoError(t, err)
428429
require.Equal(t, "1234", port.Port())
429-
require.Equal(t, "tcp", port.Proto())
430+
require.Equal(t, network.TCP, port.Proto())
430431
})
431432
}
432433

0 commit comments

Comments
 (0)