_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q14500
SetWindowsIgnoreFlushesDuringBoot
train
func (g *Generator) SetWindowsIgnoreFlushesDuringBoot(ignore bool) { g.initConfigWindows() g.Config.Windows.IgnoreFlushesDuringBoot = ignore }
go
{ "resource": "" }
q14501
AddWindowsLayerFolders
train
func (g *Generator) AddWindowsLayerFolders(folder string) { g.initConfigWindows() g.Config.Windows.LayerFolders = append(g.Config.Windows.LayerFolders, folder) }
go
{ "resource": "" }
q14502
AddWindowsDevices
train
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
{ "resource": "" }
q14503
SetWindowsNetwork
train
func (g *Generator) SetWindowsNetwork(network rspec.WindowsNetwork) { g.initConfigWindows() g.Config.Windows.Network = &network }
go
{ "resource": "" }
q14504
SetWindowsNetworkAllowUnqualifiedDNSQuery
train
func (g *Generator) SetWindowsNetworkAllowUnqualifiedDNSQuery(setting bool) { g.initConfigWindowsNetwork() g.Config.Windows.Network.AllowUnqualifiedDNSQuery = setting }
go
{ "resource": "" }
q14505
SetWindowsNetworkNamespace
train
func (g *Generator) SetWindowsNetworkNamespace(path string) { g.initConfigWindowsNetwork() g.Config.Windows.Network.NetworkNamespace = path }
go
{ "resource": "" }
q14506
SetWindowsResourcesCPU
train
func (g *Generator) SetWindowsResourcesCPU(cpu rspec.WindowsCPUResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.CPU = &cpu }
go
{ "resource": "" }
q14507
SetWindowsResourcesMemoryLimit
train
func (g *Generator) SetWindowsResourcesMemoryLimit(limit uint64) { g.initConfigWindowsResourcesMemory() g.Config.Windows.Resources.Memory.Limit = &limit }
go
{ "resource": "" }
q14508
SetWindowsResourcesStorage
train
func (g *Generator) SetWindowsResourcesStorage(storage rspec.WindowsStorageResources) { g.initConfigWindowsResources() g.Config.Windows.Resources.Storage = &storage }
go
{ "resource": "" }
q14509
SetWindowsServicing
train
func (g *Generator) SetWindowsServicing(servicing bool) { g.initConfigWindows() g.Config.Windows.Servicing = servicing }
go
{ "resource": "" }
q14510
ValidateLinuxResourcesDevices
train
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
{ "resource": "" }
q14511
IsAncestor
train
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
{ "resource": "" }
q14512
ValidateLinuxResourcesNetwork
train
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
{ "resource": "" }
q14513
ValidateLinuxResourcesMemory
train
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
{ "resource": "" }
q14514
ParseLevel
train
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
{ "resource": "" }
q14515
String
train
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
{ "resource": "" }
q14516
Error
train
func (err *Error) Error() string { return fmt.Sprintf("%s\nRefer to: %s", err.Err.Error(), err.Reference) }
go
{ "resource": "" }
q14517
NewRuntime
train
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
{ "resource": "" }
q14518
SetConfig
train
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
{ "resource": "" }
q14519
ReadStandardStreams
train
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
{ "resource": "" }
q14520
State
train
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
{ "resource": "" }
q14521
Kill
train
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
{ "resource": "" }
q14522
Delete
train
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
{ "resource": "" }
q14523
Clean
train
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
{ "resource": "" }
q14524
NewRFCErrorOrPanic
train
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
{ "resource": "" }
q14525
SplitLevel
train
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
{ "resource": "" }
q14526
ParseSyscallFlag
train
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
{ "resource": "" }
q14527
ParseDefaultAction
train
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
{ "resource": "" }
q14528
ParseDefaultActionForce
train
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
{ "resource": "" }
q14529
NewValidator
train
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
{ "resource": "" }
q14530
NewValidatorFromPath
train
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
{ "resource": "" }
q14531
CheckAll
train
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
{ "resource": "" }
q14532
JSONSchemaURL
train
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
{ "resource": "" }
q14533
CheckJSONSchema
train
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
{ "resource": "" }
q14534
CheckSemVer
train
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
{ "resource": "" }
q14535
CheckHooks
train
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
{ "resource": "" }
q14536
CheckProcess
train
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
{ "resource": "" }
q14537
CheckCapabilities
train
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
{ "resource": "" }
q14538
CheckRlimits
train
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
{ "resource": "" }
q14539
CheckMounts
train
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
{ "resource": "" }
q14540
CheckPlatform
train
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
{ "resource": "" }
q14541
CheckLinuxResources
train
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
{ "resource": "" }
q14542
CheckAnnotations
train
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
{ "resource": "" }
q14543
CapValid
train
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
{ "resource": "" }
q14544
CheckMandatoryFields
train
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
{ "resource": "" }
q14545
ValidateLinuxResourcesPids
train
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
{ "resource": "" }
q14546
removeAdapter
train
func removeAdapter(dialect string) { if HasAdapter(dialect) { dialect = strings.ToLower(dialect) delete(ds_adapters, dialect) } }
go
{ "resource": "" }
q14547
Literal
train
func (me *DefaultAdapter) Literal(buf *SqlBuilder, val interface{}) error { return me.dataset.Literal(buf, val) }
go
{ "resource": "" }
q14548
UpdateBeginSql
train
func (me *DefaultAdapter) UpdateBeginSql(buf *SqlBuilder) error { buf.Write(me.UpdateClause) return nil }
go
{ "resource": "" }
q14549
InsertBeginSql
train
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
{ "resource": "" }
q14550
DeleteBeginSql
train
func (me *DefaultAdapter) DeleteBeginSql(buf *SqlBuilder) error { buf.Write(me.DeleteClause) return nil }
go
{ "resource": "" }
q14551
TruncateSql
train
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
{ "resource": "" }
q14552
InsertColumnsSql
train
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
{ "resource": "" }
q14553
InsertValuesSql
train
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
{ "resource": "" }
q14554
SelectSql
train
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
{ "resource": "" }
q14555
SelectDistinctSql
train
func (me *DefaultAdapter) SelectDistinctSql(buf *SqlBuilder, cols ColumnList) error { buf.Write(me.SelectClause) buf.Write(me.DistinctFragment) return me.Literal(buf, cols) }
go
{ "resource": "" }
q14556
FromSql
train
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
{ "resource": "" }
q14557
SourcesSql
train
func (me *DefaultAdapter) SourcesSql(buf *SqlBuilder, from ColumnList) error { buf.WriteRune(space_rune) return me.Literal(buf, from) }
go
{ "resource": "" }
q14558
JoinSql
train
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
{ "resource": "" }
q14559
WhereSql
train
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
{ "resource": "" }
q14560
GroupBySql
train
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
{ "resource": "" }
q14561
HavingSql
train
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
{ "resource": "" }
q14562
OrderSql
train
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
{ "resource": "" }
q14563
LimitSql
train
func (me *DefaultAdapter) LimitSql(buf *SqlBuilder, limit interface{}) error { if limit != nil { buf.Write(me.LimitFragment) return me.Literal(buf, limit) } return nil }
go
{ "resource": "" }
q14564
OffsetSql
train
func (me *DefaultAdapter) OffsetSql(buf *SqlBuilder, offset uint) error { if offset > 0 { buf.Write(me.OffsetFragment) return me.Literal(buf, offset) } return nil }
go
{ "resource": "" }
q14565
DatasetSql
train
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
{ "resource": "" }
q14566
LiteralNil
train
func (me *DefaultAdapter) LiteralNil(buf *SqlBuilder) error { buf.Write(me.Null) return nil }
go
{ "resource": "" }
q14567
LiteralTime
train
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
{ "resource": "" }
q14568
LiteralFloat
train
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
{ "resource": "" }
q14569
LiteralInt
train
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
{ "resource": "" }
q14570
LiteralString
train
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
{ "resource": "" }
q14571
LiteralBytes
train
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
{ "resource": "" }
q14572
ColumnListSql
train
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
{ "resource": "" }
q14573
UpdateExpressionSql
train
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
{ "resource": "" }
q14574
CommonTableExpressionSql
train
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
{ "resource": "" }
q14575
CompoundExpressionSql
train
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
{ "resource": "" }
q14576
withDatabase
train
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
{ "resource": "" }
q14577
SetAdapter
train
func (me *Dataset) SetAdapter(adapter Adapter) *Dataset { me.adapter = adapter return me }
go
{ "resource": "" }
q14578
hasSources
train
func (me *Dataset) hasSources() bool { return me.clauses.From != nil && len(me.clauses.From.Columns()) > 0 }
go
{ "resource": "" }
q14579
WriteArg
train
func (me *SqlBuilder) WriteArg(i interface{}) { me.CurrentArgPosition++ me.args = append(me.args, i) }
go
{ "resource": "" }
q14580
Begin
train
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
{ "resource": "" }
q14581
queryAdapter
train
func (me *Database) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
go
{ "resource": "" }
q14582
Trace
train
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
{ "resource": "" }
q14583
queryAdapter
train
func (me *TxDatabase) queryAdapter(dataset *Dataset) Adapter { return NewAdapter(me.Dialect, dataset) }
go
{ "resource": "" }
q14584
getInsertColsAndVals
train
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
{ "resource": "" }
q14585
insertSql
train
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
{ "resource": "" }
q14586
insertFromSql
train
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
{ "resource": "" }
q14587
eq
train
func eq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, false) }
go
{ "resource": "" }
q14588
neq
train
func neq(lhs Expression, rhs interface{}) BooleanExpression { return checkBoolExpType(EQ_OP, lhs, rhs, true) }
go
{ "resource": "" }
q14589
gt
train
func gt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GT_OP, lhs: lhs, rhs: rhs} }
go
{ "resource": "" }
q14590
gte
train
func gte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: GTE_OP, lhs: lhs, rhs: rhs} }
go
{ "resource": "" }
q14591
lt
train
func lt(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LT_OP, lhs: lhs, rhs: rhs} }
go
{ "resource": "" }
q14592
lte
train
func lte(lhs Expression, rhs interface{}) BooleanExpression { return boolean{op: LTE_OP, lhs: lhs, rhs: rhs} }
go
{ "resource": "" }
q14593
in
train
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
{ "resource": "" }
q14594
notIn
train
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
{ "resource": "" }
q14595
is
train
func is(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, false) }
go
{ "resource": "" }
q14596
isNot
train
func isNot(lhs Expression, val interface{}) BooleanExpression { return checkBoolExpType(IS_OP, lhs, val, true) }
go
{ "resource": "" }
q14597
like
train
func like(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, false) }
go
{ "resource": "" }
q14598
iLike
train
func iLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(I_LIKE_OP, lhs, val, false) }
go
{ "resource": "" }
q14599
notLike
train
func notLike(lhs Expression, val interface{}) BooleanExpression { return checkLikeExp(LIKE_OP, lhs, val, true) }
go
{ "resource": "" }