Skip to content

Commit

Permalink
Merge pull request #558 from pini-gh/pini-network-internal
Browse files Browse the repository at this point in the history
feat: add `Internal` property to `Network` struct
  • Loading branch information
buchdag authored Dec 9, 2023
2 parents 7d5f43b + 440c599 commit 2c58e80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ type Network struct {
MacAddress string
GlobalIPv6PrefixLen int
IPPrefixLen int
Internal bool
}

type DockerImage struct {
Expand Down
1 change: 1 addition & 0 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Network struct {
MacAddress string
GlobalIPv6PrefixLen int
IPPrefixLen int
Internal bool
}

type Volume struct {
Expand Down
10 changes: 10 additions & 0 deletions internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ func (g *generator) getContainers() ([]*context.RuntimeContainer, error) {
return nil, err
}

apiNetworks, err := g.Client.ListNetworks()
if err != nil {
return nil, err
}
networks := make(map[string]docker.Network)
for _, apiNetwork := range apiNetworks {
networks[apiNetwork.Name] = apiNetwork
}

containers := []*context.RuntimeContainer{}
for _, apiContainer := range apiContainers {
opts := docker.InspectContainerOptions{ID: apiContainer.ID}
Expand Down Expand Up @@ -433,6 +442,7 @@ func (g *generator) getContainers() ([]*context.RuntimeContainer, error) {
MacAddress: v.MacAddress,
GlobalIPv6PrefixLen: v.GlobalIPv6PrefixLen,
IPPrefixLen: v.IPPrefixLen,
Internal: networks[k].Internal,
}

runtimeContainer.Networks = append(runtimeContainer.Networks,
Expand Down

0 comments on commit 2c58e80

Please sign in to comment.