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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
14,500
opencontainers/runtime-tools
generate/generate.go
SetWindowsIgnoreFlushesDuringBoot
func (g *Generator) SetWindowsIgnoreFlushesDuringBoot(ignore bool) { g.initConfigWindows() g.Config.Windows.IgnoreFlushesDuringBoot = ignore }
go
func (g *Generator) SetWindowsIgnoreFlushesDuringBoot(ignore bool) { g.initConfigWindows() g.Config.Windows.IgnoreFlushesDuringBoot = ignore }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsIgnoreFlushesDuringBoot", "(", "ignore", "bool", ")", "{", "g", ".", "initConfigWindows", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "IgnoreFlushesDuringBoot", "=", "ignore", "\n", "}" ]
// SetWindowsIgnoreFlushesDuringBoot sets g.Config.Windows.IgnoreFlushesDuringBoot.
[ "SetWindowsIgnoreFlushesDuringBoot", "sets", "g", ".", "Config", ".", "Windows", ".", "IgnoreFlushesDuringBoot", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1760-L1763
14,501
opencontainers/runtime-tools
generate/generate.go
AddWindowsLayerFolders
func (g *Generator) AddWindowsLayerFolders(folder string) { g.initConfigWindows() g.Config.Windows.LayerFolders = append(g.Config.Windows.LayerFolders, folder) }
go
func (g *Generator) AddWindowsLayerFolders(folder string) { g.initConfigWindows() g.Config.Windows.LayerFolders = append(g.Config.Windows.LayerFolders, folder) }
[ "func", "(", "g", "*", "Generator", ")", "AddWindowsLayerFolders", "(", "folder", "string", ")", "{", "g", ".", "initConfigWindows", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "LayerFolders", "=", "append", "(", "g", ".", "Config", ".", "...
// AddWindowsLayerFolders adds layer folders into g.Config.Windows.LayerFolders.
[ "AddWindowsLayerFolders", "adds", "layer", "folders", "into", "g", ".", "Config", ".", "Windows", ".", "LayerFolders", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1766-L1769
14,502
opencontainers/runtime-tools
generate/generate.go
AddWindowsDevices
func (g *Generator) AddWindowsDevices(id, idType string) error { if idType != "class" { return fmt.Errorf("Invalid idType value: %s. Windows only supports a value of class", idType) } device := rspec.WindowsDevice{ ID: id, IDType: idType, } g.initConfigWindows() for i, device := range g.Config.Windows.Devices { if device.ID == id { g.Config.Windows.Devices[i].IDType = idType return nil } } g.Config.Windows.Devices = append(g.Config.Windows.Devices, device) return nil }
go
func (g *Generator) AddWindowsDevices(id, idType string) error { if idType != "class" { return fmt.Errorf("Invalid idType value: %s. Windows only supports a value of class", idType) } device := rspec.WindowsDevice{ ID: id, IDType: idType, } g.initConfigWindows() for i, device := range g.Config.Windows.Devices { if device.ID == id { g.Config.Windows.Devices[i].IDType = idType return nil } } g.Config.Windows.Devices = append(g.Config.Windows.Devices, device) return nil }
[ "func", "(", "g", "*", "Generator", ")", "AddWindowsDevices", "(", "id", ",", "idType", "string", ")", "error", "{", "if", "idType", "!=", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "idType", ")", "\n", "}", "\n", "devic...
// AddWindowsDevices adds or sets g.Config.Windwos.Devices
[ "AddWindowsDevices", "adds", "or", "sets", "g", ".", "Config", ".", "Windwos", ".", "Devices" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1772-L1790
14,503
opencontainers/runtime-tools
generate/generate.go
SetWindowsNetwork
func (g *Generator) SetWindowsNetwork(network rspec.WindowsNetwork) { g.initConfigWindows() g.Config.Windows.Network = &network }
go
func (g *Generator) SetWindowsNetwork(network rspec.WindowsNetwork) { g.initConfigWindows() g.Config.Windows.Network = &network }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsNetwork", "(", "network", "rspec", ".", "WindowsNetwork", ")", "{", "g", ".", "initConfigWindows", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Network", "=", "&", "network", "\n", "}" ]
// SetWindowsNetwork sets g.Config.Windows.Network.
[ "SetWindowsNetwork", "sets", "g", ".", "Config", ".", "Windows", ".", "Network", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1793-L1796
14,504
opencontainers/runtime-tools
generate/generate.go
SetWindowsNetworkAllowUnqualifiedDNSQuery
func (g *Generator) SetWindowsNetworkAllowUnqualifiedDNSQuery(setting bool) { g.initConfigWindowsNetwork() g.Config.Windows.Network.AllowUnqualifiedDNSQuery = setting }
go
func (g *Generator) SetWindowsNetworkAllowUnqualifiedDNSQuery(setting bool) { g.initConfigWindowsNetwork() g.Config.Windows.Network.AllowUnqualifiedDNSQuery = setting }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsNetworkAllowUnqualifiedDNSQuery", "(", "setting", "bool", ")", "{", "g", ".", "initConfigWindowsNetwork", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Network", ".", "AllowUnqualifiedDNSQuery", "="...
// SetWindowsNetworkAllowUnqualifiedDNSQuery sets g.Config.Windows.Network.AllowUnqualifiedDNSQuery
[ "SetWindowsNetworkAllowUnqualifiedDNSQuery", "sets", "g", ".", "Config", ".", "Windows", ".", "Network", ".", "AllowUnqualifiedDNSQuery" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1799-L1802
14,505
opencontainers/runtime-tools
generate/generate.go
SetWindowsNetworkNamespace
func (g *Generator) SetWindowsNetworkNamespace(path string) { g.initConfigWindowsNetwork() g.Config.Windows.Network.NetworkNamespace = path }
go
func (g *Generator) SetWindowsNetworkNamespace(path string) { g.initConfigWindowsNetwork() g.Config.Windows.Network.NetworkNamespace = path }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsNetworkNamespace", "(", "path", "string", ")", "{", "g", ".", "initConfigWindowsNetwork", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Network", ".", "NetworkNamespace", "=", "path", "\n", "}...
// SetWindowsNetworkNamespace sets g.Config.Windows.Network.NetworkNamespace
[ "SetWindowsNetworkNamespace", "sets", "g", ".", "Config", ".", "Windows", ".", "Network", ".", "NetworkNamespace" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1805-L1808
14,506
opencontainers/runtime-tools
generate/generate.go
SetWindowsResourcesCPU
func (g *Generator) SetWindowsResourcesCPU(cpu rspec.WindowsCPUResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.CPU = &cpu }
go
func (g *Generator) SetWindowsResourcesCPU(cpu rspec.WindowsCPUResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.CPU = &cpu }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsResourcesCPU", "(", "cpu", "rspec", ".", "WindowsCPUResources", ")", "{", "g", ".", "initConfigWindowsResources", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "CPU", "=", "&"...
// SetWindowsResourcesCPU sets g.Config.Windows.Resources.CPU.
[ "SetWindowsResourcesCPU", "sets", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "CPU", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1811-L1814
14,507
opencontainers/runtime-tools
generate/generate.go
SetWindowsResourcesMemoryLimit
func (g *Generator) SetWindowsResourcesMemoryLimit(limit uint64) { g.initConfigWindowsResourcesMemory() g.Config.Windows.Resources.Memory.Limit = &limit }
go
func (g *Generator) SetWindowsResourcesMemoryLimit(limit uint64) { g.initConfigWindowsResourcesMemory() g.Config.Windows.Resources.Memory.Limit = &limit }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsResourcesMemoryLimit", "(", "limit", "uint64", ")", "{", "g", ".", "initConfigWindowsResourcesMemory", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "Memory", ".", "Limit", "=",...
// SetWindowsResourcesMemoryLimit sets g.Config.Windows.Resources.Memory.Limit.
[ "SetWindowsResourcesMemoryLimit", "sets", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "Memory", ".", "Limit", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1817-L1820
14,508
opencontainers/runtime-tools
generate/generate.go
SetWindowsResourcesStorage
func (g *Generator) SetWindowsResourcesStorage(storage rspec.WindowsStorageResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.Storage = &storage }
go
func (g *Generator) SetWindowsResourcesStorage(storage rspec.WindowsStorageResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.Storage = &storage }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsResourcesStorage", "(", "storage", "rspec", ".", "WindowsStorageResources", ")", "{", "g", ".", "initConfigWindowsResources", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "Storag...
// SetWindowsResourcesStorage sets g.Config.Windows.Resources.Storage.
[ "SetWindowsResourcesStorage", "sets", "g", ".", "Config", ".", "Windows", ".", "Resources", ".", "Storage", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1823-L1826
14,509
opencontainers/runtime-tools
generate/generate.go
SetWindowsServicing
func (g *Generator) SetWindowsServicing(servicing bool) { g.initConfigWindows() g.Config.Windows.Servicing = servicing }
go
func (g *Generator) SetWindowsServicing(servicing bool) { g.initConfigWindows() g.Config.Windows.Servicing = servicing }
[ "func", "(", "g", "*", "Generator", ")", "SetWindowsServicing", "(", "servicing", "bool", ")", "{", "g", ".", "initConfigWindows", "(", ")", "\n", "g", ".", "Config", ".", "Windows", ".", "Servicing", "=", "servicing", "\n", "}" ]
// SetWindowsServicing sets g.Config.Windows.Servicing.
[ "SetWindowsServicing", "sets", "g", ".", "Config", ".", "Windows", ".", "Servicing", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/generate.go#L1829-L1832
14,510
opencontainers/runtime-tools
validation/util/linux_resources_devices.go
ValidateLinuxResourcesDevices
func ValidateLinuxResourcesDevices(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find devices") if err != nil { t.Diagnostic(err.Error()) return nil } lnd, err := cg.GetDevicesData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get devices data") if err != nil { t.Diagnostic(err.Error()) return nil } for i, device := range config.Linux.Resources.Devices { if device.Allow == true { found := false if lnd[i-1].Type == device.Type && *lnd[i-1].Major == *device.Major && *lnd[i-1].Minor == *device.Minor && lnd[i-1].Access == device.Access { found = true } t.Ok(found, fmt.Sprintf("devices %s %d:%d %s is set correctly", device.Type, *device.Major, *device.Minor, device.Access)) t.Diagnosticf("expect: %s %d:%d %s, actual: %s %d:%d %s", device.Type, *device.Major, *device.Minor, device.Access, lnd[i-1].Type, *lnd[i-1].Major, *lnd[i-1].Minor, lnd[i-1].Access) if !found { err := specerror.NewError(specerror.DevicesApplyInOrder, fmt.Errorf("The runtime MUST apply entries in the listed order"), rspec.Version) t.Diagnostic(err.Error()) return nil } } } return nil }
go
func ValidateLinuxResourcesDevices(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find devices") if err != nil { t.Diagnostic(err.Error()) return nil } lnd, err := cg.GetDevicesData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get devices data") if err != nil { t.Diagnostic(err.Error()) return nil } for i, device := range config.Linux.Resources.Devices { if device.Allow == true { found := false if lnd[i-1].Type == device.Type && *lnd[i-1].Major == *device.Major && *lnd[i-1].Minor == *device.Minor && lnd[i-1].Access == device.Access { found = true } t.Ok(found, fmt.Sprintf("devices %s %d:%d %s is set correctly", device.Type, *device.Major, *device.Minor, device.Access)) t.Diagnosticf("expect: %s %d:%d %s, actual: %s %d:%d %s", device.Type, *device.Major, *device.Minor, device.Access, lnd[i-1].Type, *lnd[i-1].Major, *lnd[i-1].Minor, lnd[i-1].Access) if !found { err := specerror.NewError(specerror.DevicesApplyInOrder, fmt.Errorf("The runtime MUST apply entries in the listed order"), rspec.Version) t.Diagnostic(err.Error()) return nil } } } return nil }
[ "func", "ValidateLinuxResourcesDevices", "(", "config", "*", "rspec", ".", "Spec", ",", "t", "*", "tap", ".", "T", ",", "state", "*", "rspec", ".", "State", ")", "error", "{", "cg", ",", "err", ":=", "cgroups", ".", "FindCgroup", "(", ")", "\n", "t",...
// ValidateLinuxResourcesDevices validates linux.resources.devices.
[ "ValidateLinuxResourcesDevices", "validates", "linux", ".", "resources", ".", "devices", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/linux_resources_devices.go#L13-L46
14,511
opencontainers/runtime-tools
filepath/ancestor.go
IsAncestor
func IsAncestor(os, pathA, pathB, cwd string) (_ bool, err error) { if pathA == pathB { return false, nil } pathA, err = Abs(os, pathA, cwd) if err != nil { return false, err } pathB, err = Abs(os, pathB, cwd) if err != nil { return false, err } sep := Separator(os) if !strings.HasSuffix(pathA, string(sep)) { pathA = fmt.Sprintf("%s%c", pathA, sep) } if pathA == pathB { return false, nil } return strings.HasPrefix(pathB, pathA), nil }
go
func IsAncestor(os, pathA, pathB, cwd string) (_ bool, err error) { if pathA == pathB { return false, nil } pathA, err = Abs(os, pathA, cwd) if err != nil { return false, err } pathB, err = Abs(os, pathB, cwd) if err != nil { return false, err } sep := Separator(os) if !strings.HasSuffix(pathA, string(sep)) { pathA = fmt.Sprintf("%s%c", pathA, sep) } if pathA == pathB { return false, nil } return strings.HasPrefix(pathB, pathA), nil }
[ "func", "IsAncestor", "(", "os", ",", "pathA", ",", "pathB", ",", "cwd", "string", ")", "(", "_", "bool", ",", "err", "error", ")", "{", "if", "pathA", "==", "pathB", "{", "return", "false", ",", "nil", "\n", "}", "\n\n", "pathA", ",", "err", "="...
// IsAncestor returns true when pathB is an strict ancestor of pathA, // and false where the paths are equal or pathB is outside of pathA. // Paths that are not absolute will be made absolute with Abs.
[ "IsAncestor", "returns", "true", "when", "pathB", "is", "an", "strict", "ancestor", "of", "pathA", "and", "false", "where", "the", "paths", "are", "equal", "or", "pathB", "is", "outside", "of", "pathA", ".", "Paths", "that", "are", "not", "absolute", "will...
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/filepath/ancestor.go#L11-L32
14,512
opencontainers/runtime-tools
validation/util/linux_resources_network.go
ValidateLinuxResourcesNetwork
func ValidateLinuxResourcesNetwork(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find network cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lnd, err := cg.GetNetworkData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get network cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(*lnd.ClassID == *config.Linux.Resources.Network.ClassID, "network ID set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, *lnd.ClassID) for _, priority := range config.Linux.Resources.Network.Priorities { found := false for _, lip := range lnd.Priorities { if lip.Name == priority.Name { found = true t.Ok(lip.Priority == priority.Priority, fmt.Sprintf("network priority for %s is set correctly", priority.Name)) t.Diagnosticf("expect: %d, actual: %d", priority.Priority, lip.Priority) } } t.Ok(found, fmt.Sprintf("network priority for %s found", priority.Name)) } return nil }
go
func ValidateLinuxResourcesNetwork(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find network cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lnd, err := cg.GetNetworkData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get network cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(*lnd.ClassID == *config.Linux.Resources.Network.ClassID, "network ID set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, *lnd.ClassID) for _, priority := range config.Linux.Resources.Network.Priorities { found := false for _, lip := range lnd.Priorities { if lip.Name == priority.Name { found = true t.Ok(lip.Priority == priority.Priority, fmt.Sprintf("network priority for %s is set correctly", priority.Name)) t.Diagnosticf("expect: %d, actual: %d", priority.Priority, lip.Priority) } } t.Ok(found, fmt.Sprintf("network priority for %s found", priority.Name)) } return nil }
[ "func", "ValidateLinuxResourcesNetwork", "(", "config", "*", "rspec", ".", "Spec", ",", "t", "*", "tap", ".", "T", ",", "state", "*", "rspec", ".", "State", ")", "error", "{", "cg", ",", "err", ":=", "cgroups", ".", "FindCgroup", "(", ")", "\n", "t",...
// ValidateLinuxResourcesNetwork validates linux.resources.network.
[ "ValidateLinuxResourcesNetwork", "validates", "linux", ".", "resources", ".", "network", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/linux_resources_network.go#L12-L43
14,513
opencontainers/runtime-tools
validation/util/linux_resources_memory.go
ValidateLinuxResourcesMemory
func ValidateLinuxResourcesMemory(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find memory cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lm, err := cg.GetMemoryData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get memory cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(*lm.Limit == *config.Linux.Resources.Memory.Limit, "memory limit is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Limit, *lm.Limit) t.Ok(*lm.Reservation == *config.Linux.Resources.Memory.Reservation, "memory reservation is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Reservation, *lm.Reservation) t.Ok(*lm.Swap == *config.Linux.Resources.Memory.Swap, "memory swap is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Swap, *lm.Reservation) t.Ok(*lm.Kernel == *config.Linux.Resources.Memory.Kernel, "memory kernel is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Kernel, *lm.Kernel) t.Ok(*lm.KernelTCP == *config.Linux.Resources.Memory.KernelTCP, "memory kernelTCP is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.KernelTCP, *lm.Kernel) t.Ok(*lm.Swappiness == *config.Linux.Resources.Memory.Swappiness, "memory swappiness is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Swappiness, *lm.Swappiness) t.Ok(*lm.DisableOOMKiller == *config.Linux.Resources.Memory.DisableOOMKiller, "memory oom is set correctly") t.Diagnosticf("expect: %t, actual: %t", *config.Linux.Resources.Memory.DisableOOMKiller, *lm.DisableOOMKiller) return nil }
go
func ValidateLinuxResourcesMemory(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find memory cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lm, err := cg.GetMemoryData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get memory cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(*lm.Limit == *config.Linux.Resources.Memory.Limit, "memory limit is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Limit, *lm.Limit) t.Ok(*lm.Reservation == *config.Linux.Resources.Memory.Reservation, "memory reservation is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Reservation, *lm.Reservation) t.Ok(*lm.Swap == *config.Linux.Resources.Memory.Swap, "memory swap is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Swap, *lm.Reservation) t.Ok(*lm.Kernel == *config.Linux.Resources.Memory.Kernel, "memory kernel is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Kernel, *lm.Kernel) t.Ok(*lm.KernelTCP == *config.Linux.Resources.Memory.KernelTCP, "memory kernelTCP is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.KernelTCP, *lm.Kernel) t.Ok(*lm.Swappiness == *config.Linux.Resources.Memory.Swappiness, "memory swappiness is set correctly") t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Memory.Swappiness, *lm.Swappiness) t.Ok(*lm.DisableOOMKiller == *config.Linux.Resources.Memory.DisableOOMKiller, "memory oom is set correctly") t.Diagnosticf("expect: %t, actual: %t", *config.Linux.Resources.Memory.DisableOOMKiller, *lm.DisableOOMKiller) return nil }
[ "func", "ValidateLinuxResourcesMemory", "(", "config", "*", "rspec", ".", "Spec", ",", "t", "*", "tap", ".", "T", ",", "state", "*", "rspec", ".", "State", ")", "error", "{", "cg", ",", "err", ":=", "cgroups", ".", "FindCgroup", "(", ")", "\n", "t", ...
// ValidateLinuxResourcesMemory validates linux.resources.memory.
[ "ValidateLinuxResourcesMemory", "validates", "linux", ".", "resources", ".", "memory", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/linux_resources_memory.go#L10-L47
14,514
opencontainers/runtime-tools
error/error.go
ParseLevel
func ParseLevel(level string) (Level, error) { switch strings.ToUpper(level) { case "MAY": fallthrough case "OPTIONAL": return May, nil case "SHOULD": fallthrough case "SHOULDNOT": fallthrough case "RECOMMENDED": fallthrough case "NOTRECOMMENDED": return Should, nil case "MUST": fallthrough case "MUSTNOT": fallthrough case "SHALL": fallthrough case "SHALLNOT": fallthrough case "REQUIRED": return Must, nil } var l Level return l, fmt.Errorf("%q is not a valid compliance level", level) }
go
func ParseLevel(level string) (Level, error) { switch strings.ToUpper(level) { case "MAY": fallthrough case "OPTIONAL": return May, nil case "SHOULD": fallthrough case "SHOULDNOT": fallthrough case "RECOMMENDED": fallthrough case "NOTRECOMMENDED": return Should, nil case "MUST": fallthrough case "MUSTNOT": fallthrough case "SHALL": fallthrough case "SHALLNOT": fallthrough case "REQUIRED": return Must, nil } var l Level return l, fmt.Errorf("%q is not a valid compliance level", level) }
[ "func", "ParseLevel", "(", "level", "string", ")", "(", "Level", ",", "error", ")", "{", "switch", "strings", ".", "ToUpper", "(", "level", ")", "{", "case", "\"", "\"", ":", "fallthrough", "\n", "case", "\"", "\"", ":", "return", "May", ",", "nil", ...
// ParseLevel takes a string level and returns the RFC 2119 compliance level constant.
[ "ParseLevel", "takes", "a", "string", "level", "and", "returns", "the", "RFC", "2119", "compliance", "level", "constant", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/error/error.go#L59-L87
14,515
opencontainers/runtime-tools
error/error.go
String
func (level Level) String() string { switch level { case May: return "MAY" case Optional: return "OPTIONAL" case Should: return "SHOULD" case ShouldNot: return "SHOULD NOT" case Recommended: return "RECOMMENDED" case NotRecommended: return "NOT RECOMMENDED" case Must: return "MUST" case MustNot: return "MUST NOT" case Shall: return "SHALL" case ShallNot: return "SHALL NOT" case Required: return "REQUIRED" } panic(fmt.Sprintf("%d is not a valid compliance level", level)) }
go
func (level Level) String() string { switch level { case May: return "MAY" case Optional: return "OPTIONAL" case Should: return "SHOULD" case ShouldNot: return "SHOULD NOT" case Recommended: return "RECOMMENDED" case NotRecommended: return "NOT RECOMMENDED" case Must: return "MUST" case MustNot: return "MUST NOT" case Shall: return "SHALL" case ShallNot: return "SHALL NOT" case Required: return "REQUIRED" } panic(fmt.Sprintf("%d is not a valid compliance level", level)) }
[ "func", "(", "level", "Level", ")", "String", "(", ")", "string", "{", "switch", "level", "{", "case", "May", ":", "return", "\"", "\"", "\n", "case", "Optional", ":", "return", "\"", "\"", "\n", "case", "Should", ":", "return", "\"", "\"", "\n", "...
// String takes a RFC 2119 compliance level constant and returns a string representation.
[ "String", "takes", "a", "RFC", "2119", "compliance", "level", "constant", "and", "returns", "a", "string", "representation", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/error/error.go#L90-L117
14,516
opencontainers/runtime-tools
error/error.go
Error
func (err *Error) Error() string { return fmt.Sprintf("%s\nRefer to: %s", err.Err.Error(), err.Reference) }
go
func (err *Error) Error() string { return fmt.Sprintf("%s\nRefer to: %s", err.Err.Error(), err.Reference) }
[ "func", "(", "err", "*", "Error", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "err", ".", "Err", ".", "Error", "(", ")", ",", "err", ".", "Reference", ")", "\n", "}" ]
// Error returns the error message with specification reference.
[ "Error", "returns", "the", "error", "message", "with", "specification", "reference", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/error/error.go#L120-L122
14,517
opencontainers/runtime-tools
validation/util/container.go
NewRuntime
func NewRuntime(runtimeCommand string, bundleDir string) (Runtime, error) { var r Runtime var err error r.RuntimeCommand, err = exec.LookPath(runtimeCommand) if err != nil { return Runtime{}, err } r.BundleDir = bundleDir return r, err }
go
func NewRuntime(runtimeCommand string, bundleDir string) (Runtime, error) { var r Runtime var err error r.RuntimeCommand, err = exec.LookPath(runtimeCommand) if err != nil { return Runtime{}, err } r.BundleDir = bundleDir return r, err }
[ "func", "NewRuntime", "(", "runtimeCommand", "string", ",", "bundleDir", "string", ")", "(", "Runtime", ",", "error", ")", "{", "var", "r", "Runtime", "\n", "var", "err", "error", "\n", "r", ".", "RuntimeCommand", ",", "err", "=", "exec", ".", "LookPath"...
// NewRuntime create a runtime by command and the bundle directory
[ "NewRuntime", "create", "a", "runtime", "by", "command", "and", "the", "bundle", "directory" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L34-L44
14,518
opencontainers/runtime-tools
validation/util/container.go
SetConfig
func (r *Runtime) SetConfig(g *generate.Generator) error { if g == nil { return errors.New("cannot set a nil config") } return g.SaveToFile(filepath.Join(r.bundleDir(), "config.json"), generate.ExportOptions{}) }
go
func (r *Runtime) SetConfig(g *generate.Generator) error { if g == nil { return errors.New("cannot set a nil config") } return g.SaveToFile(filepath.Join(r.bundleDir(), "config.json"), generate.ExportOptions{}) }
[ "func", "(", "r", "*", "Runtime", ")", "SetConfig", "(", "g", "*", "generate", ".", "Generator", ")", "error", "{", "if", "g", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "g", ".", "SaveToFil...
// SetConfig creates a 'config.json' by the generator
[ "SetConfig", "creates", "a", "config", ".", "json", "by", "the", "generator" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L57-L62
14,519
opencontainers/runtime-tools
validation/util/container.go
ReadStandardStreams
func (r *Runtime) ReadStandardStreams() (stdout []byte, stderr []byte, err error) { _, err = r.stdout.Seek(0, io.SeekStart) stdout, err2 := ioutil.ReadAll(r.stdout) if err == nil && err2 != nil { err = err2 } _, err = r.stderr.Seek(0, io.SeekStart) stderr, err2 = ioutil.ReadAll(r.stderr) if err == nil && err2 != nil { err = err2 } return stdout, stderr, err }
go
func (r *Runtime) ReadStandardStreams() (stdout []byte, stderr []byte, err error) { _, err = r.stdout.Seek(0, io.SeekStart) stdout, err2 := ioutil.ReadAll(r.stdout) if err == nil && err2 != nil { err = err2 } _, err = r.stderr.Seek(0, io.SeekStart) stderr, err2 = ioutil.ReadAll(r.stderr) if err == nil && err2 != nil { err = err2 } return stdout, stderr, err }
[ "func", "(", "r", "*", "Runtime", ")", "ReadStandardStreams", "(", ")", "(", "stdout", "[", "]", "byte", ",", "stderr", "[", "]", "byte", ",", "err", "error", ")", "{", "_", ",", "err", "=", "r", ".", "stdout", ".", "Seek", "(", "0", ",", "io",...
// ReadStandardStreams collects content from the stdout and stderr buffers.
[ "ReadStandardStreams", "collects", "content", "from", "the", "stdout", "and", "stderr", "buffers", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L112-L124
14,520
opencontainers/runtime-tools
validation/util/container.go
State
func (r *Runtime) State() (rspecs.State, error) { var args []string args = append(args, "state") if r.ID != "" { args = append(args, r.ID) } out, err := exec.Command(r.RuntimeCommand, args...).Output() if err != nil { if e, ok := err.(*exec.ExitError); ok { if len(e.Stderr) == 0 { e.Stderr = out return rspecs.State{}, e } } return rspecs.State{}, err } var state rspecs.State err = json.Unmarshal(out, &state) if err != nil { return rspecs.State{}, specerror.NewError(specerror.DefaultStateJSONPattern, fmt.Errorf("when serialized in JSON, the format MUST adhere to the default pattern"), rspecs.Version) } return state, err }
go
func (r *Runtime) State() (rspecs.State, error) { var args []string args = append(args, "state") if r.ID != "" { args = append(args, r.ID) } out, err := exec.Command(r.RuntimeCommand, args...).Output() if err != nil { if e, ok := err.(*exec.ExitError); ok { if len(e.Stderr) == 0 { e.Stderr = out return rspecs.State{}, e } } return rspecs.State{}, err } var state rspecs.State err = json.Unmarshal(out, &state) if err != nil { return rspecs.State{}, specerror.NewError(specerror.DefaultStateJSONPattern, fmt.Errorf("when serialized in JSON, the format MUST adhere to the default pattern"), rspecs.Version) } return state, err }
[ "func", "(", "r", "*", "Runtime", ")", "State", "(", ")", "(", "rspecs", ".", "State", ",", "error", ")", "{", "var", "args", "[", "]", "string", "\n", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "if", "r", ".", "ID", "!="...
// State a container information
[ "State", "a", "container", "information" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L139-L163
14,521
opencontainers/runtime-tools
validation/util/container.go
Kill
func (r *Runtime) Kill(sig string) (err error) { var args []string args = append(args, "kill") if r.ID != "" { args = append(args, r.ID) } if sig != "" { // TODO: runc does not support this // args = append(args, "--signal", sig) args = append(args, sig) } else { args = append(args, DefaultSignal) } cmd := exec.Command(r.RuntimeCommand, args...) return execWithStderrFallbackToStdout(cmd) }
go
func (r *Runtime) Kill(sig string) (err error) { var args []string args = append(args, "kill") if r.ID != "" { args = append(args, r.ID) } if sig != "" { // TODO: runc does not support this // args = append(args, "--signal", sig) args = append(args, sig) } else { args = append(args, DefaultSignal) } cmd := exec.Command(r.RuntimeCommand, args...) return execWithStderrFallbackToStdout(cmd) }
[ "func", "(", "r", "*", "Runtime", ")", "Kill", "(", "sig", "string", ")", "(", "err", "error", ")", "{", "var", "args", "[", "]", "string", "\n", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "if", "r", ".", "ID", "!=", "\""...
// Kill a container
[ "Kill", "a", "container" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L166-L182
14,522
opencontainers/runtime-tools
validation/util/container.go
Delete
func (r *Runtime) Delete() (err error) { var args []string args = append(args, "delete") if r.ID != "" { args = append(args, r.ID) } cmd := exec.Command(r.RuntimeCommand, args...) return execWithStderrFallbackToStdout(cmd) }
go
func (r *Runtime) Delete() (err error) { var args []string args = append(args, "delete") if r.ID != "" { args = append(args, r.ID) } cmd := exec.Command(r.RuntimeCommand, args...) return execWithStderrFallbackToStdout(cmd) }
[ "func", "(", "r", "*", "Runtime", ")", "Delete", "(", ")", "(", "err", "error", ")", "{", "var", "args", "[", "]", "string", "\n", "args", "=", "append", "(", "args", ",", "\"", "\"", ")", "\n", "if", "r", ".", "ID", "!=", "\"", "\"", "{", ...
// Delete a container
[ "Delete", "a", "container" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L185-L194
14,523
opencontainers/runtime-tools
validation/util/container.go
Clean
func (r *Runtime) Clean(removeBundle bool, forceRemoveBundle bool) error { r.Kill("KILL") WaitingForStatus(*r, LifecycleStatusStopped, time.Second*10, time.Second/10) err := r.Delete() if removeBundle && (err == nil || forceRemoveBundle) { err2 := os.RemoveAll(r.bundleDir()) if err2 != nil && err == nil { err = err2 } } return err }
go
func (r *Runtime) Clean(removeBundle bool, forceRemoveBundle bool) error { r.Kill("KILL") WaitingForStatus(*r, LifecycleStatusStopped, time.Second*10, time.Second/10) err := r.Delete() if removeBundle && (err == nil || forceRemoveBundle) { err2 := os.RemoveAll(r.bundleDir()) if err2 != nil && err == nil { err = err2 } } return err }
[ "func", "(", "r", "*", "Runtime", ")", "Clean", "(", "removeBundle", "bool", ",", "forceRemoveBundle", "bool", ")", "error", "{", "r", ".", "Kill", "(", "\"", "\"", ")", "\n", "WaitingForStatus", "(", "*", "r", ",", "LifecycleStatusStopped", ",", "time",...
// Clean deletes the container. If removeBundle is set, the bundle // directory is removed after the container is deleted successfully or, if // forceRemoveBundle is true, after the deletion attempt regardless of // whether it was successful or not.
[ "Clean", "deletes", "the", "container", ".", "If", "removeBundle", "is", "set", "the", "bundle", "directory", "is", "removed", "after", "the", "container", "is", "deleted", "successfully", "or", "if", "forceRemoveBundle", "is", "true", "after", "the", "deletion"...
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/container.go#L200-L214
14,524
opencontainers/runtime-tools
specerror/error.go
NewRFCErrorOrPanic
func NewRFCErrorOrPanic(code Code, err error, version string) *rfc2119.Error { rfcError, err2 := NewRFCError(code, err, version) if err2 != nil { panic(err2.Error()) } return rfcError }
go
func NewRFCErrorOrPanic(code Code, err error, version string) *rfc2119.Error { rfcError, err2 := NewRFCError(code, err, version) if err2 != nil { panic(err2.Error()) } return rfcError }
[ "func", "NewRFCErrorOrPanic", "(", "code", "Code", ",", "err", "error", ",", "version", "string", ")", "*", "rfc2119", ".", "Error", "{", "rfcError", ",", "err2", ":=", "NewRFCError", "(", "code", ",", "err", ",", "version", ")", "\n", "if", "err2", "!...
// NewRFCErrorOrPanic creates an rfc2119.Error referencing a spec // violation and panics on failure. This is handy for situations // where you can't be bothered to check NewRFCError for failure.
[ "NewRFCErrorOrPanic", "creates", "an", "rfc2119", ".", "Error", "referencing", "a", "spec", "violation", "and", "panics", "on", "failure", ".", "This", "is", "handy", "for", "situations", "where", "you", "can", "t", "be", "bothered", "to", "check", "NewRFCErro...
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/specerror/error.go#L84-L90
14,525
opencontainers/runtime-tools
specerror/error.go
SplitLevel
func SplitLevel(errIn error, level rfc2119.Level) (levelErrors LevelErrors, errOut error) { merr, ok := errIn.(*multierror.Error) if !ok { return levelErrors, errIn } for _, err := range merr.Errors { e, ok := err.(*Error) if ok && e.Err.Level < level { fmt.Println(e) levelErrors.Warnings = append(levelErrors.Warnings, e) continue } levelErrors.Error = multierror.Append(levelErrors.Error, err) } return levelErrors, nil }
go
func SplitLevel(errIn error, level rfc2119.Level) (levelErrors LevelErrors, errOut error) { merr, ok := errIn.(*multierror.Error) if !ok { return levelErrors, errIn } for _, err := range merr.Errors { e, ok := err.(*Error) if ok && e.Err.Level < level { fmt.Println(e) levelErrors.Warnings = append(levelErrors.Warnings, e) continue } levelErrors.Error = multierror.Append(levelErrors.Error, err) } return levelErrors, nil }
[ "func", "SplitLevel", "(", "errIn", "error", ",", "level", "rfc2119", ".", "Level", ")", "(", "levelErrors", "LevelErrors", ",", "errOut", "error", ")", "{", "merr", ",", "ok", ":=", "errIn", ".", "(", "*", "multierror", ".", "Error", ")", "\n", "if", ...
// SplitLevel removes RFC 2119 errors with a level less than 'level' // from the source error. If the source error is not a multierror, it // is returned unchanged.
[ "SplitLevel", "removes", "RFC", "2119", "errors", "with", "a", "level", "less", "than", "level", "from", "the", "source", "error", ".", "If", "the", "source", "error", "is", "not", "a", "multierror", "it", "is", "returned", "unchanged", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/specerror/error.go#L137-L152
14,526
opencontainers/runtime-tools
generate/seccomp/parse_action.go
ParseSyscallFlag
func ParseSyscallFlag(args SyscallOpts, config *rspec.LinuxSeccomp) error { var arguments []string if args.Index != "" && args.Value != "" && args.ValueTwo != "" && args.Operator != "" { arguments = []string{args.Action, args.Syscall, args.Index, args.Value, args.ValueTwo, args.Operator} } else { arguments = []string{args.Action, args.Syscall} } action, _ := parseAction(arguments[0]) if action == config.DefaultAction && args.argsAreEmpty() { // default already set, no need to make changes return nil } var newSyscall rspec.LinuxSyscall numOfArgs := len(arguments) if numOfArgs == 6 || numOfArgs == 2 { argStruct, err := parseArguments(arguments[1:]) if err != nil { return err } newSyscall = newSyscallStruct(arguments[1], action, argStruct) } else { return fmt.Errorf("incorrect number of arguments to ParseSyscall: %d", numOfArgs) } descison, err := decideCourseOfAction(&newSyscall, config.Syscalls) if err != nil { return err } delimDescison := strings.Split(descison, ":") if delimDescison[0] == seccompAppend { config.Syscalls = append(config.Syscalls, newSyscall) } if delimDescison[0] == seccompOverwrite { indexForOverwrite, err := strconv.ParseInt(delimDescison[1], 10, 32) if err != nil { return err } config.Syscalls[indexForOverwrite] = newSyscall } return nil }
go
func ParseSyscallFlag(args SyscallOpts, config *rspec.LinuxSeccomp) error { var arguments []string if args.Index != "" && args.Value != "" && args.ValueTwo != "" && args.Operator != "" { arguments = []string{args.Action, args.Syscall, args.Index, args.Value, args.ValueTwo, args.Operator} } else { arguments = []string{args.Action, args.Syscall} } action, _ := parseAction(arguments[0]) if action == config.DefaultAction && args.argsAreEmpty() { // default already set, no need to make changes return nil } var newSyscall rspec.LinuxSyscall numOfArgs := len(arguments) if numOfArgs == 6 || numOfArgs == 2 { argStruct, err := parseArguments(arguments[1:]) if err != nil { return err } newSyscall = newSyscallStruct(arguments[1], action, argStruct) } else { return fmt.Errorf("incorrect number of arguments to ParseSyscall: %d", numOfArgs) } descison, err := decideCourseOfAction(&newSyscall, config.Syscalls) if err != nil { return err } delimDescison := strings.Split(descison, ":") if delimDescison[0] == seccompAppend { config.Syscalls = append(config.Syscalls, newSyscall) } if delimDescison[0] == seccompOverwrite { indexForOverwrite, err := strconv.ParseInt(delimDescison[1], 10, 32) if err != nil { return err } config.Syscalls[indexForOverwrite] = newSyscall } return nil }
[ "func", "ParseSyscallFlag", "(", "args", "SyscallOpts", ",", "config", "*", "rspec", ".", "LinuxSeccomp", ")", "error", "{", "var", "arguments", "[", "]", "string", "\n", "if", "args", ".", "Index", "!=", "\"", "\"", "&&", "args", ".", "Value", "!=", "...
// ParseSyscallFlag takes a SyscallOpts struct and the seccomp configuration // and sets the new syscall rule accordingly
[ "ParseSyscallFlag", "takes", "a", "SyscallOpts", "struct", "and", "the", "seccomp", "configuration", "and", "sets", "the", "new", "syscall", "rule", "accordingly" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/seccomp/parse_action.go#L23-L69
14,527
opencontainers/runtime-tools
generate/seccomp/parse_action.go
ParseDefaultAction
func ParseDefaultAction(action string, config *rspec.LinuxSeccomp) error { if action == "" { return nil } defaultAction, err := parseAction(action) if err != nil { return err } config.DefaultAction = defaultAction err = RemoveAllMatchingRules(config, defaultAction) if err != nil { return err } return nil }
go
func ParseDefaultAction(action string, config *rspec.LinuxSeccomp) error { if action == "" { return nil } defaultAction, err := parseAction(action) if err != nil { return err } config.DefaultAction = defaultAction err = RemoveAllMatchingRules(config, defaultAction) if err != nil { return err } return nil }
[ "func", "ParseDefaultAction", "(", "action", "string", ",", "config", "*", "rspec", ".", "LinuxSeccomp", ")", "error", "{", "if", "action", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "defaultAction", ",", "err", ":=", "parseAction", "(", ...
// ParseDefaultAction sets the default action of the seccomp configuration // and then removes any rules that were already specified with this action
[ "ParseDefaultAction", "sets", "the", "default", "action", "of", "the", "seccomp", "configuration", "and", "then", "removes", "any", "rules", "that", "were", "already", "specified", "with", "this", "action" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/seccomp/parse_action.go#L90-L105
14,528
opencontainers/runtime-tools
generate/seccomp/parse_action.go
ParseDefaultActionForce
func ParseDefaultActionForce(action string, config *rspec.LinuxSeccomp) error { if action == "" { return nil } defaultAction, err := parseAction(action) if err != nil { return err } config.DefaultAction = defaultAction return nil }
go
func ParseDefaultActionForce(action string, config *rspec.LinuxSeccomp) error { if action == "" { return nil } defaultAction, err := parseAction(action) if err != nil { return err } config.DefaultAction = defaultAction return nil }
[ "func", "ParseDefaultActionForce", "(", "action", "string", ",", "config", "*", "rspec", ".", "LinuxSeccomp", ")", "error", "{", "if", "action", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "defaultAction", ",", "err", ":=", "parseAction", "(...
// ParseDefaultActionForce simply sets the default action of the seccomp configuration
[ "ParseDefaultActionForce", "simply", "sets", "the", "default", "action", "of", "the", "seccomp", "configuration" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/generate/seccomp/parse_action.go#L108-L119
14,529
opencontainers/runtime-tools
validate/validate.go
NewValidator
func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platform string) (Validator, error) { if hostSpecific && platform != runtime.GOOS { return Validator{}, fmt.Errorf("When hostSpecific is set, platform must be same as the host platform") } return Validator{ spec: spec, bundlePath: bundlePath, HostSpecific: hostSpecific, platform: platform, }, nil }
go
func NewValidator(spec *rspec.Spec, bundlePath string, hostSpecific bool, platform string) (Validator, error) { if hostSpecific && platform != runtime.GOOS { return Validator{}, fmt.Errorf("When hostSpecific is set, platform must be same as the host platform") } return Validator{ spec: spec, bundlePath: bundlePath, HostSpecific: hostSpecific, platform: platform, }, nil }
[ "func", "NewValidator", "(", "spec", "*", "rspec", ".", "Spec", ",", "bundlePath", "string", ",", "hostSpecific", "bool", ",", "platform", "string", ")", "(", "Validator", ",", "error", ")", "{", "if", "hostSpecific", "&&", "platform", "!=", "runtime", "."...
// NewValidator creates a Validator
[ "NewValidator", "creates", "a", "Validator" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L68-L78
14,530
opencontainers/runtime-tools
validate/validate.go
NewValidatorFromPath
func NewValidatorFromPath(bundlePath string, hostSpecific bool, platform string) (Validator, error) { if bundlePath == "" { return Validator{}, fmt.Errorf("bundle path shouldn't be empty") } if _, err := os.Stat(bundlePath); err != nil { return Validator{}, err } configPath := filepath.Join(bundlePath, specConfig) content, err := ioutil.ReadFile(configPath) if err != nil { return Validator{}, specerror.NewError(specerror.ConfigInRootBundleDir, err, rspec.Version) } if !utf8.Valid(content) { return Validator{}, fmt.Errorf("%q is not encoded in UTF-8", configPath) } var spec rspec.Spec if err = json.Unmarshal(content, &spec); err != nil { return Validator{}, err } return NewValidator(&spec, bundlePath, hostSpecific, platform) }
go
func NewValidatorFromPath(bundlePath string, hostSpecific bool, platform string) (Validator, error) { if bundlePath == "" { return Validator{}, fmt.Errorf("bundle path shouldn't be empty") } if _, err := os.Stat(bundlePath); err != nil { return Validator{}, err } configPath := filepath.Join(bundlePath, specConfig) content, err := ioutil.ReadFile(configPath) if err != nil { return Validator{}, specerror.NewError(specerror.ConfigInRootBundleDir, err, rspec.Version) } if !utf8.Valid(content) { return Validator{}, fmt.Errorf("%q is not encoded in UTF-8", configPath) } var spec rspec.Spec if err = json.Unmarshal(content, &spec); err != nil { return Validator{}, err } return NewValidator(&spec, bundlePath, hostSpecific, platform) }
[ "func", "NewValidatorFromPath", "(", "bundlePath", "string", ",", "hostSpecific", "bool", ",", "platform", "string", ")", "(", "Validator", ",", "error", ")", "{", "if", "bundlePath", "==", "\"", "\"", "{", "return", "Validator", "{", "}", ",", "fmt", ".",...
// NewValidatorFromPath creates a Validator with specified bundle path
[ "NewValidatorFromPath", "creates", "a", "Validator", "with", "specified", "bundle", "path" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L81-L104
14,531
opencontainers/runtime-tools
validate/validate.go
CheckAll
func (v *Validator) CheckAll() error { var errs *multierror.Error errs = multierror.Append(errs, v.CheckJSONSchema()) errs = multierror.Append(errs, v.CheckPlatform()) errs = multierror.Append(errs, v.CheckRoot()) errs = multierror.Append(errs, v.CheckMandatoryFields()) errs = multierror.Append(errs, v.CheckSemVer()) errs = multierror.Append(errs, v.CheckMounts()) errs = multierror.Append(errs, v.CheckProcess()) errs = multierror.Append(errs, v.CheckLinux()) errs = multierror.Append(errs, v.CheckAnnotations()) if v.platform == "linux" || v.platform == "solaris" { errs = multierror.Append(errs, v.CheckHooks()) } return errs.ErrorOrNil() }
go
func (v *Validator) CheckAll() error { var errs *multierror.Error errs = multierror.Append(errs, v.CheckJSONSchema()) errs = multierror.Append(errs, v.CheckPlatform()) errs = multierror.Append(errs, v.CheckRoot()) errs = multierror.Append(errs, v.CheckMandatoryFields()) errs = multierror.Append(errs, v.CheckSemVer()) errs = multierror.Append(errs, v.CheckMounts()) errs = multierror.Append(errs, v.CheckProcess()) errs = multierror.Append(errs, v.CheckLinux()) errs = multierror.Append(errs, v.CheckAnnotations()) if v.platform == "linux" || v.platform == "solaris" { errs = multierror.Append(errs, v.CheckHooks()) } return errs.ErrorOrNil() }
[ "func", "(", "v", "*", "Validator", ")", "CheckAll", "(", ")", "error", "{", "var", "errs", "*", "multierror", ".", "Error", "\n", "errs", "=", "multierror", ".", "Append", "(", "errs", ",", "v", ".", "CheckJSONSchema", "(", ")", ")", "\n", "errs", ...
// CheckAll checks all parts of runtime bundle
[ "CheckAll", "checks", "all", "parts", "of", "runtime", "bundle" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L107-L123
14,532
opencontainers/runtime-tools
validate/validate.go
JSONSchemaURL
func JSONSchemaURL(version string) (url string, err error) { ver, err := semver.Parse(version) if err != nil { return "", specerror.NewError(specerror.SpecVersionInSemVer, err, rspec.Version) } configRenamedToConfigSchemaVersion, err := semver.Parse("1.0.0-rc2") // config.json became config-schema.json in 1.0.0-rc2 if ver.Compare(configRenamedToConfigSchemaVersion) == -1 { return "", fmt.Errorf("unsupported configuration version (older than %s)", configRenamedToConfigSchemaVersion) } return fmt.Sprintf(configSchemaTemplate, version), nil }
go
func JSONSchemaURL(version string) (url string, err error) { ver, err := semver.Parse(version) if err != nil { return "", specerror.NewError(specerror.SpecVersionInSemVer, err, rspec.Version) } configRenamedToConfigSchemaVersion, err := semver.Parse("1.0.0-rc2") // config.json became config-schema.json in 1.0.0-rc2 if ver.Compare(configRenamedToConfigSchemaVersion) == -1 { return "", fmt.Errorf("unsupported configuration version (older than %s)", configRenamedToConfigSchemaVersion) } return fmt.Sprintf(configSchemaTemplate, version), nil }
[ "func", "JSONSchemaURL", "(", "version", "string", ")", "(", "url", "string", ",", "err", "error", ")", "{", "ver", ",", "err", ":=", "semver", ".", "Parse", "(", "version", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "spec...
// JSONSchemaURL returns the URL for the JSON Schema specifying the // configuration format. It consumes configSchemaTemplate, but we // provide it as a function to isolate consumers from inconsistent // naming as runtime-spec evolves.
[ "JSONSchemaURL", "returns", "the", "URL", "for", "the", "JSON", "Schema", "specifying", "the", "configuration", "format", ".", "It", "consumes", "configSchemaTemplate", "but", "we", "provide", "it", "as", "a", "function", "to", "isolate", "consumers", "from", "i...
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L129-L139
14,533
opencontainers/runtime-tools
validate/validate.go
CheckJSONSchema
func (v *Validator) CheckJSONSchema() (errs error) { logrus.Debugf("check JSON schema") url, err := JSONSchemaURL(v.spec.Version) if err != nil { errs = multierror.Append(errs, err) return errs } schemaLoader := gojsonschema.NewReferenceLoader(url) documentLoader := gojsonschema.NewGoLoader(v.spec) result, err := gojsonschema.Validate(schemaLoader, documentLoader) if err != nil { errs = multierror.Append(errs, err) return errs } if !result.Valid() { for _, resultError := range result.Errors() { errs = multierror.Append(errs, errors.New(resultError.String())) } } return errs }
go
func (v *Validator) CheckJSONSchema() (errs error) { logrus.Debugf("check JSON schema") url, err := JSONSchemaURL(v.spec.Version) if err != nil { errs = multierror.Append(errs, err) return errs } schemaLoader := gojsonschema.NewReferenceLoader(url) documentLoader := gojsonschema.NewGoLoader(v.spec) result, err := gojsonschema.Validate(schemaLoader, documentLoader) if err != nil { errs = multierror.Append(errs, err) return errs } if !result.Valid() { for _, resultError := range result.Errors() { errs = multierror.Append(errs, errors.New(resultError.String())) } } return errs }
[ "func", "(", "v", "*", "Validator", ")", "CheckJSONSchema", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "url", ",", "err", ":=", "JSONSchemaURL", "(", "v", ".", "spec", ".", "Version", ")", "\n",...
// CheckJSONSchema validates the configuration against the // runtime-spec JSON Schema, using the version of the schema that // matches the configuration's declared version.
[ "CheckJSONSchema", "validates", "the", "configuration", "against", "the", "runtime", "-", "spec", "JSON", "Schema", "using", "the", "version", "of", "the", "schema", "that", "matches", "the", "configuration", "s", "declared", "version", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L144-L168
14,534
opencontainers/runtime-tools
validate/validate.go
CheckSemVer
func (v *Validator) CheckSemVer() (errs error) { logrus.Debugf("check semver") version := v.spec.Version _, err := semver.Parse(version) if err != nil { errs = multierror.Append(errs, specerror.NewError(specerror.SpecVersionInSemVer, fmt.Errorf("%q is not valid SemVer: %s", version, err.Error()), rspec.Version)) } if version != rspec.Version { errs = multierror.Append(errs, fmt.Errorf("validate currently only handles version %s, but the supplied configuration targets %s", rspec.Version, version)) } return }
go
func (v *Validator) CheckSemVer() (errs error) { logrus.Debugf("check semver") version := v.spec.Version _, err := semver.Parse(version) if err != nil { errs = multierror.Append(errs, specerror.NewError(specerror.SpecVersionInSemVer, fmt.Errorf("%q is not valid SemVer: %s", version, err.Error()), rspec.Version)) } if version != rspec.Version { errs = multierror.Append(errs, fmt.Errorf("validate currently only handles version %s, but the supplied configuration targets %s", rspec.Version, version)) } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckSemVer", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "version", ":=", "v", ".", "spec", ".", "Version", "\n", "_", ",", "err", ":=", "semver", "."...
// CheckSemVer checks v.spec.Version
[ "CheckSemVer", "checks", "v", ".", "spec", ".", "Version" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L253-L267
14,535
opencontainers/runtime-tools
validate/validate.go
CheckHooks
func (v *Validator) CheckHooks() (errs error) { logrus.Debugf("check hooks") if v.platform != "linux" && v.platform != "solaris" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support hooks", v.platform)) return } if v.spec.Hooks != nil { errs = multierror.Append(errs, v.checkEventHooks("prestart", v.spec.Hooks.Prestart, v.HostSpecific)) errs = multierror.Append(errs, v.checkEventHooks("poststart", v.spec.Hooks.Poststart, v.HostSpecific)) errs = multierror.Append(errs, v.checkEventHooks("poststop", v.spec.Hooks.Poststop, v.HostSpecific)) } return }
go
func (v *Validator) CheckHooks() (errs error) { logrus.Debugf("check hooks") if v.platform != "linux" && v.platform != "solaris" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support hooks", v.platform)) return } if v.spec.Hooks != nil { errs = multierror.Append(errs, v.checkEventHooks("prestart", v.spec.Hooks.Prestart, v.HostSpecific)) errs = multierror.Append(errs, v.checkEventHooks("poststart", v.spec.Hooks.Poststart, v.HostSpecific)) errs = multierror.Append(errs, v.checkEventHooks("poststop", v.spec.Hooks.Poststop, v.HostSpecific)) } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckHooks", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "if", "v", ".", "platform", "!=", "\"", "\"", "&&", "v", ".", "platform", "!=", "\"", "\"", ...
// CheckHooks check v.spec.Hooks
[ "CheckHooks", "check", "v", ".", "spec", ".", "Hooks" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L270-L285
14,536
opencontainers/runtime-tools
validate/validate.go
CheckProcess
func (v *Validator) CheckProcess() (errs error) { logrus.Debugf("check process") if v.spec.Process == nil { return } process := v.spec.Process if !osFilepath.IsAbs(v.platform, process.Cwd) { errs = multierror.Append(errs, specerror.NewError( specerror.ProcCwdAbs, fmt.Errorf("cwd %q is not an absolute path", process.Cwd), rspec.Version)) } for _, env := range process.Env { if !envValid(env) { errs = multierror.Append(errs, fmt.Errorf("env %q should be in the form of 'key=value'. The left hand side must consist solely of letters, digits, and underscores '_'", env)) } } if len(process.Args) == 0 { errs = multierror.Append(errs, specerror.NewError( specerror.ProcArgsOneEntryRequired, fmt.Errorf("args must not be empty"), rspec.Version)) } else { if filepath.IsAbs(process.Args[0]) && v.spec.Root != nil { var rootfsPath string if filepath.IsAbs(v.spec.Root.Path) { rootfsPath = v.spec.Root.Path } else { rootfsPath = filepath.Join(v.bundlePath, v.spec.Root.Path) } absPath := filepath.Join(rootfsPath, process.Args[0]) fileinfo, err := os.Stat(absPath) if os.IsNotExist(err) { logrus.Warnf("executable %q is not available in rootfs currently", process.Args[0]) } else if err != nil { errs = multierror.Append(errs, err) } else { m := fileinfo.Mode() if m.IsDir() || m&0111 == 0 { errs = multierror.Append(errs, fmt.Errorf("arg %q is not executable", process.Args[0])) } } } } if v.platform == "linux" || v.platform == "solaris" { errs = multierror.Append(errs, v.CheckRlimits()) } if v.platform == "linux" { if v.spec.Process.Capabilities != nil { errs = multierror.Append(errs, v.CheckCapabilities()) } if len(process.ApparmorProfile) > 0 { profilePath := filepath.Join(v.bundlePath, v.spec.Root.Path, "/etc/apparmor.d", process.ApparmorProfile) _, err := os.Stat(profilePath) if err != nil { errs = multierror.Append(errs, err) } } } return }
go
func (v *Validator) CheckProcess() (errs error) { logrus.Debugf("check process") if v.spec.Process == nil { return } process := v.spec.Process if !osFilepath.IsAbs(v.platform, process.Cwd) { errs = multierror.Append(errs, specerror.NewError( specerror.ProcCwdAbs, fmt.Errorf("cwd %q is not an absolute path", process.Cwd), rspec.Version)) } for _, env := range process.Env { if !envValid(env) { errs = multierror.Append(errs, fmt.Errorf("env %q should be in the form of 'key=value'. The left hand side must consist solely of letters, digits, and underscores '_'", env)) } } if len(process.Args) == 0 { errs = multierror.Append(errs, specerror.NewError( specerror.ProcArgsOneEntryRequired, fmt.Errorf("args must not be empty"), rspec.Version)) } else { if filepath.IsAbs(process.Args[0]) && v.spec.Root != nil { var rootfsPath string if filepath.IsAbs(v.spec.Root.Path) { rootfsPath = v.spec.Root.Path } else { rootfsPath = filepath.Join(v.bundlePath, v.spec.Root.Path) } absPath := filepath.Join(rootfsPath, process.Args[0]) fileinfo, err := os.Stat(absPath) if os.IsNotExist(err) { logrus.Warnf("executable %q is not available in rootfs currently", process.Args[0]) } else if err != nil { errs = multierror.Append(errs, err) } else { m := fileinfo.Mode() if m.IsDir() || m&0111 == 0 { errs = multierror.Append(errs, fmt.Errorf("arg %q is not executable", process.Args[0])) } } } } if v.platform == "linux" || v.platform == "solaris" { errs = multierror.Append(errs, v.CheckRlimits()) } if v.platform == "linux" { if v.spec.Process.Capabilities != nil { errs = multierror.Append(errs, v.CheckCapabilities()) } if len(process.ApparmorProfile) > 0 { profilePath := filepath.Join(v.bundlePath, v.spec.Root.Path, "/etc/apparmor.d", process.ApparmorProfile) _, err := os.Stat(profilePath) if err != nil { errs = multierror.Append(errs, err) } } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckProcess", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "if", "v", ".", "spec", ".", "Process", "==", "nil", "{", "return", "\n", "}", "\n\n", "proc...
// CheckProcess checks v.spec.Process
[ "CheckProcess", "checks", "v", ".", "spec", ".", "Process" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L319-L389
14,537
opencontainers/runtime-tools
validate/validate.go
CheckCapabilities
func (v *Validator) CheckCapabilities() (errs error) { if v.platform != "linux" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support process.capabilities", v.platform)) return } process := v.spec.Process var effective, permitted, inheritable, ambient bool caps := make(map[string][]string) for _, cap := range process.Capabilities.Bounding { caps[cap] = append(caps[cap], "bounding") } for _, cap := range process.Capabilities.Effective { caps[cap] = append(caps[cap], "effective") } for _, cap := range process.Capabilities.Inheritable { caps[cap] = append(caps[cap], "inheritable") } for _, cap := range process.Capabilities.Permitted { caps[cap] = append(caps[cap], "permitted") } for _, cap := range process.Capabilities.Ambient { caps[cap] = append(caps[cap], "ambient") } for capability, owns := range caps { if err := CapValid(capability, v.HostSpecific); err != nil { errs = multierror.Append(errs, fmt.Errorf("capability %q is not valid, man capabilities(7)", capability)) } effective, permitted, ambient, inheritable = false, false, false, false for _, set := range owns { if set == "effective" { effective = true continue } if set == "inheritable" { inheritable = true continue } if set == "permitted" { permitted = true continue } if set == "ambient" { ambient = true continue } } if effective && !permitted { errs = multierror.Append(errs, fmt.Errorf("effective capability %q is not allowed, as it's not permitted", capability)) } if ambient && !(permitted && inheritable) { errs = multierror.Append(errs, fmt.Errorf("ambient capability %q is not allowed, as it's not permitted and inheribate", capability)) } } return }
go
func (v *Validator) CheckCapabilities() (errs error) { if v.platform != "linux" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support process.capabilities", v.platform)) return } process := v.spec.Process var effective, permitted, inheritable, ambient bool caps := make(map[string][]string) for _, cap := range process.Capabilities.Bounding { caps[cap] = append(caps[cap], "bounding") } for _, cap := range process.Capabilities.Effective { caps[cap] = append(caps[cap], "effective") } for _, cap := range process.Capabilities.Inheritable { caps[cap] = append(caps[cap], "inheritable") } for _, cap := range process.Capabilities.Permitted { caps[cap] = append(caps[cap], "permitted") } for _, cap := range process.Capabilities.Ambient { caps[cap] = append(caps[cap], "ambient") } for capability, owns := range caps { if err := CapValid(capability, v.HostSpecific); err != nil { errs = multierror.Append(errs, fmt.Errorf("capability %q is not valid, man capabilities(7)", capability)) } effective, permitted, ambient, inheritable = false, false, false, false for _, set := range owns { if set == "effective" { effective = true continue } if set == "inheritable" { inheritable = true continue } if set == "permitted" { permitted = true continue } if set == "ambient" { ambient = true continue } } if effective && !permitted { errs = multierror.Append(errs, fmt.Errorf("effective capability %q is not allowed, as it's not permitted", capability)) } if ambient && !(permitted && inheritable) { errs = multierror.Append(errs, fmt.Errorf("ambient capability %q is not allowed, as it's not permitted and inheribate", capability)) } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckCapabilities", "(", ")", "(", "errs", "error", ")", "{", "if", "v", ".", "platform", "!=", "\"", "\"", "{", "errs", "=", "multierror", ".", "Append", "(", "errs", ",", "fmt", ".", "Errorf", "(", "\"", ...
// CheckCapabilities checks v.spec.Process.Capabilities
[ "CheckCapabilities", "checks", "v", ".", "spec", ".", "Process", ".", "Capabilities" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L392-L451
14,538
opencontainers/runtime-tools
validate/validate.go
CheckRlimits
func (v *Validator) CheckRlimits() (errs error) { if v.platform != "linux" && v.platform != "solaris" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support process.rlimits", v.platform)) return } process := v.spec.Process for index, rlimit := range process.Rlimits { for i := index + 1; i < len(process.Rlimits); i++ { if process.Rlimits[index].Type == process.Rlimits[i].Type { errs = multierror.Append(errs, specerror.NewError( specerror.PosixProcRlimitsErrorOnDup, fmt.Errorf("rlimit can not contain the same type %q", process.Rlimits[index].Type), rspec.Version)) } } errs = multierror.Append(errs, v.rlimitValid(rlimit)) } return }
go
func (v *Validator) CheckRlimits() (errs error) { if v.platform != "linux" && v.platform != "solaris" { errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support process.rlimits", v.platform)) return } process := v.spec.Process for index, rlimit := range process.Rlimits { for i := index + 1; i < len(process.Rlimits); i++ { if process.Rlimits[index].Type == process.Rlimits[i].Type { errs = multierror.Append(errs, specerror.NewError( specerror.PosixProcRlimitsErrorOnDup, fmt.Errorf("rlimit can not contain the same type %q", process.Rlimits[index].Type), rspec.Version)) } } errs = multierror.Append(errs, v.rlimitValid(rlimit)) } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckRlimits", "(", ")", "(", "errs", "error", ")", "{", "if", "v", ".", "platform", "!=", "\"", "\"", "&&", "v", ".", "platform", "!=", "\"", "\"", "{", "errs", "=", "multierror", ".", "Append", "(", "er...
// CheckRlimits checks v.spec.Process.Rlimits
[ "CheckRlimits", "checks", "v", ".", "spec", ".", "Process", ".", "Rlimits" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L454-L476
14,539
opencontainers/runtime-tools
validate/validate.go
CheckMounts
func (v *Validator) CheckMounts() (errs error) { logrus.Debugf("check mounts") supportedTypes, err := supportedMountTypes(v.platform, v.HostSpecific) if err != nil { errs = multierror.Append(errs, err) return } for i, mountA := range v.spec.Mounts { if supportedTypes != nil && !supportedTypes[mountA.Type] { errs = multierror.Append(errs, fmt.Errorf("unsupported mount type %q", mountA.Type)) } if !osFilepath.IsAbs(v.platform, mountA.Destination) { errs = multierror.Append(errs, specerror.NewError( specerror.MountsDestAbs, fmt.Errorf("mounts[%d].destination %q is not absolute", i, mountA.Destination), rspec.Version)) } for j, mountB := range v.spec.Mounts { if i == j { continue } // whether B.Desination is nested within A.Destination nested, err := osFilepath.IsAncestor(v.platform, mountA.Destination, mountB.Destination, ".") if err != nil { errs = multierror.Append(errs, err) continue } if nested { if v.platform == "windows" && i < j { errs = multierror.Append(errs, specerror.NewError( specerror.MountsDestOnWindowsNotNested, fmt.Errorf("on Windows, %v nested within %v is forbidden", mountB.Destination, mountA.Destination), rspec.Version)) } if i > j { logrus.Warnf("%v will be covered by %v", mountB.Destination, mountA.Destination) } } } } return }
go
func (v *Validator) CheckMounts() (errs error) { logrus.Debugf("check mounts") supportedTypes, err := supportedMountTypes(v.platform, v.HostSpecific) if err != nil { errs = multierror.Append(errs, err) return } for i, mountA := range v.spec.Mounts { if supportedTypes != nil && !supportedTypes[mountA.Type] { errs = multierror.Append(errs, fmt.Errorf("unsupported mount type %q", mountA.Type)) } if !osFilepath.IsAbs(v.platform, mountA.Destination) { errs = multierror.Append(errs, specerror.NewError( specerror.MountsDestAbs, fmt.Errorf("mounts[%d].destination %q is not absolute", i, mountA.Destination), rspec.Version)) } for j, mountB := range v.spec.Mounts { if i == j { continue } // whether B.Desination is nested within A.Destination nested, err := osFilepath.IsAncestor(v.platform, mountA.Destination, mountB.Destination, ".") if err != nil { errs = multierror.Append(errs, err) continue } if nested { if v.platform == "windows" && i < j { errs = multierror.Append(errs, specerror.NewError( specerror.MountsDestOnWindowsNotNested, fmt.Errorf("on Windows, %v nested within %v is forbidden", mountB.Destination, mountA.Destination), rspec.Version)) } if i > j { logrus.Warnf("%v will be covered by %v", mountB.Destination, mountA.Destination) } } } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckMounts", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "supportedTypes", ",", "err", ":=", "supportedMountTypes", "(", "v", ".", "platform", ",", "v", "...
// CheckMounts checks v.spec.Mounts
[ "CheckMounts", "checks", "v", ".", "spec", ".", "Mounts" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L520-L569
14,540
opencontainers/runtime-tools
validate/validate.go
CheckPlatform
func (v *Validator) CheckPlatform() (errs error) { logrus.Debugf("check platform") if v.platform != "linux" && v.platform != "solaris" && v.platform != "windows" { errs = multierror.Append(errs, fmt.Errorf("platform %q is not supported", v.platform)) return } if v.HostSpecific && v.platform != runtime.GOOS { errs = multierror.Append(errs, fmt.Errorf("platform %q differs from the host %q, skipping host-specific checks", v.platform, runtime.GOOS)) v.HostSpecific = false } if v.platform == "windows" { if v.spec.Windows == nil { errs = multierror.Append(errs, specerror.NewError( specerror.PlatformSpecConfOnWindowsSet, fmt.Errorf("'windows' MUST be set when platform is `windows`"), rspec.Version)) } } return }
go
func (v *Validator) CheckPlatform() (errs error) { logrus.Debugf("check platform") if v.platform != "linux" && v.platform != "solaris" && v.platform != "windows" { errs = multierror.Append(errs, fmt.Errorf("platform %q is not supported", v.platform)) return } if v.HostSpecific && v.platform != runtime.GOOS { errs = multierror.Append(errs, fmt.Errorf("platform %q differs from the host %q, skipping host-specific checks", v.platform, runtime.GOOS)) v.HostSpecific = false } if v.platform == "windows" { if v.spec.Windows == nil { errs = multierror.Append(errs, specerror.NewError( specerror.PlatformSpecConfOnWindowsSet, fmt.Errorf("'windows' MUST be set when platform is `windows`"), rspec.Version)) } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckPlatform", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "if", "v", ".", "platform", "!=", "\"", "\"", "&&", "v", ".", "platform", "!=", "\"", "\"",...
// CheckPlatform checks v.platform
[ "CheckPlatform", "checks", "v", ".", "platform" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L572-L596
14,541
opencontainers/runtime-tools
validate/validate.go
CheckLinuxResources
func (v *Validator) CheckLinuxResources() (errs error) { logrus.Debugf("check linux resources") r := v.spec.Linux.Resources if r.Memory != nil { if r.Memory.Limit != nil && r.Memory.Swap != nil && uint64(*r.Memory.Limit) > uint64(*r.Memory.Swap) { errs = multierror.Append(errs, fmt.Errorf("minimum memoryswap should be larger than memory limit")) } if r.Memory.Limit != nil && r.Memory.Reservation != nil && uint64(*r.Memory.Reservation) > uint64(*r.Memory.Limit) { errs = multierror.Append(errs, fmt.Errorf("minimum memory limit should be larger than memory reservation")) } } if r.Network != nil && v.HostSpecific { var exist bool interfaces, err := net.Interfaces() if err != nil { errs = multierror.Append(errs, err) return } for _, prio := range r.Network.Priorities { exist = false for _, ni := range interfaces { if prio.Name == ni.Name { exist = true break } } if !exist { errs = multierror.Append(errs, fmt.Errorf("interface %s does not exist currently", prio.Name)) } } } for index := 0; index < len(r.Devices); index++ { switch r.Devices[index].Type { case "a", "b", "c", "": default: errs = multierror.Append(errs, fmt.Errorf("type of devices %s is invalid", r.Devices[index].Type)) } access := []byte(r.Devices[index].Access) for i := 0; i < len(access); i++ { switch access[i] { case 'r', 'w', 'm': default: errs = multierror.Append(errs, fmt.Errorf("access %s is invalid", r.Devices[index].Access)) return } } } if r.BlockIO != nil && r.BlockIO.WeightDevice != nil { for i, weightDevice := range r.BlockIO.WeightDevice { if weightDevice.Weight == nil && weightDevice.LeafWeight == nil { errs = multierror.Append(errs, specerror.NewError( specerror.BlkIOWeightOrLeafWeightExist, fmt.Errorf("linux.resources.blockIO.weightDevice[%d] specifies neither weight nor leafWeight", i), rspec.Version)) } } } return }
go
func (v *Validator) CheckLinuxResources() (errs error) { logrus.Debugf("check linux resources") r := v.spec.Linux.Resources if r.Memory != nil { if r.Memory.Limit != nil && r.Memory.Swap != nil && uint64(*r.Memory.Limit) > uint64(*r.Memory.Swap) { errs = multierror.Append(errs, fmt.Errorf("minimum memoryswap should be larger than memory limit")) } if r.Memory.Limit != nil && r.Memory.Reservation != nil && uint64(*r.Memory.Reservation) > uint64(*r.Memory.Limit) { errs = multierror.Append(errs, fmt.Errorf("minimum memory limit should be larger than memory reservation")) } } if r.Network != nil && v.HostSpecific { var exist bool interfaces, err := net.Interfaces() if err != nil { errs = multierror.Append(errs, err) return } for _, prio := range r.Network.Priorities { exist = false for _, ni := range interfaces { if prio.Name == ni.Name { exist = true break } } if !exist { errs = multierror.Append(errs, fmt.Errorf("interface %s does not exist currently", prio.Name)) } } } for index := 0; index < len(r.Devices); index++ { switch r.Devices[index].Type { case "a", "b", "c", "": default: errs = multierror.Append(errs, fmt.Errorf("type of devices %s is invalid", r.Devices[index].Type)) } access := []byte(r.Devices[index].Access) for i := 0; i < len(access); i++ { switch access[i] { case 'r', 'w', 'm': default: errs = multierror.Append(errs, fmt.Errorf("access %s is invalid", r.Devices[index].Access)) return } } } if r.BlockIO != nil && r.BlockIO.WeightDevice != nil { for i, weightDevice := range r.BlockIO.WeightDevice { if weightDevice.Weight == nil && weightDevice.LeafWeight == nil { errs = multierror.Append(errs, specerror.NewError( specerror.BlkIOWeightOrLeafWeightExist, fmt.Errorf("linux.resources.blockIO.weightDevice[%d] specifies neither weight nor leafWeight", i), rspec.Version)) } } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckLinuxResources", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "r", ":=", "v", ".", "spec", ".", "Linux", ".", "Resources", "\n", "if", "r", ".", "M...
// CheckLinuxResources checks v.spec.Linux.Resources
[ "CheckLinuxResources", "checks", "v", ".", "spec", ".", "Linux", ".", "Resources" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L599-L662
14,542
opencontainers/runtime-tools
validate/validate.go
CheckAnnotations
func (v *Validator) CheckAnnotations() (errs error) { logrus.Debugf("check annotations") reversedDomain := regexp.MustCompile(`^[A-Za-z]{2,6}(\.[A-Za-z0-9-]{1,63})+$`) for key := range v.spec.Annotations { if strings.HasPrefix(key, "org.opencontainers") { errs = multierror.Append(errs, specerror.NewError( specerror.AnnotationsKeyReservedNS, fmt.Errorf("key %q is reserved", key), rspec.Version)) } if !reversedDomain.MatchString(key) { errs = multierror.Append(errs, specerror.NewError( specerror.AnnotationsKeyReversedDomain, fmt.Errorf("key %q SHOULD be named using a reverse domain notation", key), rspec.Version)) } } return }
go
func (v *Validator) CheckAnnotations() (errs error) { logrus.Debugf("check annotations") reversedDomain := regexp.MustCompile(`^[A-Za-z]{2,6}(\.[A-Za-z0-9-]{1,63})+$`) for key := range v.spec.Annotations { if strings.HasPrefix(key, "org.opencontainers") { errs = multierror.Append(errs, specerror.NewError( specerror.AnnotationsKeyReservedNS, fmt.Errorf("key %q is reserved", key), rspec.Version)) } if !reversedDomain.MatchString(key) { errs = multierror.Append(errs, specerror.NewError( specerror.AnnotationsKeyReversedDomain, fmt.Errorf("key %q SHOULD be named using a reverse domain notation", key), rspec.Version)) } } return }
[ "func", "(", "v", "*", "Validator", ")", "CheckAnnotations", "(", ")", "(", "errs", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "reversedDomain", ":=", "regexp", ".", "MustCompile", "(", "`^[A-Za-z]{2,6}(\\.[A-Za-z0-9-]{1,63})+$`"...
// CheckAnnotations checks v.spec.Annotations
[ "CheckAnnotations", "checks", "v", ".", "spec", ".", "Annotations" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L665-L688
14,543
opencontainers/runtime-tools
validate/validate.go
CapValid
func CapValid(c string, hostSpecific bool) error { isValid := false if !strings.HasPrefix(c, "CAP_") { return fmt.Errorf("capability %s must start with CAP_", c) } for _, cap := range capability.List() { if c == fmt.Sprintf("CAP_%s", strings.ToUpper(cap.String())) { if hostSpecific && cap > LastCap() { return fmt.Errorf("%s is not supported on the current host", c) } isValid = true break } } if !isValid { return fmt.Errorf("invalid capability: %s", c) } return nil }
go
func CapValid(c string, hostSpecific bool) error { isValid := false if !strings.HasPrefix(c, "CAP_") { return fmt.Errorf("capability %s must start with CAP_", c) } for _, cap := range capability.List() { if c == fmt.Sprintf("CAP_%s", strings.ToUpper(cap.String())) { if hostSpecific && cap > LastCap() { return fmt.Errorf("%s is not supported on the current host", c) } isValid = true break } } if !isValid { return fmt.Errorf("invalid capability: %s", c) } return nil }
[ "func", "CapValid", "(", "c", "string", ",", "hostSpecific", "bool", ")", "error", "{", "isValid", ":=", "false", "\n\n", "if", "!", "strings", ".", "HasPrefix", "(", "c", ",", "\"", "\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// CapValid checks whether a capability is valid
[ "CapValid", "checks", "whether", "a", "capability", "is", "valid" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L691-L711
14,544
opencontainers/runtime-tools
validate/validate.go
CheckMandatoryFields
func (v *Validator) CheckMandatoryFields() error { logrus.Debugf("check mandatory fields") if v.spec == nil { return fmt.Errorf("Spec can't be nil") } return checkMandatory(v.spec) }
go
func (v *Validator) CheckMandatoryFields() error { logrus.Debugf("check mandatory fields") if v.spec == nil { return fmt.Errorf("Spec can't be nil") } return checkMandatory(v.spec) }
[ "func", "(", "v", "*", "Validator", ")", "CheckMandatoryFields", "(", ")", "error", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n\n", "if", "v", ".", "spec", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", ...
// CheckMandatoryFields checks mandatory field of container's config file
[ "CheckMandatoryFields", "checks", "mandatory", "field", "of", "container", "s", "config", "file" ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validate/validate.go#L830-L838
14,545
opencontainers/runtime-tools
validation/util/linux_resources_pids.go
ValidateLinuxResourcesPids
func ValidateLinuxResourcesPids(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find pids cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lpd, err := cg.GetPidsData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get pids cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(lpd.Limit == config.Linux.Resources.Pids.Limit, "pids limit is set correctly") t.Diagnosticf("expect: %d, actual: %d", config.Linux.Resources.Pids.Limit, lpd.Limit) return nil }
go
func ValidateLinuxResourcesPids(config *rspec.Spec, t *tap.T, state *rspec.State) error { cg, err := cgroups.FindCgroup() t.Ok((err == nil), "find pids cgroup") if err != nil { t.Diagnostic(err.Error()) return nil } lpd, err := cg.GetPidsData(state.Pid, config.Linux.CgroupsPath) t.Ok((err == nil), "get pids cgroup data") if err != nil { t.Diagnostic(err.Error()) return nil } t.Ok(lpd.Limit == config.Linux.Resources.Pids.Limit, "pids limit is set correctly") t.Diagnosticf("expect: %d, actual: %d", config.Linux.Resources.Pids.Limit, lpd.Limit) return nil }
[ "func", "ValidateLinuxResourcesPids", "(", "config", "*", "rspec", ".", "Spec", ",", "t", "*", "tap", ".", "T", ",", "state", "*", "rspec", ".", "State", ")", "error", "{", "cg", ",", "err", ":=", "cgroups", ".", "FindCgroup", "(", ")", "\n", "t", ...
// ValidateLinuxResourcesPids validates linux.resources.pids.
[ "ValidateLinuxResourcesPids", "validates", "linux", ".", "resources", ".", "pids", "." ]
095789df6c2bc53a9dd4464cda8c22616d66e0d6
https://github.com/opencontainers/runtime-tools/blob/095789df6c2bc53a9dd4464cda8c22616d66e0d6/validation/util/linux_resources_pids.go#L10-L29
14,546
doug-martin/goqu
adapters.go
removeAdapter
func removeAdapter(dialect string) { if HasAdapter(dialect) { dialect = strings.ToLower(dialect) delete(ds_adapters, dialect) } }
go
func removeAdapter(dialect string) { if HasAdapter(dialect) { dialect = strings.ToLower(dialect) delete(ds_adapters, dialect) } }
[ "func", "removeAdapter", "(", "dialect", "string", ")", "{", "if", "HasAdapter", "(", "dialect", ")", "{", "dialect", "=", "strings", ".", "ToLower", "(", "dialect", ")", "\n", "delete", "(", "ds_adapters", ",", "dialect", ")", "\n", "}", "\n", "}" ]
//Clears the current adapter map, used internally for tests
[ "Clears", "the", "current", "adapter", "map", "used", "internally", "for", "tests" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/adapters.go#L251-L256
14,547
doug-martin/goqu
default_adapter.go
Literal
func (me *DefaultAdapter) Literal(buf *SqlBuilder, val interface{}) error { return me.dataset.Literal(buf, val) }
go
func (me *DefaultAdapter) Literal(buf *SqlBuilder, val interface{}) error { return me.dataset.Literal(buf, val) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "Literal", "(", "buf", "*", "SqlBuilder", ",", "val", "interface", "{", "}", ")", "error", "{", "return", "me", ".", "dataset", ".", "Literal", "(", "buf", ",", "val", ")", "\n", "}" ]
//This is a proxy to Dataset.Literal. Used internally to ensure the correct method is called on any subclasses and to prevent duplication of code
[ "This", "is", "a", "proxy", "to", "Dataset", ".", "Literal", ".", "Used", "internally", "to", "ensure", "the", "correct", "method", "is", "called", "on", "any", "subclasses", "and", "to", "prevent", "duplication", "of", "code" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L332-L334
14,548
doug-martin/goqu
default_adapter.go
UpdateBeginSql
func (me *DefaultAdapter) UpdateBeginSql(buf *SqlBuilder) error { buf.Write(me.UpdateClause) return nil }
go
func (me *DefaultAdapter) UpdateBeginSql(buf *SqlBuilder) error { buf.Write(me.UpdateClause) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "UpdateBeginSql", "(", "buf", "*", "SqlBuilder", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "UpdateClause", ")", "\n", "return", "nil", "\n", "}" ]
//Adds the correct fragment to being an UPDATE statement
[ "Adds", "the", "correct", "fragment", "to", "being", "an", "UPDATE", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L347-L350
14,549
doug-martin/goqu
default_adapter.go
InsertBeginSql
func (me *DefaultAdapter) InsertBeginSql(buf *SqlBuilder, o ConflictExpression) error { if me.SupportsInsertIgnoreSyntax() && o != nil { buf.Write(me.InsertIgnoreClause) } else { buf.Write(me.InsertClause) } return nil }
go
func (me *DefaultAdapter) InsertBeginSql(buf *SqlBuilder, o ConflictExpression) error { if me.SupportsInsertIgnoreSyntax() && o != nil { buf.Write(me.InsertIgnoreClause) } else { buf.Write(me.InsertClause) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "InsertBeginSql", "(", "buf", "*", "SqlBuilder", ",", "o", "ConflictExpression", ")", "error", "{", "if", "me", ".", "SupportsInsertIgnoreSyntax", "(", ")", "&&", "o", "!=", "nil", "{", "buf", ".", "Write", ...
//Adds the correct fragment to being an INSERT statement
[ "Adds", "the", "correct", "fragment", "to", "being", "an", "INSERT", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L353-L360
14,550
doug-martin/goqu
default_adapter.go
DeleteBeginSql
func (me *DefaultAdapter) DeleteBeginSql(buf *SqlBuilder) error { buf.Write(me.DeleteClause) return nil }
go
func (me *DefaultAdapter) DeleteBeginSql(buf *SqlBuilder) error { buf.Write(me.DeleteClause) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "DeleteBeginSql", "(", "buf", "*", "SqlBuilder", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "DeleteClause", ")", "\n", "return", "nil", "\n", "}" ]
//Adds the correct fragment to being an DELETE statement
[ "Adds", "the", "correct", "fragment", "to", "being", "an", "DELETE", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L363-L366
14,551
doug-martin/goqu
default_adapter.go
TruncateSql
func (me *DefaultAdapter) TruncateSql(buf *SqlBuilder, from ColumnList, opts TruncateOptions) error { buf.Write(me.TruncateClause) if err := me.SourcesSql(buf, from); err != nil { return err } if opts.Identity != empty_string { buf.WriteRune(space_rune) buf.WriteString(strings.ToUpper(opts.Identity)) buf.Write(me.IdentityFragment) } if opts.Cascade { buf.Write(me.CascadeFragment) } else if opts.Restrict { buf.Write(me.RestrictFragment) } return nil }
go
func (me *DefaultAdapter) TruncateSql(buf *SqlBuilder, from ColumnList, opts TruncateOptions) error { buf.Write(me.TruncateClause) if err := me.SourcesSql(buf, from); err != nil { return err } if opts.Identity != empty_string { buf.WriteRune(space_rune) buf.WriteString(strings.ToUpper(opts.Identity)) buf.Write(me.IdentityFragment) } if opts.Cascade { buf.Write(me.CascadeFragment) } else if opts.Restrict { buf.Write(me.RestrictFragment) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "TruncateSql", "(", "buf", "*", "SqlBuilder", ",", "from", "ColumnList", ",", "opts", "TruncateOptions", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "TruncateClause", ")", "\n", "if", "err", ":="...
//Generates a TRUNCATE statement
[ "Generates", "a", "TRUNCATE", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L369-L385
14,552
doug-martin/goqu
default_adapter.go
InsertColumnsSql
func (me *DefaultAdapter) InsertColumnsSql(buf *SqlBuilder, cols ColumnList) error { buf.WriteRune(space_rune) buf.WriteRune(left_paren_rune) if err := me.Literal(buf, cols); err != nil { return err } buf.WriteRune(right_paren_rune) return nil }
go
func (me *DefaultAdapter) InsertColumnsSql(buf *SqlBuilder, cols ColumnList) error { buf.WriteRune(space_rune) buf.WriteRune(left_paren_rune) if err := me.Literal(buf, cols); err != nil { return err } buf.WriteRune(right_paren_rune) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "InsertColumnsSql", "(", "buf", "*", "SqlBuilder", ",", "cols", "ColumnList", ")", "error", "{", "buf", ".", "WriteRune", "(", "space_rune", ")", "\n", "buf", ".", "WriteRune", "(", "left_paren_rune", ")", "\n...
//Adds the columns list to an insert statement
[ "Adds", "the", "columns", "list", "to", "an", "insert", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L394-L402
14,553
doug-martin/goqu
default_adapter.go
InsertValuesSql
func (me *DefaultAdapter) InsertValuesSql(buf *SqlBuilder, values [][]interface{}) error { buf.Write(me.ValuesFragment) rowLen := len(values[0]) valueLen := len(values) for i, row := range values { if len(row) != rowLen { return fmt.Errorf("Rows with different value length expected %d got %d", rowLen, len(row)) } if err := me.Literal(buf, row); err != nil { return err } if i < valueLen-1 { buf.WriteRune(comma_rune) buf.WriteRune(space_rune) } } return nil }
go
func (me *DefaultAdapter) InsertValuesSql(buf *SqlBuilder, values [][]interface{}) error { buf.Write(me.ValuesFragment) rowLen := len(values[0]) valueLen := len(values) for i, row := range values { if len(row) != rowLen { return fmt.Errorf("Rows with different value length expected %d got %d", rowLen, len(row)) } if err := me.Literal(buf, row); err != nil { return err } if i < valueLen-1 { buf.WriteRune(comma_rune) buf.WriteRune(space_rune) } } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "InsertValuesSql", "(", "buf", "*", "SqlBuilder", ",", "values", "[", "]", "[", "]", "interface", "{", "}", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "ValuesFragment", ")", "\n", "rowLen", ...
//Adds the values clause to an SQL statement
[ "Adds", "the", "values", "clause", "to", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L405-L422
14,554
doug-martin/goqu
default_adapter.go
SelectSql
func (me *DefaultAdapter) SelectSql(buf *SqlBuilder, cols ColumnList) error { buf.Write(me.SelectClause) buf.WriteRune(space_rune) if len(cols.Columns()) == 0 { buf.WriteRune(star_rune) } else { return me.Literal(buf, cols) } return nil }
go
func (me *DefaultAdapter) SelectSql(buf *SqlBuilder, cols ColumnList) error { buf.Write(me.SelectClause) buf.WriteRune(space_rune) if len(cols.Columns()) == 0 { buf.WriteRune(star_rune) } else { return me.Literal(buf, cols) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "SelectSql", "(", "buf", "*", "SqlBuilder", ",", "cols", "ColumnList", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "SelectClause", ")", "\n", "buf", ".", "WriteRune", "(", "space_rune", ")", "\...
//Adds the SELECT clause and columns to a sql statement
[ "Adds", "the", "SELECT", "clause", "and", "columns", "to", "a", "sql", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L497-L506
14,555
doug-martin/goqu
default_adapter.go
SelectDistinctSql
func (me *DefaultAdapter) SelectDistinctSql(buf *SqlBuilder, cols ColumnList) error { buf.Write(me.SelectClause) buf.Write(me.DistinctFragment) return me.Literal(buf, cols) }
go
func (me *DefaultAdapter) SelectDistinctSql(buf *SqlBuilder, cols ColumnList) error { buf.Write(me.SelectClause) buf.Write(me.DistinctFragment) return me.Literal(buf, cols) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "SelectDistinctSql", "(", "buf", "*", "SqlBuilder", ",", "cols", "ColumnList", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "SelectClause", ")", "\n", "buf", ".", "Write", "(", "me", ".", "Disti...
//Adds the SELECT DISTINCT clause and columns to a sql statement
[ "Adds", "the", "SELECT", "DISTINCT", "clause", "and", "columns", "to", "a", "sql", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L509-L513
14,556
doug-martin/goqu
default_adapter.go
FromSql
func (me *DefaultAdapter) FromSql(buf *SqlBuilder, from ColumnList) error { if from != nil && len(from.Columns()) > 0 { buf.Write(me.FromFragment) return me.SourcesSql(buf, from) } return nil }
go
func (me *DefaultAdapter) FromSql(buf *SqlBuilder, from ColumnList) error { if from != nil && len(from.Columns()) > 0 { buf.Write(me.FromFragment) return me.SourcesSql(buf, from) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "FromSql", "(", "buf", "*", "SqlBuilder", ",", "from", "ColumnList", ")", "error", "{", "if", "from", "!=", "nil", "&&", "len", "(", "from", ".", "Columns", "(", ")", ")", ">", "0", "{", "buf", ".", ...
//Adds the FROM clause and tables to an sql statement
[ "Adds", "the", "FROM", "clause", "and", "tables", "to", "an", "sql", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L524-L530
14,557
doug-martin/goqu
default_adapter.go
SourcesSql
func (me *DefaultAdapter) SourcesSql(buf *SqlBuilder, from ColumnList) error { buf.WriteRune(space_rune) return me.Literal(buf, from) }
go
func (me *DefaultAdapter) SourcesSql(buf *SqlBuilder, from ColumnList) error { buf.WriteRune(space_rune) return me.Literal(buf, from) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "SourcesSql", "(", "buf", "*", "SqlBuilder", ",", "from", "ColumnList", ")", "error", "{", "buf", ".", "WriteRune", "(", "space_rune", ")", "\n", "return", "me", ".", "Literal", "(", "buf", ",", "from", ")...
//Adds the generates the SQL for a column list
[ "Adds", "the", "generates", "the", "SQL", "for", "a", "column", "list" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L533-L536
14,558
doug-martin/goqu
default_adapter.go
JoinSql
func (me *DefaultAdapter) JoinSql(buf *SqlBuilder, joins JoiningClauses) error { if len(joins) > 0 { for _, j := range joins { joinType := me.JoinTypeLookup[j.JoinType] buf.Write(joinType) if err := me.Literal(buf, j.Table); err != nil { return err } if j.IsConditioned { buf.WriteRune(space_rune) if j.Condition == nil { return NewGoquError("Join condition required for conditioned join %s", string(joinType)) } condition := j.Condition if condition.JoinCondition() == USING_COND { buf.WriteString("USING ") } else { buf.WriteString("ON ") } switch condition.(type) { case JoinOnExpression: if err := me.Literal(buf, condition.(JoinOnExpression).On()); err != nil { return err } case JoinUsingExpression: buf.WriteRune(left_paren_rune) if err := me.Literal(buf, condition.(JoinUsingExpression).Using()); err != nil { return err } buf.WriteRune(right_paren_rune) } } } } return nil }
go
func (me *DefaultAdapter) JoinSql(buf *SqlBuilder, joins JoiningClauses) error { if len(joins) > 0 { for _, j := range joins { joinType := me.JoinTypeLookup[j.JoinType] buf.Write(joinType) if err := me.Literal(buf, j.Table); err != nil { return err } if j.IsConditioned { buf.WriteRune(space_rune) if j.Condition == nil { return NewGoquError("Join condition required for conditioned join %s", string(joinType)) } condition := j.Condition if condition.JoinCondition() == USING_COND { buf.WriteString("USING ") } else { buf.WriteString("ON ") } switch condition.(type) { case JoinOnExpression: if err := me.Literal(buf, condition.(JoinOnExpression).On()); err != nil { return err } case JoinUsingExpression: buf.WriteRune(left_paren_rune) if err := me.Literal(buf, condition.(JoinUsingExpression).Using()); err != nil { return err } buf.WriteRune(right_paren_rune) } } } } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "JoinSql", "(", "buf", "*", "SqlBuilder", ",", "joins", "JoiningClauses", ")", "error", "{", "if", "len", "(", "joins", ")", ">", "0", "{", "for", "_", ",", "j", ":=", "range", "joins", "{", "joinType", ...
//Generates the JOIN clauses for an SQL statement
[ "Generates", "the", "JOIN", "clauses", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L539-L574
14,559
doug-martin/goqu
default_adapter.go
WhereSql
func (me *DefaultAdapter) WhereSql(buf *SqlBuilder, where ExpressionList) error { if where != nil && len(where.Expressions()) > 0 { buf.Write(me.WhereFragment) return me.Literal(buf, where) } return nil }
go
func (me *DefaultAdapter) WhereSql(buf *SqlBuilder, where ExpressionList) error { if where != nil && len(where.Expressions()) > 0 { buf.Write(me.WhereFragment) return me.Literal(buf, where) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "WhereSql", "(", "buf", "*", "SqlBuilder", ",", "where", "ExpressionList", ")", "error", "{", "if", "where", "!=", "nil", "&&", "len", "(", "where", ".", "Expressions", "(", ")", ")", ">", "0", "{", "buf...
//Generates the WHERE clause for an SQL statement
[ "Generates", "the", "WHERE", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L577-L583
14,560
doug-martin/goqu
default_adapter.go
GroupBySql
func (me *DefaultAdapter) GroupBySql(buf *SqlBuilder, groupBy ColumnList) error { if groupBy != nil && len(groupBy.Columns()) > 0 { buf.Write(me.GroupByFragment) return me.Literal(buf, groupBy) } return nil }
go
func (me *DefaultAdapter) GroupBySql(buf *SqlBuilder, groupBy ColumnList) error { if groupBy != nil && len(groupBy.Columns()) > 0 { buf.Write(me.GroupByFragment) return me.Literal(buf, groupBy) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "GroupBySql", "(", "buf", "*", "SqlBuilder", ",", "groupBy", "ColumnList", ")", "error", "{", "if", "groupBy", "!=", "nil", "&&", "len", "(", "groupBy", ".", "Columns", "(", ")", ")", ">", "0", "{", "buf...
//Generates the GROUP BY clause for an SQL statement
[ "Generates", "the", "GROUP", "BY", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L586-L592
14,561
doug-martin/goqu
default_adapter.go
HavingSql
func (me *DefaultAdapter) HavingSql(buf *SqlBuilder, having ExpressionList) error { if having != nil && len(having.Expressions()) > 0 { buf.Write(me.HavingFragment) return me.Literal(buf, having) } return nil }
go
func (me *DefaultAdapter) HavingSql(buf *SqlBuilder, having ExpressionList) error { if having != nil && len(having.Expressions()) > 0 { buf.Write(me.HavingFragment) return me.Literal(buf, having) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "HavingSql", "(", "buf", "*", "SqlBuilder", ",", "having", "ExpressionList", ")", "error", "{", "if", "having", "!=", "nil", "&&", "len", "(", "having", ".", "Expressions", "(", ")", ")", ">", "0", "{", ...
//Generates the HAVING clause for an SQL statement
[ "Generates", "the", "HAVING", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L595-L601
14,562
doug-martin/goqu
default_adapter.go
OrderSql
func (me *DefaultAdapter) OrderSql(buf *SqlBuilder, order ColumnList) error { if order != nil && len(order.Columns()) > 0 { buf.Write(me.OrderByFragment) return me.Literal(buf, order) } return nil }
go
func (me *DefaultAdapter) OrderSql(buf *SqlBuilder, order ColumnList) error { if order != nil && len(order.Columns()) > 0 { buf.Write(me.OrderByFragment) return me.Literal(buf, order) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "OrderSql", "(", "buf", "*", "SqlBuilder", ",", "order", "ColumnList", ")", "error", "{", "if", "order", "!=", "nil", "&&", "len", "(", "order", ".", "Columns", "(", ")", ")", ">", "0", "{", "buf", "."...
//Generates the ORDER BY clause for an SQL statement
[ "Generates", "the", "ORDER", "BY", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L645-L651
14,563
doug-martin/goqu
default_adapter.go
LimitSql
func (me *DefaultAdapter) LimitSql(buf *SqlBuilder, limit interface{}) error { if limit != nil { buf.Write(me.LimitFragment) return me.Literal(buf, limit) } return nil }
go
func (me *DefaultAdapter) LimitSql(buf *SqlBuilder, limit interface{}) error { if limit != nil { buf.Write(me.LimitFragment) return me.Literal(buf, limit) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LimitSql", "(", "buf", "*", "SqlBuilder", ",", "limit", "interface", "{", "}", ")", "error", "{", "if", "limit", "!=", "nil", "{", "buf", ".", "Write", "(", "me", ".", "LimitFragment", ")", "\n", "retur...
//Generates the LIMIT clause for an SQL statement
[ "Generates", "the", "LIMIT", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L654-L660
14,564
doug-martin/goqu
default_adapter.go
OffsetSql
func (me *DefaultAdapter) OffsetSql(buf *SqlBuilder, offset uint) error { if offset > 0 { buf.Write(me.OffsetFragment) return me.Literal(buf, offset) } return nil }
go
func (me *DefaultAdapter) OffsetSql(buf *SqlBuilder, offset uint) error { if offset > 0 { buf.Write(me.OffsetFragment) return me.Literal(buf, offset) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "OffsetSql", "(", "buf", "*", "SqlBuilder", ",", "offset", "uint", ")", "error", "{", "if", "offset", ">", "0", "{", "buf", ".", "Write", "(", "me", ".", "OffsetFragment", ")", "\n", "return", "me", ".",...
//Generates the OFFSET clause for an SQL statement
[ "Generates", "the", "OFFSET", "clause", "for", "an", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L663-L669
14,565
doug-martin/goqu
default_adapter.go
DatasetSql
func (me *DefaultAdapter) DatasetSql(buf *SqlBuilder, dataset Dataset) error { buf.WriteRune(left_paren_rune) if buf.IsPrepared { if err := dataset.selectSqlWriteTo(buf); err != nil { return err } } else { sql, _, err := dataset.Prepared(false).ToSql() if err != nil { return err } buf.WriteString(sql) } buf.WriteRune(right_paren_rune) alias := dataset.GetClauses().Alias if alias != nil { buf.Write(me.AsFragment) return me.Literal(buf, alias) } return nil }
go
func (me *DefaultAdapter) DatasetSql(buf *SqlBuilder, dataset Dataset) error { buf.WriteRune(left_paren_rune) if buf.IsPrepared { if err := dataset.selectSqlWriteTo(buf); err != nil { return err } } else { sql, _, err := dataset.Prepared(false).ToSql() if err != nil { return err } buf.WriteString(sql) } buf.WriteRune(right_paren_rune) alias := dataset.GetClauses().Alias if alias != nil { buf.Write(me.AsFragment) return me.Literal(buf, alias) } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "DatasetSql", "(", "buf", "*", "SqlBuilder", ",", "dataset", "Dataset", ")", "error", "{", "buf", ".", "WriteRune", "(", "left_paren_rune", ")", "\n", "if", "buf", ".", "IsPrepared", "{", "if", "err", ":=", ...
//Generates creates the sql for a sub select on a Dataset
[ "Generates", "creates", "the", "sql", "for", "a", "sub", "select", "on", "a", "Dataset" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L672-L692
14,566
doug-martin/goqu
default_adapter.go
LiteralNil
func (me *DefaultAdapter) LiteralNil(buf *SqlBuilder) error { buf.Write(me.Null) return nil }
go
func (me *DefaultAdapter) LiteralNil(buf *SqlBuilder) error { buf.Write(me.Null) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralNil", "(", "buf", "*", "SqlBuilder", ")", "error", "{", "buf", ".", "Write", "(", "me", ".", "Null", ")", "\n", "return", "nil", "\n", "}" ]
//Generates SQL NULL value
[ "Generates", "SQL", "NULL", "value" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L731-L734
14,567
doug-martin/goqu
default_adapter.go
LiteralTime
func (me *DefaultAdapter) LiteralTime(buf *SqlBuilder, t time.Time) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, t) } return me.Literal(buf, t.UTC().Format(me.TimeFormat)) }
go
func (me *DefaultAdapter) LiteralTime(buf *SqlBuilder, t time.Time) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, t) } return me.Literal(buf, t.UTC().Format(me.TimeFormat)) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralTime", "(", "buf", "*", "SqlBuilder", ",", "t", "time", ".", "Time", ")", "error", "{", "if", "buf", ".", "IsPrepared", "{", "return", "me", ".", "PlaceHolderSql", "(", "buf", ",", "t", ")", "\n"...
//Generates SQL for a time.Time value
[ "Generates", "SQL", "for", "a", "time", ".", "Time", "value" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L750-L755
14,568
doug-martin/goqu
default_adapter.go
LiteralFloat
func (me *DefaultAdapter) LiteralFloat(buf *SqlBuilder, f float64) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, f) } buf.WriteString(strconv.FormatFloat(f, 'f', -1, 64)) return nil }
go
func (me *DefaultAdapter) LiteralFloat(buf *SqlBuilder, f float64) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, f) } buf.WriteString(strconv.FormatFloat(f, 'f', -1, 64)) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralFloat", "(", "buf", "*", "SqlBuilder", ",", "f", "float64", ")", "error", "{", "if", "buf", ".", "IsPrepared", "{", "return", "me", ".", "PlaceHolderSql", "(", "buf", ",", "f", ")", "\n", "}", "\...
//Generates SQL for a Float Value
[ "Generates", "SQL", "for", "a", "Float", "Value" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L758-L764
14,569
doug-martin/goqu
default_adapter.go
LiteralInt
func (me *DefaultAdapter) LiteralInt(buf *SqlBuilder, i int64) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, i) } buf.WriteString(strconv.FormatInt(i, 10)) return nil }
go
func (me *DefaultAdapter) LiteralInt(buf *SqlBuilder, i int64) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, i) } buf.WriteString(strconv.FormatInt(i, 10)) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralInt", "(", "buf", "*", "SqlBuilder", ",", "i", "int64", ")", "error", "{", "if", "buf", ".", "IsPrepared", "{", "return", "me", ".", "PlaceHolderSql", "(", "buf", ",", "i", ")", "\n", "}", "\n", ...
//Generates SQL for an int value
[ "Generates", "SQL", "for", "an", "int", "value" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L767-L773
14,570
doug-martin/goqu
default_adapter.go
LiteralString
func (me *DefaultAdapter) LiteralString(buf *SqlBuilder, s string) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, s) } buf.WriteRune(me.StringQuote) for _, char := range s { if e, ok := me.EscapedRunes[char]; ok { buf.Write(e) } else { buf.WriteRune(char) } } buf.WriteRune(me.StringQuote) return nil }
go
func (me *DefaultAdapter) LiteralString(buf *SqlBuilder, s string) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, s) } buf.WriteRune(me.StringQuote) for _, char := range s { if e, ok := me.EscapedRunes[char]; ok { buf.Write(e) } else { buf.WriteRune(char) } } buf.WriteRune(me.StringQuote) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralString", "(", "buf", "*", "SqlBuilder", ",", "s", "string", ")", "error", "{", "if", "buf", ".", "IsPrepared", "{", "return", "me", ".", "PlaceHolderSql", "(", "buf", ",", "s", ")", "\n", "}", "\...
//Generates SQL for a string
[ "Generates", "SQL", "for", "a", "string" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L776-L791
14,571
doug-martin/goqu
default_adapter.go
LiteralBytes
func (me *DefaultAdapter) LiteralBytes(buf *SqlBuilder, bs []byte) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, bs) } buf.WriteRune(me.StringQuote) i := 0 for len(bs) > 0 { char, l := utf8.DecodeRune(bs) if e, ok := me.EscapedRunes[char]; ok { buf.Write(e) } else { buf.WriteRune(char) } i++ bs = bs[l:] } buf.WriteRune(me.StringQuote) return nil }
go
func (me *DefaultAdapter) LiteralBytes(buf *SqlBuilder, bs []byte) error { if buf.IsPrepared { return me.PlaceHolderSql(buf, bs) } buf.WriteRune(me.StringQuote) i := 0 for len(bs) > 0 { char, l := utf8.DecodeRune(bs) if e, ok := me.EscapedRunes[char]; ok { buf.Write(e) } else { buf.WriteRune(char) } i++ bs = bs[l:] } buf.WriteRune(me.StringQuote) return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "LiteralBytes", "(", "buf", "*", "SqlBuilder", ",", "bs", "[", "]", "byte", ")", "error", "{", "if", "buf", ".", "IsPrepared", "{", "return", "me", ".", "PlaceHolderSql", "(", "buf", ",", "bs", ")", "\n"...
// Generates SQL for a slice of bytes
[ "Generates", "SQL", "for", "a", "slice", "of", "bytes" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L794-L812
14,572
doug-martin/goqu
default_adapter.go
ColumnListSql
func (me *DefaultAdapter) ColumnListSql(buf *SqlBuilder, columnList ColumnList) error { cols := columnList.Columns() colLen := len(cols) for i, col := range cols { if err := me.Literal(buf, col); err != nil { return err } if i < colLen-1 { buf.WriteRune(comma_rune) buf.WriteRune(space_rune) } } return nil }
go
func (me *DefaultAdapter) ColumnListSql(buf *SqlBuilder, columnList ColumnList) error { cols := columnList.Columns() colLen := len(cols) for i, col := range cols { if err := me.Literal(buf, col); err != nil { return err } if i < colLen-1 { buf.WriteRune(comma_rune) buf.WriteRune(space_rune) } } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "ColumnListSql", "(", "buf", "*", "SqlBuilder", ",", "columnList", "ColumnList", ")", "error", "{", "cols", ":=", "columnList", ".", "Columns", "(", ")", "\n", "colLen", ":=", "len", "(", "cols", ")", "\n", ...
//Generates SQL for a ColumnList
[ "Generates", "SQL", "for", "a", "ColumnList" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L950-L963
14,573
doug-martin/goqu
default_adapter.go
UpdateExpressionSql
func (me *DefaultAdapter) UpdateExpressionSql(buf *SqlBuilder, update UpdateExpression) error { if err := me.Literal(buf, update.Col()); err != nil { return err } buf.WriteRune(me.SetOperatorRune) return me.Literal(buf, update.Val()) }
go
func (me *DefaultAdapter) UpdateExpressionSql(buf *SqlBuilder, update UpdateExpression) error { if err := me.Literal(buf, update.Col()); err != nil { return err } buf.WriteRune(me.SetOperatorRune) return me.Literal(buf, update.Val()) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "UpdateExpressionSql", "(", "buf", "*", "SqlBuilder", ",", "update", "UpdateExpression", ")", "error", "{", "if", "err", ":=", "me", ".", "Literal", "(", "buf", ",", "update", ".", "Col", "(", ")", ")", ";...
//Generates SQL for an UpdateEpxresion
[ "Generates", "SQL", "for", "an", "UpdateEpxresion" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L966-L972
14,574
doug-martin/goqu
default_adapter.go
CommonTableExpressionSql
func (me *DefaultAdapter) CommonTableExpressionSql(buf *SqlBuilder, cte CommonTableExpression) error { if err := me.Literal(buf, cte.Name()); err != nil { return err } buf.Write(me.AsFragment) if err := me.Literal(buf, cte.SubQuery()); err != nil { return err } return nil }
go
func (me *DefaultAdapter) CommonTableExpressionSql(buf *SqlBuilder, cte CommonTableExpression) error { if err := me.Literal(buf, cte.Name()); err != nil { return err } buf.Write(me.AsFragment) if err := me.Literal(buf, cte.SubQuery()); err != nil { return err } return nil }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "CommonTableExpressionSql", "(", "buf", "*", "SqlBuilder", ",", "cte", "CommonTableExpression", ")", "error", "{", "if", "err", ":=", "me", ".", "Literal", "(", "buf", ",", "cte", ".", "Name", "(", ")", ")",...
//Generates SQL for a CommonTableExpression
[ "Generates", "SQL", "for", "a", "CommonTableExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L1023-L1032
14,575
doug-martin/goqu
default_adapter.go
CompoundExpressionSql
func (me *DefaultAdapter) CompoundExpressionSql(buf *SqlBuilder, compound CompoundExpression) error { switch compound.Type() { case UNION: buf.Write(me.UnionFragment) case UNION_ALL: buf.Write(me.UnionAllFragment) case INTERSECT: buf.Write(me.IntersectFragment) case INTERSECT_ALL: buf.Write(me.IntersectAllFragment) } return me.Literal(buf, compound.Rhs()) }
go
func (me *DefaultAdapter) CompoundExpressionSql(buf *SqlBuilder, compound CompoundExpression) error { switch compound.Type() { case UNION: buf.Write(me.UnionFragment) case UNION_ALL: buf.Write(me.UnionAllFragment) case INTERSECT: buf.Write(me.IntersectFragment) case INTERSECT_ALL: buf.Write(me.IntersectAllFragment) } return me.Literal(buf, compound.Rhs()) }
[ "func", "(", "me", "*", "DefaultAdapter", ")", "CompoundExpressionSql", "(", "buf", "*", "SqlBuilder", ",", "compound", "CompoundExpression", ")", "error", "{", "switch", "compound", ".", "Type", "(", ")", "{", "case", "UNION", ":", "buf", ".", "Write", "(...
//Generates SQL for a CompoundExpression
[ "Generates", "SQL", "for", "a", "CompoundExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/default_adapter.go#L1035-L1047
14,576
doug-martin/goqu
dataset.go
withDatabase
func withDatabase(db database) *Dataset { ret := new(Dataset) ret.database = db ret.clauses = clauses{ Select: cols(Star()), } ret.adapter = db.queryAdapter(ret) return ret }
go
func withDatabase(db database) *Dataset { ret := new(Dataset) ret.database = db ret.clauses = clauses{ Select: cols(Star()), } ret.adapter = db.queryAdapter(ret) return ret }
[ "func", "withDatabase", "(", "db", "database", ")", "*", "Dataset", "{", "ret", ":=", "new", "(", "Dataset", ")", "\n", "ret", ".", "database", "=", "db", "\n", "ret", ".", "clauses", "=", "clauses", "{", "Select", ":", "cols", "(", "Star", "(", ")...
//used internally by database to create a database with a specific adapter
[ "used", "internally", "by", "database", "to", "create", "a", "database", "with", "a", "specific", "adapter" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset.go#L142-L150
14,577
doug-martin/goqu
dataset.go
SetAdapter
func (me *Dataset) SetAdapter(adapter Adapter) *Dataset { me.adapter = adapter return me }
go
func (me *Dataset) SetAdapter(adapter Adapter) *Dataset { me.adapter = adapter return me }
[ "func", "(", "me", "*", "Dataset", ")", "SetAdapter", "(", "adapter", "Adapter", ")", "*", "Dataset", "{", "me", ".", "adapter", "=", "adapter", "\n", "return", "me", "\n", "}" ]
//Sets the adapter used to serialize values and create the SQL statement
[ "Sets", "the", "adapter", "used", "to", "serialize", "values", "and", "create", "the", "SQL", "statement" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset.go#L153-L156
14,578
doug-martin/goqu
dataset.go
hasSources
func (me *Dataset) hasSources() bool { return me.clauses.From != nil && len(me.clauses.From.Columns()) > 0 }
go
func (me *Dataset) hasSources() bool { return me.clauses.From != nil && len(me.clauses.From.Columns()) > 0 }
[ "func", "(", "me", "*", "Dataset", ")", "hasSources", "(", ")", "bool", "{", "return", "me", ".", "clauses", ".", "From", "!=", "nil", "&&", "len", "(", "me", ".", "clauses", ".", "From", ".", "Columns", "(", ")", ")", ">", "0", "\n", "}" ]
//Returns true if the dataset has a FROM clause
[ "Returns", "true", "if", "the", "dataset", "has", "a", "FROM", "clause" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset.go#L192-L194
14,579
doug-martin/goqu
sql_builder.go
WriteArg
func (me *SqlBuilder) WriteArg(i interface{}) { me.CurrentArgPosition++ me.args = append(me.args, i) }
go
func (me *SqlBuilder) WriteArg(i interface{}) { me.CurrentArgPosition++ me.args = append(me.args, i) }
[ "func", "(", "me", "*", "SqlBuilder", ")", "WriteArg", "(", "i", "interface", "{", "}", ")", "{", "me", ".", "CurrentArgPosition", "++", "\n", "me", ".", "args", "=", "append", "(", "me", ".", "args", ",", "i", ")", "\n", "}" ]
//Adds an argument to the builder, used when IsPrepared is false
[ "Adds", "an", "argument", "to", "the", "builder", "used", "when", "IsPrepared", "is", "false" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/sql_builder.go#L20-L23
14,580
doug-martin/goqu
database.go
Begin
func (me *Database) Begin() (*TxDatabase, error) { tx, err := me.Db.Begin() if err != nil { return nil, err } return &TxDatabase{Dialect: me.Dialect, Tx: tx, logger: me.logger}, nil }
go
func (me *Database) Begin() (*TxDatabase, error) { tx, err := me.Db.Begin() if err != nil { return nil, err } return &TxDatabase{Dialect: me.Dialect, Tx: tx, logger: me.logger}, nil }
[ "func", "(", "me", "*", "Database", ")", "Begin", "(", ")", "(", "*", "TxDatabase", ",", "error", ")", "{", "tx", ",", "err", ":=", "me", ".", "Db", ".", "Begin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n...
//Starts a new Transaction.
[ "Starts", "a", "new", "Transaction", "." ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/database.go#L69-L75
14,581
doug-martin/goqu
database.go
queryAdapter
func (me *Database) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
go
func (me *Database) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
[ "func", "(", "me", "*", "Database", ")", "queryAdapter", "(", "dataset", "*", "Dataset", ")", "Adapter", "{", "return", "NewAdapter", "(", "me", ".", "Dialect", ",", "dataset", ")", "\n", "}" ]
//used internally to create a new Adapter for a dataset
[ "used", "internally", "to", "create", "a", "new", "Adapter", "for", "a", "dataset" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/database.go#L78-L80
14,582
doug-martin/goqu
database.go
Trace
func (me *Database) Trace(op, sql string, args ...interface{}) { if me.logger != nil { if sql != "" { if len(args) != 0 { me.logger.Printf("[goqu] %s [query:=`%s` args:=%+v]", op, sql, args) } else { me.logger.Printf("[goqu] %s [query:=`%s`]", op, sql) } } else { me.logger.Printf("[goqu] %s", op) } } }
go
func (me *Database) Trace(op, sql string, args ...interface{}) { if me.logger != nil { if sql != "" { if len(args) != 0 { me.logger.Printf("[goqu] %s [query:=`%s` args:=%+v]", op, sql, args) } else { me.logger.Printf("[goqu] %s [query:=`%s`]", op, sql) } } else { me.logger.Printf("[goqu] %s", op) } } }
[ "func", "(", "me", "*", "Database", ")", "Trace", "(", "op", ",", "sql", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "me", ".", "logger", "!=", "nil", "{", "if", "sql", "!=", "\"", "\"", "{", "if", "len", "(", "args", ...
//Logs a given operation with the specified sql and arguments
[ "Logs", "a", "given", "operation", "with", "the", "specified", "sql", "and", "arguments" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/database.go#L100-L112
14,583
doug-martin/goqu
database.go
queryAdapter
func (me *TxDatabase) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
go
func (me *TxDatabase) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
[ "func", "(", "me", "*", "TxDatabase", ")", "queryAdapter", "(", "dataset", "*", "Dataset", ")", "Adapter", "{", "return", "NewAdapter", "(", "me", ".", "Dialect", ",", "dataset", ")", "\n", "}" ]
//used internally to create a new query adapter for a Dataset
[ "used", "internally", "to", "create", "a", "new", "query", "adapter", "for", "a", "Dataset" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/database.go#L394-L396
14,584
doug-martin/goqu
dataset_insert.go
getInsertColsAndVals
func (me *Dataset) getInsertColsAndVals(rows ...interface{}) (columns ColumnList, vals [][]interface{}, err error) { var mapKeys valueSlice rowValue := reflect.Indirect(reflect.ValueOf(rows[0])) rowType := rowValue.Type() rowKind := rowValue.Kind() vals = make([][]interface{}, len(rows)) for i, row := range rows { if rowType != reflect.Indirect(reflect.ValueOf(row)).Type() { return nil, nil, NewGoquError("Rows must be all the same type expected %+v got %+v", rowType, reflect.Indirect(reflect.ValueOf(row)).Type()) } newRowValue := reflect.Indirect(reflect.ValueOf(row)) switch rowKind { case reflect.Map: if columns == nil { mapKeys = valueSlice(newRowValue.MapKeys()) sort.Sort(mapKeys) colKeys := make([]interface{}, len(mapKeys)) for j, key := range mapKeys { colKeys[j] = key.Interface() } columns = cols(colKeys...) } newMapKeys := valueSlice(newRowValue.MapKeys()) if len(newMapKeys) != len(mapKeys) { return nil, nil, NewGoquError("Rows with different value length expected %d got %d", len(mapKeys), len(newMapKeys)) } if !mapKeys.Equal(newMapKeys) { return nil, nil, NewGoquError("Rows with different keys expected %s got %s", mapKeys.String(), newMapKeys.String()) } rowVals := make([]interface{}, len(mapKeys)) for j, key := range mapKeys { rowVals[j] = newRowValue.MapIndex(key).Interface() } vals[i] = rowVals case reflect.Struct: var ( rowCols []interface{} rowVals []interface{} ) rowCols, rowVals = me.getFieldsValues(newRowValue) if columns == nil { columns = cols(rowCols...) } vals[i] = rowVals default: return nil, nil, NewGoquError("Unsupported insert must be map, goqu.Record, or struct type got: %T", row) } } return columns, vals, nil }
go
func (me *Dataset) getInsertColsAndVals(rows ...interface{}) (columns ColumnList, vals [][]interface{}, err error) { var mapKeys valueSlice rowValue := reflect.Indirect(reflect.ValueOf(rows[0])) rowType := rowValue.Type() rowKind := rowValue.Kind() vals = make([][]interface{}, len(rows)) for i, row := range rows { if rowType != reflect.Indirect(reflect.ValueOf(row)).Type() { return nil, nil, NewGoquError("Rows must be all the same type expected %+v got %+v", rowType, reflect.Indirect(reflect.ValueOf(row)).Type()) } newRowValue := reflect.Indirect(reflect.ValueOf(row)) switch rowKind { case reflect.Map: if columns == nil { mapKeys = valueSlice(newRowValue.MapKeys()) sort.Sort(mapKeys) colKeys := make([]interface{}, len(mapKeys)) for j, key := range mapKeys { colKeys[j] = key.Interface() } columns = cols(colKeys...) } newMapKeys := valueSlice(newRowValue.MapKeys()) if len(newMapKeys) != len(mapKeys) { return nil, nil, NewGoquError("Rows with different value length expected %d got %d", len(mapKeys), len(newMapKeys)) } if !mapKeys.Equal(newMapKeys) { return nil, nil, NewGoquError("Rows with different keys expected %s got %s", mapKeys.String(), newMapKeys.String()) } rowVals := make([]interface{}, len(mapKeys)) for j, key := range mapKeys { rowVals[j] = newRowValue.MapIndex(key).Interface() } vals[i] = rowVals case reflect.Struct: var ( rowCols []interface{} rowVals []interface{} ) rowCols, rowVals = me.getFieldsValues(newRowValue) if columns == nil { columns = cols(rowCols...) } vals[i] = rowVals default: return nil, nil, NewGoquError("Unsupported insert must be map, goqu.Record, or struct type got: %T", row) } } return columns, vals, nil }
[ "func", "(", "me", "*", "Dataset", ")", "getInsertColsAndVals", "(", "rows", "...", "interface", "{", "}", ")", "(", "columns", "ColumnList", ",", "vals", "[", "]", "[", "]", "interface", "{", "}", ",", "err", "error", ")", "{", "var", "mapKeys", "va...
//parses the rows gathering and sorting unique columns and values for each record
[ "parses", "the", "rows", "gathering", "and", "sorting", "unique", "columns", "and", "values", "for", "each", "record" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset_insert.go#L92-L141
14,585
doug-martin/goqu
dataset_insert.go
insertSql
func (me *Dataset) insertSql(cols ColumnList, values [][]interface{}, prepared bool, c ConflictExpression) (string, []interface{}, error) { buf := NewSqlBuilder(prepared) if err := me.adapter.CommonTablesSql(buf, me.clauses.CommonTables); err != nil { return "", nil, err } if err := me.adapter.InsertBeginSql(buf, c); err != nil { return "", nil, err } if err := me.adapter.SourcesSql(buf, me.clauses.From); err != nil { return "", nil, NewGoquError(err.Error()) } if cols == nil { if err := me.adapter.DefaultValuesSql(buf); err != nil { return "", nil, NewGoquError(err.Error()) } } else { if err := me.adapter.InsertColumnsSql(buf, cols); err != nil { return "", nil, NewGoquError(err.Error()) } if err := me.adapter.InsertValuesSql(buf, values); err != nil { return "", nil, NewGoquError(err.Error()) } } if err := me.adapter.OnConflictSql(buf, c); err != nil { return "", nil, err } if me.adapter.SupportsReturn() { if err := me.adapter.ReturningSql(buf, me.clauses.Returning); err != nil { return "", nil, err } } else if me.clauses.Returning != nil { return "", nil, NewGoquError("Adapter does not support RETURNING clause") } sql, args := buf.ToSql() return sql, args, nil }
go
func (me *Dataset) insertSql(cols ColumnList, values [][]interface{}, prepared bool, c ConflictExpression) (string, []interface{}, error) { buf := NewSqlBuilder(prepared) if err := me.adapter.CommonTablesSql(buf, me.clauses.CommonTables); err != nil { return "", nil, err } if err := me.adapter.InsertBeginSql(buf, c); err != nil { return "", nil, err } if err := me.adapter.SourcesSql(buf, me.clauses.From); err != nil { return "", nil, NewGoquError(err.Error()) } if cols == nil { if err := me.adapter.DefaultValuesSql(buf); err != nil { return "", nil, NewGoquError(err.Error()) } } else { if err := me.adapter.InsertColumnsSql(buf, cols); err != nil { return "", nil, NewGoquError(err.Error()) } if err := me.adapter.InsertValuesSql(buf, values); err != nil { return "", nil, NewGoquError(err.Error()) } } if err := me.adapter.OnConflictSql(buf, c); err != nil { return "", nil, err } if me.adapter.SupportsReturn() { if err := me.adapter.ReturningSql(buf, me.clauses.Returning); err != nil { return "", nil, err } } else if me.clauses.Returning != nil { return "", nil, NewGoquError("Adapter does not support RETURNING clause") } sql, args := buf.ToSql() return sql, args, nil }
[ "func", "(", "me", "*", "Dataset", ")", "insertSql", "(", "cols", "ColumnList", ",", "values", "[", "]", "[", "]", "interface", "{", "}", ",", "prepared", "bool", ",", "c", "ConflictExpression", ")", "(", "string", ",", "[", "]", "interface", "{", "}...
//Creates an INSERT statement with the columns and values passed in
[ "Creates", "an", "INSERT", "statement", "with", "the", "columns", "and", "values", "passed", "in" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset_insert.go#L166-L202
14,586
doug-martin/goqu
dataset_insert.go
insertFromSql
func (me *Dataset) insertFromSql(other Dataset, prepared bool, c ConflictExpression) (string, []interface{}, error) { buf := NewSqlBuilder(prepared) if err := me.adapter.CommonTablesSql(buf, me.clauses.CommonTables); err != nil { return "", nil, err } if err := me.adapter.InsertBeginSql(buf, nil); err != nil { return "", nil, err } if err := me.adapter.SourcesSql(buf, me.clauses.From); err != nil { return "", nil, NewGoquError(err.Error()) } buf.WriteString(" ") if err := other.selectSqlWriteTo(buf); err != nil { return "", nil, err } if err := me.adapter.OnConflictSql(buf, c); err != nil { return "", nil, err } if me.adapter.SupportsReturn() { if err := me.adapter.ReturningSql(buf, me.clauses.Returning); err != nil { return "", nil, err } } else if me.clauses.Returning != nil { return "", nil, NewGoquError("Adapter does not support RETURNING clause") } sql, args := buf.ToSql() return sql, args, nil }
go
func (me *Dataset) insertFromSql(other Dataset, prepared bool, c ConflictExpression) (string, []interface{}, error) { buf := NewSqlBuilder(prepared) if err := me.adapter.CommonTablesSql(buf, me.clauses.CommonTables); err != nil { return "", nil, err } if err := me.adapter.InsertBeginSql(buf, nil); err != nil { return "", nil, err } if err := me.adapter.SourcesSql(buf, me.clauses.From); err != nil { return "", nil, NewGoquError(err.Error()) } buf.WriteString(" ") if err := other.selectSqlWriteTo(buf); err != nil { return "", nil, err } if err := me.adapter.OnConflictSql(buf, c); err != nil { return "", nil, err } if me.adapter.SupportsReturn() { if err := me.adapter.ReturningSql(buf, me.clauses.Returning); err != nil { return "", nil, err } } else if me.clauses.Returning != nil { return "", nil, NewGoquError("Adapter does not support RETURNING clause") } sql, args := buf.ToSql() return sql, args, nil }
[ "func", "(", "me", "*", "Dataset", ")", "insertFromSql", "(", "other", "Dataset", ",", "prepared", "bool", ",", "c", "ConflictExpression", ")", "(", "string", ",", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "buf", ":=", "NewSqlBuilder", "...
//Creates an insert statement with values coming from another dataset
[ "Creates", "an", "insert", "statement", "with", "values", "coming", "from", "another", "dataset" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/dataset_insert.go#L205-L232
14,587
doug-martin/goqu
expressions.go
eq
func eq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, false) }
go
func eq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, false) }
[ "func", "eq", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkBoolExpType", "(", "EQ_OP", ",", "lhs", ",", "rhs", ",", "false", ")", "\n", "}" ]
//used internally to create an equality BooleanExpression
[ "used", "internally", "to", "create", "an", "equality", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L914-L916
14,588
doug-martin/goqu
expressions.go
neq
func neq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, true) }
go
func neq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, true) }
[ "func", "neq", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkBoolExpType", "(", "EQ_OP", ",", "lhs", ",", "rhs", ",", "true", ")", "\n", "}" ]
//used internally to create an in-equality BooleanExpression
[ "used", "internally", "to", "create", "an", "in", "-", "equality", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L919-L921
14,589
doug-martin/goqu
expressions.go
gt
func gt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GT_OP, lhs: lhs, rhs: rhs} }
go
func gt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GT_OP, lhs: lhs, rhs: rhs} }
[ "func", "gt", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "boolean", "{", "op", ":", "GT_OP", ",", "lhs", ":", "lhs", ",", "rhs", ":", "rhs", "}", "\n", "}" ]
//used internally to create an gt comparison BooleanExpression
[ "used", "internally", "to", "create", "an", "gt", "comparison", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L924-L926
14,590
doug-martin/goqu
expressions.go
gte
func gte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GTE_OP, lhs: lhs, rhs: rhs} }
go
func gte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GTE_OP, lhs: lhs, rhs: rhs} }
[ "func", "gte", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "boolean", "{", "op", ":", "GTE_OP", ",", "lhs", ":", "lhs", ",", "rhs", ":", "rhs", "}", "\n", "}" ]
//used internally to create an gte comparison BooleanExpression
[ "used", "internally", "to", "create", "an", "gte", "comparison", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L929-L931
14,591
doug-martin/goqu
expressions.go
lt
func lt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LT_OP, lhs: lhs, rhs: rhs} }
go
func lt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LT_OP, lhs: lhs, rhs: rhs} }
[ "func", "lt", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "boolean", "{", "op", ":", "LT_OP", ",", "lhs", ":", "lhs", ",", "rhs", ":", "rhs", "}", "\n", "}" ]
//used internally to create an lt comparison BooleanExpression
[ "used", "internally", "to", "create", "an", "lt", "comparison", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L934-L936
14,592
doug-martin/goqu
expressions.go
lte
func lte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LTE_OP, lhs: lhs, rhs: rhs} }
go
func lte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LTE_OP, lhs: lhs, rhs: rhs} }
[ "func", "lte", "(", "lhs", "Expression", ",", "rhs", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "boolean", "{", "op", ":", "LTE_OP", ",", "lhs", ":", "lhs", ",", "rhs", ":", "rhs", "}", "\n", "}" ]
//used internally to create an lte comparison BooleanExpression
[ "used", "internally", "to", "create", "an", "lte", "comparison", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L939-L941
14,593
doug-martin/goqu
expressions.go
in
func in(lhs Expression, vals ...interface{}) BooleanExpression { if len(vals) == 1 && reflect.Indirect(reflect.ValueOf(vals[0])).Kind() == reflect.Slice { return boolean{op: IN_OP, lhs: lhs, rhs: vals[0]} } return boolean{op: IN_OP, lhs: lhs, rhs: vals} }
go
func in(lhs Expression, vals ...interface{}) BooleanExpression { if len(vals) == 1 && reflect.Indirect(reflect.ValueOf(vals[0])).Kind() == reflect.Slice { return boolean{op: IN_OP, lhs: lhs, rhs: vals[0]} } return boolean{op: IN_OP, lhs: lhs, rhs: vals} }
[ "func", "in", "(", "lhs", "Expression", ",", "vals", "...", "interface", "{", "}", ")", "BooleanExpression", "{", "if", "len", "(", "vals", ")", "==", "1", "&&", "reflect", ".", "Indirect", "(", "reflect", ".", "ValueOf", "(", "vals", "[", "0", "]", ...
//used internally to create an IN BooleanExpression
[ "used", "internally", "to", "create", "an", "IN", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L944-L949
14,594
doug-martin/goqu
expressions.go
notIn
func notIn(lhs Expression, vals ...interface{}) BooleanExpression { if len(vals) == 1 && reflect.Indirect(reflect.ValueOf(vals[0])).Kind() == reflect.Slice { return boolean{op: NOT_IN_OP, lhs: lhs, rhs: vals[0]} } return boolean{op: NOT_IN_OP, lhs: lhs, rhs: vals} }
go
func notIn(lhs Expression, vals ...interface{}) BooleanExpression { if len(vals) == 1 && reflect.Indirect(reflect.ValueOf(vals[0])).Kind() == reflect.Slice { return boolean{op: NOT_IN_OP, lhs: lhs, rhs: vals[0]} } return boolean{op: NOT_IN_OP, lhs: lhs, rhs: vals} }
[ "func", "notIn", "(", "lhs", "Expression", ",", "vals", "...", "interface", "{", "}", ")", "BooleanExpression", "{", "if", "len", "(", "vals", ")", "==", "1", "&&", "reflect", ".", "Indirect", "(", "reflect", ".", "ValueOf", "(", "vals", "[", "0", "]...
//used internally to create a NOT IN BooleanExpression
[ "used", "internally", "to", "create", "a", "NOT", "IN", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L952-L957
14,595
doug-martin/goqu
expressions.go
is
func is(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, false) }
go
func is(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, false) }
[ "func", "is", "(", "lhs", "Expression", ",", "val", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkBoolExpType", "(", "IS_OP", ",", "lhs", ",", "val", ",", "false", ")", "\n", "}" ]
//used internally to create an IS BooleanExpression
[ "used", "internally", "to", "create", "an", "IS", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L960-L962
14,596
doug-martin/goqu
expressions.go
isNot
func isNot(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, true) }
go
func isNot(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, true) }
[ "func", "isNot", "(", "lhs", "Expression", ",", "val", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkBoolExpType", "(", "IS_OP", ",", "lhs", ",", "val", ",", "true", ")", "\n", "}" ]
//used internally to create an IS NOT BooleanExpression
[ "used", "internally", "to", "create", "an", "IS", "NOT", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L965-L967
14,597
doug-martin/goqu
expressions.go
like
func like(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, false) }
go
func like(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, false) }
[ "func", "like", "(", "lhs", "Expression", ",", "val", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkLikeExp", "(", "LIKE_OP", ",", "lhs", ",", "val", ",", "false", ")", "\n", "}" ]
//used internally to create a LIKE BooleanExpression
[ "used", "internally", "to", "create", "a", "LIKE", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L970-L972
14,598
doug-martin/goqu
expressions.go
iLike
func iLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(I_LIKE_OP, lhs, val, false) }
go
func iLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(I_LIKE_OP, lhs, val, false) }
[ "func", "iLike", "(", "lhs", "Expression", ",", "val", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkLikeExp", "(", "I_LIKE_OP", ",", "lhs", ",", "val", ",", "false", ")", "\n", "}" ]
//used internally to create an ILIKE BooleanExpression
[ "used", "internally", "to", "create", "an", "ILIKE", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L975-L977
14,599
doug-martin/goqu
expressions.go
notLike
func notLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, true) }
go
func notLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, true) }
[ "func", "notLike", "(", "lhs", "Expression", ",", "val", "interface", "{", "}", ")", "BooleanExpression", "{", "return", "checkLikeExp", "(", "LIKE_OP", ",", "lhs", ",", "val", ",", "true", ")", "\n", "}" ]
//used internally to create a NOT LIKE BooleanExpression
[ "used", "internally", "to", "create", "a", "NOT", "LIKE", "BooleanExpression" ]
6803bc2ea3462276f0e87814761a787d5537c4eb
https://github.com/doug-martin/goqu/blob/6803bc2ea3462276f0e87814761a787d5537c4eb/expressions.go#L980-L982