MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / GetNetwork

Method GetNetwork

server-source-code/internal/store/docker.go:729–746  ·  view source on GitHub ↗

GetNetwork returns a network by ID with host info.

(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

727
728// GetNetwork returns a network by ID with host info.
729func (s *DockerStore) GetNetwork(ctx context.Context, id string) (*NetworkDetail, error) {
730 d := s.db.DB(ctx)
731 n, err := d.Queries.GetNetworkByID(ctx, id)
732 if err != nil {
733 return nil, err
734 }
735
736 hostRows, _ := d.Queries.GetDockerHostsByIDs(ctx, []string{n.HostID})
737 var hostPtr *HostInfo
738 if len(hostRows) > 0 {
739 hostPtr = dockerHostDetailRowToHostInfo(hostRows[0])
740 }
741
742 return &NetworkDetail{
743 Network: dbDockerNetworkToModel(n),
744 Hosts: hostPtr,
745 }, nil
746}
747
748// NetworkDetail is network with host.
749type NetworkDetail struct {

Callers

nothing calls this directly

Calls 5

dbDockerNetworkToModelFunction · 0.85
DBMethod · 0.65
GetNetworkByIDMethod · 0.65
GetDockerHostsByIDsMethod · 0.65

Tested by

no test coverage detected