id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
14,200
u-root/dhcp4
dhcp4opts/types.go
UnmarshalBinary
func (o *OptionCodes) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *o = make(OptionCodes, 0, b.Len()) for b.Has(1) { *o = append(*o, dhcp4.OptionCode(b.Read8())) } return b.FinError() }
go
func (o *OptionCodes) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *o = make(OptionCodes, 0, b.Len()) for b.Has(1) { *o = append(*o, dhcp4.OptionCode(b.Read8())) } return b.FinError() }
[ "func", "(", "o", "*", "OptionCodes", ")", "UnmarshalBinary", "(", "p", "[", "]", "byte", ")", "error", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "p", ")", "\n", "*", "o", "=", "make", "(", "OptionCodes", ",", "0", ",", "b", ".", "Len", "(", ")", ")", "\n", "for", "b", ".", "Has", "(", "1", ")", "{", "*", "o", "=", "append", "(", "*", "o", ",", "dhcp4", ".", "OptionCode", "(", "b", ".", "Read8", "(", ")", ")", ")", "\n", "}", "\n", "return", "b", ".", "FinError", "(", ")", "\n", "}" ]
// UnmarshalBinary reads the option code list from binary.
[ "UnmarshalBinary", "reads", "the", "option", "code", "list", "from", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/types.go#L168-L175
14,201
u-root/dhcp4
dhcp4opts/types.go
MarshalBinary
func (u Uint16) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(nil) b.Write16(uint16(u)) return b.Data(), nil }
go
func (u Uint16) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(nil) b.Write16(uint16(u)) return b.Data(), nil }
[ "func", "(", "u", "Uint16", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "nil", ")", "\n", "b", ".", "Write16", "(", "uint16", "(", "u", ")", ")", "\n", "return", "b", ".", "Data", "(", ")", ",", "nil", "\n", "}" ]
// MarshalBinary writes the uint16 to binary.
[ "MarshalBinary", "writes", "the", "uint16", "to", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/types.go#L182-L186
14,202
u-root/dhcp4
dhcp4opts/types.go
UnmarshalBinary
func (u *Uint16) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *u = Uint16(b.Read16()) return b.FinError() }
go
func (u *Uint16) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *u = Uint16(b.Read16()) return b.FinError() }
[ "func", "(", "u", "*", "Uint16", ")", "UnmarshalBinary", "(", "p", "[", "]", "byte", ")", "error", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "p", ")", "\n", "*", "u", "=", "Uint16", "(", "b", ".", "Read16", "(", ")", ")", "\n", "return", "b", ".", "FinError", "(", ")", "\n", "}" ]
// UnmarshalBinary reads the uint16 from binary.
[ "UnmarshalBinary", "reads", "the", "uint16", "from", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/types.go#L189-L193
14,203
u-root/dhcp4
dhcp4opts/types.go
MarshalBinary
func (u Uint32) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(nil) b.Write32(uint32(u)) return b.Data(), nil }
go
func (u Uint32) MarshalBinary() ([]byte, error) { b := uio.NewBigEndianBuffer(nil) b.Write32(uint32(u)) return b.Data(), nil }
[ "func", "(", "u", "Uint32", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "nil", ")", "\n", "b", ".", "Write32", "(", "uint32", "(", "u", ")", ")", "\n", "return", "b", ".", "Data", "(", ")", ",", "nil", "\n", "}" ]
// MarshalBinary writes the uint32 to binary.
[ "MarshalBinary", "writes", "the", "uint32", "to", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/types.go#L200-L204
14,204
u-root/dhcp4
dhcp4opts/types.go
UnmarshalBinary
func (u *Uint32) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *u = Uint32(b.Read32()) return b.FinError() }
go
func (u *Uint32) UnmarshalBinary(p []byte) error { b := uio.NewBigEndianBuffer(p) *u = Uint32(b.Read32()) return b.FinError() }
[ "func", "(", "u", "*", "Uint32", ")", "UnmarshalBinary", "(", "p", "[", "]", "byte", ")", "error", "{", "b", ":=", "uio", ".", "NewBigEndianBuffer", "(", "p", ")", "\n", "*", "u", "=", "Uint32", "(", "b", ".", "Read32", "(", ")", ")", "\n", "return", "b", ".", "FinError", "(", ")", "\n", "}" ]
// UnmarshalBinary reads the uint32 from binary.
[ "UnmarshalBinary", "reads", "the", "uint32", "from", "binary", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/types.go#L207-L211
14,205
u-root/dhcp4
dhcp4client/conn_linux.go
NewIPv4UDPConn
func NewIPv4UDPConn(iface string, port int) (net.PacketConn, error) { fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, unix.IPPROTO_UDP) if err != nil { return nil, err } f := os.NewFile(uintptr(fd), "") // net.FilePacketConn dups the FD, so we have to close this in any case. defer f.Close() // Allow broadcasting. if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_BROADCAST, 1); err != nil { return nil, err } // Allow reusing the addr to aid debugging. if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); err != nil { return nil, err } // Bind directly to the interface. if err := unix.BindToDevice(fd, iface); err != nil { return nil, err } // Bind to the port. if err := unix.Bind(fd, &unix.SockaddrInet4{Port: port}); err != nil { return nil, err } return net.FilePacketConn(f) }
go
func NewIPv4UDPConn(iface string, port int) (net.PacketConn, error) { fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, unix.IPPROTO_UDP) if err != nil { return nil, err } f := os.NewFile(uintptr(fd), "") // net.FilePacketConn dups the FD, so we have to close this in any case. defer f.Close() // Allow broadcasting. if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_BROADCAST, 1); err != nil { return nil, err } // Allow reusing the addr to aid debugging. if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); err != nil { return nil, err } // Bind directly to the interface. if err := unix.BindToDevice(fd, iface); err != nil { return nil, err } // Bind to the port. if err := unix.Bind(fd, &unix.SockaddrInet4{Port: port}); err != nil { return nil, err } return net.FilePacketConn(f) }
[ "func", "NewIPv4UDPConn", "(", "iface", "string", ",", "port", "int", ")", "(", "net", ".", "PacketConn", ",", "error", ")", "{", "fd", ",", "err", ":=", "unix", ".", "Socket", "(", "unix", ".", "AF_INET", ",", "unix", ".", "SOCK_DGRAM", ",", "unix", ".", "IPPROTO_UDP", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "f", ":=", "os", ".", "NewFile", "(", "uintptr", "(", "fd", ")", ",", "\"", "\"", ")", "\n", "// net.FilePacketConn dups the FD, so we have to close this in any case.", "defer", "f", ".", "Close", "(", ")", "\n\n", "// Allow broadcasting.", "if", "err", ":=", "unix", ".", "SetsockoptInt", "(", "fd", ",", "unix", ".", "SOL_SOCKET", ",", "unix", ".", "SO_BROADCAST", ",", "1", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Allow reusing the addr to aid debugging.", "if", "err", ":=", "unix", ".", "SetsockoptInt", "(", "fd", ",", "unix", ".", "SOL_SOCKET", ",", "unix", ".", "SO_REUSEADDR", ",", "1", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Bind directly to the interface.", "if", "err", ":=", "unix", ".", "BindToDevice", "(", "fd", ",", "iface", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// Bind to the port.", "if", "err", ":=", "unix", ".", "Bind", "(", "fd", ",", "&", "unix", ".", "SockaddrInet4", "{", "Port", ":", "port", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "net", ".", "FilePacketConn", "(", "f", ")", "\n", "}" ]
// NewIPv4UDPConn returns a UDP connection bound to both the interface and port // given based on a IPv4 DGRAM socket. The UDP connection allows broadcasting.
[ "NewIPv4UDPConn", "returns", "a", "UDP", "connection", "bound", "to", "both", "the", "interface", "and", "port", "given", "based", "on", "a", "IPv4", "DGRAM", "socket", ".", "The", "UDP", "connection", "allows", "broadcasting", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/conn_linux.go#L24-L51
14,206
u-root/dhcp4
dhcp4client/conn_linux.go
NewPacketUDPConn
func NewPacketUDPConn(iface string, port int) (net.PacketConn, error) { ifc, err := net.InterfaceByName(iface) if err != nil { return nil, err } rawConn, err := raw.ListenPacket(ifc, uint16(ethernet.EtherTypeIPv4), &raw.Config{LinuxSockDGRAM: true}) if err != nil { return nil, err } return NewBroadcastUDPConn(rawConn, &net.UDPAddr{Port: port}), nil }
go
func NewPacketUDPConn(iface string, port int) (net.PacketConn, error) { ifc, err := net.InterfaceByName(iface) if err != nil { return nil, err } rawConn, err := raw.ListenPacket(ifc, uint16(ethernet.EtherTypeIPv4), &raw.Config{LinuxSockDGRAM: true}) if err != nil { return nil, err } return NewBroadcastUDPConn(rawConn, &net.UDPAddr{Port: port}), nil }
[ "func", "NewPacketUDPConn", "(", "iface", "string", ",", "port", "int", ")", "(", "net", ".", "PacketConn", ",", "error", ")", "{", "ifc", ",", "err", ":=", "net", ".", "InterfaceByName", "(", "iface", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "rawConn", ",", "err", ":=", "raw", ".", "ListenPacket", "(", "ifc", ",", "uint16", "(", "ethernet", ".", "EtherTypeIPv4", ")", ",", "&", "raw", ".", "Config", "{", "LinuxSockDGRAM", ":", "true", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "NewBroadcastUDPConn", "(", "rawConn", ",", "&", "net", ".", "UDPAddr", "{", "Port", ":", "port", "}", ")", ",", "nil", "\n", "}" ]
// NewPacketUDPConn returns a UDP connection bound to the interface and port // given based on a raw packet socket. All packets are broadcasted.
[ "NewPacketUDPConn", "returns", "a", "UDP", "connection", "bound", "to", "the", "interface", "and", "port", "given", "based", "on", "a", "raw", "packet", "socket", ".", "All", "packets", "are", "broadcasted", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/conn_linux.go#L55-L65
14,207
u-root/dhcp4
dhcp4client/conn_linux.go
NewBroadcastUDPConn
func NewBroadcastUDPConn(rawPacketConn net.PacketConn, boundAddr *net.UDPAddr) net.PacketConn { return &UDPPacketConn{ PacketConn: rawPacketConn, boundAddr: boundAddr, } }
go
func NewBroadcastUDPConn(rawPacketConn net.PacketConn, boundAddr *net.UDPAddr) net.PacketConn { return &UDPPacketConn{ PacketConn: rawPacketConn, boundAddr: boundAddr, } }
[ "func", "NewBroadcastUDPConn", "(", "rawPacketConn", "net", ".", "PacketConn", ",", "boundAddr", "*", "net", ".", "UDPAddr", ")", "net", ".", "PacketConn", "{", "return", "&", "UDPPacketConn", "{", "PacketConn", ":", "rawPacketConn", ",", "boundAddr", ":", "boundAddr", ",", "}", "\n", "}" ]
// NewBroadcastUDPConn returns a PacketConn that marshals and unmarshals UDP // packets, sending them to the broadcast MAC at on rawPacketConn. // // Calls to ReadFrom will only return packets destined to boundAddr.
[ "NewBroadcastUDPConn", "returns", "a", "PacketConn", "that", "marshals", "and", "unmarshals", "UDP", "packets", "sending", "them", "to", "the", "broadcast", "MAC", "at", "on", "rawPacketConn", ".", "Calls", "to", "ReadFrom", "will", "only", "return", "packets", "destined", "to", "boundAddr", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/conn_linux.go#L82-L87
14,208
u-root/dhcp4
dhcp4client/conn_linux.go
ReadFrom
func (upc *UDPPacketConn) ReadFrom(b []byte) (int, net.Addr, error) { ipLen := IPv4MaximumHeaderSize udpLen := UDPMinimumSize for { pkt := make([]byte, ipLen+udpLen+len(b)) n, _, err := upc.PacketConn.ReadFrom(pkt) if err != nil { return 0, nil, err } pkt = pkt[:n] buf := uio.NewBigEndianBuffer(pkt) // To read the header length, access data directly. ipHdr := IPv4(buf.Data()) ipHdr = IPv4(buf.Consume(int(ipHdr.HeaderLength()))) if ipHdr.TransportProtocol() != UDPProtocolNumber { continue } udpHdr := UDP(buf.Consume(udpLen)) addr := &net.UDPAddr{ IP: net.IP(ipHdr.DestinationAddress()), Port: int(udpHdr.DestinationPort()), } if !udpMatch(addr, upc.boundAddr) { continue } return copy(b, buf.ReadAll()), addr, nil } }
go
func (upc *UDPPacketConn) ReadFrom(b []byte) (int, net.Addr, error) { ipLen := IPv4MaximumHeaderSize udpLen := UDPMinimumSize for { pkt := make([]byte, ipLen+udpLen+len(b)) n, _, err := upc.PacketConn.ReadFrom(pkt) if err != nil { return 0, nil, err } pkt = pkt[:n] buf := uio.NewBigEndianBuffer(pkt) // To read the header length, access data directly. ipHdr := IPv4(buf.Data()) ipHdr = IPv4(buf.Consume(int(ipHdr.HeaderLength()))) if ipHdr.TransportProtocol() != UDPProtocolNumber { continue } udpHdr := UDP(buf.Consume(udpLen)) addr := &net.UDPAddr{ IP: net.IP(ipHdr.DestinationAddress()), Port: int(udpHdr.DestinationPort()), } if !udpMatch(addr, upc.boundAddr) { continue } return copy(b, buf.ReadAll()), addr, nil } }
[ "func", "(", "upc", "*", "UDPPacketConn", ")", "ReadFrom", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "net", ".", "Addr", ",", "error", ")", "{", "ipLen", ":=", "IPv4MaximumHeaderSize", "\n", "udpLen", ":=", "UDPMinimumSize", "\n\n", "for", "{", "pkt", ":=", "make", "(", "[", "]", "byte", ",", "ipLen", "+", "udpLen", "+", "len", "(", "b", ")", ")", "\n", "n", ",", "_", ",", "err", ":=", "upc", ".", "PacketConn", ".", "ReadFrom", "(", "pkt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "nil", ",", "err", "\n", "}", "\n", "pkt", "=", "pkt", "[", ":", "n", "]", "\n", "buf", ":=", "uio", ".", "NewBigEndianBuffer", "(", "pkt", ")", "\n\n", "// To read the header length, access data directly.", "ipHdr", ":=", "IPv4", "(", "buf", ".", "Data", "(", ")", ")", "\n", "ipHdr", "=", "IPv4", "(", "buf", ".", "Consume", "(", "int", "(", "ipHdr", ".", "HeaderLength", "(", ")", ")", ")", ")", "\n\n", "if", "ipHdr", ".", "TransportProtocol", "(", ")", "!=", "UDPProtocolNumber", "{", "continue", "\n", "}", "\n", "udpHdr", ":=", "UDP", "(", "buf", ".", "Consume", "(", "udpLen", ")", ")", "\n\n", "addr", ":=", "&", "net", ".", "UDPAddr", "{", "IP", ":", "net", ".", "IP", "(", "ipHdr", ".", "DestinationAddress", "(", ")", ")", ",", "Port", ":", "int", "(", "udpHdr", ".", "DestinationPort", "(", ")", ")", ",", "}", "\n", "if", "!", "udpMatch", "(", "addr", ",", "upc", ".", "boundAddr", ")", "{", "continue", "\n", "}", "\n", "return", "copy", "(", "b", ",", "buf", ".", "ReadAll", "(", ")", ")", ",", "addr", ",", "nil", "\n", "}", "\n", "}" ]
// ReadFrom implements net.PacketConn.ReadFrom. // // ReadFrom reads raw IP packets and will try to match them against // upc.boundAddr. Any matching packets are returned via the given buffer.
[ "ReadFrom", "implements", "net", ".", "PacketConn", ".", "ReadFrom", ".", "ReadFrom", "reads", "raw", "IP", "packets", "and", "will", "try", "to", "match", "them", "against", "upc", ".", "boundAddr", ".", "Any", "matching", "packets", "are", "returned", "via", "the", "given", "buffer", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/conn_linux.go#L103-L134
14,209
u-root/dhcp4
dhcp4client/conn_linux.go
WriteTo
func (upc *UDPPacketConn) WriteTo(b []byte, addr net.Addr) (int, error) { udpAddr, ok := addr.(*net.UDPAddr) if !ok { return 0, fmt.Errorf("must supply UDPAddr") } // Using the boundAddr is not quite right here, but it works. packet := udp4pkt(b, udpAddr, upc.boundAddr) return upc.PacketConn.WriteTo(packet, &raw.Addr{HardwareAddr: BroadcastMac}) }
go
func (upc *UDPPacketConn) WriteTo(b []byte, addr net.Addr) (int, error) { udpAddr, ok := addr.(*net.UDPAddr) if !ok { return 0, fmt.Errorf("must supply UDPAddr") } // Using the boundAddr is not quite right here, but it works. packet := udp4pkt(b, udpAddr, upc.boundAddr) return upc.PacketConn.WriteTo(packet, &raw.Addr{HardwareAddr: BroadcastMac}) }
[ "func", "(", "upc", "*", "UDPPacketConn", ")", "WriteTo", "(", "b", "[", "]", "byte", ",", "addr", "net", ".", "Addr", ")", "(", "int", ",", "error", ")", "{", "udpAddr", ",", "ok", ":=", "addr", ".", "(", "*", "net", ".", "UDPAddr", ")", "\n", "if", "!", "ok", "{", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Using the boundAddr is not quite right here, but it works.", "packet", ":=", "udp4pkt", "(", "b", ",", "udpAddr", ",", "upc", ".", "boundAddr", ")", "\n", "return", "upc", ".", "PacketConn", ".", "WriteTo", "(", "packet", ",", "&", "raw", ".", "Addr", "{", "HardwareAddr", ":", "BroadcastMac", "}", ")", "\n", "}" ]
// WriteTo implements net.PacketConn.WriteTo and broadcasts all packets at the // raw socket level. // // WriteTo wraps the given packet in the appropriate UDP and IP header before // sending it on the packet conn.
[ "WriteTo", "implements", "net", ".", "PacketConn", ".", "WriteTo", "and", "broadcasts", "all", "packets", "at", "the", "raw", "socket", "level", ".", "WriteTo", "wraps", "the", "given", "packet", "in", "the", "appropriate", "UDP", "and", "IP", "header", "before", "sending", "it", "on", "the", "packet", "conn", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/conn_linux.go#L141-L150
14,210
u-root/dhcp4
dhcp4client/ipv4.go
PseudoHeaderChecksum
func PseudoHeaderChecksum(protocol TransportProtocolNumber, srcAddr net.IP, dstAddr net.IP) uint16 { xsum := Checksum([]byte(srcAddr), 0) xsum = Checksum([]byte(dstAddr), xsum) return Checksum([]byte{0, uint8(protocol)}, xsum) }
go
func PseudoHeaderChecksum(protocol TransportProtocolNumber, srcAddr net.IP, dstAddr net.IP) uint16 { xsum := Checksum([]byte(srcAddr), 0) xsum = Checksum([]byte(dstAddr), xsum) return Checksum([]byte{0, uint8(protocol)}, xsum) }
[ "func", "PseudoHeaderChecksum", "(", "protocol", "TransportProtocolNumber", ",", "srcAddr", "net", ".", "IP", ",", "dstAddr", "net", ".", "IP", ")", "uint16", "{", "xsum", ":=", "Checksum", "(", "[", "]", "byte", "(", "srcAddr", ")", ",", "0", ")", "\n", "xsum", "=", "Checksum", "(", "[", "]", "byte", "(", "dstAddr", ")", ",", "xsum", ")", "\n", "return", "Checksum", "(", "[", "]", "byte", "{", "0", ",", "uint8", "(", "protocol", ")", "}", ",", "xsum", ")", "\n", "}" ]
// PseudoHeaderChecksum calculates the pseudo-header checksum for the // given destination protocol and network address, ignoring the length // field. Pseudo-headers are needed by transport layers when calculating // their own checksum.
[ "PseudoHeaderChecksum", "calculates", "the", "pseudo", "-", "header", "checksum", "for", "the", "given", "destination", "protocol", "and", "network", "address", "ignoring", "the", "length", "field", ".", "Pseudo", "-", "headers", "are", "needed", "by", "transport", "layers", "when", "calculating", "their", "own", "checksum", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4client/ipv4.go#L419-L423
14,211
u-root/dhcp4
dhcp4opts/options.go
GetSubnetMask
func GetSubnetMask(o dhcp4.Options) SubnetMask { v := o.Get(dhcp4.OptionSubnetMask) if v == nil { return nil } var s SubnetMask if err := (&s).UnmarshalBinary(v); err != nil { return nil } return s }
go
func GetSubnetMask(o dhcp4.Options) SubnetMask { v := o.Get(dhcp4.OptionSubnetMask) if v == nil { return nil } var s SubnetMask if err := (&s).UnmarshalBinary(v); err != nil { return nil } return s }
[ "func", "GetSubnetMask", "(", "o", "dhcp4", ".", "Options", ")", "SubnetMask", "{", "v", ":=", "o", ".", "Get", "(", "dhcp4", ".", "OptionSubnetMask", ")", "\n", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "var", "s", "SubnetMask", "\n", "if", "err", ":=", "(", "&", "s", ")", ".", "UnmarshalBinary", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "s", "\n", "}" ]
// GetSubnetMask returns the subnet mask of `o`. // // This returns nil if the option is not present or did not contain a valid // value. // // The subnet mask option is defined by RFC 2132, Section 3.3.
[ "GetSubnetMask", "returns", "the", "subnet", "mask", "of", "o", ".", "This", "returns", "nil", "if", "the", "option", "is", "not", "present", "or", "did", "not", "contain", "a", "valid", "value", ".", "The", "subnet", "mask", "option", "is", "defined", "by", "RFC", "2132", "Section", "3", ".", "3", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/options.go#L22-L32
14,212
u-root/dhcp4
dhcp4opts/options.go
GetDHCPMessageType
func GetDHCPMessageType(o dhcp4.Options) DHCPMessageType { v := o.Get(dhcp4.OptionDHCPMessageType) if v == nil { return 0 } var d DHCPMessageType if err := (&d).UnmarshalBinary(v); err != nil { return 0 } return d }
go
func GetDHCPMessageType(o dhcp4.Options) DHCPMessageType { v := o.Get(dhcp4.OptionDHCPMessageType) if v == nil { return 0 } var d DHCPMessageType if err := (&d).UnmarshalBinary(v); err != nil { return 0 } return d }
[ "func", "GetDHCPMessageType", "(", "o", "dhcp4", ".", "Options", ")", "DHCPMessageType", "{", "v", ":=", "o", ".", "Get", "(", "dhcp4", ".", "OptionDHCPMessageType", ")", "\n", "if", "v", "==", "nil", "{", "return", "0", "\n", "}", "\n\n", "var", "d", "DHCPMessageType", "\n", "if", "err", ":=", "(", "&", "d", ")", ".", "UnmarshalBinary", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "0", "\n", "}", "\n", "return", "d", "\n", "}" ]
// GetDHCPMessageType returns the DHCP message type of `o`. // // This returns 0 if the option is not present or did not contain a valid // value. // // The DHCP message type option is defined by RFC 2132, Section 9.6.
[ "GetDHCPMessageType", "returns", "the", "DHCP", "message", "type", "of", "o", ".", "This", "returns", "0", "if", "the", "option", "is", "not", "present", "or", "did", "not", "contain", "a", "valid", "value", ".", "The", "DHCP", "message", "type", "option", "is", "defined", "by", "RFC", "2132", "Section", "9", ".", "6", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/options.go#L299-L310
14,213
u-root/dhcp4
dhcp4opts/options.go
GetParameterRequestList
func GetParameterRequestList(o dhcp4.Options) OptionCodes { v := o.Get(dhcp4.OptionParameterRequestList) if v == nil { return nil } var oc OptionCodes if err := (&oc).UnmarshalBinary(v); err != nil { return nil } return oc }
go
func GetParameterRequestList(o dhcp4.Options) OptionCodes { v := o.Get(dhcp4.OptionParameterRequestList) if v == nil { return nil } var oc OptionCodes if err := (&oc).UnmarshalBinary(v); err != nil { return nil } return oc }
[ "func", "GetParameterRequestList", "(", "o", "dhcp4", ".", "Options", ")", "OptionCodes", "{", "v", ":=", "o", ".", "Get", "(", "dhcp4", ".", "OptionParameterRequestList", ")", "\n", "if", "v", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "var", "oc", "OptionCodes", "\n", "if", "err", ":=", "(", "&", "oc", ")", ".", "UnmarshalBinary", "(", "v", ")", ";", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "oc", "\n", "}" ]
// GetParameterRequestList returns the list of requested DHCP option codes in // `o`. // // This returns nil if the option is not present or did not contain a valid // value. // // The parameter request list option is defined by RFC 2132, Section 9.8.
[ "GetParameterRequestList", "returns", "the", "list", "of", "requested", "DHCP", "option", "codes", "in", "o", ".", "This", "returns", "nil", "if", "the", "option", "is", "not", "present", "or", "did", "not", "contain", "a", "valid", "value", ".", "The", "parameter", "request", "list", "option", "is", "defined", "by", "RFC", "2132", "Section", "9", ".", "8", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/options.go#L319-L329
14,214
u-root/dhcp4
dhcp4opts/options.go
GetMaximumDHCPMessageSize
func GetMaximumDHCPMessageSize(o dhcp4.Options) (uint16, error) { v := o.Get(dhcp4.OptionMaximumDHCPMessageSize) if v == nil { return 0, dhcp4.ErrOptionNotPresent } var u Uint16 return uint16(u), (&u).UnmarshalBinary(v) }
go
func GetMaximumDHCPMessageSize(o dhcp4.Options) (uint16, error) { v := o.Get(dhcp4.OptionMaximumDHCPMessageSize) if v == nil { return 0, dhcp4.ErrOptionNotPresent } var u Uint16 return uint16(u), (&u).UnmarshalBinary(v) }
[ "func", "GetMaximumDHCPMessageSize", "(", "o", "dhcp4", ".", "Options", ")", "(", "uint16", ",", "error", ")", "{", "v", ":=", "o", ".", "Get", "(", "dhcp4", ".", "OptionMaximumDHCPMessageSize", ")", "\n", "if", "v", "==", "nil", "{", "return", "0", ",", "dhcp4", ".", "ErrOptionNotPresent", "\n", "}", "\n", "var", "u", "Uint16", "\n", "return", "uint16", "(", "u", ")", ",", "(", "&", "u", ")", ".", "UnmarshalBinary", "(", "v", ")", "\n", "}" ]
// GetMaximumDHCPMessageSize returns the maximum DHCP message size of `o`. // // The maximum DHCP message size option is defined by RFC 2132, Section 9.10.
[ "GetMaximumDHCPMessageSize", "returns", "the", "maximum", "DHCP", "message", "size", "of", "o", ".", "The", "maximum", "DHCP", "message", "size", "option", "is", "defined", "by", "RFC", "2132", "Section", "9", ".", "10", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/options.go#L334-L341
14,215
u-root/dhcp4
dhcp4opts/options.go
GetIPAddressLeaseTime
func GetIPAddressLeaseTime(o dhcp4.Options) (time.Duration, error) { v := o.Get(dhcp4.OptionIPAddressLeaseTime) if v == nil { return 0, dhcp4.ErrOptionNotPresent } var u Uint32 return time.Duration(u) * time.Second, (&u).UnmarshalBinary(v) }
go
func GetIPAddressLeaseTime(o dhcp4.Options) (time.Duration, error) { v := o.Get(dhcp4.OptionIPAddressLeaseTime) if v == nil { return 0, dhcp4.ErrOptionNotPresent } var u Uint32 return time.Duration(u) * time.Second, (&u).UnmarshalBinary(v) }
[ "func", "GetIPAddressLeaseTime", "(", "o", "dhcp4", ".", "Options", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "v", ":=", "o", ".", "Get", "(", "dhcp4", ".", "OptionIPAddressLeaseTime", ")", "\n", "if", "v", "==", "nil", "{", "return", "0", ",", "dhcp4", ".", "ErrOptionNotPresent", "\n", "}", "\n", "var", "u", "Uint32", "\n", "return", "time", ".", "Duration", "(", "u", ")", "*", "time", ".", "Second", ",", "(", "&", "u", ")", ".", "UnmarshalBinary", "(", "v", ")", "\n", "}" ]
// GetIPAddressLeaseTime returns the proposed lease time. // // The IP address lease time message is defined by RFC 2132, Section 9.2.
[ "GetIPAddressLeaseTime", "returns", "the", "proposed", "lease", "time", ".", "The", "IP", "address", "lease", "time", "message", "is", "defined", "by", "RFC", "2132", "Section", "9", ".", "2", "." ]
03363dc71ec82763595440b4b2c3e5f69f47a4e0
https://github.com/u-root/dhcp4/blob/03363dc71ec82763595440b4b2c3e5f69f47a4e0/dhcp4opts/options.go#L346-L353
14,216
lestrrat-go/jsref
provider/fs.go
Get
func (fp *FS) Get(key *url.URL) (out interface{}, err error) { if pdebug.Enabled { g := pdebug.Marker("provider.FS.Get(%s)", key.String()).BindError(&err) defer g.End() } if strings.ToLower(key.Scheme) != "file" { return nil, errors.New("unsupported scheme '" + key.Scheme + "'") } // Everything other than "Path" is ignored path := filepath.Clean(filepath.Join(fp.Root, key.Path)) mpkey := &url.URL{Path: path} if x, err := fp.mp.Get(mpkey); err == nil { return x, nil } fi, err := os.Stat(path) if err != nil { return nil, errors.Wrap(err, "failed to stat local resource") } if fi.IsDir() { return nil, errors.New("target is not a file") } f, err := os.Open(path) if err != nil { return nil, errors.Wrap(err, "failed to open local resource") } defer f.Close() var x interface{} dec := json.NewDecoder(f) if err := dec.Decode(&x); err != nil { return nil, errors.Wrap(err, "failed to parse JSON local resource") } fp.mp.Set(path, x) return x, nil }
go
func (fp *FS) Get(key *url.URL) (out interface{}, err error) { if pdebug.Enabled { g := pdebug.Marker("provider.FS.Get(%s)", key.String()).BindError(&err) defer g.End() } if strings.ToLower(key.Scheme) != "file" { return nil, errors.New("unsupported scheme '" + key.Scheme + "'") } // Everything other than "Path" is ignored path := filepath.Clean(filepath.Join(fp.Root, key.Path)) mpkey := &url.URL{Path: path} if x, err := fp.mp.Get(mpkey); err == nil { return x, nil } fi, err := os.Stat(path) if err != nil { return nil, errors.Wrap(err, "failed to stat local resource") } if fi.IsDir() { return nil, errors.New("target is not a file") } f, err := os.Open(path) if err != nil { return nil, errors.Wrap(err, "failed to open local resource") } defer f.Close() var x interface{} dec := json.NewDecoder(f) if err := dec.Decode(&x); err != nil { return nil, errors.Wrap(err, "failed to parse JSON local resource") } fp.mp.Set(path, x) return x, nil }
[ "func", "(", "fp", "*", "FS", ")", "Get", "(", "key", "*", "url", ".", "URL", ")", "(", "out", "interface", "{", "}", ",", "err", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ",", "key", ".", "String", "(", ")", ")", ".", "BindError", "(", "&", "err", ")", "\n", "defer", "g", ".", "End", "(", ")", "\n", "}", "\n\n", "if", "strings", ".", "ToLower", "(", "key", ".", "Scheme", ")", "!=", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", "+", "key", ".", "Scheme", "+", "\"", "\"", ")", "\n", "}", "\n\n", "// Everything other than \"Path\" is ignored", "path", ":=", "filepath", ".", "Clean", "(", "filepath", ".", "Join", "(", "fp", ".", "Root", ",", "key", ".", "Path", ")", ")", "\n\n", "mpkey", ":=", "&", "url", ".", "URL", "{", "Path", ":", "path", "}", "\n", "if", "x", ",", "err", ":=", "fp", ".", "mp", ".", "Get", "(", "mpkey", ")", ";", "err", "==", "nil", "{", "return", "x", ",", "nil", "\n", "}", "\n\n", "fi", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "fi", ".", "IsDir", "(", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "var", "x", "interface", "{", "}", "\n", "dec", ":=", "json", ".", "NewDecoder", "(", "f", ")", "\n", "if", "err", ":=", "dec", ".", "Decode", "(", "&", "x", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "fp", ".", "mp", ".", "Set", "(", "path", ",", "x", ")", "\n\n", "return", "x", ",", "nil", "\n", "}" ]
// Get fetches the document specified by the `key` argument. // Everything other than `.Path` is ignored. // Note that once a document is read, it WILL be cached for the // duration of this object, unless you call `Reset`
[ "Get", "fetches", "the", "document", "specified", "by", "the", "key", "argument", ".", "Everything", "other", "than", ".", "Path", "is", "ignored", ".", "Note", "that", "once", "a", "document", "is", "read", "it", "WILL", "be", "cached", "for", "the", "duration", "of", "this", "object", "unless", "you", "call", "Reset" ]
1b590508f37d3af76c77c8328e16978d2889b486
https://github.com/lestrrat-go/jsref/blob/1b590508f37d3af76c77c8328e16978d2889b486/provider/fs.go#L28-L70
14,217
lestrrat-go/jsref
provider/http.go
Get
func (hp *HTTP) Get(key *url.URL) (interface{}, error) { if pdebug.Enabled { g := pdebug.Marker("HTTP.Get(%s)", key) defer g.End() } switch strings.ToLower(key.Scheme) { case "http", "https": default: return nil, errors.New("key is not http/https URL") } v, err := hp.mp.Get(key) if err == nil { // Found! return v, nil } res, err := hp.Client.Get(key.String()) if err != nil { return nil, errors.Wrap(err, "failed to fetch HTTP resource") } defer res.Body.Close() dec := json.NewDecoder(res.Body) var x interface{} if err := dec.Decode(&x); err != nil { return nil, errors.Wrap(err, "failed to parse JSON from HTTP resource") } return x, nil }
go
func (hp *HTTP) Get(key *url.URL) (interface{}, error) { if pdebug.Enabled { g := pdebug.Marker("HTTP.Get(%s)", key) defer g.End() } switch strings.ToLower(key.Scheme) { case "http", "https": default: return nil, errors.New("key is not http/https URL") } v, err := hp.mp.Get(key) if err == nil { // Found! return v, nil } res, err := hp.Client.Get(key.String()) if err != nil { return nil, errors.Wrap(err, "failed to fetch HTTP resource") } defer res.Body.Close() dec := json.NewDecoder(res.Body) var x interface{} if err := dec.Decode(&x); err != nil { return nil, errors.Wrap(err, "failed to parse JSON from HTTP resource") } return x, nil }
[ "func", "(", "hp", "*", "HTTP", ")", "Get", "(", "key", "*", "url", ".", "URL", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "pdebug", ".", "Enabled", "{", "g", ":=", "pdebug", ".", "Marker", "(", "\"", "\"", ",", "key", ")", "\n", "defer", "g", ".", "End", "(", ")", "\n", "}", "\n\n", "switch", "strings", ".", "ToLower", "(", "key", ".", "Scheme", ")", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "default", ":", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "v", ",", "err", ":=", "hp", ".", "mp", ".", "Get", "(", "key", ")", "\n", "if", "err", "==", "nil", "{", "// Found!", "return", "v", ",", "nil", "\n", "}", "\n\n", "res", ",", "err", ":=", "hp", ".", "Client", ".", "Get", "(", "key", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "defer", "res", ".", "Body", ".", "Close", "(", ")", "\n\n", "dec", ":=", "json", ".", "NewDecoder", "(", "res", ".", "Body", ")", "\n\n", "var", "x", "interface", "{", "}", "\n", "if", "err", ":=", "dec", ".", "Decode", "(", "&", "x", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Wrap", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "x", ",", "nil", "\n", "}" ]
// Get fetches the document specified by the `key` argument, making // a HTTP request if necessary. // Note that once a document is read, it WILL be cached for the // duration of this object, unless you call `Reset`
[ "Get", "fetches", "the", "document", "specified", "by", "the", "key", "argument", "making", "a", "HTTP", "request", "if", "necessary", ".", "Note", "that", "once", "a", "document", "is", "read", "it", "WILL", "be", "cached", "for", "the", "duration", "of", "this", "object", "unless", "you", "call", "Reset" ]
1b590508f37d3af76c77c8328e16978d2889b486
https://github.com/lestrrat-go/jsref/blob/1b590508f37d3af76c77c8328e16978d2889b486/provider/http.go#L29-L60
14,218
lestrrat-go/jsref
jsref.go
AddProvider
func (r *Resolver) AddProvider(p Provider) error { r.providers = append(r.providers, p) return nil }
go
func (r *Resolver) AddProvider(p Provider) error { r.providers = append(r.providers, p) return nil }
[ "func", "(", "r", "*", "Resolver", ")", "AddProvider", "(", "p", "Provider", ")", "error", "{", "r", ".", "providers", "=", "append", "(", "r", ".", "providers", ",", "p", ")", "\n", "return", "nil", "\n", "}" ]
// AddProvider adds a new Provider to be searched for in case // a JSON pointer with more than just the URI fragment is given.
[ "AddProvider", "adds", "a", "new", "Provider", "to", "be", "searched", "for", "in", "case", "a", "JSON", "pointer", "with", "more", "than", "just", "the", "URI", "fragment", "is", "given", "." ]
1b590508f37d3af76c77c8328e16978d2889b486
https://github.com/lestrrat-go/jsref/blob/1b590508f37d3af76c77c8328e16978d2889b486/jsref.go#L54-L57
14,219
ory/herodot
negotiator.go
NewNegotiationHandler
func NewNegotiationHandler(logger logrus.FieldLogger) *NegotiationHandler { return &NegotiationHandler{ json: NewJSONWriter(logger), plain: NewTextWriter(logger, "plain"), html: NewTextWriter(logger, "html"), types: []string{ "application/json", }, } }
go
func NewNegotiationHandler(logger logrus.FieldLogger) *NegotiationHandler { return &NegotiationHandler{ json: NewJSONWriter(logger), plain: NewTextWriter(logger, "plain"), html: NewTextWriter(logger, "html"), types: []string{ "application/json", }, } }
[ "func", "NewNegotiationHandler", "(", "logger", "logrus", ".", "FieldLogger", ")", "*", "NegotiationHandler", "{", "return", "&", "NegotiationHandler", "{", "json", ":", "NewJSONWriter", "(", "logger", ")", ",", "plain", ":", "NewTextWriter", "(", "logger", ",", "\"", "\"", ")", ",", "html", ":", "NewTextWriter", "(", "logger", ",", "\"", "\"", ")", ",", "types", ":", "[", "]", "string", "{", "\"", "\"", ",", "}", ",", "}", "\n", "}" ]
// NewNegotiationHandler creates a new NewNegotiationHandler.
[ "NewNegotiationHandler", "creates", "a", "new", "NewNegotiationHandler", "." ]
60b8dd877ce7ed74f961a4eede7989511ce7b68a
https://github.com/ory/herodot/blob/60b8dd877ce7ed74f961a4eede7989511ce7b68a/negotiator.go#L19-L28
14,220
ory/herodot
plain.go
NewTextWriter
func NewTextWriter(logger logrus.FieldLogger, contentType string) *TextWriter { if contentType == "" { contentType = "plain" } writer := &TextWriter{ logger: logger, contentType: "text/" + contentType, } writer.Reporter = DefaultErrorReporter return writer }
go
func NewTextWriter(logger logrus.FieldLogger, contentType string) *TextWriter { if contentType == "" { contentType = "plain" } writer := &TextWriter{ logger: logger, contentType: "text/" + contentType, } writer.Reporter = DefaultErrorReporter return writer }
[ "func", "NewTextWriter", "(", "logger", "logrus", ".", "FieldLogger", ",", "contentType", "string", ")", "*", "TextWriter", "{", "if", "contentType", "==", "\"", "\"", "{", "contentType", "=", "\"", "\"", "\n", "}", "\n\n", "writer", ":=", "&", "TextWriter", "{", "logger", ":", "logger", ",", "contentType", ":", "\"", "\"", "+", "contentType", ",", "}", "\n\n", "writer", ".", "Reporter", "=", "DefaultErrorReporter", "\n", "return", "writer", "\n", "}" ]
// NewPlainWriter returns a json
[ "NewPlainWriter", "returns", "a", "json" ]
60b8dd877ce7ed74f961a4eede7989511ce7b68a
https://github.com/ory/herodot/blob/60b8dd877ce7ed74f961a4eede7989511ce7b68a/plain.go#L39-L51
14,221
ory/herodot
json.go
NewJSONWriter
func NewJSONWriter(logger logrus.FieldLogger) *JSONWriter { writer := &JSONWriter{logger: logger} writer.Reporter = DefaultErrorReporter writer.ErrorEnhancer = defaultJSONErrorEnhancer return writer }
go
func NewJSONWriter(logger logrus.FieldLogger) *JSONWriter { writer := &JSONWriter{logger: logger} writer.Reporter = DefaultErrorReporter writer.ErrorEnhancer = defaultJSONErrorEnhancer return writer }
[ "func", "NewJSONWriter", "(", "logger", "logrus", ".", "FieldLogger", ")", "*", "JSONWriter", "{", "writer", ":=", "&", "JSONWriter", "{", "logger", ":", "logger", "}", "\n\n", "writer", ".", "Reporter", "=", "DefaultErrorReporter", "\n", "writer", ".", "ErrorEnhancer", "=", "defaultJSONErrorEnhancer", "\n", "return", "writer", "\n", "}" ]
// NewJSONWriter returns a json
[ "NewJSONWriter", "returns", "a", "json" ]
60b8dd877ce7ed74f961a4eede7989511ce7b68a
https://github.com/ory/herodot/blob/60b8dd877ce7ed74f961a4eede7989511ce7b68a/json.go#L44-L50
14,222
docker/libcompose
cli/docker/app/factory.go
Create
func (p *ProjectFactory) Create(c *cli.Context) (project.APIProject, error) { context := &ctx.Context{} context.LoggerFactory = logger.NewColorLoggerFactory() Populate(context, c) return docker.NewProject(context, nil) }
go
func (p *ProjectFactory) Create(c *cli.Context) (project.APIProject, error) { context := &ctx.Context{} context.LoggerFactory = logger.NewColorLoggerFactory() Populate(context, c) return docker.NewProject(context, nil) }
[ "func", "(", "p", "*", "ProjectFactory", ")", "Create", "(", "c", "*", "cli", ".", "Context", ")", "(", "project", ".", "APIProject", ",", "error", ")", "{", "context", ":=", "&", "ctx", ".", "Context", "{", "}", "\n", "context", ".", "LoggerFactory", "=", "logger", ".", "NewColorLoggerFactory", "(", ")", "\n", "Populate", "(", "context", ",", "c", ")", "\n", "return", "docker", ".", "NewProject", "(", "context", ",", "nil", ")", "\n", "}" ]
// Create implements ProjectFactory.Create using docker client.
[ "Create", "implements", "ProjectFactory", ".", "Create", "using", "docker", "client", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/docker/app/factory.go#L16-L21
14,223
docker/libcompose
docker/volume/volume.go
Inspect
func (v *Volume) Inspect(ctx context.Context) (types.Volume, error) { return v.client.VolumeInspect(ctx, v.fullName()) }
go
func (v *Volume) Inspect(ctx context.Context) (types.Volume, error) { return v.client.VolumeInspect(ctx, v.fullName()) }
[ "func", "(", "v", "*", "Volume", ")", "Inspect", "(", "ctx", "context", ".", "Context", ")", "(", "types", ".", "Volume", ",", "error", ")", "{", "return", "v", ".", "client", ".", "VolumeInspect", "(", "ctx", ",", "v", ".", "fullName", "(", ")", ")", "\n", "}" ]
// Inspect inspect the current volume
[ "Inspect", "inspect", "the", "current", "volume" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/volume/volume.go#L35-L37
14,224
docker/libcompose
docker/volume/volume.go
EnsureItExists
func (v *Volume) EnsureItExists(ctx context.Context) error { volumeResource, err := v.Inspect(ctx) if v.external { if client.IsErrNotFound(err) { // FIXME(shouze) introduce some libcompose error type return fmt.Errorf("Volume %s declared as external, but could not be found. Please create the volume manually using docker volume create %s and try again", v.name, v.name) } return err } if err != nil && client.IsErrNotFound(err) { return v.create(ctx) } if volumeResource.Driver != v.driver { return fmt.Errorf("Volume %q needs to be recreated - driver has changed", v.name) } return err }
go
func (v *Volume) EnsureItExists(ctx context.Context) error { volumeResource, err := v.Inspect(ctx) if v.external { if client.IsErrNotFound(err) { // FIXME(shouze) introduce some libcompose error type return fmt.Errorf("Volume %s declared as external, but could not be found. Please create the volume manually using docker volume create %s and try again", v.name, v.name) } return err } if err != nil && client.IsErrNotFound(err) { return v.create(ctx) } if volumeResource.Driver != v.driver { return fmt.Errorf("Volume %q needs to be recreated - driver has changed", v.name) } return err }
[ "func", "(", "v", "*", "Volume", ")", "EnsureItExists", "(", "ctx", "context", ".", "Context", ")", "error", "{", "volumeResource", ",", "err", ":=", "v", ".", "Inspect", "(", "ctx", ")", "\n", "if", "v", ".", "external", "{", "if", "client", ".", "IsErrNotFound", "(", "err", ")", "{", "// FIXME(shouze) introduce some libcompose error type", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ".", "name", ",", "v", ".", "name", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "if", "err", "!=", "nil", "&&", "client", ".", "IsErrNotFound", "(", "err", ")", "{", "return", "v", ".", "create", "(", "ctx", ")", "\n", "}", "\n", "if", "volumeResource", ".", "Driver", "!=", "v", ".", "driver", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "v", ".", "name", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// EnsureItExists make sure the volume exists and return an error if it does not exists // and cannot be created.
[ "EnsureItExists", "make", "sure", "the", "volume", "exists", "and", "return", "an", "error", "if", "it", "does", "not", "exists", "and", "cannot", "be", "created", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/volume/volume.go#L51-L67
14,225
docker/libcompose
docker/volume/volume.go
NewVolume
func NewVolume(projectName, name string, config *config.VolumeConfig, client client.VolumeAPIClient) *Volume { vol := &Volume{ client: client, projectName: projectName, name: name, } if config != nil { vol.driver = config.Driver vol.driverOptions = config.DriverOpts vol.external = config.External.External } return vol }
go
func NewVolume(projectName, name string, config *config.VolumeConfig, client client.VolumeAPIClient) *Volume { vol := &Volume{ client: client, projectName: projectName, name: name, } if config != nil { vol.driver = config.Driver vol.driverOptions = config.DriverOpts vol.external = config.External.External } return vol }
[ "func", "NewVolume", "(", "projectName", ",", "name", "string", ",", "config", "*", "config", ".", "VolumeConfig", ",", "client", "client", ".", "VolumeAPIClient", ")", "*", "Volume", "{", "vol", ":=", "&", "Volume", "{", "client", ":", "client", ",", "projectName", ":", "projectName", ",", "name", ":", "name", ",", "}", "\n", "if", "config", "!=", "nil", "{", "vol", ".", "driver", "=", "config", ".", "Driver", "\n", "vol", ".", "driverOptions", "=", "config", ".", "DriverOpts", "\n", "vol", ".", "external", "=", "config", ".", "External", ".", "External", "\n\n", "}", "\n", "return", "vol", "\n", "}" ]
// NewVolume creates a new volume from the specified name and config.
[ "NewVolume", "creates", "a", "new", "volume", "from", "the", "specified", "name", "and", "config", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/volume/volume.go#L82-L95
14,226
docker/libcompose
docker/volume/volume.go
VolumesFromServices
func VolumesFromServices(cli client.VolumeAPIClient, projectName string, volumeConfigs map[string]*config.VolumeConfig, services *config.ServiceConfigs, volumeEnabled bool) (*Volumes, error) { var err error volumes := make([]*Volume, 0, len(volumeConfigs)) for name, config := range volumeConfigs { volume := NewVolume(projectName, name, config, cli) volumes = append(volumes, volume) } return &Volumes{ volumes: volumes, volumeEnabled: volumeEnabled, }, err }
go
func VolumesFromServices(cli client.VolumeAPIClient, projectName string, volumeConfigs map[string]*config.VolumeConfig, services *config.ServiceConfigs, volumeEnabled bool) (*Volumes, error) { var err error volumes := make([]*Volume, 0, len(volumeConfigs)) for name, config := range volumeConfigs { volume := NewVolume(projectName, name, config, cli) volumes = append(volumes, volume) } return &Volumes{ volumes: volumes, volumeEnabled: volumeEnabled, }, err }
[ "func", "VolumesFromServices", "(", "cli", "client", ".", "VolumeAPIClient", ",", "projectName", "string", ",", "volumeConfigs", "map", "[", "string", "]", "*", "config", ".", "VolumeConfig", ",", "services", "*", "config", ".", "ServiceConfigs", ",", "volumeEnabled", "bool", ")", "(", "*", "Volumes", ",", "error", ")", "{", "var", "err", "error", "\n", "volumes", ":=", "make", "(", "[", "]", "*", "Volume", ",", "0", ",", "len", "(", "volumeConfigs", ")", ")", "\n", "for", "name", ",", "config", ":=", "range", "volumeConfigs", "{", "volume", ":=", "NewVolume", "(", "projectName", ",", "name", ",", "config", ",", "cli", ")", "\n", "volumes", "=", "append", "(", "volumes", ",", "volume", ")", "\n", "}", "\n", "return", "&", "Volumes", "{", "volumes", ":", "volumes", ",", "volumeEnabled", ":", "volumeEnabled", ",", "}", ",", "err", "\n", "}" ]
// VolumesFromServices creates a new Volumes struct based on volumes configurations and // services configuration. If a volume is defined but not used by any service, it will return // an error along the Volumes.
[ "VolumesFromServices", "creates", "a", "new", "Volumes", "struct", "based", "on", "volumes", "configurations", "and", "services", "configuration", ".", "If", "a", "volume", "is", "defined", "but", "not", "used", "by", "any", "service", "it", "will", "return", "an", "error", "along", "the", "Volumes", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/volume/volume.go#L134-L145
14,227
docker/libcompose
docker/ctx/context.go
LookupConfig
func (c *Context) LookupConfig() error { if c.ConfigFile != nil { return nil } config, err := cliconfig.Load(c.ConfigDir) if err != nil { return err } c.ConfigFile = config return nil }
go
func (c *Context) LookupConfig() error { if c.ConfigFile != nil { return nil } config, err := cliconfig.Load(c.ConfigDir) if err != nil { return err } c.ConfigFile = config return nil }
[ "func", "(", "c", "*", "Context", ")", "LookupConfig", "(", ")", "error", "{", "if", "c", ".", "ConfigFile", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "config", ",", "err", ":=", "cliconfig", ".", "Load", "(", "c", ".", "ConfigDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "c", ".", "ConfigFile", "=", "config", "\n\n", "return", "nil", "\n", "}" ]
// LookupConfig tries to load the docker configuration files, if any.
[ "LookupConfig", "tries", "to", "load", "the", "docker", "configuration", "files", "if", "any", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/ctx/context.go#L22-L35
14,228
docker/libcompose
docker/container/functions.go
ListByFilter
func ListByFilter(ctx context.Context, clientInstance client.ContainerAPIClient, containerFilters ...map[string][]string) ([]types.Container, error) { filterArgs := filters.NewArgs() // FIXME(vdemeester) I don't like 3 for loops >_< for _, filter := range containerFilters { for key, filterValue := range filter { for _, value := range filterValue { filterArgs.Add(key, value) } } } return clientInstance.ContainerList(ctx, types.ContainerListOptions{ All: true, Filters: filterArgs, }) }
go
func ListByFilter(ctx context.Context, clientInstance client.ContainerAPIClient, containerFilters ...map[string][]string) ([]types.Container, error) { filterArgs := filters.NewArgs() // FIXME(vdemeester) I don't like 3 for loops >_< for _, filter := range containerFilters { for key, filterValue := range filter { for _, value := range filterValue { filterArgs.Add(key, value) } } } return clientInstance.ContainerList(ctx, types.ContainerListOptions{ All: true, Filters: filterArgs, }) }
[ "func", "ListByFilter", "(", "ctx", "context", ".", "Context", ",", "clientInstance", "client", ".", "ContainerAPIClient", ",", "containerFilters", "...", "map", "[", "string", "]", "[", "]", "string", ")", "(", "[", "]", "types", ".", "Container", ",", "error", ")", "{", "filterArgs", ":=", "filters", ".", "NewArgs", "(", ")", "\n\n", "// FIXME(vdemeester) I don't like 3 for loops >_<", "for", "_", ",", "filter", ":=", "range", "containerFilters", "{", "for", "key", ",", "filterValue", ":=", "range", "filter", "{", "for", "_", ",", "value", ":=", "range", "filterValue", "{", "filterArgs", ".", "Add", "(", "key", ",", "value", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "clientInstance", ".", "ContainerList", "(", "ctx", ",", "types", ".", "ContainerListOptions", "{", "All", ":", "true", ",", "Filters", ":", "filterArgs", ",", "}", ")", "\n", "}" ]
// ListByFilter looks up the hosts containers with the specified filters and // returns a list of container matching it, or an error.
[ "ListByFilter", "looks", "up", "the", "hosts", "containers", "with", "the", "specified", "filters", "and", "returns", "a", "list", "of", "container", "matching", "it", "or", "an", "error", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/functions.go#L12-L28
14,229
docker/libcompose
docker/container/functions.go
Get
func Get(ctx context.Context, clientInstance client.ContainerAPIClient, id string) (*types.ContainerJSON, error) { container, err := clientInstance.ContainerInspect(ctx, id) if err != nil { if client.IsErrNotFound(err) { return nil, nil } return nil, err } return &container, nil }
go
func Get(ctx context.Context, clientInstance client.ContainerAPIClient, id string) (*types.ContainerJSON, error) { container, err := clientInstance.ContainerInspect(ctx, id) if err != nil { if client.IsErrNotFound(err) { return nil, nil } return nil, err } return &container, nil }
[ "func", "Get", "(", "ctx", "context", ".", "Context", ",", "clientInstance", "client", ".", "ContainerAPIClient", ",", "id", "string", ")", "(", "*", "types", ".", "ContainerJSON", ",", "error", ")", "{", "container", ",", "err", ":=", "clientInstance", ".", "ContainerInspect", "(", "ctx", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "if", "client", ".", "IsErrNotFound", "(", "err", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "container", ",", "nil", "\n", "}" ]
// Get looks up the hosts containers with the specified ID // or name and returns it, or an error.
[ "Get", "looks", "up", "the", "hosts", "containers", "with", "the", "specified", "ID", "or", "name", "and", "returns", "it", "or", "an", "error", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/functions.go#L32-L41
14,230
docker/libcompose
lookup/file.go
relativePath
func relativePath(file, relativeTo string) string { // stdin: return the current working directory if possible. if relativeTo == "-" { if cwd, err := os.Getwd(); err == nil { return filepath.Join(cwd, file) } } // If the given file is already an absolute path, just return it. // Otherwise, the returned path will be relative to the given relativeTo // path. if filepath.IsAbs(file) { return file } abs, err := filepath.Abs(filepath.Join(path.Dir(relativeTo), file)) if err != nil { logrus.Errorf("Failed to get absolute directory: %s", err) return file } return abs }
go
func relativePath(file, relativeTo string) string { // stdin: return the current working directory if possible. if relativeTo == "-" { if cwd, err := os.Getwd(); err == nil { return filepath.Join(cwd, file) } } // If the given file is already an absolute path, just return it. // Otherwise, the returned path will be relative to the given relativeTo // path. if filepath.IsAbs(file) { return file } abs, err := filepath.Abs(filepath.Join(path.Dir(relativeTo), file)) if err != nil { logrus.Errorf("Failed to get absolute directory: %s", err) return file } return abs }
[ "func", "relativePath", "(", "file", ",", "relativeTo", "string", ")", "string", "{", "// stdin: return the current working directory if possible.", "if", "relativeTo", "==", "\"", "\"", "{", "if", "cwd", ",", "err", ":=", "os", ".", "Getwd", "(", ")", ";", "err", "==", "nil", "{", "return", "filepath", ".", "Join", "(", "cwd", ",", "file", ")", "\n", "}", "\n", "}", "\n\n", "// If the given file is already an absolute path, just return it.", "// Otherwise, the returned path will be relative to the given relativeTo", "// path.", "if", "filepath", ".", "IsAbs", "(", "file", ")", "{", "return", "file", "\n", "}", "\n\n", "abs", ",", "err", ":=", "filepath", ".", "Abs", "(", "filepath", ".", "Join", "(", "path", ".", "Dir", "(", "relativeTo", ")", ",", "file", ")", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "file", "\n", "}", "\n", "return", "abs", "\n", "}" ]
// relativePath returns the proper relative path for the given file path. If // the relativeTo string equals "-", then it means that it's from the stdin, // and the returned path will be the current working directory. Otherwise, if // file is really an absolute path, then it will be returned without any // changes. Otherwise, the returned path will be a combination of relativeTo // and file.
[ "relativePath", "returns", "the", "proper", "relative", "path", "for", "the", "given", "file", "path", ".", "If", "the", "relativeTo", "string", "equals", "-", "then", "it", "means", "that", "it", "s", "from", "the", "stdin", "and", "the", "returned", "path", "will", "be", "the", "current", "working", "directory", ".", "Otherwise", "if", "file", "is", "really", "an", "absolute", "path", "then", "it", "will", "be", "returned", "without", "any", "changes", ".", "Otherwise", "the", "returned", "path", "will", "be", "a", "combination", "of", "relativeTo", "and", "file", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/lookup/file.go#L19-L40
14,231
docker/libcompose
lookup/file.go
ResolvePath
func (f *FileResourceLookup) ResolvePath(path, relativeTo string) string { vs := strings.SplitN(path, ":", 2) if len(vs) != 2 || filepath.IsAbs(vs[0]) { return path } vs[0] = relativePath(vs[0], relativeTo) return strings.Join(vs, ":") }
go
func (f *FileResourceLookup) ResolvePath(path, relativeTo string) string { vs := strings.SplitN(path, ":", 2) if len(vs) != 2 || filepath.IsAbs(vs[0]) { return path } vs[0] = relativePath(vs[0], relativeTo) return strings.Join(vs, ":") }
[ "func", "(", "f", "*", "FileResourceLookup", ")", "ResolvePath", "(", "path", ",", "relativeTo", "string", ")", "string", "{", "vs", ":=", "strings", ".", "SplitN", "(", "path", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "vs", ")", "!=", "2", "||", "filepath", ".", "IsAbs", "(", "vs", "[", "0", "]", ")", "{", "return", "path", "\n", "}", "\n", "vs", "[", "0", "]", "=", "relativePath", "(", "vs", "[", "0", "]", ",", "relativeTo", ")", "\n", "return", "strings", ".", "Join", "(", "vs", ",", "\"", "\"", ")", "\n", "}" ]
// ResolvePath returns the path to be used for the given path volume. This // function already takes care of relative paths.
[ "ResolvePath", "returns", "the", "path", "to", "be", "used", "for", "the", "given", "path", "volume", ".", "This", "function", "already", "takes", "care", "of", "relative", "paths", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/lookup/file.go#L59-L66
14,232
docker/libcompose
cli/logger/color_logger.go
NewColorLoggerFactory
func NewColorLoggerFactory() *ColorLoggerFactory { return &ColorLoggerFactory{ tty: terminal.IsTerminal(int(os.Stdout.Fd())), } }
go
func NewColorLoggerFactory() *ColorLoggerFactory { return &ColorLoggerFactory{ tty: terminal.IsTerminal(int(os.Stdout.Fd())), } }
[ "func", "NewColorLoggerFactory", "(", ")", "*", "ColorLoggerFactory", "{", "return", "&", "ColorLoggerFactory", "{", "tty", ":", "terminal", ".", "IsTerminal", "(", "int", "(", "os", ".", "Stdout", ".", "Fd", "(", ")", ")", ")", ",", "}", "\n", "}" ]
// NewColorLoggerFactory creates a new ColorLoggerFactory.
[ "NewColorLoggerFactory", "creates", "a", "new", "ColorLoggerFactory", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/logger/color_logger.go#L27-L31
14,233
docker/libcompose
cli/logger/color_logger.go
CreateContainerLogger
func (c *ColorLoggerFactory) CreateContainerLogger(name string) logger.Logger { return c.create(name) }
go
func (c *ColorLoggerFactory) CreateContainerLogger(name string) logger.Logger { return c.create(name) }
[ "func", "(", "c", "*", "ColorLoggerFactory", ")", "CreateContainerLogger", "(", "name", "string", ")", "logger", ".", "Logger", "{", "return", "c", ".", "create", "(", "name", ")", "\n", "}" ]
// CreateContainerLogger implements logger.Factory.CreateContainerLogger.
[ "CreateContainerLogger", "implements", "logger", ".", "Factory", ".", "CreateContainerLogger", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/logger/color_logger.go#L34-L36
14,234
docker/libcompose
cli/logger/color_logger.go
create
func (c *ColorLoggerFactory) create(name string) logger.Logger { if c.maxLength < len(name) { c.maxLength = len(name) } return &ColorLogger{ name: name, factory: c, colorPrefix: <-colorPrefix, } }
go
func (c *ColorLoggerFactory) create(name string) logger.Logger { if c.maxLength < len(name) { c.maxLength = len(name) } return &ColorLogger{ name: name, factory: c, colorPrefix: <-colorPrefix, } }
[ "func", "(", "c", "*", "ColorLoggerFactory", ")", "create", "(", "name", "string", ")", "logger", ".", "Logger", "{", "if", "c", ".", "maxLength", "<", "len", "(", "name", ")", "{", "c", ".", "maxLength", "=", "len", "(", "name", ")", "\n", "}", "\n\n", "return", "&", "ColorLogger", "{", "name", ":", "name", ",", "factory", ":", "c", ",", "colorPrefix", ":", "<-", "colorPrefix", ",", "}", "\n", "}" ]
// CreateBuildLogger implements logger.Factory.CreateContainerLogger.
[ "CreateBuildLogger", "implements", "logger", ".", "Factory", ".", "CreateContainerLogger", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/logger/color_logger.go#L49-L59
14,235
docker/libcompose
cli/logger/color_logger.go
Out
func (c *ColorLogger) Out(bytes []byte) { if len(bytes) == 0 { return } logFmt, name := c.getLogFmt() message := fmt.Sprintf(logFmt, name, string(bytes)) fmt.Print(message) }
go
func (c *ColorLogger) Out(bytes []byte) { if len(bytes) == 0 { return } logFmt, name := c.getLogFmt() message := fmt.Sprintf(logFmt, name, string(bytes)) fmt.Print(message) }
[ "func", "(", "c", "*", "ColorLogger", ")", "Out", "(", "bytes", "[", "]", "byte", ")", "{", "if", "len", "(", "bytes", ")", "==", "0", "{", "return", "\n", "}", "\n", "logFmt", ",", "name", ":=", "c", ".", "getLogFmt", "(", ")", "\n", "message", ":=", "fmt", ".", "Sprintf", "(", "logFmt", ",", "name", ",", "string", "(", "bytes", ")", ")", "\n", "fmt", ".", "Print", "(", "message", ")", "\n", "}" ]
// Out implements logger.Logger.Out.
[ "Out", "implements", "logger", ".", "Logger", ".", "Out", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/logger/color_logger.go#L62-L69
14,236
docker/libcompose
cli/logger/color_logger.go
Err
func (c *ColorLogger) Err(bytes []byte) { if len(bytes) == 0 { return } logFmt, name := c.getLogFmt() message := fmt.Sprintf(logFmt, name, string(bytes)) fmt.Fprint(os.Stderr, message) }
go
func (c *ColorLogger) Err(bytes []byte) { if len(bytes) == 0 { return } logFmt, name := c.getLogFmt() message := fmt.Sprintf(logFmt, name, string(bytes)) fmt.Fprint(os.Stderr, message) }
[ "func", "(", "c", "*", "ColorLogger", ")", "Err", "(", "bytes", "[", "]", "byte", ")", "{", "if", "len", "(", "bytes", ")", "==", "0", "{", "return", "\n", "}", "\n", "logFmt", ",", "name", ":=", "c", ".", "getLogFmt", "(", ")", "\n", "message", ":=", "fmt", ".", "Sprintf", "(", "logFmt", ",", "name", ",", "string", "(", "bytes", ")", ")", "\n", "fmt", ".", "Fprint", "(", "os", ".", "Stderr", ",", "message", ")", "\n", "}" ]
// Err implements logger.Logger.Err.
[ "Err", "implements", "logger", ".", "Logger", ".", "Err", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/logger/color_logger.go#L72-L79
14,237
docker/libcompose
lookup/simple_env.go
Lookup
func (o *OsEnvLookup) Lookup(key string, config *config.ServiceConfig) []string { ret := os.Getenv(key) if ret == "" { return []string{} } return []string{fmt.Sprintf("%s=%s", key, ret)} }
go
func (o *OsEnvLookup) Lookup(key string, config *config.ServiceConfig) []string { ret := os.Getenv(key) if ret == "" { return []string{} } return []string{fmt.Sprintf("%s=%s", key, ret)} }
[ "func", "(", "o", "*", "OsEnvLookup", ")", "Lookup", "(", "key", "string", ",", "config", "*", "config", ".", "ServiceConfig", ")", "[", "]", "string", "{", "ret", ":=", "os", ".", "Getenv", "(", "key", ")", "\n", "if", "ret", "==", "\"", "\"", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n", "return", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "key", ",", "ret", ")", "}", "\n", "}" ]
// Lookup creates a string slice of string containing a "docker-friendly" environment string // in the form of 'key=value'. It gets environment values using os.Getenv. // If the os environment variable does not exists, the slice is empty. serviceName and config // are not used at all in this implementation.
[ "Lookup", "creates", "a", "string", "slice", "of", "string", "containing", "a", "docker", "-", "friendly", "environment", "string", "in", "the", "form", "of", "key", "=", "value", ".", "It", "gets", "environment", "values", "using", "os", ".", "Getenv", ".", "If", "the", "os", "environment", "variable", "does", "not", "exists", "the", "slice", "is", "empty", ".", "serviceName", "and", "config", "are", "not", "used", "at", "all", "in", "this", "implementation", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/lookup/simple_env.go#L18-L24
14,238
docker/libcompose
project/project_config.go
Config
func (p *Project) Config() (string, error) { cfg := ExportedConfig{ Version: "2.0", Services: p.ServiceConfigs.All(), Volumes: p.VolumeConfigs, Networks: p.NetworkConfigs, } bytes, err := yaml.Marshal(cfg) return string(bytes), err }
go
func (p *Project) Config() (string, error) { cfg := ExportedConfig{ Version: "2.0", Services: p.ServiceConfigs.All(), Volumes: p.VolumeConfigs, Networks: p.NetworkConfigs, } bytes, err := yaml.Marshal(cfg) return string(bytes), err }
[ "func", "(", "p", "*", "Project", ")", "Config", "(", ")", "(", "string", ",", "error", ")", "{", "cfg", ":=", "ExportedConfig", "{", "Version", ":", "\"", "\"", ",", "Services", ":", "p", ".", "ServiceConfigs", ".", "All", "(", ")", ",", "Volumes", ":", "p", ".", "VolumeConfigs", ",", "Networks", ":", "p", ".", "NetworkConfigs", ",", "}", "\n\n", "bytes", ",", "err", ":=", "yaml", ".", "Marshal", "(", "cfg", ")", "\n", "return", "string", "(", "bytes", ")", ",", "err", "\n", "}" ]
// Config validates and print the compose file.
[ "Config", "validates", "and", "print", "the", "compose", "file", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project_config.go#L17-L27
14,239
docker/libcompose
project/empty.go
Create
func (e *EmptyService) Create(ctx context.Context, options options.Create) error { return nil }
go
func (e *EmptyService) Create(ctx context.Context, options options.Create) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "options", "options", ".", "Create", ")", "error", "{", "return", "nil", "\n", "}" ]
// Create implements Service.Create but does nothing.
[ "Create", "implements", "Service", ".", "Create", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L20-L22
14,240
docker/libcompose
project/empty.go
Build
func (e *EmptyService) Build(ctx context.Context, buildOptions options.Build) error { return nil }
go
func (e *EmptyService) Build(ctx context.Context, buildOptions options.Build) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Build", "(", "ctx", "context", ".", "Context", ",", "buildOptions", "options", ".", "Build", ")", "error", "{", "return", "nil", "\n", "}" ]
// Build implements Service.Build but does nothing.
[ "Build", "implements", "Service", ".", "Build", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L25-L27
14,241
docker/libcompose
project/empty.go
Up
func (e *EmptyService) Up(ctx context.Context, options options.Up) error { return nil }
go
func (e *EmptyService) Up(ctx context.Context, options options.Up) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Up", "(", "ctx", "context", ".", "Context", ",", "options", "options", ".", "Up", ")", "error", "{", "return", "nil", "\n", "}" ]
// Up implements Service.Up but does nothing.
[ "Up", "implements", "Service", ".", "Up", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L30-L32
14,242
docker/libcompose
project/empty.go
Delete
func (e *EmptyService) Delete(ctx context.Context, options options.Delete) error { return nil }
go
func (e *EmptyService) Delete(ctx context.Context, options options.Delete) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Delete", "(", "ctx", "context", ".", "Context", ",", "options", "options", ".", "Delete", ")", "error", "{", "return", "nil", "\n", "}" ]
// Delete implements Service.Delete but does nothing.
[ "Delete", "implements", "Service", ".", "Delete", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L45-L47
14,243
docker/libcompose
project/empty.go
Log
func (e *EmptyService) Log(ctx context.Context, follow bool) error { return nil }
go
func (e *EmptyService) Log(ctx context.Context, follow bool) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Log", "(", "ctx", "context", ".", "Context", ",", "follow", "bool", ")", "error", "{", "return", "nil", "\n", "}" ]
// Log implements Service.Log but does nothing.
[ "Log", "implements", "Service", ".", "Log", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L55-L57
14,244
docker/libcompose
project/empty.go
Kill
func (e *EmptyService) Kill(ctx context.Context, signal string) error { return nil }
go
func (e *EmptyService) Kill(ctx context.Context, signal string) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Kill", "(", "ctx", "context", ".", "Context", ",", "signal", "string", ")", "error", "{", "return", "nil", "\n", "}" ]
// Kill implements Service.Kill but does nothing.
[ "Kill", "implements", "Service", ".", "Kill", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L65-L67
14,245
docker/libcompose
project/empty.go
Containers
func (e *EmptyService) Containers(ctx context.Context) ([]Container, error) { return []Container{}, nil }
go
func (e *EmptyService) Containers(ctx context.Context) ([]Container, error) { return []Container{}, nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Containers", "(", "ctx", "context", ".", "Context", ")", "(", "[", "]", "Container", ",", "error", ")", "{", "return", "[", "]", "Container", "{", "}", ",", "nil", "\n", "}" ]
// Containers implements Service.Containers but does nothing.
[ "Containers", "implements", "Service", ".", "Containers", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L70-L72
14,246
docker/libcompose
project/empty.go
Scale
func (e *EmptyService) Scale(ctx context.Context, count int, timeout int) error { return nil }
go
func (e *EmptyService) Scale(ctx context.Context, count int, timeout int) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Scale", "(", "ctx", "context", ".", "Context", ",", "count", "int", ",", "timeout", "int", ")", "error", "{", "return", "nil", "\n", "}" ]
// Scale implements Service.Scale but does nothing.
[ "Scale", "implements", "Service", ".", "Scale", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L75-L77
14,247
docker/libcompose
project/empty.go
Info
func (e *EmptyService) Info(ctx context.Context) (InfoSet, error) { return InfoSet{}, nil }
go
func (e *EmptyService) Info(ctx context.Context) (InfoSet, error) { return InfoSet{}, nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Info", "(", "ctx", "context", ".", "Context", ")", "(", "InfoSet", ",", "error", ")", "{", "return", "InfoSet", "{", "}", ",", "nil", "\n", "}" ]
// Info implements Service.Info but does nothing.
[ "Info", "implements", "Service", ".", "Info", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L80-L82
14,248
docker/libcompose
project/empty.go
Run
func (e *EmptyService) Run(ctx context.Context, commandParts []string, options options.Run) (int, error) { return 0, nil }
go
func (e *EmptyService) Run(ctx context.Context, commandParts []string, options options.Run) (int, error) { return 0, nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "commandParts", "[", "]", "string", ",", "options", "options", ".", "Run", ")", "(", "int", ",", "error", ")", "{", "return", "0", ",", "nil", "\n", "}" ]
// Run implements Service.Run but does nothing.
[ "Run", "implements", "Service", ".", "Run", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L95-L97
14,249
docker/libcompose
project/empty.go
RemoveImage
func (e *EmptyService) RemoveImage(ctx context.Context, imageType options.ImageType) error { return nil }
go
func (e *EmptyService) RemoveImage(ctx context.Context, imageType options.ImageType) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "RemoveImage", "(", "ctx", "context", ".", "Context", ",", "imageType", "options", ".", "ImageType", ")", "error", "{", "return", "nil", "\n", "}" ]
// RemoveImage implements Service.RemoveImage but does nothing.
[ "RemoveImage", "implements", "Service", ".", "RemoveImage", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L100-L102
14,250
docker/libcompose
project/empty.go
Events
func (e *EmptyService) Events(ctx context.Context, events chan events.ContainerEvent) error { return nil }
go
func (e *EmptyService) Events(ctx context.Context, events chan events.ContainerEvent) error { return nil }
[ "func", "(", "e", "*", "EmptyService", ")", "Events", "(", "ctx", "context", ".", "Context", ",", "events", "chan", "events", ".", "ContainerEvent", ")", "error", "{", "return", "nil", "\n", "}" ]
// Events implements Service.Events but does nothing.
[ "Events", "implements", "Service", ".", "Events", "but", "does", "nothing", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/empty.go#L105-L107
14,251
docker/libcompose
cli/app/events.go
ProjectEvents
func ProjectEvents(p project.APIProject, c *cli.Context) error { evts, err := p.Events(context.Background(), c.Args()...) if err != nil { return err } var printfn func(events.ContainerEvent) if c.Bool("json") { printfn = printJSON } else { printfn = printStd } for event := range evts { printfn(event) } return nil }
go
func ProjectEvents(p project.APIProject, c *cli.Context) error { evts, err := p.Events(context.Background(), c.Args()...) if err != nil { return err } var printfn func(events.ContainerEvent) if c.Bool("json") { printfn = printJSON } else { printfn = printStd } for event := range evts { printfn(event) } return nil }
[ "func", "ProjectEvents", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "evts", ",", "err", ":=", "p", ".", "Events", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "printfn", "func", "(", "events", ".", "ContainerEvent", ")", "\n\n", "if", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "printfn", "=", "printJSON", "\n", "}", "else", "{", "printfn", "=", "printStd", "\n", "}", "\n", "for", "event", ":=", "range", "evts", "{", "printfn", "(", "event", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectEvents listen for real-time events of containers.
[ "ProjectEvents", "listen", "for", "real", "-", "time", "events", "of", "containers", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/events.go#L18-L34
14,252
docker/libcompose
cli/app/version.go
Version
func Version(c *cli.Context) error { if c.Bool("short") { fmt.Println(version.VERSION) return nil } tmpl, err := template.New("").Parse(versionTemplate) if err != nil { logrus.Fatal(err) } v := struct { Version string GitCommit string GoVersion string BuildTime string Os string Arch string }{ Version: version.VERSION, GitCommit: version.GITCOMMIT, GoVersion: runtime.Version(), BuildTime: version.BUILDTIME, Os: runtime.GOOS, Arch: runtime.GOARCH, } if err := tmpl.Execute(os.Stdout, v); err != nil { logrus.Fatal(err) } fmt.Printf("\n") return nil }
go
func Version(c *cli.Context) error { if c.Bool("short") { fmt.Println(version.VERSION) return nil } tmpl, err := template.New("").Parse(versionTemplate) if err != nil { logrus.Fatal(err) } v := struct { Version string GitCommit string GoVersion string BuildTime string Os string Arch string }{ Version: version.VERSION, GitCommit: version.GITCOMMIT, GoVersion: runtime.Version(), BuildTime: version.BUILDTIME, Os: runtime.GOOS, Arch: runtime.GOARCH, } if err := tmpl.Execute(os.Stdout, v); err != nil { logrus.Fatal(err) } fmt.Printf("\n") return nil }
[ "func", "Version", "(", "c", "*", "cli", ".", "Context", ")", "error", "{", "if", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "fmt", ".", "Println", "(", "version", ".", "VERSION", ")", "\n", "return", "nil", "\n", "}", "\n\n", "tmpl", ",", "err", ":=", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "versionTemplate", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Fatal", "(", "err", ")", "\n", "}", "\n\n", "v", ":=", "struct", "{", "Version", "string", "\n", "GitCommit", "string", "\n", "GoVersion", "string", "\n", "BuildTime", "string", "\n", "Os", "string", "\n", "Arch", "string", "\n", "}", "{", "Version", ":", "version", ".", "VERSION", ",", "GitCommit", ":", "version", ".", "GITCOMMIT", ",", "GoVersion", ":", "runtime", ".", "Version", "(", ")", ",", "BuildTime", ":", "version", ".", "BUILDTIME", ",", "Os", ":", "runtime", ".", "GOOS", ",", "Arch", ":", "runtime", ".", "GOARCH", ",", "}", "\n\n", "if", "err", ":=", "tmpl", ".", "Execute", "(", "os", ".", "Stdout", ",", "v", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\"", ")", "\n", "return", "nil", "\n", "}" ]
// Version prints the libcompose version number and additionnal informations.
[ "Version", "prints", "the", "libcompose", "version", "number", "and", "additionnal", "informations", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/version.go#L20-L52
14,253
docker/libcompose
docker/image/image.go
Exists
func Exists(ctx context.Context, clt client.ImageAPIClient, image string) (bool, error) { _, err := InspectImage(ctx, clt, image) if err != nil { if client.IsErrNotFound(err) { return false, nil } return false, err } return true, nil }
go
func Exists(ctx context.Context, clt client.ImageAPIClient, image string) (bool, error) { _, err := InspectImage(ctx, clt, image) if err != nil { if client.IsErrNotFound(err) { return false, nil } return false, err } return true, nil }
[ "func", "Exists", "(", "ctx", "context", ".", "Context", ",", "clt", "client", ".", "ImageAPIClient", ",", "image", "string", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "err", ":=", "InspectImage", "(", "ctx", ",", "clt", ",", "image", ")", "\n", "if", "err", "!=", "nil", "{", "if", "client", ".", "IsErrNotFound", "(", "err", ")", "{", "return", "false", ",", "nil", "\n", "}", "\n", "return", "false", ",", "err", "\n", "}", "\n", "return", "true", ",", "nil", "\n", "}" ]
// Exists return whether or not the service image already exists
[ "Exists", "return", "whether", "or", "not", "the", "service", "image", "already", "exists" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/image/image.go#L22-L31
14,254
docker/libcompose
docker/auth/auth.go
Lookup
func (c *ConfigLookup) Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig { if c.ConfigFile == nil || repoInfo == nil || repoInfo.Index == nil { return types.AuthConfig{} } return registry.ResolveAuthConfig(c.ConfigFile.AuthConfigs, repoInfo.Index) }
go
func (c *ConfigLookup) Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig { if c.ConfigFile == nil || repoInfo == nil || repoInfo.Index == nil { return types.AuthConfig{} } return registry.ResolveAuthConfig(c.ConfigFile.AuthConfigs, repoInfo.Index) }
[ "func", "(", "c", "*", "ConfigLookup", ")", "Lookup", "(", "repoInfo", "*", "registry", ".", "RepositoryInfo", ")", "types", ".", "AuthConfig", "{", "if", "c", ".", "ConfigFile", "==", "nil", "||", "repoInfo", "==", "nil", "||", "repoInfo", ".", "Index", "==", "nil", "{", "return", "types", ".", "AuthConfig", "{", "}", "\n", "}", "\n", "return", "registry", ".", "ResolveAuthConfig", "(", "c", ".", "ConfigFile", ".", "AuthConfigs", ",", "repoInfo", ".", "Index", ")", "\n", "}" ]
// Lookup uses a Docker config file to lookup authentication information
[ "Lookup", "uses", "a", "Docker", "config", "file", "to", "lookup", "authentication", "information" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/auth/auth.go#L28-L33
14,255
docker/libcompose
docker/auth/auth.go
All
func (c *ConfigLookup) All() map[string]types.AuthConfig { if c.ConfigFile == nil { return map[string]types.AuthConfig{} } return c.ConfigFile.AuthConfigs }
go
func (c *ConfigLookup) All() map[string]types.AuthConfig { if c.ConfigFile == nil { return map[string]types.AuthConfig{} } return c.ConfigFile.AuthConfigs }
[ "func", "(", "c", "*", "ConfigLookup", ")", "All", "(", ")", "map", "[", "string", "]", "types", ".", "AuthConfig", "{", "if", "c", ".", "ConfigFile", "==", "nil", "{", "return", "map", "[", "string", "]", "types", ".", "AuthConfig", "{", "}", "\n", "}", "\n", "return", "c", ".", "ConfigFile", ".", "AuthConfigs", "\n", "}" ]
// All uses a Docker config file to get all authentication information
[ "All", "uses", "a", "Docker", "config", "file", "to", "get", "all", "authentication", "information" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/auth/auth.go#L36-L41
14,256
docker/libcompose
config/interpolation.go
Interpolate
func Interpolate(key string, data *interface{}, environmentLookup EnvironmentLookup) error { return parseConfig(key, data, func(s string) string { values := environmentLookup.Lookup(s, nil) if len(values) == 0 { if val, ok := defaultValues[s]; ok { return val } logrus.Warnf("The %s variable is not set. Substituting a blank string.", s) return "" } if strings.SplitN(values[0], "=", 2)[1] == "" { if val, ok := defaultValues[s]; ok { return val } } // Use first result if many are given value := values[0] // Environment variables come in key=value format // Return everything past first '=' return strings.SplitN(value, "=", 2)[1] }) }
go
func Interpolate(key string, data *interface{}, environmentLookup EnvironmentLookup) error { return parseConfig(key, data, func(s string) string { values := environmentLookup.Lookup(s, nil) if len(values) == 0 { if val, ok := defaultValues[s]; ok { return val } logrus.Warnf("The %s variable is not set. Substituting a blank string.", s) return "" } if strings.SplitN(values[0], "=", 2)[1] == "" { if val, ok := defaultValues[s]; ok { return val } } // Use first result if many are given value := values[0] // Environment variables come in key=value format // Return everything past first '=' return strings.SplitN(value, "=", 2)[1] }) }
[ "func", "Interpolate", "(", "key", "string", ",", "data", "*", "interface", "{", "}", ",", "environmentLookup", "EnvironmentLookup", ")", "error", "{", "return", "parseConfig", "(", "key", ",", "data", ",", "func", "(", "s", "string", ")", "string", "{", "values", ":=", "environmentLookup", ".", "Lookup", "(", "s", ",", "nil", ")", "\n\n", "if", "len", "(", "values", ")", "==", "0", "{", "if", "val", ",", "ok", ":=", "defaultValues", "[", "s", "]", ";", "ok", "{", "return", "val", "\n", "}", "\n", "logrus", ".", "Warnf", "(", "\"", "\"", ",", "s", ")", "\n", "return", "\"", "\"", "\n", "}", "\n\n", "if", "strings", ".", "SplitN", "(", "values", "[", "0", "]", ",", "\"", "\"", ",", "2", ")", "[", "1", "]", "==", "\"", "\"", "{", "if", "val", ",", "ok", ":=", "defaultValues", "[", "s", "]", ";", "ok", "{", "return", "val", "\n", "}", "\n", "}", "\n\n", "// Use first result if many are given", "value", ":=", "values", "[", "0", "]", "\n\n", "// Environment variables come in key=value format", "// Return everything past first '='", "return", "strings", ".", "SplitN", "(", "value", ",", "\"", "\"", ",", "2", ")", "[", "1", "]", "\n", "}", ")", "\n", "}" ]
// Interpolate replaces variables in a map entry
[ "Interpolate", "replaces", "variables", "in", "a", "map", "entry" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/config/interpolation.go#L174-L199
14,257
docker/libcompose
docker/project.go
NewProject
func NewProject(context *ctx.Context, parseOptions *config.ParseOptions) (project.APIProject, error) { if err := context.LookupConfig(); err != nil { logrus.Errorf("Failed to load docker config: %v", err) } if context.AuthLookup == nil { context.AuthLookup = auth.NewConfigLookup(context.ConfigFile) } if context.ServiceFactory == nil { context.ServiceFactory = service.NewFactory(context) } if context.ClientFactory == nil { factory, err := client.NewDefaultFactory(client.Options{}) if err != nil { return nil, err } context.ClientFactory = factory } if context.NetworksFactory == nil { networksFactory := &network.DockerFactory{ ClientFactory: context.ClientFactory, } context.NetworksFactory = networksFactory } if context.VolumesFactory == nil { volumesFactory := &volume.DockerFactory{ ClientFactory: context.ClientFactory, } context.VolumesFactory = volumesFactory } // FIXME(vdemeester) Remove the context duplication ? runtime := &Project{ clientFactory: context.ClientFactory, } p := project.NewProject(&context.Context, runtime, parseOptions) err := p.Parse() if err != nil { return nil, err } return p, err }
go
func NewProject(context *ctx.Context, parseOptions *config.ParseOptions) (project.APIProject, error) { if err := context.LookupConfig(); err != nil { logrus.Errorf("Failed to load docker config: %v", err) } if context.AuthLookup == nil { context.AuthLookup = auth.NewConfigLookup(context.ConfigFile) } if context.ServiceFactory == nil { context.ServiceFactory = service.NewFactory(context) } if context.ClientFactory == nil { factory, err := client.NewDefaultFactory(client.Options{}) if err != nil { return nil, err } context.ClientFactory = factory } if context.NetworksFactory == nil { networksFactory := &network.DockerFactory{ ClientFactory: context.ClientFactory, } context.NetworksFactory = networksFactory } if context.VolumesFactory == nil { volumesFactory := &volume.DockerFactory{ ClientFactory: context.ClientFactory, } context.VolumesFactory = volumesFactory } // FIXME(vdemeester) Remove the context duplication ? runtime := &Project{ clientFactory: context.ClientFactory, } p := project.NewProject(&context.Context, runtime, parseOptions) err := p.Parse() if err != nil { return nil, err } return p, err }
[ "func", "NewProject", "(", "context", "*", "ctx", ".", "Context", ",", "parseOptions", "*", "config", ".", "ParseOptions", ")", "(", "project", ".", "APIProject", ",", "error", ")", "{", "if", "err", ":=", "context", ".", "LookupConfig", "(", ")", ";", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "if", "context", ".", "AuthLookup", "==", "nil", "{", "context", ".", "AuthLookup", "=", "auth", ".", "NewConfigLookup", "(", "context", ".", "ConfigFile", ")", "\n", "}", "\n\n", "if", "context", ".", "ServiceFactory", "==", "nil", "{", "context", ".", "ServiceFactory", "=", "service", ".", "NewFactory", "(", "context", ")", "\n", "}", "\n\n", "if", "context", ".", "ClientFactory", "==", "nil", "{", "factory", ",", "err", ":=", "client", ".", "NewDefaultFactory", "(", "client", ".", "Options", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "context", ".", "ClientFactory", "=", "factory", "\n", "}", "\n\n", "if", "context", ".", "NetworksFactory", "==", "nil", "{", "networksFactory", ":=", "&", "network", ".", "DockerFactory", "{", "ClientFactory", ":", "context", ".", "ClientFactory", ",", "}", "\n", "context", ".", "NetworksFactory", "=", "networksFactory", "\n", "}", "\n\n", "if", "context", ".", "VolumesFactory", "==", "nil", "{", "volumesFactory", ":=", "&", "volume", ".", "DockerFactory", "{", "ClientFactory", ":", "context", ".", "ClientFactory", ",", "}", "\n", "context", ".", "VolumesFactory", "=", "volumesFactory", "\n", "}", "\n\n", "// FIXME(vdemeester) Remove the context duplication ?", "runtime", ":=", "&", "Project", "{", "clientFactory", ":", "context", ".", "ClientFactory", ",", "}", "\n", "p", ":=", "project", ".", "NewProject", "(", "&", "context", ".", "Context", ",", "runtime", ",", "parseOptions", ")", "\n\n", "err", ":=", "p", ".", "Parse", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "p", ",", "err", "\n", "}" ]
// NewProject creates a Project with the specified context.
[ "NewProject", "creates", "a", "Project", "with", "the", "specified", "context", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/project.go#L21-L69
14,258
docker/libcompose
docker/project.go
RemoveOrphans
func (p *Project) RemoveOrphans(ctx context.Context, projectName string, serviceConfigs *config.ServiceConfigs) error { client := p.clientFactory.Create(nil) filter := filters.NewArgs() filter.Add("label", labels.PROJECT.EqString(projectName)) containers, err := client.ContainerList(ctx, types.ContainerListOptions{ Filters: filter, }) if err != nil { return err } currentServices := map[string]struct{}{} for _, serviceName := range serviceConfigs.Keys() { currentServices[serviceName] = struct{}{} } for _, container := range containers { serviceLabel := container.Labels[labels.SERVICE.Str()] if _, ok := currentServices[serviceLabel]; !ok { if err := client.ContainerKill(ctx, container.ID, "SIGKILL"); err != nil { return err } if err := client.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{ Force: true, }); err != nil { return err } } } return nil }
go
func (p *Project) RemoveOrphans(ctx context.Context, projectName string, serviceConfigs *config.ServiceConfigs) error { client := p.clientFactory.Create(nil) filter := filters.NewArgs() filter.Add("label", labels.PROJECT.EqString(projectName)) containers, err := client.ContainerList(ctx, types.ContainerListOptions{ Filters: filter, }) if err != nil { return err } currentServices := map[string]struct{}{} for _, serviceName := range serviceConfigs.Keys() { currentServices[serviceName] = struct{}{} } for _, container := range containers { serviceLabel := container.Labels[labels.SERVICE.Str()] if _, ok := currentServices[serviceLabel]; !ok { if err := client.ContainerKill(ctx, container.ID, "SIGKILL"); err != nil { return err } if err := client.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{ Force: true, }); err != nil { return err } } } return nil }
[ "func", "(", "p", "*", "Project", ")", "RemoveOrphans", "(", "ctx", "context", ".", "Context", ",", "projectName", "string", ",", "serviceConfigs", "*", "config", ".", "ServiceConfigs", ")", "error", "{", "client", ":=", "p", ".", "clientFactory", ".", "Create", "(", "nil", ")", "\n", "filter", ":=", "filters", ".", "NewArgs", "(", ")", "\n", "filter", ".", "Add", "(", "\"", "\"", ",", "labels", ".", "PROJECT", ".", "EqString", "(", "projectName", ")", ")", "\n", "containers", ",", "err", ":=", "client", ".", "ContainerList", "(", "ctx", ",", "types", ".", "ContainerListOptions", "{", "Filters", ":", "filter", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "currentServices", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "serviceName", ":=", "range", "serviceConfigs", ".", "Keys", "(", ")", "{", "currentServices", "[", "serviceName", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "for", "_", ",", "container", ":=", "range", "containers", "{", "serviceLabel", ":=", "container", ".", "Labels", "[", "labels", ".", "SERVICE", ".", "Str", "(", ")", "]", "\n", "if", "_", ",", "ok", ":=", "currentServices", "[", "serviceLabel", "]", ";", "!", "ok", "{", "if", "err", ":=", "client", ".", "ContainerKill", "(", "ctx", ",", "container", ".", "ID", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "client", ".", "ContainerRemove", "(", "ctx", ",", "container", ".", "ID", ",", "types", ".", "ContainerRemoveOptions", "{", "Force", ":", "true", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// RemoveOrphans implements project.RuntimeProject.RemoveOrphans. // It will remove orphan containers that are part of the project but not to any services.
[ "RemoveOrphans", "implements", "project", ".", "RuntimeProject", ".", "RemoveOrphans", ".", "It", "will", "remove", "orphan", "containers", "that", "are", "part", "of", "the", "project", "but", "not", "to", "any", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/project.go#L78-L106
14,259
docker/libcompose
project/project.go
NewProject
func NewProject(context *Context, runtime RuntimeProject, parseOptions *config.ParseOptions) *Project { p := &Project{ context: context, runtime: runtime, ParseOptions: parseOptions, ServiceConfigs: config.NewServiceConfigs(), VolumeConfigs: make(map[string]*config.VolumeConfig), NetworkConfigs: make(map[string]*config.NetworkConfig), } if context.LoggerFactory == nil { context.LoggerFactory = &logger.NullLogger{} } if context.ResourceLookup == nil { context.ResourceLookup = &lookup.FileResourceLookup{} } if context.EnvironmentLookup == nil { var envPath, absPath, cwd string var err error if len(context.ComposeFiles) > 0 { absPath, err = filepath.Abs(context.ComposeFiles[0]) dir, _ := path.Split(absPath) envPath = filepath.Join(dir, ".env") } else { cwd, err = os.Getwd() envPath = filepath.Join(cwd, ".env") } if err != nil { log.Errorf("Could not get the rooted path name to the current directory: %v", err) return nil } context.EnvironmentLookup = &lookup.ComposableEnvLookup{ Lookups: []config.EnvironmentLookup{ &lookup.EnvfileLookup{ Path: envPath, }, &lookup.OsEnvLookup{}, }, } } context.Project = p p.listeners = []chan<- events.Event{NewDefaultListener(p)} return p }
go
func NewProject(context *Context, runtime RuntimeProject, parseOptions *config.ParseOptions) *Project { p := &Project{ context: context, runtime: runtime, ParseOptions: parseOptions, ServiceConfigs: config.NewServiceConfigs(), VolumeConfigs: make(map[string]*config.VolumeConfig), NetworkConfigs: make(map[string]*config.NetworkConfig), } if context.LoggerFactory == nil { context.LoggerFactory = &logger.NullLogger{} } if context.ResourceLookup == nil { context.ResourceLookup = &lookup.FileResourceLookup{} } if context.EnvironmentLookup == nil { var envPath, absPath, cwd string var err error if len(context.ComposeFiles) > 0 { absPath, err = filepath.Abs(context.ComposeFiles[0]) dir, _ := path.Split(absPath) envPath = filepath.Join(dir, ".env") } else { cwd, err = os.Getwd() envPath = filepath.Join(cwd, ".env") } if err != nil { log.Errorf("Could not get the rooted path name to the current directory: %v", err) return nil } context.EnvironmentLookup = &lookup.ComposableEnvLookup{ Lookups: []config.EnvironmentLookup{ &lookup.EnvfileLookup{ Path: envPath, }, &lookup.OsEnvLookup{}, }, } } context.Project = p p.listeners = []chan<- events.Event{NewDefaultListener(p)} return p }
[ "func", "NewProject", "(", "context", "*", "Context", ",", "runtime", "RuntimeProject", ",", "parseOptions", "*", "config", ".", "ParseOptions", ")", "*", "Project", "{", "p", ":=", "&", "Project", "{", "context", ":", "context", ",", "runtime", ":", "runtime", ",", "ParseOptions", ":", "parseOptions", ",", "ServiceConfigs", ":", "config", ".", "NewServiceConfigs", "(", ")", ",", "VolumeConfigs", ":", "make", "(", "map", "[", "string", "]", "*", "config", ".", "VolumeConfig", ")", ",", "NetworkConfigs", ":", "make", "(", "map", "[", "string", "]", "*", "config", ".", "NetworkConfig", ")", ",", "}", "\n\n", "if", "context", ".", "LoggerFactory", "==", "nil", "{", "context", ".", "LoggerFactory", "=", "&", "logger", ".", "NullLogger", "{", "}", "\n", "}", "\n\n", "if", "context", ".", "ResourceLookup", "==", "nil", "{", "context", ".", "ResourceLookup", "=", "&", "lookup", ".", "FileResourceLookup", "{", "}", "\n", "}", "\n\n", "if", "context", ".", "EnvironmentLookup", "==", "nil", "{", "var", "envPath", ",", "absPath", ",", "cwd", "string", "\n", "var", "err", "error", "\n", "if", "len", "(", "context", ".", "ComposeFiles", ")", ">", "0", "{", "absPath", ",", "err", "=", "filepath", ".", "Abs", "(", "context", ".", "ComposeFiles", "[", "0", "]", ")", "\n", "dir", ",", "_", ":=", "path", ".", "Split", "(", "absPath", ")", "\n", "envPath", "=", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", "\n", "}", "else", "{", "cwd", ",", "err", "=", "os", ".", "Getwd", "(", ")", "\n", "envPath", "=", "filepath", ".", "Join", "(", "cwd", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", "\n", "}", "\n", "context", ".", "EnvironmentLookup", "=", "&", "lookup", ".", "ComposableEnvLookup", "{", "Lookups", ":", "[", "]", "config", ".", "EnvironmentLookup", "{", "&", "lookup", ".", "EnvfileLookup", "{", "Path", ":", "envPath", ",", "}", ",", "&", "lookup", ".", "OsEnvLookup", "{", "}", ",", "}", ",", "}", "\n", "}", "\n\n", "context", ".", "Project", "=", "p", "\n\n", "p", ".", "listeners", "=", "[", "]", "chan", "<-", "events", ".", "Event", "{", "NewDefaultListener", "(", "p", ")", "}", "\n\n", "return", "p", "\n", "}" ]
// NewProject creates a new project with the specified context.
[ "NewProject", "creates", "a", "new", "project", "with", "the", "specified", "context", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L50-L99
14,260
docker/libcompose
project/project.go
CreateService
func (p *Project) CreateService(name string) (Service, error) { existing, ok := p.GetServiceConfig(name) if !ok { return nil, fmt.Errorf("Failed to find service: %s", name) } // Copy because we are about to modify the environment config := *existing if p.context.EnvironmentLookup != nil { parsedEnv := make([]string, 0, len(config.Environment)) for _, env := range config.Environment { parts := strings.SplitN(env, "=", 2) if len(parts) > 1 { parsedEnv = append(parsedEnv, env) continue } else { env = parts[0] } for _, value := range p.context.EnvironmentLookup.Lookup(env, &config) { parsedEnv = append(parsedEnv, value) } } config.Environment = parsedEnv // check the environment for extra build Args that are set but not given a value in the compose file for arg, value := range config.Build.Args { if *value == "\x00" { envValue := p.context.EnvironmentLookup.Lookup(arg, &config) // depending on what we get back we do different things switch l := len(envValue); l { case 0: delete(config.Build.Args, arg) case 1: parts := strings.SplitN(envValue[0], "=", 2) config.Build.Args[parts[0]] = &parts[1] default: return nil, fmt.Errorf("tried to set Build Arg %#v to multi-value %#v", arg, envValue) } } } } return p.context.ServiceFactory.Create(p, name, &config) }
go
func (p *Project) CreateService(name string) (Service, error) { existing, ok := p.GetServiceConfig(name) if !ok { return nil, fmt.Errorf("Failed to find service: %s", name) } // Copy because we are about to modify the environment config := *existing if p.context.EnvironmentLookup != nil { parsedEnv := make([]string, 0, len(config.Environment)) for _, env := range config.Environment { parts := strings.SplitN(env, "=", 2) if len(parts) > 1 { parsedEnv = append(parsedEnv, env) continue } else { env = parts[0] } for _, value := range p.context.EnvironmentLookup.Lookup(env, &config) { parsedEnv = append(parsedEnv, value) } } config.Environment = parsedEnv // check the environment for extra build Args that are set but not given a value in the compose file for arg, value := range config.Build.Args { if *value == "\x00" { envValue := p.context.EnvironmentLookup.Lookup(arg, &config) // depending on what we get back we do different things switch l := len(envValue); l { case 0: delete(config.Build.Args, arg) case 1: parts := strings.SplitN(envValue[0], "=", 2) config.Build.Args[parts[0]] = &parts[1] default: return nil, fmt.Errorf("tried to set Build Arg %#v to multi-value %#v", arg, envValue) } } } } return p.context.ServiceFactory.Create(p, name, &config) }
[ "func", "(", "p", "*", "Project", ")", "CreateService", "(", "name", "string", ")", "(", "Service", ",", "error", ")", "{", "existing", ",", "ok", ":=", "p", ".", "GetServiceConfig", "(", "name", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "// Copy because we are about to modify the environment", "config", ":=", "*", "existing", "\n\n", "if", "p", ".", "context", ".", "EnvironmentLookup", "!=", "nil", "{", "parsedEnv", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "config", ".", "Environment", ")", ")", "\n\n", "for", "_", ",", "env", ":=", "range", "config", ".", "Environment", "{", "parts", ":=", "strings", ".", "SplitN", "(", "env", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "parts", ")", ">", "1", "{", "parsedEnv", "=", "append", "(", "parsedEnv", ",", "env", ")", "\n", "continue", "\n", "}", "else", "{", "env", "=", "parts", "[", "0", "]", "\n", "}", "\n\n", "for", "_", ",", "value", ":=", "range", "p", ".", "context", ".", "EnvironmentLookup", ".", "Lookup", "(", "env", ",", "&", "config", ")", "{", "parsedEnv", "=", "append", "(", "parsedEnv", ",", "value", ")", "\n", "}", "\n", "}", "\n\n", "config", ".", "Environment", "=", "parsedEnv", "\n\n", "// check the environment for extra build Args that are set but not given a value in the compose file", "for", "arg", ",", "value", ":=", "range", "config", ".", "Build", ".", "Args", "{", "if", "*", "value", "==", "\"", "\\x00", "\"", "{", "envValue", ":=", "p", ".", "context", ".", "EnvironmentLookup", ".", "Lookup", "(", "arg", ",", "&", "config", ")", "\n", "// depending on what we get back we do different things", "switch", "l", ":=", "len", "(", "envValue", ")", ";", "l", "{", "case", "0", ":", "delete", "(", "config", ".", "Build", ".", "Args", ",", "arg", ")", "\n", "case", "1", ":", "parts", ":=", "strings", ".", "SplitN", "(", "envValue", "[", "0", "]", ",", "\"", "\"", ",", "2", ")", "\n", "config", ".", "Build", ".", "Args", "[", "parts", "[", "0", "]", "]", "=", "&", "parts", "[", "1", "]", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "arg", ",", "envValue", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "p", ".", "context", ".", "ServiceFactory", ".", "Create", "(", "p", ",", "name", ",", "&", "config", ")", "\n", "}" ]
// CreateService creates a service with the specified name based. If there // is no config in the project for this service, it will return an error.
[ "CreateService", "creates", "a", "service", "with", "the", "specified", "name", "based", ".", "If", "there", "is", "no", "config", "in", "the", "project", "for", "this", "service", "it", "will", "return", "an", "error", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L134-L181
14,261
docker/libcompose
project/project.go
AddConfig
func (p *Project) AddConfig(name string, config *config.ServiceConfig) error { p.Notify(events.ServiceAdd, name, nil) p.ServiceConfigs.Add(name, config) p.reload = append(p.reload, name) return nil }
go
func (p *Project) AddConfig(name string, config *config.ServiceConfig) error { p.Notify(events.ServiceAdd, name, nil) p.ServiceConfigs.Add(name, config) p.reload = append(p.reload, name) return nil }
[ "func", "(", "p", "*", "Project", ")", "AddConfig", "(", "name", "string", ",", "config", "*", "config", ".", "ServiceConfig", ")", "error", "{", "p", ".", "Notify", "(", "events", ".", "ServiceAdd", ",", "name", ",", "nil", ")", "\n\n", "p", ".", "ServiceConfigs", ".", "Add", "(", "name", ",", "config", ")", "\n", "p", ".", "reload", "=", "append", "(", "p", ".", "reload", ",", "name", ")", "\n\n", "return", "nil", "\n", "}" ]
// AddConfig adds the specified service config for the specified name.
[ "AddConfig", "adds", "the", "specified", "service", "config", "for", "the", "specified", "name", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L184-L191
14,262
docker/libcompose
project/project.go
AddVolumeConfig
func (p *Project) AddVolumeConfig(name string, config *config.VolumeConfig) error { p.Notify(events.VolumeAdd, name, nil) p.VolumeConfigs[name] = config return nil }
go
func (p *Project) AddVolumeConfig(name string, config *config.VolumeConfig) error { p.Notify(events.VolumeAdd, name, nil) p.VolumeConfigs[name] = config return nil }
[ "func", "(", "p", "*", "Project", ")", "AddVolumeConfig", "(", "name", "string", ",", "config", "*", "config", ".", "VolumeConfig", ")", "error", "{", "p", ".", "Notify", "(", "events", ".", "VolumeAdd", ",", "name", ",", "nil", ")", "\n", "p", ".", "VolumeConfigs", "[", "name", "]", "=", "config", "\n", "return", "nil", "\n", "}" ]
// AddVolumeConfig adds the specified volume config for the specified name.
[ "AddVolumeConfig", "adds", "the", "specified", "volume", "config", "for", "the", "specified", "name", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L194-L198
14,263
docker/libcompose
project/project.go
AddNetworkConfig
func (p *Project) AddNetworkConfig(name string, config *config.NetworkConfig) error { p.Notify(events.NetworkAdd, name, nil) p.NetworkConfigs[name] = config return nil }
go
func (p *Project) AddNetworkConfig(name string, config *config.NetworkConfig) error { p.Notify(events.NetworkAdd, name, nil) p.NetworkConfigs[name] = config return nil }
[ "func", "(", "p", "*", "Project", ")", "AddNetworkConfig", "(", "name", "string", ",", "config", "*", "config", ".", "NetworkConfig", ")", "error", "{", "p", ".", "Notify", "(", "events", ".", "NetworkAdd", ",", "name", ",", "nil", ")", "\n", "p", ".", "NetworkConfigs", "[", "name", "]", "=", "config", "\n", "return", "nil", "\n", "}" ]
// AddNetworkConfig adds the specified network config for the specified name.
[ "AddNetworkConfig", "adds", "the", "specified", "network", "config", "for", "the", "specified", "name", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L201-L205
14,264
docker/libcompose
project/project.go
AddListener
func (p *Project) AddListener(c chan<- events.Event) { if !p.hasListeners { for _, l := range p.listeners { close(l) } p.hasListeners = true p.listeners = []chan<- events.Event{c} } else { p.listeners = append(p.listeners, c) } }
go
func (p *Project) AddListener(c chan<- events.Event) { if !p.hasListeners { for _, l := range p.listeners { close(l) } p.hasListeners = true p.listeners = []chan<- events.Event{c} } else { p.listeners = append(p.listeners, c) } }
[ "func", "(", "p", "*", "Project", ")", "AddListener", "(", "c", "chan", "<-", "events", ".", "Event", ")", "{", "if", "!", "p", ".", "hasListeners", "{", "for", "_", ",", "l", ":=", "range", "p", ".", "listeners", "{", "close", "(", "l", ")", "\n", "}", "\n", "p", ".", "hasListeners", "=", "true", "\n", "p", ".", "listeners", "=", "[", "]", "chan", "<-", "events", ".", "Event", "{", "c", "}", "\n", "}", "else", "{", "p", ".", "listeners", "=", "append", "(", "p", ".", "listeners", ",", "c", ")", "\n", "}", "\n", "}" ]
// AddListener adds the specified listener to the project. // This implements implicitly events.Emitter.
[ "AddListener", "adds", "the", "specified", "listener", "to", "the", "project", ".", "This", "implements", "implicitly", "events", ".", "Emitter", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L520-L530
14,265
docker/libcompose
project/project.go
Notify
func (p *Project) Notify(eventType events.EventType, serviceName string, data map[string]string) { if eventType == events.NoEvent { return } event := events.Event{ EventType: eventType, ServiceName: serviceName, Data: data, } for _, l := range p.listeners { l <- event } }
go
func (p *Project) Notify(eventType events.EventType, serviceName string, data map[string]string) { if eventType == events.NoEvent { return } event := events.Event{ EventType: eventType, ServiceName: serviceName, Data: data, } for _, l := range p.listeners { l <- event } }
[ "func", "(", "p", "*", "Project", ")", "Notify", "(", "eventType", "events", ".", "EventType", ",", "serviceName", "string", ",", "data", "map", "[", "string", "]", "string", ")", "{", "if", "eventType", "==", "events", ".", "NoEvent", "{", "return", "\n", "}", "\n\n", "event", ":=", "events", ".", "Event", "{", "EventType", ":", "eventType", ",", "ServiceName", ":", "serviceName", ",", "Data", ":", "data", ",", "}", "\n\n", "for", "_", ",", "l", ":=", "range", "p", ".", "listeners", "{", "l", "<-", "event", "\n", "}", "\n", "}" ]
// Notify notifies all project listener with the specified eventType, service name and datas. // This implements implicitly events.Notifier interface.
[ "Notify", "notifies", "all", "project", "listener", "with", "the", "specified", "eventType", "service", "name", "and", "datas", ".", "This", "implements", "implicitly", "events", ".", "Notifier", "interface", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L534-L548
14,266
docker/libcompose
project/project.go
GetServiceConfig
func (p *Project) GetServiceConfig(name string) (*config.ServiceConfig, bool) { return p.ServiceConfigs.Get(name) }
go
func (p *Project) GetServiceConfig(name string) (*config.ServiceConfig, bool) { return p.ServiceConfigs.Get(name) }
[ "func", "(", "p", "*", "Project", ")", "GetServiceConfig", "(", "name", "string", ")", "(", "*", "config", ".", "ServiceConfig", ",", "bool", ")", "{", "return", "p", ".", "ServiceConfigs", ".", "Get", "(", "name", ")", "\n", "}" ]
// GetServiceConfig looks up a service config for a given service name, returning the ServiceConfig // object and a bool flag indicating whether it was found
[ "GetServiceConfig", "looks", "up", "a", "service", "config", "for", "a", "given", "service", "name", "returning", "the", "ServiceConfig", "object", "and", "a", "bool", "flag", "indicating", "whether", "it", "was", "found" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project.go#L552-L554
14,267
docker/libcompose
cli/app/app.go
BeforeApp
func BeforeApp(c *cli.Context) error { if c.GlobalBool("verbose") { logrus.SetLevel(logrus.DebugLevel) } if version.ShowWarning() { logrus.Warning("Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose)") } return nil }
go
func BeforeApp(c *cli.Context) error { if c.GlobalBool("verbose") { logrus.SetLevel(logrus.DebugLevel) } if version.ShowWarning() { logrus.Warning("Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose)") } return nil }
[ "func", "BeforeApp", "(", "c", "*", "cli", ".", "Context", ")", "error", "{", "if", "c", ".", "GlobalBool", "(", "\"", "\"", ")", "{", "logrus", ".", "SetLevel", "(", "logrus", ".", "DebugLevel", ")", "\n", "}", "\n\n", "if", "version", ".", "ShowWarning", "(", ")", "{", "logrus", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// BeforeApp is an action that is executed before any cli command.
[ "BeforeApp", "is", "an", "action", "that", "is", "executed", "before", "any", "cli", "command", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L31-L40
14,268
docker/libcompose
cli/app/app.go
WithProject
func WithProject(factory ProjectFactory, action ProjectAction) func(context *cli.Context) error { return func(context *cli.Context) error { p, err := factory.Create(context) if err != nil { logrus.Fatalf("Failed to read project: %v", err) } return action(p, context) } }
go
func WithProject(factory ProjectFactory, action ProjectAction) func(context *cli.Context) error { return func(context *cli.Context) error { p, err := factory.Create(context) if err != nil { logrus.Fatalf("Failed to read project: %v", err) } return action(p, context) } }
[ "func", "WithProject", "(", "factory", "ProjectFactory", ",", "action", "ProjectAction", ")", "func", "(", "context", "*", "cli", ".", "Context", ")", "error", "{", "return", "func", "(", "context", "*", "cli", ".", "Context", ")", "error", "{", "p", ",", "err", ":=", "factory", ".", "Create", "(", "context", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Fatalf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "action", "(", "p", ",", "context", ")", "\n", "}", "\n", "}" ]
// WithProject is a helper function to create a cli.Command action with a ProjectFactory.
[ "WithProject", "is", "a", "helper", "function", "to", "create", "a", "cli", ".", "Command", "action", "with", "a", "ProjectFactory", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L43-L51
14,269
docker/libcompose
cli/app/app.go
ProjectPs
func ProjectPs(p project.APIProject, c *cli.Context) error { qFlag := c.Bool("q") allInfo, err := p.Ps(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } columns := []string{"Name", "Command", "State", "Ports"} if qFlag { columns = []string{"Id"} } os.Stdout.WriteString(allInfo.String(columns, !qFlag)) return nil }
go
func ProjectPs(p project.APIProject, c *cli.Context) error { qFlag := c.Bool("q") allInfo, err := p.Ps(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } columns := []string{"Name", "Command", "State", "Ports"} if qFlag { columns = []string{"Id"} } os.Stdout.WriteString(allInfo.String(columns, !qFlag)) return nil }
[ "func", "ProjectPs", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "qFlag", ":=", "c", ".", "Bool", "(", "\"", "\"", ")", "\n", "allInfo", ",", "err", ":=", "p", ".", "Ps", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "columns", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", "\n", "if", "qFlag", "{", "columns", "=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "}", "\n", "os", ".", "Stdout", ".", "WriteString", "(", "allInfo", ".", "String", "(", "columns", ",", "!", "qFlag", ")", ")", "\n", "return", "nil", "\n", "}" ]
// ProjectPs lists the containers.
[ "ProjectPs", "lists", "the", "containers", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L54-L66
14,270
docker/libcompose
cli/app/app.go
ProjectPort
func ProjectPort(p project.APIProject, c *cli.Context) error { if len(c.Args()) != 2 { return cli.NewExitError("Please pass arguments in the form: SERVICE PORT", 1) } index := c.Int("index") protocol := c.String("protocol") serviceName := c.Args()[0] privatePort := c.Args()[1] port, err := p.Port(context.Background(), index, protocol, serviceName, privatePort) if err != nil { return cli.NewExitError(err.Error(), 1) } fmt.Println(port) return nil }
go
func ProjectPort(p project.APIProject, c *cli.Context) error { if len(c.Args()) != 2 { return cli.NewExitError("Please pass arguments in the form: SERVICE PORT", 1) } index := c.Int("index") protocol := c.String("protocol") serviceName := c.Args()[0] privatePort := c.Args()[1] port, err := p.Port(context.Background(), index, protocol, serviceName, privatePort) if err != nil { return cli.NewExitError(err.Error(), 1) } fmt.Println(port) return nil }
[ "func", "ProjectPort", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "if", "len", "(", "c", ".", "Args", "(", ")", ")", "!=", "2", "{", "return", "cli", ".", "NewExitError", "(", "\"", "\"", ",", "1", ")", "\n", "}", "\n\n", "index", ":=", "c", ".", "Int", "(", "\"", "\"", ")", "\n", "protocol", ":=", "c", ".", "String", "(", "\"", "\"", ")", "\n", "serviceName", ":=", "c", ".", "Args", "(", ")", "[", "0", "]", "\n", "privatePort", ":=", "c", ".", "Args", "(", ")", "[", "1", "]", "\n\n", "port", ",", "err", ":=", "p", ".", "Port", "(", "context", ".", "Background", "(", ")", ",", "index", ",", "protocol", ",", "serviceName", ",", "privatePort", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "fmt", ".", "Println", "(", "port", ")", "\n", "return", "nil", "\n", "}" ]
// ProjectPort prints the public port for a port binding.
[ "ProjectPort", "prints", "the", "public", "port", "for", "a", "port", "binding", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L69-L85
14,271
docker/libcompose
cli/app/app.go
ProjectStop
func ProjectStop(p project.APIProject, c *cli.Context) error { err := p.Stop(context.Background(), c.Int("timeout"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectStop(p project.APIProject, c *cli.Context) error { err := p.Stop(context.Background(), c.Int("timeout"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectStop", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Stop", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Int", "(", "\"", "\"", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectStop stops all services.
[ "ProjectStop", "stops", "all", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L88-L94
14,272
docker/libcompose
cli/app/app.go
ProjectBuild
func ProjectBuild(p project.APIProject, c *cli.Context) error { config := options.Build{ NoCache: c.Bool("no-cache"), ForceRemove: c.Bool("force-rm"), Pull: c.Bool("pull"), } err := p.Build(context.Background(), config, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectBuild(p project.APIProject, c *cli.Context) error { config := options.Build{ NoCache: c.Bool("no-cache"), ForceRemove: c.Bool("force-rm"), Pull: c.Bool("pull"), } err := p.Build(context.Background(), config, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectBuild", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "config", ":=", "options", ".", "Build", "{", "NoCache", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "ForceRemove", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "Pull", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "}", "\n", "err", ":=", "p", ".", "Build", "(", "context", ".", "Background", "(", ")", ",", "config", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectBuild builds or rebuilds services.
[ "ProjectBuild", "builds", "or", "rebuilds", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L111-L122
14,273
docker/libcompose
cli/app/app.go
ProjectCreate
func ProjectCreate(p project.APIProject, c *cli.Context) error { options := options.Create{ NoRecreate: c.Bool("no-recreate"), ForceRecreate: c.Bool("force-recreate"), NoBuild: c.Bool("no-build"), } err := p.Create(context.Background(), options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectCreate(p project.APIProject, c *cli.Context) error { options := options.Create{ NoRecreate: c.Bool("no-recreate"), ForceRecreate: c.Bool("force-recreate"), NoBuild: c.Bool("no-build"), } err := p.Create(context.Background(), options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectCreate", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "options", ":=", "options", ".", "Create", "{", "NoRecreate", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "ForceRecreate", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "NoBuild", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "}", "\n", "err", ":=", "p", ".", "Create", "(", "context", ".", "Background", "(", ")", ",", "options", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectCreate creates all services but do not start them.
[ "ProjectCreate", "creates", "all", "services", "but", "do", "not", "start", "them", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L125-L136
14,274
docker/libcompose
cli/app/app.go
ProjectUp
func ProjectUp(p project.APIProject, c *cli.Context) error { options := options.Up{ Create: options.Create{ NoRecreate: c.Bool("no-recreate"), ForceRecreate: c.Bool("force-recreate"), NoBuild: c.Bool("no-build"), ForceBuild: c.Bool("build"), }, } ctx, cancelFun := context.WithCancel(context.Background()) err := p.Up(ctx, options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } if !c.Bool("d") { signalChan := make(chan os.Signal, 1) cleanupDone := make(chan bool) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) errChan := make(chan error) go func() { errChan <- p.Log(ctx, true, c.Args()...) }() go func() { select { case <-signalChan: fmt.Printf("\nGracefully stopping...\n") cancelFun() ProjectStop(p, c) cleanupDone <- true case err := <-errChan: if err != nil { logrus.Fatal(err) } cleanupDone <- true } }() <-cleanupDone return nil } return nil }
go
func ProjectUp(p project.APIProject, c *cli.Context) error { options := options.Up{ Create: options.Create{ NoRecreate: c.Bool("no-recreate"), ForceRecreate: c.Bool("force-recreate"), NoBuild: c.Bool("no-build"), ForceBuild: c.Bool("build"), }, } ctx, cancelFun := context.WithCancel(context.Background()) err := p.Up(ctx, options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } if !c.Bool("d") { signalChan := make(chan os.Signal, 1) cleanupDone := make(chan bool) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) errChan := make(chan error) go func() { errChan <- p.Log(ctx, true, c.Args()...) }() go func() { select { case <-signalChan: fmt.Printf("\nGracefully stopping...\n") cancelFun() ProjectStop(p, c) cleanupDone <- true case err := <-errChan: if err != nil { logrus.Fatal(err) } cleanupDone <- true } }() <-cleanupDone return nil } return nil }
[ "func", "ProjectUp", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "options", ":=", "options", ".", "Up", "{", "Create", ":", "options", ".", "Create", "{", "NoRecreate", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "ForceRecreate", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "NoBuild", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "ForceBuild", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "}", ",", "}", "\n", "ctx", ",", "cancelFun", ":=", "context", ".", "WithCancel", "(", "context", ".", "Background", "(", ")", ")", "\n", "err", ":=", "p", ".", "Up", "(", "ctx", ",", "options", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "if", "!", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "signalChan", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "cleanupDone", ":=", "make", "(", "chan", "bool", ")", "\n", "signal", ".", "Notify", "(", "signalChan", ",", "syscall", ".", "SIGINT", ",", "syscall", ".", "SIGTERM", ")", "\n", "errChan", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "errChan", "<-", "p", ".", "Log", "(", "ctx", ",", "true", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "}", "(", ")", "\n", "go", "func", "(", ")", "{", "select", "{", "case", "<-", "signalChan", ":", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ")", "\n", "cancelFun", "(", ")", "\n", "ProjectStop", "(", "p", ",", "c", ")", "\n", "cleanupDone", "<-", "true", "\n", "case", "err", ":=", "<-", "errChan", ":", "if", "err", "!=", "nil", "{", "logrus", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "cleanupDone", "<-", "true", "\n", "}", "\n", "}", "(", ")", "\n", "<-", "cleanupDone", "\n", "return", "nil", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectUp brings all services up.
[ "ProjectUp", "brings", "all", "services", "up", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L139-L179
14,275
docker/libcompose
cli/app/app.go
ProjectRun
func ProjectRun(p project.APIProject, c *cli.Context) error { if len(c.Args()) == 0 { logrus.Fatal("No service specified") } serviceName := c.Args()[0] commandParts := c.Args()[1:] options := options.Run{ Detached: c.Bool("d"), } exitCode, err := p.Run(context.Background(), serviceName, commandParts, options) if err != nil { return cli.NewExitError(err.Error(), 1) } return cli.NewExitError("", exitCode) }
go
func ProjectRun(p project.APIProject, c *cli.Context) error { if len(c.Args()) == 0 { logrus.Fatal("No service specified") } serviceName := c.Args()[0] commandParts := c.Args()[1:] options := options.Run{ Detached: c.Bool("d"), } exitCode, err := p.Run(context.Background(), serviceName, commandParts, options) if err != nil { return cli.NewExitError(err.Error(), 1) } return cli.NewExitError("", exitCode) }
[ "func", "ProjectRun", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "if", "len", "(", "c", ".", "Args", "(", ")", ")", "==", "0", "{", "logrus", ".", "Fatal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "serviceName", ":=", "c", ".", "Args", "(", ")", "[", "0", "]", "\n", "commandParts", ":=", "c", ".", "Args", "(", ")", "[", "1", ":", "]", "\n\n", "options", ":=", "options", ".", "Run", "{", "Detached", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "}", "\n\n", "exitCode", ",", "err", ":=", "p", ".", "Run", "(", "context", ".", "Background", "(", ")", ",", "serviceName", ",", "commandParts", ",", "options", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "cli", ".", "NewExitError", "(", "\"", "\"", ",", "exitCode", ")", "\n", "}" ]
// ProjectRun runs a given command within a service's container.
[ "ProjectRun", "runs", "a", "given", "command", "within", "a", "service", "s", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L182-L199
14,276
docker/libcompose
cli/app/app.go
ProjectStart
func ProjectStart(p project.APIProject, c *cli.Context) error { err := p.Start(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectStart(p project.APIProject, c *cli.Context) error { err := p.Start(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectStart", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Start", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectStart starts services.
[ "ProjectStart", "starts", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L202-L208
14,277
docker/libcompose
cli/app/app.go
ProjectRestart
func ProjectRestart(p project.APIProject, c *cli.Context) error { err := p.Restart(context.Background(), c.Int("timeout"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectRestart(p project.APIProject, c *cli.Context) error { err := p.Restart(context.Background(), c.Int("timeout"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectRestart", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Restart", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Int", "(", "\"", "\"", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectRestart restarts services.
[ "ProjectRestart", "restarts", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L211-L217
14,278
docker/libcompose
cli/app/app.go
ProjectLog
func ProjectLog(p project.APIProject, c *cli.Context) error { err := p.Log(context.Background(), c.Bool("follow"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectLog(p project.APIProject, c *cli.Context) error { err := p.Log(context.Background(), c.Bool("follow"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectLog", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Log", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectLog gets services logs.
[ "ProjectLog", "gets", "services", "logs", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L220-L226
14,279
docker/libcompose
cli/app/app.go
ProjectPull
func ProjectPull(p project.APIProject, c *cli.Context) error { err := p.Pull(context.Background(), c.Args()...) if err != nil && !c.Bool("ignore-pull-failures") { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectPull(p project.APIProject, c *cli.Context) error { err := p.Pull(context.Background(), c.Args()...) if err != nil && !c.Bool("ignore-pull-failures") { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectPull", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Pull", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectPull pulls images for services.
[ "ProjectPull", "pulls", "images", "for", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L229-L235
14,280
docker/libcompose
cli/app/app.go
ProjectDelete
func ProjectDelete(p project.APIProject, c *cli.Context) error { options := options.Delete{ RemoveVolume: c.Bool("v"), } if !c.Bool("force") { stoppedContainers, err := p.Containers(context.Background(), project.Filter{ State: project.Stopped, }, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } if len(stoppedContainers) == 0 { fmt.Println("No stopped containers") return nil } fmt.Printf("Going to remove %v\nAre you sure? [yN]\n", strings.Join(stoppedContainers, ", ")) var answer string _, err = fmt.Scanln(&answer) if err != nil { return cli.NewExitError(err.Error(), 1) } if answer != "y" && answer != "Y" { return nil } } err := p.Delete(context.Background(), options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectDelete(p project.APIProject, c *cli.Context) error { options := options.Delete{ RemoveVolume: c.Bool("v"), } if !c.Bool("force") { stoppedContainers, err := p.Containers(context.Background(), project.Filter{ State: project.Stopped, }, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } if len(stoppedContainers) == 0 { fmt.Println("No stopped containers") return nil } fmt.Printf("Going to remove %v\nAre you sure? [yN]\n", strings.Join(stoppedContainers, ", ")) var answer string _, err = fmt.Scanln(&answer) if err != nil { return cli.NewExitError(err.Error(), 1) } if answer != "y" && answer != "Y" { return nil } } err := p.Delete(context.Background(), options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectDelete", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "options", ":=", "options", ".", "Delete", "{", "RemoveVolume", ":", "c", ".", "Bool", "(", "\"", "\"", ")", ",", "}", "\n", "if", "!", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "stoppedContainers", ",", "err", ":=", "p", ".", "Containers", "(", "context", ".", "Background", "(", ")", ",", "project", ".", "Filter", "{", "State", ":", "project", ".", "Stopped", ",", "}", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "if", "len", "(", "stoppedContainers", ")", "==", "0", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n", "fmt", ".", "Printf", "(", "\"", "\\n", "\\n", "\"", ",", "strings", ".", "Join", "(", "stoppedContainers", ",", "\"", "\"", ")", ")", "\n", "var", "answer", "string", "\n", "_", ",", "err", "=", "fmt", ".", "Scanln", "(", "&", "answer", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "if", "answer", "!=", "\"", "\"", "&&", "answer", "!=", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "}", "\n", "err", ":=", "p", ".", "Delete", "(", "context", ".", "Background", "(", ")", ",", "options", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectDelete deletes services.
[ "ProjectDelete", "deletes", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L238-L268
14,281
docker/libcompose
cli/app/app.go
ProjectKill
func ProjectKill(p project.APIProject, c *cli.Context) error { err := p.Kill(context.Background(), c.String("signal"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectKill(p project.APIProject, c *cli.Context) error { err := p.Kill(context.Background(), c.String("signal"), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectKill", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Kill", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "String", "(", "\"", "\"", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectKill forces stop service containers.
[ "ProjectKill", "forces", "stop", "service", "containers", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L271-L277
14,282
docker/libcompose
cli/app/app.go
ProjectConfig
func ProjectConfig(p project.APIProject, c *cli.Context) error { yaml, err := p.Config() if err != nil { return cli.NewExitError(err.Error(), 1) } if !c.Bool("quiet") { fmt.Println(yaml) } return nil }
go
func ProjectConfig(p project.APIProject, c *cli.Context) error { yaml, err := p.Config() if err != nil { return cli.NewExitError(err.Error(), 1) } if !c.Bool("quiet") { fmt.Println(yaml) } return nil }
[ "func", "ProjectConfig", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "yaml", ",", "err", ":=", "p", ".", "Config", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "if", "!", "c", ".", "Bool", "(", "\"", "\"", ")", "{", "fmt", ".", "Println", "(", "yaml", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectConfig validates and print the compose file.
[ "ProjectConfig", "validates", "and", "print", "the", "compose", "file", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L280-L289
14,283
docker/libcompose
cli/app/app.go
ProjectPause
func ProjectPause(p project.APIProject, c *cli.Context) error { err := p.Pause(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectPause(p project.APIProject, c *cli.Context) error { err := p.Pause(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectPause", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Pause", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectPause pauses service containers.
[ "ProjectPause", "pauses", "service", "containers", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L292-L298
14,284
docker/libcompose
cli/app/app.go
ProjectUnpause
func ProjectUnpause(p project.APIProject, c *cli.Context) error { err := p.Unpause(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
go
func ProjectUnpause(p project.APIProject, c *cli.Context) error { err := p.Unpause(context.Background(), c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } return nil }
[ "func", "ProjectUnpause", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "err", ":=", "p", ".", "Unpause", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Args", "(", ")", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "1", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectUnpause unpauses service containers.
[ "ProjectUnpause", "unpauses", "service", "containers", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L301-L307
14,285
docker/libcompose
cli/app/app.go
ProjectScale
func ProjectScale(p project.APIProject, c *cli.Context) error { servicesScale := map[string]int{} for _, arg := range c.Args() { kv := strings.SplitN(arg, "=", 2) if len(kv) != 2 { return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %s", arg), 2) } name := kv[0] count, err := strconv.Atoi(kv[1]) if err != nil { return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %v", err), 2) } servicesScale[name] = count } err := p.Scale(context.Background(), c.Int("timeout"), servicesScale) if err != nil { return cli.NewExitError(err.Error(), 0) } return nil }
go
func ProjectScale(p project.APIProject, c *cli.Context) error { servicesScale := map[string]int{} for _, arg := range c.Args() { kv := strings.SplitN(arg, "=", 2) if len(kv) != 2 { return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %s", arg), 2) } name := kv[0] count, err := strconv.Atoi(kv[1]) if err != nil { return cli.NewExitError(fmt.Sprintf("Invalid scale parameter: %v", err), 2) } servicesScale[name] = count } err := p.Scale(context.Background(), c.Int("timeout"), servicesScale) if err != nil { return cli.NewExitError(err.Error(), 0) } return nil }
[ "func", "ProjectScale", "(", "p", "project", ".", "APIProject", ",", "c", "*", "cli", ".", "Context", ")", "error", "{", "servicesScale", ":=", "map", "[", "string", "]", "int", "{", "}", "\n", "for", "_", ",", "arg", ":=", "range", "c", ".", "Args", "(", ")", "{", "kv", ":=", "strings", ".", "SplitN", "(", "arg", ",", "\"", "\"", ",", "2", ")", "\n", "if", "len", "(", "kv", ")", "!=", "2", "{", "return", "cli", ".", "NewExitError", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "arg", ")", ",", "2", ")", "\n", "}", "\n\n", "name", ":=", "kv", "[", "0", "]", "\n\n", "count", ",", "err", ":=", "strconv", ".", "Atoi", "(", "kv", "[", "1", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ",", "2", ")", "\n", "}", "\n\n", "servicesScale", "[", "name", "]", "=", "count", "\n", "}", "\n\n", "err", ":=", "p", ".", "Scale", "(", "context", ".", "Background", "(", ")", ",", "c", ".", "Int", "(", "\"", "\"", ")", ",", "servicesScale", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cli", ".", "NewExitError", "(", "err", ".", "Error", "(", ")", ",", "0", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ProjectScale scales services.
[ "ProjectScale", "scales", "services", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/cli/app/app.go#L310-L333
14,286
docker/libcompose
config/merge_v2.go
MergeServicesV2
func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup, resourceLookup ResourceLookup, file string, datas RawServiceMap, options *ParseOptions) (map[string]*ServiceConfig, error) { if options.Validate { if err := validateV2(datas); err != nil { return nil, err } } for name, data := range datas { data, err := parseV2(resourceLookup, environmentLookup, file, data, datas, options) if err != nil { logrus.Errorf("Failed to parse service %s: %v", name, err) return nil, err } if serviceConfig, ok := existingServices.Get(name); ok { var rawExistingService RawService if err := utils.Convert(serviceConfig, &rawExistingService); err != nil { return nil, err } data = mergeConfig(rawExistingService, data) } datas[name] = data } if options.Validate { var errs []string for name, data := range datas { err := validateServiceConstraintsv2(data, name) if err != nil { errs = append(errs, err.Error()) } } if len(errs) != 0 { return nil, fmt.Errorf(strings.Join(errs, "\n")) } } serviceConfigs := make(map[string]*ServiceConfig) if err := utils.Convert(datas, &serviceConfigs); err != nil { return nil, err } return serviceConfigs, nil }
go
func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup, resourceLookup ResourceLookup, file string, datas RawServiceMap, options *ParseOptions) (map[string]*ServiceConfig, error) { if options.Validate { if err := validateV2(datas); err != nil { return nil, err } } for name, data := range datas { data, err := parseV2(resourceLookup, environmentLookup, file, data, datas, options) if err != nil { logrus.Errorf("Failed to parse service %s: %v", name, err) return nil, err } if serviceConfig, ok := existingServices.Get(name); ok { var rawExistingService RawService if err := utils.Convert(serviceConfig, &rawExistingService); err != nil { return nil, err } data = mergeConfig(rawExistingService, data) } datas[name] = data } if options.Validate { var errs []string for name, data := range datas { err := validateServiceConstraintsv2(data, name) if err != nil { errs = append(errs, err.Error()) } } if len(errs) != 0 { return nil, fmt.Errorf(strings.Join(errs, "\n")) } } serviceConfigs := make(map[string]*ServiceConfig) if err := utils.Convert(datas, &serviceConfigs); err != nil { return nil, err } return serviceConfigs, nil }
[ "func", "MergeServicesV2", "(", "existingServices", "*", "ServiceConfigs", ",", "environmentLookup", "EnvironmentLookup", ",", "resourceLookup", "ResourceLookup", ",", "file", "string", ",", "datas", "RawServiceMap", ",", "options", "*", "ParseOptions", ")", "(", "map", "[", "string", "]", "*", "ServiceConfig", ",", "error", ")", "{", "if", "options", ".", "Validate", "{", "if", "err", ":=", "validateV2", "(", "datas", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "for", "name", ",", "data", ":=", "range", "datas", "{", "data", ",", "err", ":=", "parseV2", "(", "resourceLookup", ",", "environmentLookup", ",", "file", ",", "data", ",", "datas", ",", "options", ")", "\n", "if", "err", "!=", "nil", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "serviceConfig", ",", "ok", ":=", "existingServices", ".", "Get", "(", "name", ")", ";", "ok", "{", "var", "rawExistingService", "RawService", "\n", "if", "err", ":=", "utils", ".", "Convert", "(", "serviceConfig", ",", "&", "rawExistingService", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "data", "=", "mergeConfig", "(", "rawExistingService", ",", "data", ")", "\n", "}", "\n\n", "datas", "[", "name", "]", "=", "data", "\n", "}", "\n\n", "if", "options", ".", "Validate", "{", "var", "errs", "[", "]", "string", "\n", "for", "name", ",", "data", ":=", "range", "datas", "{", "err", ":=", "validateServiceConstraintsv2", "(", "data", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "errs", ")", "!=", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "strings", ".", "Join", "(", "errs", ",", "\"", "\\n", "\"", ")", ")", "\n", "}", "\n", "}", "\n\n", "serviceConfigs", ":=", "make", "(", "map", "[", "string", "]", "*", "ServiceConfig", ")", "\n", "if", "err", ":=", "utils", ".", "Convert", "(", "datas", ",", "&", "serviceConfigs", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "serviceConfigs", ",", "nil", "\n", "}" ]
// MergeServicesV2 merges a v2 compose file into an existing set of service configs
[ "MergeServicesV2", "merges", "a", "v2", "compose", "file", "into", "an", "existing", "set", "of", "service", "configs" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/config/merge_v2.go#L13-L58
14,287
docker/libcompose
project/service.go
NewServiceRelationship
func NewServiceRelationship(nameAlias string, relType ServiceRelationshipType) ServiceRelationship { name, alias := NameAlias(nameAlias) return ServiceRelationship{ Target: name, Alias: alias, Type: relType, } }
go
func NewServiceRelationship(nameAlias string, relType ServiceRelationshipType) ServiceRelationship { name, alias := NameAlias(nameAlias) return ServiceRelationship{ Target: name, Alias: alias, Type: relType, } }
[ "func", "NewServiceRelationship", "(", "nameAlias", "string", ",", "relType", "ServiceRelationshipType", ")", "ServiceRelationship", "{", "name", ",", "alias", ":=", "NameAlias", "(", "nameAlias", ")", "\n", "return", "ServiceRelationship", "{", "Target", ":", "name", ",", "Alias", ":", "alias", ",", "Type", ":", "relType", ",", "}", "\n", "}" ]
// NewServiceRelationship creates a new Relationship based on the specified alias // and relationship type.
[ "NewServiceRelationship", "creates", "a", "new", "Relationship", "based", "on", "the", "specified", "alias", "and", "relationship", "type", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/service.go#L90-L97
14,288
docker/libcompose
lookup/envfile.go
Lookup
func (l *EnvfileLookup) Lookup(key string, config *config.ServiceConfig) []string { envs, err := opts.ParseEnvFile(l.Path) if err != nil { return []string{} } for _, env := range envs { e := strings.Split(env, "=") if e[0] == key { return []string{env} } } return []string{} }
go
func (l *EnvfileLookup) Lookup(key string, config *config.ServiceConfig) []string { envs, err := opts.ParseEnvFile(l.Path) if err != nil { return []string{} } for _, env := range envs { e := strings.Split(env, "=") if e[0] == key { return []string{env} } } return []string{} }
[ "func", "(", "l", "*", "EnvfileLookup", ")", "Lookup", "(", "key", "string", ",", "config", "*", "config", ".", "ServiceConfig", ")", "[", "]", "string", "{", "envs", ",", "err", ":=", "opts", ".", "ParseEnvFile", "(", "l", ".", "Path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "string", "{", "}", "\n", "}", "\n", "for", "_", ",", "env", ":=", "range", "envs", "{", "e", ":=", "strings", ".", "Split", "(", "env", ",", "\"", "\"", ")", "\n", "if", "e", "[", "0", "]", "==", "key", "{", "return", "[", "]", "string", "{", "env", "}", "\n", "}", "\n", "}", "\n", "return", "[", "]", "string", "{", "}", "\n", "}" ]
// Lookup creates a string slice of string containing a "docker-friendly" environment string // in the form of 'key=value'. It gets environment values using a '.env' file in the specified // path.
[ "Lookup", "creates", "a", "string", "slice", "of", "string", "containing", "a", "docker", "-", "friendly", "environment", "string", "in", "the", "form", "of", "key", "=", "value", ".", "It", "gets", "environment", "values", "using", "a", ".", "env", "file", "in", "the", "specified", "path", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/lookup/envfile.go#L19-L31
14,289
docker/libcompose
project/project_containers.go
Containers
func (p *Project) Containers(ctx context.Context, filter Filter, services ...string) ([]string, error) { containers := []string{} var lock sync.Mutex err := p.forEach(services, wrapperAction(func(wrapper *serviceWrapper, wrappers map[string]*serviceWrapper) { wrapper.Do(nil, events.NoEvent, events.NoEvent, func(service Service) error { serviceContainers, innerErr := service.Containers(ctx) if innerErr != nil { return innerErr } for _, container := range serviceContainers { running := container.IsRunning(ctx) switch filter.State { case Running: if !running { continue } case Stopped: if running { continue } case AnyState: // Don't do a thing default: // Invalid state filter return fmt.Errorf("Invalid container filter: %s", filter.State) } containerID := container.ID() lock.Lock() containers = append(containers, containerID) lock.Unlock() } return nil }) }), nil) if err != nil { return nil, err } return containers, nil }
go
func (p *Project) Containers(ctx context.Context, filter Filter, services ...string) ([]string, error) { containers := []string{} var lock sync.Mutex err := p.forEach(services, wrapperAction(func(wrapper *serviceWrapper, wrappers map[string]*serviceWrapper) { wrapper.Do(nil, events.NoEvent, events.NoEvent, func(service Service) error { serviceContainers, innerErr := service.Containers(ctx) if innerErr != nil { return innerErr } for _, container := range serviceContainers { running := container.IsRunning(ctx) switch filter.State { case Running: if !running { continue } case Stopped: if running { continue } case AnyState: // Don't do a thing default: // Invalid state filter return fmt.Errorf("Invalid container filter: %s", filter.State) } containerID := container.ID() lock.Lock() containers = append(containers, containerID) lock.Unlock() } return nil }) }), nil) if err != nil { return nil, err } return containers, nil }
[ "func", "(", "p", "*", "Project", ")", "Containers", "(", "ctx", "context", ".", "Context", ",", "filter", "Filter", ",", "services", "...", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "containers", ":=", "[", "]", "string", "{", "}", "\n", "var", "lock", "sync", ".", "Mutex", "\n\n", "err", ":=", "p", ".", "forEach", "(", "services", ",", "wrapperAction", "(", "func", "(", "wrapper", "*", "serviceWrapper", ",", "wrappers", "map", "[", "string", "]", "*", "serviceWrapper", ")", "{", "wrapper", ".", "Do", "(", "nil", ",", "events", ".", "NoEvent", ",", "events", ".", "NoEvent", ",", "func", "(", "service", "Service", ")", "error", "{", "serviceContainers", ",", "innerErr", ":=", "service", ".", "Containers", "(", "ctx", ")", "\n", "if", "innerErr", "!=", "nil", "{", "return", "innerErr", "\n", "}", "\n\n", "for", "_", ",", "container", ":=", "range", "serviceContainers", "{", "running", ":=", "container", ".", "IsRunning", "(", "ctx", ")", "\n", "switch", "filter", ".", "State", "{", "case", "Running", ":", "if", "!", "running", "{", "continue", "\n", "}", "\n", "case", "Stopped", ":", "if", "running", "{", "continue", "\n", "}", "\n", "case", "AnyState", ":", "// Don't do a thing", "default", ":", "// Invalid state filter", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "filter", ".", "State", ")", "\n", "}", "\n", "containerID", ":=", "container", ".", "ID", "(", ")", "\n", "lock", ".", "Lock", "(", ")", "\n", "containers", "=", "append", "(", "containers", ",", "containerID", ")", "\n", "lock", ".", "Unlock", "(", ")", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "}", ")", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "containers", ",", "nil", "\n", "}" ]
// Containers lists the containers for the specified services. Can be filter using // the Filter struct.
[ "Containers", "lists", "the", "containers", "for", "the", "specified", "services", ".", "Can", "be", "filter", "using", "the", "Filter", "struct", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/project/project_containers.go#L14-L54
14,290
docker/libcompose
docker/container/container.go
New
func New(ctx context.Context, client client.ContainerAPIClient, id string) (*Container, error) { container, err := Get(ctx, client, id) if err != nil { return nil, err } return &Container{ client: client, id: id, container: container, }, nil }
go
func New(ctx context.Context, client client.ContainerAPIClient, id string) (*Container, error) { container, err := Get(ctx, client, id) if err != nil { return nil, err } return &Container{ client: client, id: id, container: container, }, nil }
[ "func", "New", "(", "ctx", "context", ".", "Context", ",", "client", "client", ".", "ContainerAPIClient", ",", "id", "string", ")", "(", "*", "Container", ",", "error", ")", "{", "container", ",", "err", ":=", "Get", "(", "ctx", ",", "client", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "Container", "{", "client", ":", "client", ",", "id", ":", "id", ",", "container", ":", "container", ",", "}", ",", "nil", "\n", "}" ]
// New creates a container struct with the specified client, id and name
[ "New", "creates", "a", "container", "struct", "with", "the", "specified", "client", "id", "and", "name" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L45-L55
14,291
docker/libcompose
docker/container/container.go
NewInspected
func NewInspected(client client.ContainerAPIClient, container *types.ContainerJSON) *Container { return &Container{ client: client, id: container.ID, container: container, } }
go
func NewInspected(client client.ContainerAPIClient, container *types.ContainerJSON) *Container { return &Container{ client: client, id: container.ID, container: container, } }
[ "func", "NewInspected", "(", "client", "client", ".", "ContainerAPIClient", ",", "container", "*", "types", ".", "ContainerJSON", ")", "*", "Container", "{", "return", "&", "Container", "{", "client", ":", "client", ",", "id", ":", "container", ".", "ID", ",", "container", ":", "container", ",", "}", "\n", "}" ]
// NewInspected creates a container struct from an inspected container
[ "NewInspected", "creates", "a", "container", "struct", "from", "an", "inspected", "container" ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L58-L64
14,292
docker/libcompose
docker/container/container.go
Info
func (c *Container) Info(ctx context.Context) (project.Info, error) { infos, err := ListByFilter(ctx, c.client, map[string][]string{ "name": {c.container.Name}, }) if err != nil || len(infos) == 0 { return nil, err } info := infos[0] result := project.Info{} result["Id"] = c.container.ID result["Name"] = name(info.Names) result["Command"] = info.Command result["State"] = info.Status result["Ports"] = portString(info.Ports) return result, nil }
go
func (c *Container) Info(ctx context.Context) (project.Info, error) { infos, err := ListByFilter(ctx, c.client, map[string][]string{ "name": {c.container.Name}, }) if err != nil || len(infos) == 0 { return nil, err } info := infos[0] result := project.Info{} result["Id"] = c.container.ID result["Name"] = name(info.Names) result["Command"] = info.Command result["State"] = info.Status result["Ports"] = portString(info.Ports) return result, nil }
[ "func", "(", "c", "*", "Container", ")", "Info", "(", "ctx", "context", ".", "Context", ")", "(", "project", ".", "Info", ",", "error", ")", "{", "infos", ",", "err", ":=", "ListByFilter", "(", "ctx", ",", "c", ".", "client", ",", "map", "[", "string", "]", "[", "]", "string", "{", "\"", "\"", ":", "{", "c", ".", "container", ".", "Name", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "||", "len", "(", "infos", ")", "==", "0", "{", "return", "nil", ",", "err", "\n", "}", "\n", "info", ":=", "infos", "[", "0", "]", "\n\n", "result", ":=", "project", ".", "Info", "{", "}", "\n", "result", "[", "\"", "\"", "]", "=", "c", ".", "container", ".", "ID", "\n", "result", "[", "\"", "\"", "]", "=", "name", "(", "info", ".", "Names", ")", "\n", "result", "[", "\"", "\"", "]", "=", "info", ".", "Command", "\n", "result", "[", "\"", "\"", "]", "=", "info", ".", "Status", "\n", "result", "[", "\"", "\"", "]", "=", "portString", "(", "info", ".", "Ports", ")", "\n\n", "return", "result", ",", "nil", "\n", "}" ]
// Info returns info about the container, like name, command, state or ports.
[ "Info", "returns", "info", "about", "the", "container", "like", "name", "command", "state", "or", "ports", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L67-L84
14,293
docker/libcompose
docker/container/container.go
Rename
func (c *Container) Rename(ctx context.Context, newName string) error { return c.client.ContainerRename(ctx, c.container.ID, newName) }
go
func (c *Container) Rename(ctx context.Context, newName string) error { return c.client.ContainerRename(ctx, c.container.ID, newName) }
[ "func", "(", "c", "*", "Container", ")", "Rename", "(", "ctx", "context", ".", "Context", ",", "newName", "string", ")", "error", "{", "return", "c", ".", "client", ".", "ContainerRename", "(", "ctx", ",", "c", ".", "container", ".", "ID", ",", "newName", ")", "\n", "}" ]
// Rename rename the container.
[ "Rename", "rename", "the", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L115-L117
14,294
docker/libcompose
docker/container/container.go
Remove
func (c *Container) Remove(ctx context.Context, removeVolume bool) error { return c.client.ContainerRemove(ctx, c.container.ID, types.ContainerRemoveOptions{ Force: true, RemoveVolumes: removeVolume, }) }
go
func (c *Container) Remove(ctx context.Context, removeVolume bool) error { return c.client.ContainerRemove(ctx, c.container.ID, types.ContainerRemoveOptions{ Force: true, RemoveVolumes: removeVolume, }) }
[ "func", "(", "c", "*", "Container", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "removeVolume", "bool", ")", "error", "{", "return", "c", ".", "client", ".", "ContainerRemove", "(", "ctx", ",", "c", ".", "container", ".", "ID", ",", "types", ".", "ContainerRemoveOptions", "{", "Force", ":", "true", ",", "RemoveVolumes", ":", "removeVolume", ",", "}", ")", "\n", "}" ]
// Remove removes the container.
[ "Remove", "removes", "the", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L120-L125
14,295
docker/libcompose
docker/container/container.go
Stop
func (c *Container) Stop(ctx context.Context, timeout int) error { timeoutDuration := time.Duration(timeout) * time.Second return c.client.ContainerStop(ctx, c.container.ID, &timeoutDuration) }
go
func (c *Container) Stop(ctx context.Context, timeout int) error { timeoutDuration := time.Duration(timeout) * time.Second return c.client.ContainerStop(ctx, c.container.ID, &timeoutDuration) }
[ "func", "(", "c", "*", "Container", ")", "Stop", "(", "ctx", "context", ".", "Context", ",", "timeout", "int", ")", "error", "{", "timeoutDuration", ":=", "time", ".", "Duration", "(", "timeout", ")", "*", "time", ".", "Second", "\n", "return", "c", ".", "client", ".", "ContainerStop", "(", "ctx", ",", "c", ".", "container", ".", "ID", ",", "&", "timeoutDuration", ")", "\n", "}" ]
// Stop stops the container.
[ "Stop", "stops", "the", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L128-L131
14,296
docker/libcompose
docker/container/container.go
Pause
func (c *Container) Pause(ctx context.Context) error { if !c.container.State.Paused { if err := c.client.ContainerPause(ctx, c.container.ID); err != nil { return err } return c.updateInnerContainer(ctx) } return nil }
go
func (c *Container) Pause(ctx context.Context) error { if !c.container.State.Paused { if err := c.client.ContainerPause(ctx, c.container.ID); err != nil { return err } return c.updateInnerContainer(ctx) } return nil }
[ "func", "(", "c", "*", "Container", ")", "Pause", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "!", "c", ".", "container", ".", "State", ".", "Paused", "{", "if", "err", ":=", "c", ".", "client", ".", "ContainerPause", "(", "ctx", ",", "c", ".", "container", ".", "ID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "updateInnerContainer", "(", "ctx", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Pause pauses the container. If the containers are already paused, don't fail.
[ "Pause", "pauses", "the", "container", ".", "If", "the", "containers", "are", "already", "paused", "don", "t", "fail", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L134-L142
14,297
docker/libcompose
docker/container/container.go
Unpause
func (c *Container) Unpause(ctx context.Context) error { if c.container.State.Paused { if err := c.client.ContainerUnpause(ctx, c.container.ID); err != nil { return err } return c.updateInnerContainer(ctx) } return nil }
go
func (c *Container) Unpause(ctx context.Context) error { if c.container.State.Paused { if err := c.client.ContainerUnpause(ctx, c.container.ID); err != nil { return err } return c.updateInnerContainer(ctx) } return nil }
[ "func", "(", "c", "*", "Container", ")", "Unpause", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "c", ".", "container", ".", "State", ".", "Paused", "{", "if", "err", ":=", "c", ".", "client", ".", "ContainerUnpause", "(", "ctx", ",", "c", ".", "container", ".", "ID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "c", ".", "updateInnerContainer", "(", "ctx", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Unpause unpauses the container. If the containers are not paused, don't fail.
[ "Unpause", "unpauses", "the", "container", ".", "If", "the", "containers", "are", "not", "paused", "don", "t", "fail", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L145-L153
14,298
docker/libcompose
docker/container/container.go
Kill
func (c *Container) Kill(ctx context.Context, signal string) error { return c.client.ContainerKill(ctx, c.container.ID, signal) }
go
func (c *Container) Kill(ctx context.Context, signal string) error { return c.client.ContainerKill(ctx, c.container.ID, signal) }
[ "func", "(", "c", "*", "Container", ")", "Kill", "(", "ctx", "context", ".", "Context", ",", "signal", "string", ")", "error", "{", "return", "c", ".", "client", ".", "ContainerKill", "(", "ctx", ",", "c", ".", "container", ".", "ID", ",", "signal", ")", "\n", "}" ]
// Kill kill the container.
[ "Kill", "kill", "the", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L165-L167
14,299
docker/libcompose
docker/container/container.go
IsRunning
func (c *Container) IsRunning(ctx context.Context) bool { return c.container.State.Running }
go
func (c *Container) IsRunning(ctx context.Context) bool { return c.container.State.Running }
[ "func", "(", "c", "*", "Container", ")", "IsRunning", "(", "ctx", "context", ".", "Context", ")", "bool", "{", "return", "c", ".", "container", ".", "State", ".", "Running", "\n", "}" ]
// IsRunning returns the running state of the container.
[ "IsRunning", "returns", "the", "running", "state", "of", "the", "container", "." ]
213509acef0fe8f2358f4c0bb977eb3f4889ea15
https://github.com/docker/libcompose/blob/213509acef0fe8f2358f4c0bb977eb3f4889ea15/docker/container/container.go#L170-L172