repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/server.go
signAndMarshal
func signAndMarshal(k Signer, rand io.Reader, data []byte) ([]byte, error) { sig, err := k.Sign(rand, data) if err != nil { return nil, err } return Marshal(sig), nil }
go
func signAndMarshal(k Signer, rand io.Reader, data []byte) ([]byte, error) { sig, err := k.Sign(rand, data) if err != nil { return nil, err } return Marshal(sig), nil }
[ "func", "signAndMarshal", "(", "k", "Signer", ",", "rand", "io", ".", "Reader", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "sig", ",", "err", ":=", "k", ".", "Sign", "(", "rand", ",", "data", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "Marshal", "(", "sig", ")", ",", "nil", "\n", "}" ]
// signAndMarshal signs the data with the appropriate algorithm, // and serializes the result in SSH wire format.
[ "signAndMarshal", "signs", "the", "data", "with", "the", "appropriate", "algorithm", "and", "serializes", "the", "result", "in", "SSH", "wire", "format", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/server.go#L156-L163
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/explain.go
PrintModelDescription
func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swaggerSchema *swagger.ApiDeclaration, r bool) error { recursive = r // this is global for convenience apiVer := apiutil.GetVersion(swaggerSchema.ApiVersion) + "." var pointedModel *swagger.NamedModel for i := range swaggerSchema.Models.List { name := swaggerSchema.Models.List[i].Name allModels[name] = &swaggerSchema.Models.List[i] if strings.ToLower(name) == strings.ToLower(apiVer+inModel) { pointedModel = &swaggerSchema.Models.List[i] } } if pointedModel == nil { return fmt.Errorf("requested resource %q is not defined", inModel) } if len(fieldsPath) == 0 { return printTopLevelResourceInfo(w, pointedModel) } var pointedModelAsProp *swagger.NamedModelProperty for _, field := range fieldsPath { if prop, nextModel, isModel := getField(pointedModel, field); prop != nil { if isModel { pointedModelAsProp = prop pointedModel = allModels[nextModel] } else { return printPrimitive(w, prop) } } else { return fmt.Errorf("field %q does not exist", field) } } return printModelInfo(w, pointedModel, pointedModelAsProp) }
go
func PrintModelDescription(inModel string, fieldsPath []string, w io.Writer, swaggerSchema *swagger.ApiDeclaration, r bool) error { recursive = r // this is global for convenience apiVer := apiutil.GetVersion(swaggerSchema.ApiVersion) + "." var pointedModel *swagger.NamedModel for i := range swaggerSchema.Models.List { name := swaggerSchema.Models.List[i].Name allModels[name] = &swaggerSchema.Models.List[i] if strings.ToLower(name) == strings.ToLower(apiVer+inModel) { pointedModel = &swaggerSchema.Models.List[i] } } if pointedModel == nil { return fmt.Errorf("requested resource %q is not defined", inModel) } if len(fieldsPath) == 0 { return printTopLevelResourceInfo(w, pointedModel) } var pointedModelAsProp *swagger.NamedModelProperty for _, field := range fieldsPath { if prop, nextModel, isModel := getField(pointedModel, field); prop != nil { if isModel { pointedModelAsProp = prop pointedModel = allModels[nextModel] } else { return printPrimitive(w, prop) } } else { return fmt.Errorf("field %q does not exist", field) } } return printModelInfo(w, pointedModel, pointedModelAsProp) }
[ "func", "PrintModelDescription", "(", "inModel", "string", ",", "fieldsPath", "[", "]", "string", ",", "w", "io", ".", "Writer", ",", "swaggerSchema", "*", "swagger", ".", "ApiDeclaration", ",", "r", "bool", ")", "error", "{", "recursive", "=", "r", "// this is global for convenience", "\n", "apiVer", ":=", "apiutil", ".", "GetVersion", "(", "swaggerSchema", ".", "ApiVersion", ")", "+", "\"", "\"", "\n\n", "var", "pointedModel", "*", "swagger", ".", "NamedModel", "\n", "for", "i", ":=", "range", "swaggerSchema", ".", "Models", ".", "List", "{", "name", ":=", "swaggerSchema", ".", "Models", ".", "List", "[", "i", "]", ".", "Name", "\n\n", "allModels", "[", "name", "]", "=", "&", "swaggerSchema", ".", "Models", ".", "List", "[", "i", "]", "\n", "if", "strings", ".", "ToLower", "(", "name", ")", "==", "strings", ".", "ToLower", "(", "apiVer", "+", "inModel", ")", "{", "pointedModel", "=", "&", "swaggerSchema", ".", "Models", ".", "List", "[", "i", "]", "\n", "}", "\n", "}", "\n", "if", "pointedModel", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "inModel", ")", "\n", "}", "\n\n", "if", "len", "(", "fieldsPath", ")", "==", "0", "{", "return", "printTopLevelResourceInfo", "(", "w", ",", "pointedModel", ")", "\n", "}", "\n\n", "var", "pointedModelAsProp", "*", "swagger", ".", "NamedModelProperty", "\n", "for", "_", ",", "field", ":=", "range", "fieldsPath", "{", "if", "prop", ",", "nextModel", ",", "isModel", ":=", "getField", "(", "pointedModel", ",", "field", ")", ";", "prop", "!=", "nil", "{", "if", "isModel", "{", "pointedModelAsProp", "=", "prop", "\n", "pointedModel", "=", "allModels", "[", "nextModel", "]", "\n", "}", "else", "{", "return", "printPrimitive", "(", "w", ",", "prop", ")", "\n", "}", "\n", "}", "else", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "field", ")", "\n", "}", "\n", "}", "\n", "return", "printModelInfo", "(", "w", ",", "pointedModel", ",", "pointedModelAsProp", ")", "\n", "}" ]
// PrintModelDescription prints the description of a specific model or dot path
[ "PrintModelDescription", "prints", "the", "description", "of", "a", "specific", "model", "or", "dot", "path" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/explain.go#L41-L76
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount.go
GetMountRefs
func GetMountRefs(mounter Interface, mountPath string) ([]string, error) { mps, err := mounter.List() if err != nil { return nil, err } // Find the device name. deviceName := "" for i := range mps { if mps[i].Path == mountPath { deviceName = mps[i].Device break } } // Find all references to the device. var refs []string if deviceName == "" { glog.Warningf("could not determine device for path: %q", mountPath) } else { for i := range mps { if mps[i].Device == deviceName && mps[i].Path != mountPath { refs = append(refs, mps[i].Path) } } } return refs, nil }
go
func GetMountRefs(mounter Interface, mountPath string) ([]string, error) { mps, err := mounter.List() if err != nil { return nil, err } // Find the device name. deviceName := "" for i := range mps { if mps[i].Path == mountPath { deviceName = mps[i].Device break } } // Find all references to the device. var refs []string if deviceName == "" { glog.Warningf("could not determine device for path: %q", mountPath) } else { for i := range mps { if mps[i].Device == deviceName && mps[i].Path != mountPath { refs = append(refs, mps[i].Path) } } } return refs, nil }
[ "func", "GetMountRefs", "(", "mounter", "Interface", ",", "mountPath", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "mps", ",", "err", ":=", "mounter", ".", "List", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Find the device name.", "deviceName", ":=", "\"", "\"", "\n", "for", "i", ":=", "range", "mps", "{", "if", "mps", "[", "i", "]", ".", "Path", "==", "mountPath", "{", "deviceName", "=", "mps", "[", "i", "]", ".", "Device", "\n", "break", "\n", "}", "\n", "}", "\n\n", "// Find all references to the device.", "var", "refs", "[", "]", "string", "\n", "if", "deviceName", "==", "\"", "\"", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "mountPath", ")", "\n", "}", "else", "{", "for", "i", ":=", "range", "mps", "{", "if", "mps", "[", "i", "]", ".", "Device", "==", "deviceName", "&&", "mps", "[", "i", "]", ".", "Path", "!=", "mountPath", "{", "refs", "=", "append", "(", "refs", ",", "mps", "[", "i", "]", ".", "Path", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "refs", ",", "nil", "\n", "}" ]
// GetMountRefs finds all other references to the device referenced // by mountPath; returns a list of paths.
[ "GetMountRefs", "finds", "all", "other", "references", "to", "the", "device", "referenced", "by", "mountPath", ";", "returns", "a", "list", "of", "paths", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount.go#L80-L107
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateHasLabel
func ValidateHasLabel(meta api.ObjectMeta, fldPath *field.Path, key, expectedValue string) field.ErrorList { allErrs := field.ErrorList{} actualValue, found := meta.Labels[key] if !found { allErrs = append(allErrs, field.Required(fldPath.Child("labels"), key+"="+expectedValue)) return allErrs } if actualValue != expectedValue { allErrs = append(allErrs, field.Invalid(fldPath.Child("labels"), meta.Labels, "expected "+key+"="+expectedValue)) } return allErrs }
go
func ValidateHasLabel(meta api.ObjectMeta, fldPath *field.Path, key, expectedValue string) field.ErrorList { allErrs := field.ErrorList{} actualValue, found := meta.Labels[key] if !found { allErrs = append(allErrs, field.Required(fldPath.Child("labels"), key+"="+expectedValue)) return allErrs } if actualValue != expectedValue { allErrs = append(allErrs, field.Invalid(fldPath.Child("labels"), meta.Labels, "expected "+key+"="+expectedValue)) } return allErrs }
[ "func", "ValidateHasLabel", "(", "meta", "api", ".", "ObjectMeta", ",", "fldPath", "*", "field", ".", "Path", ",", "key", ",", "expectedValue", "string", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "field", ".", "ErrorList", "{", "}", "\n", "actualValue", ",", "found", ":=", "meta", ".", "Labels", "[", "key", "]", "\n", "if", "!", "found", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Required", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "key", "+", "\"", "\"", "+", "expectedValue", ")", ")", "\n", "return", "allErrs", "\n", "}", "\n", "if", "actualValue", "!=", "expectedValue", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Invalid", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "meta", ".", "Labels", ",", "\"", "\"", "+", "key", "+", "\"", "\"", "+", "expectedValue", ")", ")", "\n", "}", "\n", "return", "allErrs", "\n", "}" ]
// ValidateHasLabel requires that api.ObjectMeta has a Label with key and expectedValue
[ "ValidateHasLabel", "requires", "that", "api", ".", "ObjectMeta", "has", "a", "Label", "with", "key", "and", "expectedValue" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L88-L99
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidatePodName
func ValidatePodName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidatePodName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidatePodName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidatePodName can be used to check whether the given pod name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidatePodName", "can", "be", "used", "to", "check", "whether", "the", "given", "pod", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L138-L140
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateReplicationControllerName
func ValidateReplicationControllerName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateReplicationControllerName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateReplicationControllerName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateReplicationControllerName can be used to check whether the given replication // controller name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateReplicationControllerName", "can", "be", "used", "to", "check", "whether", "the", "given", "replication", "controller", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L146-L148
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateServiceName
func ValidateServiceName(name string, prefix bool) (bool, string) { return NameIsDNS952Label(name, prefix) }
go
func ValidateServiceName(name string, prefix bool) (bool, string) { return NameIsDNS952Label(name, prefix) }
[ "func", "ValidateServiceName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNS952Label", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateServiceName can be used to check whether the given service name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateServiceName", "can", "be", "used", "to", "check", "whether", "the", "given", "service", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L153-L155
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateNodeName
func ValidateNodeName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateNodeName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateNodeName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateNodeName can be used to check whether the given node name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateNodeName", "can", "be", "used", "to", "check", "whether", "the", "given", "node", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L160-L162
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateNamespaceName
func ValidateNamespaceName(name string, prefix bool) (bool, string) { return NameIsDNSLabel(name, prefix) }
go
func ValidateNamespaceName(name string, prefix bool) (bool, string) { return NameIsDNSLabel(name, prefix) }
[ "func", "ValidateNamespaceName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSLabel", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateNamespaceName can be used to check whether the given namespace name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateNamespaceName", "can", "be", "used", "to", "check", "whether", "the", "given", "namespace", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L167-L169
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateLimitRangeName
func ValidateLimitRangeName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateLimitRangeName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateLimitRangeName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateLimitRangeName can be used to check whether the given limit range name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateLimitRangeName", "can", "be", "used", "to", "check", "whether", "the", "given", "limit", "range", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L174-L176
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateResourceQuotaName
func ValidateResourceQuotaName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateResourceQuotaName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateResourceQuotaName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateResourceQuotaName can be used to check whether the given // resource quota name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateResourceQuotaName", "can", "be", "used", "to", "check", "whether", "the", "given", "resource", "quota", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L182-L184
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateSecretName
func ValidateSecretName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateSecretName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateSecretName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateSecretName can be used to check whether the given secret name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateSecretName", "can", "be", "used", "to", "check", "whether", "the", "given", "secret", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L189-L191
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateServiceAccountName
func ValidateServiceAccountName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateServiceAccountName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateServiceAccountName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateServiceAccountName can be used to check whether the given service account name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateServiceAccountName", "can", "be", "used", "to", "check", "whether", "the", "given", "service", "account", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L196-L198
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateEndpointsName
func ValidateEndpointsName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
go
func ValidateEndpointsName(name string, prefix bool) (bool, string) { return NameIsDNSSubdomain(name, prefix) }
[ "func", "ValidateEndpointsName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "return", "NameIsDNSSubdomain", "(", "name", ",", "prefix", ")", "\n", "}" ]
// ValidateEndpointsName can be used to check whether the given endpoints name is valid. // Prefix indicates this name will be used as part of generation, in which case // trailing dashes are allowed.
[ "ValidateEndpointsName", "can", "be", "used", "to", "check", "whether", "the", "given", "endpoints", "name", "is", "valid", ".", "Prefix", "indicates", "this", "name", "will", "be", "used", "as", "part", "of", "generation", "in", "which", "case", "trailing", "dashes", "are", "allowed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L203-L205
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
NameIsDNS952Label
func NameIsDNS952Label(name string, prefix bool) (bool, string) { if prefix { name = maskTrailingDash(name) } if validation.IsDNS952Label(name) { return true, "" } return false, DNS952LabelErrorMsg }
go
func NameIsDNS952Label(name string, prefix bool) (bool, string) { if prefix { name = maskTrailingDash(name) } if validation.IsDNS952Label(name) { return true, "" } return false, DNS952LabelErrorMsg }
[ "func", "NameIsDNS952Label", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "if", "prefix", "{", "name", "=", "maskTrailingDash", "(", "name", ")", "\n", "}", "\n", "if", "validation", ".", "IsDNS952Label", "(", "name", ")", "{", "return", "true", ",", "\"", "\"", "\n", "}", "\n", "return", "false", ",", "DNS952LabelErrorMsg", "\n", "}" ]
// NameIsDNS952Label is a ValidateNameFunc for names that must be a DNS 952 label.
[ "NameIsDNS952Label", "is", "a", "ValidateNameFunc", "for", "names", "that", "must", "be", "a", "DNS", "952", "label", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L230-L238
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateNodeSelectorRequirement
func ValidateNodeSelectorRequirement(rq api.NodeSelectorRequirement, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} switch rq.Operator { case api.NodeSelectorOpIn, api.NodeSelectorOpNotIn: if len(rq.Values) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("values"), "must be specified when `operator` is 'In' or 'NotIn'")) } case api.NodeSelectorOpExists, api.NodeSelectorOpDoesNotExist: if len(rq.Values) > 0 { allErrs = append(allErrs, field.Forbidden(fldPath.Child("values"), "may not be specified when `operator` is 'Exists' or 'DoesNotExist'")) } case api.NodeSelectorOpGt, api.NodeSelectorOpLt: if len(rq.Values) != 1 { allErrs = append(allErrs, field.Required(fldPath.Child("values"), "must be specified single value when `operator` is 'Lt' or 'Gt'")) } default: allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), rq.Operator, "not a valid selector operator")) } allErrs = append(allErrs, ValidateLabelName(rq.Key, fldPath.Child("key"))...) return allErrs }
go
func ValidateNodeSelectorRequirement(rq api.NodeSelectorRequirement, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} switch rq.Operator { case api.NodeSelectorOpIn, api.NodeSelectorOpNotIn: if len(rq.Values) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("values"), "must be specified when `operator` is 'In' or 'NotIn'")) } case api.NodeSelectorOpExists, api.NodeSelectorOpDoesNotExist: if len(rq.Values) > 0 { allErrs = append(allErrs, field.Forbidden(fldPath.Child("values"), "may not be specified when `operator` is 'Exists' or 'DoesNotExist'")) } case api.NodeSelectorOpGt, api.NodeSelectorOpLt: if len(rq.Values) != 1 { allErrs = append(allErrs, field.Required(fldPath.Child("values"), "must be specified single value when `operator` is 'Lt' or 'Gt'")) } default: allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), rq.Operator, "not a valid selector operator")) } allErrs = append(allErrs, ValidateLabelName(rq.Key, fldPath.Child("key"))...) return allErrs }
[ "func", "ValidateNodeSelectorRequirement", "(", "rq", "api", ".", "NodeSelectorRequirement", ",", "fldPath", "*", "field", ".", "Path", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "field", ".", "ErrorList", "{", "}", "\n", "switch", "rq", ".", "Operator", "{", "case", "api", ".", "NodeSelectorOpIn", ",", "api", ".", "NodeSelectorOpNotIn", ":", "if", "len", "(", "rq", ".", "Values", ")", "==", "0", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Required", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "case", "api", ".", "NodeSelectorOpExists", ",", "api", ".", "NodeSelectorOpDoesNotExist", ":", "if", "len", "(", "rq", ".", "Values", ")", ">", "0", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Forbidden", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "case", "api", ".", "NodeSelectorOpGt", ",", "api", ".", "NodeSelectorOpLt", ":", "if", "len", "(", "rq", ".", "Values", ")", "!=", "1", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Required", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "default", ":", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Invalid", "(", "fldPath", ".", "Child", "(", "\"", "\"", ")", ",", "rq", ".", "Operator", ",", "\"", "\"", ")", ")", "\n", "}", "\n", "allErrs", "=", "append", "(", "allErrs", ",", "ValidateLabelName", "(", "rq", ".", "Key", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "return", "allErrs", "\n", "}" ]
// ValidateNodeSelectorRequirement tests that the specified NodeSelectorRequirement fields has valid data
[ "ValidateNodeSelectorRequirement", "tests", "that", "the", "specified", "NodeSelectorRequirement", "fields", "has", "valid", "data" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L1396-L1417
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidatePreferredSchedulingTerms
func ValidatePreferredSchedulingTerms(terms []api.PreferredSchedulingTerm, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} for i, term := range terms { if term.Weight <= 0 || term.Weight > 100 { allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("weight"), term.Weight, "must be in the range 1-100")) } allErrs = append(allErrs, ValidateNodeSelectorTerm(term.Preference, fldPath.Index(i).Child("preference"))...) } return allErrs }
go
func ValidatePreferredSchedulingTerms(terms []api.PreferredSchedulingTerm, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} for i, term := range terms { if term.Weight <= 0 || term.Weight > 100 { allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("weight"), term.Weight, "must be in the range 1-100")) } allErrs = append(allErrs, ValidateNodeSelectorTerm(term.Preference, fldPath.Index(i).Child("preference"))...) } return allErrs }
[ "func", "ValidatePreferredSchedulingTerms", "(", "terms", "[", "]", "api", ".", "PreferredSchedulingTerm", ",", "fldPath", "*", "field", ".", "Path", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "field", ".", "ErrorList", "{", "}", "\n\n", "for", "i", ",", "term", ":=", "range", "terms", "{", "if", "term", ".", "Weight", "<=", "0", "||", "term", ".", "Weight", ">", "100", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Invalid", "(", "fldPath", ".", "Index", "(", "i", ")", ".", "Child", "(", "\"", "\"", ")", ",", "term", ".", "Weight", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "allErrs", "=", "append", "(", "allErrs", ",", "ValidateNodeSelectorTerm", "(", "term", ".", "Preference", ",", "fldPath", ".", "Index", "(", "i", ")", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "}", "\n", "return", "allErrs", "\n", "}" ]
// ValidatePreferredSchedulingTerms tests that the specified SoftNodeAffinity fields has valid data
[ "ValidatePreferredSchedulingTerms", "tests", "that", "the", "specified", "SoftNodeAffinity", "fields", "has", "valid", "data" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L1449-L1460
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateAffinityInPodAnnotations
func ValidateAffinityInPodAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} affinity, err := api.GetAffinityFromPodAnnotations(annotations) if err != nil { allErrs = append(allErrs, field.Invalid(fldPath, api.AffinityAnnotationKey, err.Error())) return allErrs } if affinity.NodeAffinity != nil { na := affinity.NodeAffinity // TODO: Uncomment the next three lines once RequiredDuringSchedulingRequiredDuringExecution is implemented. // if na.RequiredDuringSchedulingRequiredDuringExecution != nil { // allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child("requiredDuringSchedulingRequiredDuringExecution"))...) // } if na.RequiredDuringSchedulingIgnoredDuringExecution != nil { allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingIgnoredDuringExecution, fldPath.Child("requiredDuringSchedulingIgnoredDuringExecution"))...) } if len(na.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { allErrs = append(allErrs, ValidatePreferredSchedulingTerms(na.PreferredDuringSchedulingIgnoredDuringExecution, fldPath.Child("preferredDuringSchedulingIgnoredDuringExecution"))...) } } return allErrs }
go
func ValidateAffinityInPodAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} affinity, err := api.GetAffinityFromPodAnnotations(annotations) if err != nil { allErrs = append(allErrs, field.Invalid(fldPath, api.AffinityAnnotationKey, err.Error())) return allErrs } if affinity.NodeAffinity != nil { na := affinity.NodeAffinity // TODO: Uncomment the next three lines once RequiredDuringSchedulingRequiredDuringExecution is implemented. // if na.RequiredDuringSchedulingRequiredDuringExecution != nil { // allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child("requiredDuringSchedulingRequiredDuringExecution"))...) // } if na.RequiredDuringSchedulingIgnoredDuringExecution != nil { allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingIgnoredDuringExecution, fldPath.Child("requiredDuringSchedulingIgnoredDuringExecution"))...) } if len(na.PreferredDuringSchedulingIgnoredDuringExecution) > 0 { allErrs = append(allErrs, ValidatePreferredSchedulingTerms(na.PreferredDuringSchedulingIgnoredDuringExecution, fldPath.Child("preferredDuringSchedulingIgnoredDuringExecution"))...) } } return allErrs }
[ "func", "ValidateAffinityInPodAnnotations", "(", "annotations", "map", "[", "string", "]", "string", ",", "fldPath", "*", "field", ".", "Path", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "field", ".", "ErrorList", "{", "}", "\n\n", "affinity", ",", "err", ":=", "api", ".", "GetAffinityFromPodAnnotations", "(", "annotations", ")", "\n", "if", "err", "!=", "nil", "{", "allErrs", "=", "append", "(", "allErrs", ",", "field", ".", "Invalid", "(", "fldPath", ",", "api", ".", "AffinityAnnotationKey", ",", "err", ".", "Error", "(", ")", ")", ")", "\n", "return", "allErrs", "\n", "}", "\n\n", "if", "affinity", ".", "NodeAffinity", "!=", "nil", "{", "na", ":=", "affinity", ".", "NodeAffinity", "\n\n", "// TODO: Uncomment the next three lines once RequiredDuringSchedulingRequiredDuringExecution is implemented.", "// if na.RequiredDuringSchedulingRequiredDuringExecution != nil {", "//\tallErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child(\"requiredDuringSchedulingRequiredDuringExecution\"))...)", "// }", "if", "na", ".", "RequiredDuringSchedulingIgnoredDuringExecution", "!=", "nil", "{", "allErrs", "=", "append", "(", "allErrs", ",", "ValidateNodeSelector", "(", "na", ".", "RequiredDuringSchedulingIgnoredDuringExecution", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "}", "\n\n", "if", "len", "(", "na", ".", "PreferredDuringSchedulingIgnoredDuringExecution", ")", ">", "0", "{", "allErrs", "=", "append", "(", "allErrs", ",", "ValidatePreferredSchedulingTerms", "(", "na", ".", "PreferredDuringSchedulingIgnoredDuringExecution", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n\n", "}", "\n", "}", "\n\n", "return", "allErrs", "\n", "}" ]
// ValidateAffinityInPodAnnotations tests that the serialized Affinity in Pod.Annotations has valid data
[ "ValidateAffinityInPodAnnotations", "tests", "that", "the", "serialized", "Affinity", "in", "Pod", ".", "Annotations", "has", "valid", "data" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L1463-L1491
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateReplicationControllerSpec
func ValidateReplicationControllerSpec(spec *api.ReplicationControllerSpec, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, ValidateNonEmptySelector(spec.Selector, fldPath.Child("selector"))...) allErrs = append(allErrs, ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...) allErrs = append(allErrs, ValidatePodTemplateSpecForRC(spec.Template, spec.Selector, spec.Replicas, fldPath.Child("template"))...) return allErrs }
go
func ValidateReplicationControllerSpec(spec *api.ReplicationControllerSpec, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, ValidateNonEmptySelector(spec.Selector, fldPath.Child("selector"))...) allErrs = append(allErrs, ValidateNonnegativeField(int64(spec.Replicas), fldPath.Child("replicas"))...) allErrs = append(allErrs, ValidatePodTemplateSpecForRC(spec.Template, spec.Selector, spec.Replicas, fldPath.Child("template"))...) return allErrs }
[ "func", "ValidateReplicationControllerSpec", "(", "spec", "*", "api", ".", "ReplicationControllerSpec", ",", "fldPath", "*", "field", ".", "Path", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "field", ".", "ErrorList", "{", "}", "\n", "allErrs", "=", "append", "(", "allErrs", ",", "ValidateNonEmptySelector", "(", "spec", ".", "Selector", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "allErrs", "=", "append", "(", "allErrs", ",", "ValidateNonnegativeField", "(", "int64", "(", "spec", ".", "Replicas", ")", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "allErrs", "=", "append", "(", "allErrs", ",", "ValidatePodTemplateSpecForRC", "(", "spec", ".", "Template", ",", "spec", ".", "Selector", ",", "spec", ".", "Replicas", ",", "fldPath", ".", "Child", "(", "\"", "\"", ")", ")", "...", ")", "\n", "return", "allErrs", "\n", "}" ]
// ValidateReplicationControllerSpec tests if required fields in the replication controller spec are set.
[ "ValidateReplicationControllerSpec", "tests", "if", "required", "fields", "in", "the", "replication", "controller", "spec", "are", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L1861-L1867
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateNamespace
func ValidateNamespace(namespace *api.Namespace) field.ErrorList { allErrs := ValidateObjectMeta(&namespace.ObjectMeta, false, ValidateNamespaceName, field.NewPath("metadata")) for i := range namespace.Spec.Finalizers { allErrs = append(allErrs, validateFinalizerName(string(namespace.Spec.Finalizers[i]), field.NewPath("spec", "finalizers"))...) } return allErrs }
go
func ValidateNamespace(namespace *api.Namespace) field.ErrorList { allErrs := ValidateObjectMeta(&namespace.ObjectMeta, false, ValidateNamespaceName, field.NewPath("metadata")) for i := range namespace.Spec.Finalizers { allErrs = append(allErrs, validateFinalizerName(string(namespace.Spec.Finalizers[i]), field.NewPath("spec", "finalizers"))...) } return allErrs }
[ "func", "ValidateNamespace", "(", "namespace", "*", "api", ".", "Namespace", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "ValidateObjectMeta", "(", "&", "namespace", ".", "ObjectMeta", ",", "false", ",", "ValidateNamespaceName", ",", "field", ".", "NewPath", "(", "\"", "\"", ")", ")", "\n", "for", "i", ":=", "range", "namespace", ".", "Spec", ".", "Finalizers", "{", "allErrs", "=", "append", "(", "allErrs", ",", "validateFinalizerName", "(", "string", "(", "namespace", ".", "Spec", ".", "Finalizers", "[", "i", "]", ")", ",", "field", ".", "NewPath", "(", "\"", "\"", ",", "\"", "\"", ")", ")", "...", ")", "\n", "}", "\n", "return", "allErrs", "\n", "}" ]
// ValidateNamespace tests if required fields are set.
[ "ValidateNamespace", "tests", "if", "required", "fields", "are", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L2348-L2354
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go
ValidateNamespaceFinalizeUpdate
func ValidateNamespaceFinalizeUpdate(newNamespace, oldNamespace *api.Namespace) field.ErrorList { allErrs := ValidateObjectMetaUpdate(&newNamespace.ObjectMeta, &oldNamespace.ObjectMeta, field.NewPath("metadata")) fldPath := field.NewPath("spec", "finalizers") for i := range newNamespace.Spec.Finalizers { idxPath := fldPath.Index(i) allErrs = append(allErrs, validateFinalizerName(string(newNamespace.Spec.Finalizers[i]), idxPath)...) } newNamespace.Status = oldNamespace.Status return allErrs }
go
func ValidateNamespaceFinalizeUpdate(newNamespace, oldNamespace *api.Namespace) field.ErrorList { allErrs := ValidateObjectMetaUpdate(&newNamespace.ObjectMeta, &oldNamespace.ObjectMeta, field.NewPath("metadata")) fldPath := field.NewPath("spec", "finalizers") for i := range newNamespace.Spec.Finalizers { idxPath := fldPath.Index(i) allErrs = append(allErrs, validateFinalizerName(string(newNamespace.Spec.Finalizers[i]), idxPath)...) } newNamespace.Status = oldNamespace.Status return allErrs }
[ "func", "ValidateNamespaceFinalizeUpdate", "(", "newNamespace", ",", "oldNamespace", "*", "api", ".", "Namespace", ")", "field", ".", "ErrorList", "{", "allErrs", ":=", "ValidateObjectMetaUpdate", "(", "&", "newNamespace", ".", "ObjectMeta", ",", "&", "oldNamespace", ".", "ObjectMeta", ",", "field", ".", "NewPath", "(", "\"", "\"", ")", ")", "\n\n", "fldPath", ":=", "field", ".", "NewPath", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "for", "i", ":=", "range", "newNamespace", ".", "Spec", ".", "Finalizers", "{", "idxPath", ":=", "fldPath", ".", "Index", "(", "i", ")", "\n", "allErrs", "=", "append", "(", "allErrs", ",", "validateFinalizerName", "(", "string", "(", "newNamespace", ".", "Spec", ".", "Finalizers", "[", "i", "]", ")", ",", "idxPath", ")", "...", ")", "\n", "}", "\n", "newNamespace", ".", "Status", "=", "oldNamespace", ".", "Status", "\n", "return", "allErrs", "\n", "}" ]
// ValidateNamespaceFinalizeUpdate tests to see if the update is legal for an end user to make. // newNamespace is updated with fields that cannot be changed.
[ "ValidateNamespaceFinalizeUpdate", "tests", "to", "see", "if", "the", "update", "is", "legal", "for", "an", "end", "user", "to", "make", ".", "newNamespace", "is", "updated", "with", "fields", "that", "cannot", "be", "changed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/validation.go#L2400-L2410
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/auth_loaders.go
LoadAuth
func (a *PromptingAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { var auth clientauth.Info // Prompt for user/pass and write a file if none exists. if _, err := os.Stat(path); os.IsNotExist(err) { auth = *a.Prompt() data, err := json.Marshal(auth) if err != nil { return &auth, err } err = ioutil.WriteFile(path, data, 0600) return &auth, err } authPtr, err := clientauth.LoadFromFile(path) if err != nil { return nil, err } return authPtr, nil }
go
func (a *PromptingAuthLoader) LoadAuth(path string) (*clientauth.Info, error) { var auth clientauth.Info // Prompt for user/pass and write a file if none exists. if _, err := os.Stat(path); os.IsNotExist(err) { auth = *a.Prompt() data, err := json.Marshal(auth) if err != nil { return &auth, err } err = ioutil.WriteFile(path, data, 0600) return &auth, err } authPtr, err := clientauth.LoadFromFile(path) if err != nil { return nil, err } return authPtr, nil }
[ "func", "(", "a", "*", "PromptingAuthLoader", ")", "LoadAuth", "(", "path", "string", ")", "(", "*", "clientauth", ".", "Info", ",", "error", ")", "{", "var", "auth", "clientauth", ".", "Info", "\n", "// Prompt for user/pass and write a file if none exists.", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", ";", "os", ".", "IsNotExist", "(", "err", ")", "{", "auth", "=", "*", "a", ".", "Prompt", "(", ")", "\n", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "auth", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "auth", ",", "err", "\n", "}", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "path", ",", "data", ",", "0600", ")", "\n", "return", "&", "auth", ",", "err", "\n", "}", "\n", "authPtr", ",", "err", ":=", "clientauth", ".", "LoadFromFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "authPtr", ",", "nil", "\n", "}" ]
// LoadAuth parses an AuthInfo object from a file path. It prompts user and creates file if it doesn't exist.
[ "LoadAuth", "parses", "an", "AuthInfo", "object", "from", "a", "file", "path", ".", "It", "prompts", "user", "and", "creates", "file", "if", "it", "doesn", "t", "exist", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/auth_loaders.go#L48-L65
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/rest/rest.go
Delete
func (w GracefulDeleteAdapter) Delete(ctx api.Context, name string, options *api.DeleteOptions) (runtime.Object, error) { return w.Deleter.Delete(ctx, name) }
go
func (w GracefulDeleteAdapter) Delete(ctx api.Context, name string, options *api.DeleteOptions) (runtime.Object, error) { return w.Deleter.Delete(ctx, name) }
[ "func", "(", "w", "GracefulDeleteAdapter", ")", "Delete", "(", "ctx", "api", ".", "Context", ",", "name", "string", ",", "options", "*", "api", ".", "DeleteOptions", ")", "(", "runtime", ".", "Object", ",", "error", ")", "{", "return", "w", ".", "Deleter", ".", "Delete", "(", "ctx", ",", "name", ")", "\n", "}" ]
// Delete implements RESTGracefulDeleter in terms of Deleter
[ "Delete", "implements", "RESTGracefulDeleter", "in", "terms", "of", "Deleter" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/rest/rest.go#L132-L134
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/expiration_cache.go
getTimestampedEntry
func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bool) { item, _ := c.cacheStorage.Get(key) // TODO: Check the cast instead if tsEntry, ok := item.(*timestampedEntry); ok { return tsEntry, true } return nil, false }
go
func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bool) { item, _ := c.cacheStorage.Get(key) // TODO: Check the cast instead if tsEntry, ok := item.(*timestampedEntry); ok { return tsEntry, true } return nil, false }
[ "func", "(", "c", "*", "ExpirationCache", ")", "getTimestampedEntry", "(", "key", "string", ")", "(", "*", "timestampedEntry", ",", "bool", ")", "{", "item", ",", "_", ":=", "c", ".", "cacheStorage", ".", "Get", "(", "key", ")", "\n", "// TODO: Check the cast instead", "if", "tsEntry", ",", "ok", ":=", "item", ".", "(", "*", "timestampedEntry", ")", ";", "ok", "{", "return", "tsEntry", ",", "true", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
// getTimestampedEntry returnes the timestampedEntry stored under the given key.
[ "getTimestampedEntry", "returnes", "the", "timestampedEntry", "stored", "under", "the", "given", "key", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/expiration_cache.go#L69-L76
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/expiration_cache.go
getOrExpire
func (c *ExpirationCache) getOrExpire(key string) (interface{}, bool) { timestampedItem, exists := c.getTimestampedEntry(key) if !exists { return nil, false } if c.expirationPolicy.IsExpired(timestampedItem) { glog.V(4).Infof("Entry %v: %+v has expired", key, timestampedItem.obj) // Since expiration happens lazily on read, don't hold up // the reader trying to acquire a write lock for the delete. // The next reader will retry the delete even if this one // fails; as long as we only return un-expired entries a // reader doesn't need to wait for the result of the delete. go func() { defer runtime.HandleCrash() c.cacheStorage.Delete(key) }() return nil, false } return timestampedItem.obj, true }
go
func (c *ExpirationCache) getOrExpire(key string) (interface{}, bool) { timestampedItem, exists := c.getTimestampedEntry(key) if !exists { return nil, false } if c.expirationPolicy.IsExpired(timestampedItem) { glog.V(4).Infof("Entry %v: %+v has expired", key, timestampedItem.obj) // Since expiration happens lazily on read, don't hold up // the reader trying to acquire a write lock for the delete. // The next reader will retry the delete even if this one // fails; as long as we only return un-expired entries a // reader doesn't need to wait for the result of the delete. go func() { defer runtime.HandleCrash() c.cacheStorage.Delete(key) }() return nil, false } return timestampedItem.obj, true }
[ "func", "(", "c", "*", "ExpirationCache", ")", "getOrExpire", "(", "key", "string", ")", "(", "interface", "{", "}", ",", "bool", ")", "{", "timestampedItem", ",", "exists", ":=", "c", ".", "getTimestampedEntry", "(", "key", ")", "\n", "if", "!", "exists", "{", "return", "nil", ",", "false", "\n", "}", "\n", "if", "c", ".", "expirationPolicy", ".", "IsExpired", "(", "timestampedItem", ")", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "key", ",", "timestampedItem", ".", "obj", ")", "\n", "// Since expiration happens lazily on read, don't hold up", "// the reader trying to acquire a write lock for the delete.", "// The next reader will retry the delete even if this one", "// fails; as long as we only return un-expired entries a", "// reader doesn't need to wait for the result of the delete.", "go", "func", "(", ")", "{", "defer", "runtime", ".", "HandleCrash", "(", ")", "\n", "c", ".", "cacheStorage", ".", "Delete", "(", "key", ")", "\n", "}", "(", ")", "\n", "return", "nil", ",", "false", "\n", "}", "\n", "return", "timestampedItem", ".", "obj", ",", "true", "\n", "}" ]
// getOrExpire retrieves the object from the timestampedEntry if and only if it hasn't // already expired. It kicks-off a go routine to delete expired objects from // the store and sets exists=false.
[ "getOrExpire", "retrieves", "the", "object", "from", "the", "timestampedEntry", "if", "and", "only", "if", "it", "hasn", "t", "already", "expired", ".", "It", "kicks", "-", "off", "a", "go", "routine", "to", "delete", "expired", "objects", "from", "the", "store", "and", "sets", "exists", "=", "false", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/expiration_cache.go#L81-L100
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go
NewSerializer
func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer, pretty bool) runtime.Serializer { return &Serializer{ meta: meta, creater: creater, typer: typer, yaml: false, pretty: pretty, } }
go
func NewSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer, pretty bool) runtime.Serializer { return &Serializer{ meta: meta, creater: creater, typer: typer, yaml: false, pretty: pretty, } }
[ "func", "NewSerializer", "(", "meta", "MetaFactory", ",", "creater", "runtime", ".", "ObjectCreater", ",", "typer", "runtime", ".", "Typer", ",", "pretty", "bool", ")", "runtime", ".", "Serializer", "{", "return", "&", "Serializer", "{", "meta", ":", "meta", ",", "creater", ":", "creater", ",", "typer", ":", "typer", ",", "yaml", ":", "false", ",", "pretty", ":", "pretty", ",", "}", "\n", "}" ]
// NewSerializer creates a JSON serializer that handles encoding versioned objects into the proper JSON form. If typer // is not nil, the object has the group, version, and kind fields set.
[ "NewSerializer", "creates", "a", "JSON", "serializer", "that", "handles", "encoding", "versioned", "objects", "into", "the", "proper", "JSON", "form", ".", "If", "typer", "is", "not", "nil", "the", "object", "has", "the", "group", "version", "and", "kind", "fields", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go#L33-L41
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go
NewYAMLSerializer
func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer) runtime.Serializer { return &Serializer{ meta: meta, creater: creater, typer: typer, yaml: true, } }
go
func NewYAMLSerializer(meta MetaFactory, creater runtime.ObjectCreater, typer runtime.Typer) runtime.Serializer { return &Serializer{ meta: meta, creater: creater, typer: typer, yaml: true, } }
[ "func", "NewYAMLSerializer", "(", "meta", "MetaFactory", ",", "creater", "runtime", ".", "ObjectCreater", ",", "typer", "runtime", ".", "Typer", ")", "runtime", ".", "Serializer", "{", "return", "&", "Serializer", "{", "meta", ":", "meta", ",", "creater", ":", "creater", ",", "typer", ":", "typer", ",", "yaml", ":", "true", ",", "}", "\n", "}" ]
// NewYAMLSerializer creates a YAML serializer that handles encoding versioned objects into the proper YAML form. If typer // is not nil, the object has the group, version, and kind fields set. This serializer supports only the subset of YAML that // matches JSON, and will error if constructs are used that do not serialize to JSON.
[ "NewYAMLSerializer", "creates", "a", "YAML", "serializer", "that", "handles", "encoding", "versioned", "objects", "into", "the", "proper", "YAML", "form", ".", "If", "typer", "is", "not", "nil", "the", "object", "has", "the", "group", "version", "and", "kind", "fields", "set", ".", "This", "serializer", "supports", "only", "the", "subset", "of", "YAML", "that", "matches", "JSON", "and", "will", "error", "if", "constructs", "are", "used", "that", "do", "not", "serialize", "to", "JSON", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go#L46-L53
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go
EncodeToStream
func (s *Serializer) EncodeToStream(obj runtime.Object, w io.Writer, overrides ...unversioned.GroupVersion) error { if s.yaml { json, err := json.Marshal(obj) if err != nil { return err } data, err := yaml.JSONToYAML(json) if err != nil { return err } _, err = w.Write(data) return err } if s.pretty { data, err := json.MarshalIndent(obj, "", " ") if err != nil { return err } _, err = w.Write(data) return err } encoder := json.NewEncoder(w) return encoder.Encode(obj) }
go
func (s *Serializer) EncodeToStream(obj runtime.Object, w io.Writer, overrides ...unversioned.GroupVersion) error { if s.yaml { json, err := json.Marshal(obj) if err != nil { return err } data, err := yaml.JSONToYAML(json) if err != nil { return err } _, err = w.Write(data) return err } if s.pretty { data, err := json.MarshalIndent(obj, "", " ") if err != nil { return err } _, err = w.Write(data) return err } encoder := json.NewEncoder(w) return encoder.Encode(obj) }
[ "func", "(", "s", "*", "Serializer", ")", "EncodeToStream", "(", "obj", "runtime", ".", "Object", ",", "w", "io", ".", "Writer", ",", "overrides", "...", "unversioned", ".", "GroupVersion", ")", "error", "{", "if", "s", ".", "yaml", "{", "json", ",", "err", ":=", "json", ".", "Marshal", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "data", ",", "err", ":=", "yaml", ".", "JSONToYAML", "(", "json", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", "=", "w", ".", "Write", "(", "data", ")", "\n", "return", "err", "\n", "}", "\n\n", "if", "s", ".", "pretty", "{", "data", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "obj", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", "=", "w", ".", "Write", "(", "data", ")", "\n", "return", "err", "\n", "}", "\n", "encoder", ":=", "json", ".", "NewEncoder", "(", "w", ")", "\n", "return", "encoder", ".", "Encode", "(", "obj", ")", "\n", "}" ]
// EncodeToStream serializes the provided object to the given writer. Overrides is ignored.
[ "EncodeToStream", "serializes", "the", "provided", "object", "to", "the", "given", "writer", ".", "Overrides", "is", "ignored", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/json/json.go#L158-L182
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/labels/selector.go
parseKeyAndInferOperator
func (p *Parser) parseKeyAndInferOperator() (string, Operator, error) { var operator Operator tok, literal := p.consume(Values) if tok == DoesNotExistToken { operator = DoesNotExistOperator tok, literal = p.consume(Values) } if tok != IdentifierToken { err := fmt.Errorf("found '%s', expected: identifier", literal) return "", "", err } if err := validateLabelKey(literal); err != nil { return "", "", err } if t, _ := p.lookahead(Values); t == EndOfStringToken || t == CommaToken { if operator != DoesNotExistOperator { operator = ExistsOperator } } return literal, operator, nil }
go
func (p *Parser) parseKeyAndInferOperator() (string, Operator, error) { var operator Operator tok, literal := p.consume(Values) if tok == DoesNotExistToken { operator = DoesNotExistOperator tok, literal = p.consume(Values) } if tok != IdentifierToken { err := fmt.Errorf("found '%s', expected: identifier", literal) return "", "", err } if err := validateLabelKey(literal); err != nil { return "", "", err } if t, _ := p.lookahead(Values); t == EndOfStringToken || t == CommaToken { if operator != DoesNotExistOperator { operator = ExistsOperator } } return literal, operator, nil }
[ "func", "(", "p", "*", "Parser", ")", "parseKeyAndInferOperator", "(", ")", "(", "string", ",", "Operator", ",", "error", ")", "{", "var", "operator", "Operator", "\n", "tok", ",", "literal", ":=", "p", ".", "consume", "(", "Values", ")", "\n", "if", "tok", "==", "DoesNotExistToken", "{", "operator", "=", "DoesNotExistOperator", "\n", "tok", ",", "literal", "=", "p", ".", "consume", "(", "Values", ")", "\n", "}", "\n", "if", "tok", "!=", "IdentifierToken", "{", "err", ":=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "literal", ")", "\n", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "err", ":=", "validateLabelKey", "(", "literal", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "t", ",", "_", ":=", "p", ".", "lookahead", "(", "Values", ")", ";", "t", "==", "EndOfStringToken", "||", "t", "==", "CommaToken", "{", "if", "operator", "!=", "DoesNotExistOperator", "{", "operator", "=", "ExistsOperator", "\n", "}", "\n", "}", "\n", "return", "literal", ",", "operator", ",", "nil", "\n", "}" ]
// parseKeyAndInferOperator parse literals. // in case of no operator '!, in, notin, ==, =, !=' are found // the 'exists' operator is inferred
[ "parseKeyAndInferOperator", "parse", "literals", ".", "in", "case", "of", "no", "operator", "!", "in", "notin", "==", "=", "!", "=", "are", "found", "the", "exists", "operator", "is", "inferred" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/labels/selector.go#L542-L562
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go
Type
func (t *Token) Type() string { if strings.EqualFold(t.TokenType, "bearer") { return "Bearer" } if strings.EqualFold(t.TokenType, "mac") { return "MAC" } if strings.EqualFold(t.TokenType, "basic") { return "Basic" } if t.TokenType != "" { return t.TokenType } return "Bearer" }
go
func (t *Token) Type() string { if strings.EqualFold(t.TokenType, "bearer") { return "Bearer" } if strings.EqualFold(t.TokenType, "mac") { return "MAC" } if strings.EqualFold(t.TokenType, "basic") { return "Basic" } if t.TokenType != "" { return t.TokenType } return "Bearer" }
[ "func", "(", "t", "*", "Token", ")", "Type", "(", ")", "string", "{", "if", "strings", ".", "EqualFold", "(", "t", ".", "TokenType", ",", "\"", "\"", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "strings", ".", "EqualFold", "(", "t", ".", "TokenType", ",", "\"", "\"", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "strings", ".", "EqualFold", "(", "t", ".", "TokenType", ",", "\"", "\"", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "t", ".", "TokenType", "!=", "\"", "\"", "{", "return", "t", ".", "TokenType", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// Type returns t.TokenType if non-empty, else "Bearer".
[ "Type", "returns", "t", ".", "TokenType", "if", "non", "-", "empty", "else", "Bearer", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go#L56-L70
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go
SetAuthHeader
func (t *Token) SetAuthHeader(r *http.Request) { r.Header.Set("Authorization", t.Type()+" "+t.AccessToken) }
go
func (t *Token) SetAuthHeader(r *http.Request) { r.Header.Set("Authorization", t.Type()+" "+t.AccessToken) }
[ "func", "(", "t", "*", "Token", ")", "SetAuthHeader", "(", "r", "*", "http", ".", "Request", ")", "{", "r", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "t", ".", "Type", "(", ")", "+", "\"", "\"", "+", "t", ".", "AccessToken", ")", "\n", "}" ]
// SetAuthHeader sets the Authorization header to r using the access // token in t. // // This method is unnecessary when using Transport or an HTTP Client // returned by this package.
[ "SetAuthHeader", "sets", "the", "Authorization", "header", "to", "r", "using", "the", "access", "token", "in", "t", ".", "This", "method", "is", "unnecessary", "when", "using", "Transport", "or", "an", "HTTP", "Client", "returned", "by", "this", "package", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go#L77-L79
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go
WithExtra
func (t *Token) WithExtra(extra interface{}) *Token { t2 := new(Token) *t2 = *t t2.raw = extra return t2 }
go
func (t *Token) WithExtra(extra interface{}) *Token { t2 := new(Token) *t2 = *t t2.raw = extra return t2 }
[ "func", "(", "t", "*", "Token", ")", "WithExtra", "(", "extra", "interface", "{", "}", ")", "*", "Token", "{", "t2", ":=", "new", "(", "Token", ")", "\n", "*", "t2", "=", "*", "t", "\n", "t2", ".", "raw", "=", "extra", "\n", "return", "t2", "\n", "}" ]
// WithExtra returns a new Token that's a clone of t, but using the // provided raw extra map. This is only intended for use by packages // implementing derivative OAuth2 flows.
[ "WithExtra", "returns", "a", "new", "Token", "that", "s", "a", "clone", "of", "t", "but", "using", "the", "provided", "raw", "extra", "map", ".", "This", "is", "only", "intended", "for", "use", "by", "packages", "implementing", "derivative", "OAuth2", "flows", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go#L84-L89
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go
Valid
func (t *Token) Valid() bool { return t != nil && t.AccessToken != "" && !t.expired() }
go
func (t *Token) Valid() bool { return t != nil && t.AccessToken != "" && !t.expired() }
[ "func", "(", "t", "*", "Token", ")", "Valid", "(", ")", "bool", "{", "return", "t", "!=", "nil", "&&", "t", ".", "AccessToken", "!=", "\"", "\"", "&&", "!", "t", ".", "expired", "(", ")", "\n", "}" ]
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.
[ "Valid", "reports", "whether", "t", "is", "non", "-", "nil", "has", "an", "AccessToken", "and", "is", "not", "expired", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/token.go#L115-L117
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go
encodeBase64
func encodeBase64(s string) string { const lineLen = 70 encLen := base64.StdEncoding.EncodedLen(len(s)) lines := encLen/lineLen + 1 buf := make([]byte, encLen*2+lines) in := buf[0:encLen] out := buf[encLen:] base64.StdEncoding.Encode(in, []byte(s)) k := 0 for i := 0; i < len(in); i += lineLen { j := i + lineLen if j > len(in) { j = len(in) } k += copy(out[k:], in[i:j]) if lines > 1 { out[k] = '\n' k++ } } return string(out[:k]) }
go
func encodeBase64(s string) string { const lineLen = 70 encLen := base64.StdEncoding.EncodedLen(len(s)) lines := encLen/lineLen + 1 buf := make([]byte, encLen*2+lines) in := buf[0:encLen] out := buf[encLen:] base64.StdEncoding.Encode(in, []byte(s)) k := 0 for i := 0; i < len(in); i += lineLen { j := i + lineLen if j > len(in) { j = len(in) } k += copy(out[k:], in[i:j]) if lines > 1 { out[k] = '\n' k++ } } return string(out[:k]) }
[ "func", "encodeBase64", "(", "s", "string", ")", "string", "{", "const", "lineLen", "=", "70", "\n", "encLen", ":=", "base64", ".", "StdEncoding", ".", "EncodedLen", "(", "len", "(", "s", ")", ")", "\n", "lines", ":=", "encLen", "/", "lineLen", "+", "1", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "encLen", "*", "2", "+", "lines", ")", "\n", "in", ":=", "buf", "[", "0", ":", "encLen", "]", "\n", "out", ":=", "buf", "[", "encLen", ":", "]", "\n", "base64", ".", "StdEncoding", ".", "Encode", "(", "in", ",", "[", "]", "byte", "(", "s", ")", ")", "\n", "k", ":=", "0", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "in", ")", ";", "i", "+=", "lineLen", "{", "j", ":=", "i", "+", "lineLen", "\n", "if", "j", ">", "len", "(", "in", ")", "{", "j", "=", "len", "(", "in", ")", "\n", "}", "\n", "k", "+=", "copy", "(", "out", "[", "k", ":", "]", ",", "in", "[", "i", ":", "j", "]", ")", "\n", "if", "lines", ">", "1", "{", "out", "[", "k", "]", "=", "'\\n'", "\n", "k", "++", "\n", "}", "\n", "}", "\n", "return", "string", "(", "out", "[", ":", "k", "]", ")", "\n", "}" ]
// encodeBase64 encodes s as base64 that is broken up into multiple lines // as appropriate for the resulting length.
[ "encodeBase64", "encodes", "s", "as", "base64", "that", "is", "broken", "up", "into", "multiple", "lines", "as", "appropriate", "for", "the", "resulting", "length", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/resolve.go#L182-L203
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go
KindFor
func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) { resource = expandResourceShortcut(resource) return e.RESTMapper.KindFor(resource) }
go
func (e ShortcutExpander) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) { resource = expandResourceShortcut(resource) return e.RESTMapper.KindFor(resource) }
[ "func", "(", "e", "ShortcutExpander", ")", "KindFor", "(", "resource", "unversioned", ".", "GroupVersionResource", ")", "(", "unversioned", ".", "GroupVersionKind", ",", "error", ")", "{", "resource", "=", "expandResourceShortcut", "(", "resource", ")", "\n", "return", "e", ".", "RESTMapper", ".", "KindFor", "(", "resource", ")", "\n", "}" ]
// KindFor implements meta.RESTMapper. It expands the resource first, then invokes the wrapped // mapper.
[ "KindFor", "implements", "meta", ".", "RESTMapper", ".", "It", "expands", "the", "resource", "first", "then", "invokes", "the", "wrapped", "mapper", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go#L87-L90
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go
ResourceSingularizer
func (e ShortcutExpander) ResourceSingularizer(resource string) (string, error) { return e.RESTMapper.ResourceSingularizer(expandResourceShortcut(unversioned.GroupVersionResource{Resource: resource}).Resource) }
go
func (e ShortcutExpander) ResourceSingularizer(resource string) (string, error) { return e.RESTMapper.ResourceSingularizer(expandResourceShortcut(unversioned.GroupVersionResource{Resource: resource}).Resource) }
[ "func", "(", "e", "ShortcutExpander", ")", "ResourceSingularizer", "(", "resource", "string", ")", "(", "string", ",", "error", ")", "{", "return", "e", ".", "RESTMapper", ".", "ResourceSingularizer", "(", "expandResourceShortcut", "(", "unversioned", ".", "GroupVersionResource", "{", "Resource", ":", "resource", "}", ")", ".", "Resource", ")", "\n", "}" ]
// ResourceSingularizer expands the named resource and then singularizes it.
[ "ResourceSingularizer", "expands", "the", "named", "resource", "and", "then", "singularizes", "it", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go#L93-L95
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go
parseLiteralSource
func parseLiteralSource(source string) (keyName, value string, err error) { items := strings.Split(source, "=") if len(items) != 2 { return "", "", fmt.Errorf("invalid literal source %v, expected key=value", source) } return items[0], items[1], nil }
go
func parseLiteralSource(source string) (keyName, value string, err error) { items := strings.Split(source, "=") if len(items) != 2 { return "", "", fmt.Errorf("invalid literal source %v, expected key=value", source) } return items[0], items[1], nil }
[ "func", "parseLiteralSource", "(", "source", "string", ")", "(", "keyName", ",", "value", "string", ",", "err", "error", ")", "{", "items", ":=", "strings", ".", "Split", "(", "source", ",", "\"", "\"", ")", "\n", "if", "len", "(", "items", ")", "!=", "2", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "source", ")", "\n", "}", "\n\n", "return", "items", "[", "0", "]", ",", "items", "[", "1", "]", ",", "nil", "\n", "}" ]
// parseLiteralSource parses the source key=val pair
[ "parseLiteralSource", "parses", "the", "source", "key", "=", "val", "pair" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/kubectl.go#L151-L158
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go
IsRegisteredVersion
func IsRegisteredVersion(v unversioned.GroupVersion) bool { _, found := registeredVersions[v] return found }
go
func IsRegisteredVersion(v unversioned.GroupVersion) bool { _, found := registeredVersions[v] return found }
[ "func", "IsRegisteredVersion", "(", "v", "unversioned", ".", "GroupVersion", ")", "bool", "{", "_", ",", "found", ":=", "registeredVersions", "[", "v", "]", "\n", "return", "found", "\n", "}" ]
// IsRegisteredVersion returns if a version is registered.
[ "IsRegisteredVersion", "returns", "if", "a", "version", "is", "registered", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go#L103-L106
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go
EnabledVersions
func EnabledVersions() (ret []unversioned.GroupVersion) { for v := range enabledVersions { ret = append(ret, v) } return }
go
func EnabledVersions() (ret []unversioned.GroupVersion) { for v := range enabledVersions { ret = append(ret, v) } return }
[ "func", "EnabledVersions", "(", ")", "(", "ret", "[", "]", "unversioned", ".", "GroupVersion", ")", "{", "for", "v", ":=", "range", "enabledVersions", "{", "ret", "=", "append", "(", "ret", ",", "v", ")", "\n", "}", "\n", "return", "\n", "}" ]
// EnabledVersions returns all enabled versions.
[ "EnabledVersions", "returns", "all", "enabled", "versions", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go#L109-L114
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go
RegisteredVersions
func RegisteredVersions() (ret []unversioned.GroupVersion) { for v := range registeredVersions { ret = append(ret, v) } return }
go
func RegisteredVersions() (ret []unversioned.GroupVersion) { for v := range registeredVersions { ret = append(ret, v) } return }
[ "func", "RegisteredVersions", "(", ")", "(", "ret", "[", "]", "unversioned", ".", "GroupVersion", ")", "{", "for", "v", ":=", "range", "registeredVersions", "{", "ret", "=", "append", "(", "ret", ",", "v", ")", "\n", "}", "\n", "return", "\n", "}" ]
// RegisteredVersions returns all registered versions.
[ "RegisteredVersions", "returns", "all", "registered", "versions", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go#L117-L122
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go
EnabledVersionsForGroup
func EnabledVersionsForGroup(group string) (ret []unversioned.GroupVersion) { for v := range enabledVersions { if v.Group == group { ret = append(ret, v) } } return }
go
func EnabledVersionsForGroup(group string) (ret []unversioned.GroupVersion) { for v := range enabledVersions { if v.Group == group { ret = append(ret, v) } } return }
[ "func", "EnabledVersionsForGroup", "(", "group", "string", ")", "(", "ret", "[", "]", "unversioned", ".", "GroupVersion", ")", "{", "for", "v", ":=", "range", "enabledVersions", "{", "if", "v", ".", "Group", "==", "group", "{", "ret", "=", "append", "(", "ret", ",", "v", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// EnabledVersionsForGroup returns all enabled versions for a group.
[ "EnabledVersionsForGroup", "returns", "all", "enabled", "versions", "for", "a", "group", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go#L125-L132
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go
RegisteredVersionsForGroup
func RegisteredVersionsForGroup(group string) (ret []unversioned.GroupVersion) { for v := range registeredVersions { if v.Group == group { ret = append(ret, v) } } return }
go
func RegisteredVersionsForGroup(group string) (ret []unversioned.GroupVersion) { for v := range registeredVersions { if v.Group == group { ret = append(ret, v) } } return }
[ "func", "RegisteredVersionsForGroup", "(", "group", "string", ")", "(", "ret", "[", "]", "unversioned", ".", "GroupVersion", ")", "{", "for", "v", ":=", "range", "registeredVersions", "{", "if", "v", ".", "Group", "==", "group", "{", "ret", "=", "append", "(", "ret", ",", "v", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// RegisteredVersionsForGroup returns all registered versions for a group.
[ "RegisteredVersionsForGroup", "returns", "all", "registered", "versions", "for", "a", "group", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/registered/registered.go#L135-L142
train
kubernetes-retired/contrib
docker-micro-benchmark/Godeps/_workspace/src/golang.org/x/net/proxy/socks5.go
SOCKS5
func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { s := &socks5{ network: network, addr: addr, forward: forward, } if auth != nil { s.user = auth.User s.password = auth.Password } return s, nil }
go
func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { s := &socks5{ network: network, addr: addr, forward: forward, } if auth != nil { s.user = auth.User s.password = auth.Password } return s, nil }
[ "func", "SOCKS5", "(", "network", ",", "addr", "string", ",", "auth", "*", "Auth", ",", "forward", "Dialer", ")", "(", "Dialer", ",", "error", ")", "{", "s", ":=", "&", "socks5", "{", "network", ":", "network", ",", "addr", ":", "addr", ",", "forward", ":", "forward", ",", "}", "\n", "if", "auth", "!=", "nil", "{", "s", ".", "user", "=", "auth", ".", "User", "\n", "s", ".", "password", "=", "auth", ".", "Password", "\n", "}", "\n\n", "return", "s", ",", "nil", "\n", "}" ]
// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address // with an optional username and password. See RFC 1928.
[ "SOCKS5", "returns", "a", "Dialer", "that", "makes", "SOCKSv5", "connections", "to", "the", "given", "address", "with", "an", "optional", "username", "and", "password", ".", "See", "RFC", "1928", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/Godeps/_workspace/src/golang.org/x/net/proxy/socks5.go#L16-L28
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/multirestmapper.go
KindsFor
func (m MultiRESTMapper) KindsFor(resource unversioned.GroupVersionResource) (gvk []unversioned.GroupVersionKind, err error) { for _, t := range m { gvks, err := t.KindsFor(resource) // ignore "no match" errors, but any other error percolates back up if !IsNoResourceMatchError(err) { return gvks, err } } return nil, &NoResourceMatchError{PartialResource: resource} }
go
func (m MultiRESTMapper) KindsFor(resource unversioned.GroupVersionResource) (gvk []unversioned.GroupVersionKind, err error) { for _, t := range m { gvks, err := t.KindsFor(resource) // ignore "no match" errors, but any other error percolates back up if !IsNoResourceMatchError(err) { return gvks, err } } return nil, &NoResourceMatchError{PartialResource: resource} }
[ "func", "(", "m", "MultiRESTMapper", ")", "KindsFor", "(", "resource", "unversioned", ".", "GroupVersionResource", ")", "(", "gvk", "[", "]", "unversioned", ".", "GroupVersionKind", ",", "err", "error", ")", "{", "for", "_", ",", "t", ":=", "range", "m", "{", "gvks", ",", "err", ":=", "t", ".", "KindsFor", "(", "resource", ")", "\n", "// ignore \"no match\" errors, but any other error percolates back up", "if", "!", "IsNoResourceMatchError", "(", "err", ")", "{", "return", "gvks", ",", "err", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "&", "NoResourceMatchError", "{", "PartialResource", ":", "resource", "}", "\n", "}" ]
// KindsFor provides the Kind mappings for the REST resources. This implementation supports multiple REST schemas and returns // the first match.
[ "KindsFor", "provides", "the", "Kind", "mappings", "for", "the", "REST", "resources", ".", "This", "implementation", "supports", "multiple", "REST", "schemas", "and", "returns", "the", "first", "match", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/multirestmapper.go#L65-L74
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
Listen
func (c *Client) Listen(n, addr string) (net.Listener, error) { laddr, err := net.ResolveTCPAddr(n, addr) if err != nil { return nil, err } return c.ListenTCP(laddr) }
go
func (c *Client) Listen(n, addr string) (net.Listener, error) { laddr, err := net.ResolveTCPAddr(n, addr) if err != nil { return nil, err } return c.ListenTCP(laddr) }
[ "func", "(", "c", "*", "Client", ")", "Listen", "(", "n", ",", "addr", "string", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "laddr", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "n", ",", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "c", ".", "ListenTCP", "(", "laddr", ")", "\n", "}" ]
// Listen requests the remote peer open a listening socket on // addr. Incoming connections will be available by calling Accept on // the returned net.Listener. The listener must be serviced, or the // SSH connection may hang.
[ "Listen", "requests", "the", "remote", "peer", "open", "a", "listening", "socket", "on", "addr", ".", "Incoming", "connections", "will", "be", "available", "by", "calling", "Accept", "on", "the", "returned", "net", ".", "Listener", ".", "The", "listener", "must", "be", "serviced", "or", "the", "SSH", "connection", "may", "hang", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L23-L29
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
isBrokenOpenSSHVersion
func isBrokenOpenSSHVersion(versionStr string) bool { i := strings.Index(versionStr, openSSHPrefix) if i < 0 { return false } i += len(openSSHPrefix) j := i for ; j < len(versionStr); j++ { if versionStr[j] < '0' || versionStr[j] > '9' { break } } version, _ := strconv.Atoi(versionStr[i:j]) return version < 6 }
go
func isBrokenOpenSSHVersion(versionStr string) bool { i := strings.Index(versionStr, openSSHPrefix) if i < 0 { return false } i += len(openSSHPrefix) j := i for ; j < len(versionStr); j++ { if versionStr[j] < '0' || versionStr[j] > '9' { break } } version, _ := strconv.Atoi(versionStr[i:j]) return version < 6 }
[ "func", "isBrokenOpenSSHVersion", "(", "versionStr", "string", ")", "bool", "{", "i", ":=", "strings", ".", "Index", "(", "versionStr", ",", "openSSHPrefix", ")", "\n", "if", "i", "<", "0", "{", "return", "false", "\n", "}", "\n", "i", "+=", "len", "(", "openSSHPrefix", ")", "\n", "j", ":=", "i", "\n", "for", ";", "j", "<", "len", "(", "versionStr", ")", ";", "j", "++", "{", "if", "versionStr", "[", "j", "]", "<", "'0'", "||", "versionStr", "[", "j", "]", ">", "'9'", "{", "break", "\n", "}", "\n", "}", "\n", "version", ",", "_", ":=", "strconv", ".", "Atoi", "(", "versionStr", "[", "i", ":", "j", "]", ")", "\n", "return", "version", "<", "6", "\n", "}" ]
// isBrokenOpenSSHVersion returns true if the given version string // specifies a version of OpenSSH that is known to have a bug in port // forwarding.
[ "isBrokenOpenSSHVersion", "returns", "true", "if", "the", "given", "version", "string", "specifies", "a", "version", "of", "OpenSSH", "that", "is", "known", "to", "have", "a", "bug", "in", "port", "forwarding", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L45-L59
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
autoPortListenWorkaround
func (c *Client) autoPortListenWorkaround(laddr *net.TCPAddr) (net.Listener, error) { var sshListener net.Listener var err error const tries = 10 for i := 0; i < tries; i++ { addr := *laddr addr.Port = 1024 + portRandomizer.Intn(60000) sshListener, err = c.ListenTCP(&addr) if err == nil { laddr.Port = addr.Port return sshListener, err } } return nil, fmt.Errorf("ssh: listen on random port failed after %d tries: %v", tries, err) }
go
func (c *Client) autoPortListenWorkaround(laddr *net.TCPAddr) (net.Listener, error) { var sshListener net.Listener var err error const tries = 10 for i := 0; i < tries; i++ { addr := *laddr addr.Port = 1024 + portRandomizer.Intn(60000) sshListener, err = c.ListenTCP(&addr) if err == nil { laddr.Port = addr.Port return sshListener, err } } return nil, fmt.Errorf("ssh: listen on random port failed after %d tries: %v", tries, err) }
[ "func", "(", "c", "*", "Client", ")", "autoPortListenWorkaround", "(", "laddr", "*", "net", ".", "TCPAddr", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "var", "sshListener", "net", ".", "Listener", "\n", "var", "err", "error", "\n", "const", "tries", "=", "10", "\n", "for", "i", ":=", "0", ";", "i", "<", "tries", ";", "i", "++", "{", "addr", ":=", "*", "laddr", "\n", "addr", ".", "Port", "=", "1024", "+", "portRandomizer", ".", "Intn", "(", "60000", ")", "\n", "sshListener", ",", "err", "=", "c", ".", "ListenTCP", "(", "&", "addr", ")", "\n", "if", "err", "==", "nil", "{", "laddr", ".", "Port", "=", "addr", ".", "Port", "\n", "return", "sshListener", ",", "err", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tries", ",", "err", ")", "\n", "}" ]
// autoPortListenWorkaround simulates automatic port allocation by // trying random ports repeatedly.
[ "autoPortListenWorkaround", "simulates", "automatic", "port", "allocation", "by", "trying", "random", "ports", "repeatedly", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L63-L77
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
ListenTCP
func (c *Client) ListenTCP(laddr *net.TCPAddr) (net.Listener, error) { if laddr.Port == 0 && isBrokenOpenSSHVersion(string(c.ServerVersion())) { return c.autoPortListenWorkaround(laddr) } m := channelForwardMsg{ laddr.IP.String(), uint32(laddr.Port), } // send message ok, resp, err := c.SendRequest("tcpip-forward", true, Marshal(&m)) if err != nil { return nil, err } if !ok { return nil, errors.New("ssh: tcpip-forward request denied by peer") } // If the original port was 0, then the remote side will // supply a real port number in the response. if laddr.Port == 0 { var p struct { Port uint32 } if err := Unmarshal(resp, &p); err != nil { return nil, err } laddr.Port = int(p.Port) } // Register this forward, using the port number we obtained. ch := c.forwards.add(*laddr) return &tcpListener{laddr, c, ch}, nil }
go
func (c *Client) ListenTCP(laddr *net.TCPAddr) (net.Listener, error) { if laddr.Port == 0 && isBrokenOpenSSHVersion(string(c.ServerVersion())) { return c.autoPortListenWorkaround(laddr) } m := channelForwardMsg{ laddr.IP.String(), uint32(laddr.Port), } // send message ok, resp, err := c.SendRequest("tcpip-forward", true, Marshal(&m)) if err != nil { return nil, err } if !ok { return nil, errors.New("ssh: tcpip-forward request denied by peer") } // If the original port was 0, then the remote side will // supply a real port number in the response. if laddr.Port == 0 { var p struct { Port uint32 } if err := Unmarshal(resp, &p); err != nil { return nil, err } laddr.Port = int(p.Port) } // Register this forward, using the port number we obtained. ch := c.forwards.add(*laddr) return &tcpListener{laddr, c, ch}, nil }
[ "func", "(", "c", "*", "Client", ")", "ListenTCP", "(", "laddr", "*", "net", ".", "TCPAddr", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "if", "laddr", ".", "Port", "==", "0", "&&", "isBrokenOpenSSHVersion", "(", "string", "(", "c", ".", "ServerVersion", "(", ")", ")", ")", "{", "return", "c", ".", "autoPortListenWorkaround", "(", "laddr", ")", "\n", "}", "\n\n", "m", ":=", "channelForwardMsg", "{", "laddr", ".", "IP", ".", "String", "(", ")", ",", "uint32", "(", "laddr", ".", "Port", ")", ",", "}", "\n", "// send message", "ok", ",", "resp", ",", "err", ":=", "c", ".", "SendRequest", "(", "\"", "\"", ",", "true", ",", "Marshal", "(", "&", "m", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// If the original port was 0, then the remote side will", "// supply a real port number in the response.", "if", "laddr", ".", "Port", "==", "0", "{", "var", "p", "struct", "{", "Port", "uint32", "\n", "}", "\n", "if", "err", ":=", "Unmarshal", "(", "resp", ",", "&", "p", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "laddr", ".", "Port", "=", "int", "(", "p", ".", "Port", ")", "\n", "}", "\n\n", "// Register this forward, using the port number we obtained.", "ch", ":=", "c", ".", "forwards", ".", "add", "(", "*", "laddr", ")", "\n\n", "return", "&", "tcpListener", "{", "laddr", ",", "c", ",", "ch", "}", ",", "nil", "\n", "}" ]
// ListenTCP requests the remote peer open a listening socket // on laddr. Incoming connections will be available by calling // Accept on the returned net.Listener.
[ "ListenTCP", "requests", "the", "remote", "peer", "open", "a", "listening", "socket", "on", "laddr", ".", "Incoming", "connections", "will", "be", "available", "by", "calling", "Accept", "on", "the", "returned", "net", ".", "Listener", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L88-L122
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
remove
func (l *forwardList) remove(addr net.TCPAddr) { l.Lock() defer l.Unlock() for i, f := range l.entries { if addr.IP.Equal(f.laddr.IP) && addr.Port == f.laddr.Port { l.entries = append(l.entries[:i], l.entries[i+1:]...) close(f.c) return } } }
go
func (l *forwardList) remove(addr net.TCPAddr) { l.Lock() defer l.Unlock() for i, f := range l.entries { if addr.IP.Equal(f.laddr.IP) && addr.Port == f.laddr.Port { l.entries = append(l.entries[:i], l.entries[i+1:]...) close(f.c) return } } }
[ "func", "(", "l", "*", "forwardList", ")", "remove", "(", "addr", "net", ".", "TCPAddr", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "for", "i", ",", "f", ":=", "range", "l", ".", "entries", "{", "if", "addr", ".", "IP", ".", "Equal", "(", "f", ".", "laddr", ".", "IP", ")", "&&", "addr", ".", "Port", "==", "f", ".", "laddr", ".", "Port", "{", "l", ".", "entries", "=", "append", "(", "l", ".", "entries", "[", ":", "i", "]", ",", "l", ".", "entries", "[", "i", "+", "1", ":", "]", "...", ")", "\n", "close", "(", "f", ".", "c", ")", "\n", "return", "\n", "}", "\n", "}", "\n", "}" ]
// remove removes the forward entry, and the channel feeding its // listener.
[ "remove", "removes", "the", "forward", "entry", "and", "the", "channel", "feeding", "its", "listener", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L212-L222
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
closeAll
func (l *forwardList) closeAll() { l.Lock() defer l.Unlock() for _, f := range l.entries { close(f.c) } l.entries = nil }
go
func (l *forwardList) closeAll() { l.Lock() defer l.Unlock() for _, f := range l.entries { close(f.c) } l.entries = nil }
[ "func", "(", "l", "*", "forwardList", ")", "closeAll", "(", ")", "{", "l", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "Unlock", "(", ")", "\n", "for", "_", ",", "f", ":=", "range", "l", ".", "entries", "{", "close", "(", "f", ".", "c", ")", "\n", "}", "\n", "l", ".", "entries", "=", "nil", "\n", "}" ]
// closeAll closes and clears all forwards.
[ "closeAll", "closes", "and", "clears", "all", "forwards", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L225-L232
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go
DialTCP
func (c *Client) DialTCP(n string, laddr, raddr *net.TCPAddr) (net.Conn, error) { if laddr == nil { laddr = &net.TCPAddr{ IP: net.IPv4zero, Port: 0, } } ch, err := c.dial(laddr.IP.String(), laddr.Port, raddr.IP.String(), raddr.Port) if err != nil { return nil, err } return &tcpChanConn{ Channel: ch, laddr: laddr, raddr: raddr, }, nil }
go
func (c *Client) DialTCP(n string, laddr, raddr *net.TCPAddr) (net.Conn, error) { if laddr == nil { laddr = &net.TCPAddr{ IP: net.IPv4zero, Port: 0, } } ch, err := c.dial(laddr.IP.String(), laddr.Port, raddr.IP.String(), raddr.Port) if err != nil { return nil, err } return &tcpChanConn{ Channel: ch, laddr: laddr, raddr: raddr, }, nil }
[ "func", "(", "c", "*", "Client", ")", "DialTCP", "(", "n", "string", ",", "laddr", ",", "raddr", "*", "net", ".", "TCPAddr", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "if", "laddr", "==", "nil", "{", "laddr", "=", "&", "net", ".", "TCPAddr", "{", "IP", ":", "net", ".", "IPv4zero", ",", "Port", ":", "0", ",", "}", "\n", "}", "\n", "ch", ",", "err", ":=", "c", ".", "dial", "(", "laddr", ".", "IP", ".", "String", "(", ")", ",", "laddr", ".", "Port", ",", "raddr", ".", "IP", ".", "String", "(", ")", ",", "raddr", ".", "Port", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "tcpChanConn", "{", "Channel", ":", "ch", ",", "laddr", ":", "laddr", ",", "raddr", ":", "raddr", ",", "}", ",", "nil", "\n", "}" ]
// DialTCP connects to the remote address raddr on the network net, // which must be "tcp", "tcp4", or "tcp6". If laddr is not nil, it is used // as the local address for the connection.
[ "DialTCP", "connects", "to", "the", "remote", "address", "raddr", "on", "the", "network", "net", "which", "must", "be", "tcp", "tcp4", "or", "tcp6", ".", "If", "laddr", "is", "not", "nil", "it", "is", "used", "as", "the", "local", "address", "for", "the", "connection", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip.go#L324-L340
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/helper.go
DecodeList
func DecodeList(objects []Object, decoders ...ObjectDecoder) []error { errs := []error(nil) for i, obj := range objects { switch t := obj.(type) { case *Unknown: for _, decoder := range decoders { gv, err := unversioned.ParseGroupVersion(t.APIVersion) if err != nil { errs = append(errs, err) break } if !decoder.Recognizes(gv.WithKind(t.Kind)) { continue } obj, err := Decode(decoder, t.RawJSON) if err != nil { errs = append(errs, err) break } objects[i] = obj break } } } return errs }
go
func DecodeList(objects []Object, decoders ...ObjectDecoder) []error { errs := []error(nil) for i, obj := range objects { switch t := obj.(type) { case *Unknown: for _, decoder := range decoders { gv, err := unversioned.ParseGroupVersion(t.APIVersion) if err != nil { errs = append(errs, err) break } if !decoder.Recognizes(gv.WithKind(t.Kind)) { continue } obj, err := Decode(decoder, t.RawJSON) if err != nil { errs = append(errs, err) break } objects[i] = obj break } } } return errs }
[ "func", "DecodeList", "(", "objects", "[", "]", "Object", ",", "decoders", "...", "ObjectDecoder", ")", "[", "]", "error", "{", "errs", ":=", "[", "]", "error", "(", "nil", ")", "\n", "for", "i", ",", "obj", ":=", "range", "objects", "{", "switch", "t", ":=", "obj", ".", "(", "type", ")", "{", "case", "*", "Unknown", ":", "for", "_", ",", "decoder", ":=", "range", "decoders", "{", "gv", ",", "err", ":=", "unversioned", ".", "ParseGroupVersion", "(", "t", ".", "APIVersion", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "break", "\n", "}", "\n\n", "if", "!", "decoder", ".", "Recognizes", "(", "gv", ".", "WithKind", "(", "t", ".", "Kind", ")", ")", "{", "continue", "\n", "}", "\n", "obj", ",", "err", ":=", "Decode", "(", "decoder", ",", "t", ".", "RawJSON", ")", "\n", "if", "err", "!=", "nil", "{", "errs", "=", "append", "(", "errs", ",", "err", ")", "\n", "break", "\n", "}", "\n", "objects", "[", "i", "]", "=", "obj", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "errs", "\n", "}" ]
// DecodeList alters the list in place, attempting to decode any objects found in // the list that have the runtime.Unknown type. Any errors that occur are returned // after the entire list is processed. Decoders are tried in order.
[ "DecodeList", "alters", "the", "list", "in", "place", "attempting", "to", "decode", "any", "objects", "found", "in", "the", "list", "that", "have", "the", "runtime", ".", "Unknown", "type", ".", "Any", "errors", "that", "occur", "are", "returned", "after", "the", "entire", "list", "is", "processed", ".", "Decoders", "are", "tried", "in", "order", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/helper.go#L54-L80
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go
newLimitRanges
func newLimitRanges(c *Client, namespace string) *limitRanges { return &limitRanges{ r: c, ns: namespace, } }
go
func newLimitRanges(c *Client, namespace string) *limitRanges { return &limitRanges{ r: c, ns: namespace, } }
[ "func", "newLimitRanges", "(", "c", "*", "Client", ",", "namespace", "string", ")", "*", "limitRanges", "{", "return", "&", "limitRanges", "{", "r", ":", "c", ",", "ns", ":", "namespace", ",", "}", "\n", "}" ]
// newLimitRanges returns a limitRanges
[ "newLimitRanges", "returns", "a", "limitRanges" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go#L48-L53
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go
Update
func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange, err error) { result = &api.LimitRange{} if len(limitRange.ResourceVersion) == 0 { err = fmt.Errorf("invalid update object, missing resource version: %v", limitRange) return } err = c.r.Put().Namespace(c.ns).Resource("limitRanges").Name(limitRange.Name).Body(limitRange).Do().Into(result) return }
go
func (c *limitRanges) Update(limitRange *api.LimitRange) (result *api.LimitRange, err error) { result = &api.LimitRange{} if len(limitRange.ResourceVersion) == 0 { err = fmt.Errorf("invalid update object, missing resource version: %v", limitRange) return } err = c.r.Put().Namespace(c.ns).Resource("limitRanges").Name(limitRange.Name).Body(limitRange).Do().Into(result) return }
[ "func", "(", "c", "*", "limitRanges", ")", "Update", "(", "limitRange", "*", "api", ".", "LimitRange", ")", "(", "result", "*", "api", ".", "LimitRange", ",", "err", "error", ")", "{", "result", "=", "&", "api", ".", "LimitRange", "{", "}", "\n", "if", "len", "(", "limitRange", ".", "ResourceVersion", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "limitRange", ")", "\n", "return", "\n", "}", "\n", "err", "=", "c", ".", "r", ".", "Put", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "limitRange", ".", "Name", ")", ".", "Body", "(", "limitRange", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Update takes the representation of a limitRange to update. Returns the server's representation of the limitRange, and an error, if it occurs.
[ "Update", "takes", "the", "representation", "of", "a", "limitRange", "to", "update", ".", "Returns", "the", "server", "s", "representation", "of", "the", "limitRange", "and", "an", "error", "if", "it", "occurs", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go#L82-L90
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go
Watch
func (c *limitRanges) Watch(opts api.ListOptions) (watch.Interface, error) { return c.r.Get(). Prefix("watch"). Namespace(c.ns). Resource("limitRanges"). VersionedParams(&opts, api.Scheme). Watch() }
go
func (c *limitRanges) Watch(opts api.ListOptions) (watch.Interface, error) { return c.r.Get(). Prefix("watch"). Namespace(c.ns). Resource("limitRanges"). VersionedParams(&opts, api.Scheme). Watch() }
[ "func", "(", "c", "*", "limitRanges", ")", "Watch", "(", "opts", "api", ".", "ListOptions", ")", "(", "watch", ".", "Interface", ",", "error", ")", "{", "return", "c", ".", "r", ".", "Get", "(", ")", ".", "Prefix", "(", "\"", "\"", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "VersionedParams", "(", "&", "opts", ",", "api", ".", "Scheme", ")", ".", "Watch", "(", ")", "\n", "}" ]
// Watch returns a watch.Interface that watches the requested resource
[ "Watch", "returns", "a", "watch", ".", "Interface", "that", "watches", "the", "requested", "resource" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/limit_ranges.go#L93-L100
train
kubernetes-retired/contrib
node-perf-dash/types.go
GetDataPerBuild
func (b TestToBuildData) GetDataPerBuild(job, build, test, node string) *DataPerBuild { if _, ok := b[test]; !ok { b[test] = &DataPerTest{ Job: job, Data: map[string]DataPerNode{}, } } if _, ok := b[test].Data[node]; !ok { b[test].Data[node] = DataPerNode{} } if _, ok := b[test].Data[node][build]; !ok { b[test].Data[node][build] = &DataPerBuild{} } return b[test].Data[node][build] }
go
func (b TestToBuildData) GetDataPerBuild(job, build, test, node string) *DataPerBuild { if _, ok := b[test]; !ok { b[test] = &DataPerTest{ Job: job, Data: map[string]DataPerNode{}, } } if _, ok := b[test].Data[node]; !ok { b[test].Data[node] = DataPerNode{} } if _, ok := b[test].Data[node][build]; !ok { b[test].Data[node][build] = &DataPerBuild{} } return b[test].Data[node][build] }
[ "func", "(", "b", "TestToBuildData", ")", "GetDataPerBuild", "(", "job", ",", "build", ",", "test", ",", "node", "string", ")", "*", "DataPerBuild", "{", "if", "_", ",", "ok", ":=", "b", "[", "test", "]", ";", "!", "ok", "{", "b", "[", "test", "]", "=", "&", "DataPerTest", "{", "Job", ":", "job", ",", "Data", ":", "map", "[", "string", "]", "DataPerNode", "{", "}", ",", "}", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "b", "[", "test", "]", ".", "Data", "[", "node", "]", ";", "!", "ok", "{", "b", "[", "test", "]", ".", "Data", "[", "node", "]", "=", "DataPerNode", "{", "}", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "b", "[", "test", "]", ".", "Data", "[", "node", "]", "[", "build", "]", ";", "!", "ok", "{", "b", "[", "test", "]", ".", "Data", "[", "node", "]", "[", "build", "]", "=", "&", "DataPerBuild", "{", "}", "\n", "}", "\n", "return", "b", "[", "test", "]", ".", "Data", "[", "node", "]", "[", "build", "]", "\n", "}" ]
// GetDataPerBuild creates a DataPerBuild structure for the given build using // the specified job, test, and node if it does not exist, and then returns it.
[ "GetDataPerBuild", "creates", "a", "DataPerBuild", "structure", "for", "the", "given", "build", "using", "the", "specified", "job", "test", "and", "node", "if", "it", "does", "not", "exist", "and", "then", "returns", "it", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/types.go#L48-L62
train
kubernetes-retired/contrib
node-perf-dash/types.go
ServeHTTP
func (b TestToBuildData) ServeHTTP(res http.ResponseWriter, req *http.Request) { data, err := json.Marshal(b) if err != nil { res.Header().Set("Content-type", "text/html") res.WriteHeader(http.StatusInternalServerError) res.Write([]byte(fmt.Sprintf("<h3>Internal Error</h3><p>%v", err))) return } res.Header().Set("Content-type", "application/json") res.WriteHeader(http.StatusOK) res.Write(data) }
go
func (b TestToBuildData) ServeHTTP(res http.ResponseWriter, req *http.Request) { data, err := json.Marshal(b) if err != nil { res.Header().Set("Content-type", "text/html") res.WriteHeader(http.StatusInternalServerError) res.Write([]byte(fmt.Sprintf("<h3>Internal Error</h3><p>%v", err))) return } res.Header().Set("Content-type", "application/json") res.WriteHeader(http.StatusOK) res.Write(data) }
[ "func", "(", "b", "TestToBuildData", ")", "ServeHTTP", "(", "res", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "res", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "res", ".", "WriteHeader", "(", "http", ".", "StatusInternalServerError", ")", "\n", "res", ".", "Write", "(", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", ")", "\n", "return", "\n", "}", "\n", "res", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "res", ".", "WriteHeader", "(", "http", ".", "StatusOK", ")", "\n", "res", ".", "Write", "(", "data", ")", "\n", "}" ]
// ServeHTTP is the HTTP handler for serving TestToBuildData.
[ "ServeHTTP", "is", "the", "HTTP", "handler", "for", "serving", "TestToBuildData", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/node-perf-dash/types.go#L65-L76
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/delta_fifo.go
GetByKey
func (f *DeltaFIFO) GetByKey(key string) (item interface{}, exists bool, err error) { f.lock.RLock() defer f.lock.RUnlock() d, exists := f.items[key] if exists { // Copy item's slice so operations on this slice (delta // compression) won't interfere with the object we return. d = copyDeltas(d) } return d, exists, nil }
go
func (f *DeltaFIFO) GetByKey(key string) (item interface{}, exists bool, err error) { f.lock.RLock() defer f.lock.RUnlock() d, exists := f.items[key] if exists { // Copy item's slice so operations on this slice (delta // compression) won't interfere with the object we return. d = copyDeltas(d) } return d, exists, nil }
[ "func", "(", "f", "*", "DeltaFIFO", ")", "GetByKey", "(", "key", "string", ")", "(", "item", "interface", "{", "}", ",", "exists", "bool", ",", "err", "error", ")", "{", "f", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "f", ".", "lock", ".", "RUnlock", "(", ")", "\n", "d", ",", "exists", ":=", "f", ".", "items", "[", "key", "]", "\n", "if", "exists", "{", "// Copy item's slice so operations on this slice (delta", "// compression) won't interfere with the object we return.", "d", "=", "copyDeltas", "(", "d", ")", "\n", "}", "\n", "return", "d", ",", "exists", ",", "nil", "\n", "}" ]
// GetByKey returns the complete list of deltas for the requested item, // setting exists=false if that list is empty. // You should treat the items returned inside the deltas as immutable.
[ "GetByKey", "returns", "the", "complete", "list", "of", "deltas", "for", "the", "requested", "item", "setting", "exists", "=", "false", "if", "that", "list", "is", "empty", ".", "You", "should", "treat", "the", "items", "returned", "inside", "the", "deltas", "as", "immutable", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/delta_fifo.go#L345-L355
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/name.go
ValidatePathSegmentName
func ValidatePathSegmentName(name string, prefix bool) (bool, string) { if prefix { return IsValidPathSegmentPrefix(name) } else { return IsValidPathSegmentName(name) } }
go
func ValidatePathSegmentName(name string, prefix bool) (bool, string) { if prefix { return IsValidPathSegmentPrefix(name) } else { return IsValidPathSegmentName(name) } }
[ "func", "ValidatePathSegmentName", "(", "name", "string", ",", "prefix", "bool", ")", "(", "bool", ",", "string", ")", "{", "if", "prefix", "{", "return", "IsValidPathSegmentPrefix", "(", "name", ")", "\n", "}", "else", "{", "return", "IsValidPathSegmentName", "(", "name", ")", "\n", "}", "\n", "}" ]
// ValidatePathSegmentName validates the name can be safely encoded as a path segment
[ "ValidatePathSegmentName", "validates", "the", "name", "can", "be", "safely", "encoded", "as", "a", "path", "segment" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/name.go#L60-L66
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/context.go
WithNamespaceDefaultIfNone
func WithNamespaceDefaultIfNone(parent Context) Context { namespace, ok := NamespaceFrom(parent) if !ok || len(namespace) == 0 { return WithNamespace(parent, NamespaceDefault) } return parent }
go
func WithNamespaceDefaultIfNone(parent Context) Context { namespace, ok := NamespaceFrom(parent) if !ok || len(namespace) == 0 { return WithNamespace(parent, NamespaceDefault) } return parent }
[ "func", "WithNamespaceDefaultIfNone", "(", "parent", "Context", ")", "Context", "{", "namespace", ",", "ok", ":=", "NamespaceFrom", "(", "parent", ")", "\n", "if", "!", "ok", "||", "len", "(", "namespace", ")", "==", "0", "{", "return", "WithNamespace", "(", "parent", ",", "NamespaceDefault", ")", "\n", "}", "\n", "return", "parent", "\n", "}" ]
// WithNamespaceDefaultIfNone returns a context whose namespace is the default if and only if the parent context has no namespace value
[ "WithNamespaceDefaultIfNone", "returns", "a", "context", "whose", "namespace", "is", "the", "default", "if", "and", "only", "if", "the", "parent", "context", "has", "no", "namespace", "value" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/context.go#L104-L110
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/context.go
WithUser
func WithUser(parent Context, user user.Info) Context { return WithValue(parent, userKey, user) }
go
func WithUser(parent Context, user user.Info) Context { return WithValue(parent, userKey, user) }
[ "func", "WithUser", "(", "parent", "Context", ",", "user", "user", ".", "Info", ")", "Context", "{", "return", "WithValue", "(", "parent", ",", "userKey", ",", "user", ")", "\n", "}" ]
// WithUser returns a copy of parent in which the user value is set
[ "WithUser", "returns", "a", "copy", "of", "parent", "in", "which", "the", "user", "value", "is", "set" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/context.go#L113-L115
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go
EnableCrossGroupDecoding
func EnableCrossGroupDecoding(d runtime.Decoder, sourceGroup, destGroup string) error { internal, ok := d.(*codec) if !ok { return fmt.Errorf("unsupported decoder type") } dest, ok := internal.decodeVersion[destGroup] if !ok { return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) } internal.decodeVersion[sourceGroup] = dest return nil }
go
func EnableCrossGroupDecoding(d runtime.Decoder, sourceGroup, destGroup string) error { internal, ok := d.(*codec) if !ok { return fmt.Errorf("unsupported decoder type") } dest, ok := internal.decodeVersion[destGroup] if !ok { return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) } internal.decodeVersion[sourceGroup] = dest return nil }
[ "func", "EnableCrossGroupDecoding", "(", "d", "runtime", ".", "Decoder", ",", "sourceGroup", ",", "destGroup", "string", ")", "error", "{", "internal", ",", "ok", ":=", "d", ".", "(", "*", "codec", ")", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "dest", ",", "ok", ":=", "internal", ".", "decodeVersion", "[", "destGroup", "]", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "destGroup", ")", "\n", "}", "\n", "internal", ".", "decodeVersion", "[", "sourceGroup", "]", "=", "dest", "\n\n", "return", "nil", "\n", "}" ]
// EnableCrossGroupDecoding modifies the given decoder in place, if it is a codec // from this package. It allows objects from one group to be auto-decoded into // another group. 'destGroup' must already exist in the codec.
[ "EnableCrossGroupDecoding", "modifies", "the", "given", "decoder", "in", "place", "if", "it", "is", "a", "codec", "from", "this", "package", ".", "It", "allows", "objects", "from", "one", "group", "to", "be", "auto", "-", "decoded", "into", "another", "group", ".", "destGroup", "must", "already", "exist", "in", "the", "codec", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go#L30-L43
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go
EnableCrossGroupEncoding
func EnableCrossGroupEncoding(e runtime.Encoder, sourceGroup, destGroup string) error { internal, ok := e.(*codec) if !ok { return fmt.Errorf("unsupported encoder type") } dest, ok := internal.encodeVersion[destGroup] if !ok { return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) } internal.encodeVersion[sourceGroup] = dest return nil }
go
func EnableCrossGroupEncoding(e runtime.Encoder, sourceGroup, destGroup string) error { internal, ok := e.(*codec) if !ok { return fmt.Errorf("unsupported encoder type") } dest, ok := internal.encodeVersion[destGroup] if !ok { return fmt.Errorf("group %q is not a possible destination group in the given codec", destGroup) } internal.encodeVersion[sourceGroup] = dest return nil }
[ "func", "EnableCrossGroupEncoding", "(", "e", "runtime", ".", "Encoder", ",", "sourceGroup", ",", "destGroup", "string", ")", "error", "{", "internal", ",", "ok", ":=", "e", ".", "(", "*", "codec", ")", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "dest", ",", "ok", ":=", "internal", ".", "encodeVersion", "[", "destGroup", "]", "\n", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "destGroup", ")", "\n", "}", "\n", "internal", ".", "encodeVersion", "[", "sourceGroup", "]", "=", "dest", "\n\n", "return", "nil", "\n", "}" ]
// EnableCrossGroupEncoding modifies the given encoder in place, if it is a codec // from this package. It allows objects from one group to be auto-decoded into // another group. 'destGroup' must already exist in the codec.
[ "EnableCrossGroupEncoding", "modifies", "the", "given", "encoder", "in", "place", "if", "it", "is", "a", "codec", "from", "this", "package", ".", "It", "allows", "objects", "from", "one", "group", "to", "be", "auto", "-", "decoded", "into", "another", "group", ".", "destGroup", "must", "already", "exist", "in", "the", "codec", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go#L48-L61
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go
NewCodecForScheme
func NewCodecForScheme( // TODO: I should be a scheme interface? scheme *runtime.Scheme, serializer runtime.Serializer, encodeVersion []unversioned.GroupVersion, decodeVersion []unversioned.GroupVersion, ) runtime.Codec { return NewCodec(serializer, scheme, scheme, scheme, runtime.ObjectTyperToTyper(scheme), encodeVersion, decodeVersion) }
go
func NewCodecForScheme( // TODO: I should be a scheme interface? scheme *runtime.Scheme, serializer runtime.Serializer, encodeVersion []unversioned.GroupVersion, decodeVersion []unversioned.GroupVersion, ) runtime.Codec { return NewCodec(serializer, scheme, scheme, scheme, runtime.ObjectTyperToTyper(scheme), encodeVersion, decodeVersion) }
[ "func", "NewCodecForScheme", "(", "// TODO: I should be a scheme interface?", "scheme", "*", "runtime", ".", "Scheme", ",", "serializer", "runtime", ".", "Serializer", ",", "encodeVersion", "[", "]", "unversioned", ".", "GroupVersion", ",", "decodeVersion", "[", "]", "unversioned", ".", "GroupVersion", ",", ")", "runtime", ".", "Codec", "{", "return", "NewCodec", "(", "serializer", ",", "scheme", ",", "scheme", ",", "scheme", ",", "runtime", ".", "ObjectTyperToTyper", "(", "scheme", ")", ",", "encodeVersion", ",", "decodeVersion", ")", "\n", "}" ]
// NewCodecForScheme is a convenience method for callers that are using a scheme.
[ "NewCodecForScheme", "is", "a", "convenience", "method", "for", "callers", "that", "are", "using", "a", "scheme", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go#L64-L72
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go
EncodeToStream
func (c *codec) EncodeToStream(obj runtime.Object, w io.Writer, overrides ...unversioned.GroupVersion) error { if _, ok := obj.(*runtime.Unknown); ok { return c.serializer.EncodeToStream(obj, w, overrides...) } gvk, isUnversioned, err := c.typer.ObjectKind(obj) if err != nil { return err } if (c.encodeVersion == nil && len(overrides) == 0) || isUnversioned { old := obj.GetObjectKind().GroupVersionKind() obj.GetObjectKind().SetGroupVersionKind(gvk) defer obj.GetObjectKind().SetGroupVersionKind(old) return c.serializer.EncodeToStream(obj, w, overrides...) } targetGV, ok := c.encodeVersion[gvk.Group] // use override if provided for i, override := range overrides { if override.Group == gvk.Group { ok = true targetGV = override // swap the position of the override overrides[0], overrides[i] = targetGV, overrides[0] break } } // attempt a conversion to the sole encode version if !ok && len(c.encodeVersion) == 1 { ok = true for _, v := range c.encodeVersion { targetGV = v } // ensure the target override is first overrides = promoteOrPrependGroupVersion(targetGV, overrides) } // if no fallback is available, error if !ok { return fmt.Errorf("the codec does not recognize group %q for kind %q and cannot encode it", gvk.Group, gvk.Kind) } // Perform a conversion if necessary if gvk.GroupVersion() != targetGV { out, err := c.convertor.ConvertToVersion(obj, targetGV.String()) if err != nil { if ok { return err } } else { obj = out } } else { old := obj.GetObjectKind().GroupVersionKind() defer obj.GetObjectKind().SetGroupVersionKind(old) obj.GetObjectKind().SetGroupVersionKind(&unversioned.GroupVersionKind{Group: targetGV.Group, Version: targetGV.Version, Kind: gvk.Kind}) } return c.serializer.EncodeToStream(obj, w, overrides...) }
go
func (c *codec) EncodeToStream(obj runtime.Object, w io.Writer, overrides ...unversioned.GroupVersion) error { if _, ok := obj.(*runtime.Unknown); ok { return c.serializer.EncodeToStream(obj, w, overrides...) } gvk, isUnversioned, err := c.typer.ObjectKind(obj) if err != nil { return err } if (c.encodeVersion == nil && len(overrides) == 0) || isUnversioned { old := obj.GetObjectKind().GroupVersionKind() obj.GetObjectKind().SetGroupVersionKind(gvk) defer obj.GetObjectKind().SetGroupVersionKind(old) return c.serializer.EncodeToStream(obj, w, overrides...) } targetGV, ok := c.encodeVersion[gvk.Group] // use override if provided for i, override := range overrides { if override.Group == gvk.Group { ok = true targetGV = override // swap the position of the override overrides[0], overrides[i] = targetGV, overrides[0] break } } // attempt a conversion to the sole encode version if !ok && len(c.encodeVersion) == 1 { ok = true for _, v := range c.encodeVersion { targetGV = v } // ensure the target override is first overrides = promoteOrPrependGroupVersion(targetGV, overrides) } // if no fallback is available, error if !ok { return fmt.Errorf("the codec does not recognize group %q for kind %q and cannot encode it", gvk.Group, gvk.Kind) } // Perform a conversion if necessary if gvk.GroupVersion() != targetGV { out, err := c.convertor.ConvertToVersion(obj, targetGV.String()) if err != nil { if ok { return err } } else { obj = out } } else { old := obj.GetObjectKind().GroupVersionKind() defer obj.GetObjectKind().SetGroupVersionKind(old) obj.GetObjectKind().SetGroupVersionKind(&unversioned.GroupVersionKind{Group: targetGV.Group, Version: targetGV.Version, Kind: gvk.Kind}) } return c.serializer.EncodeToStream(obj, w, overrides...) }
[ "func", "(", "c", "*", "codec", ")", "EncodeToStream", "(", "obj", "runtime", ".", "Object", ",", "w", "io", ".", "Writer", ",", "overrides", "...", "unversioned", ".", "GroupVersion", ")", "error", "{", "if", "_", ",", "ok", ":=", "obj", ".", "(", "*", "runtime", ".", "Unknown", ")", ";", "ok", "{", "return", "c", ".", "serializer", ".", "EncodeToStream", "(", "obj", ",", "w", ",", "overrides", "...", ")", "\n", "}", "\n", "gvk", ",", "isUnversioned", ",", "err", ":=", "c", ".", "typer", ".", "ObjectKind", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "(", "c", ".", "encodeVersion", "==", "nil", "&&", "len", "(", "overrides", ")", "==", "0", ")", "||", "isUnversioned", "{", "old", ":=", "obj", ".", "GetObjectKind", "(", ")", ".", "GroupVersionKind", "(", ")", "\n", "obj", ".", "GetObjectKind", "(", ")", ".", "SetGroupVersionKind", "(", "gvk", ")", "\n", "defer", "obj", ".", "GetObjectKind", "(", ")", ".", "SetGroupVersionKind", "(", "old", ")", "\n", "return", "c", ".", "serializer", ".", "EncodeToStream", "(", "obj", ",", "w", ",", "overrides", "...", ")", "\n", "}", "\n\n", "targetGV", ",", "ok", ":=", "c", ".", "encodeVersion", "[", "gvk", ".", "Group", "]", "\n", "// use override if provided", "for", "i", ",", "override", ":=", "range", "overrides", "{", "if", "override", ".", "Group", "==", "gvk", ".", "Group", "{", "ok", "=", "true", "\n", "targetGV", "=", "override", "\n", "// swap the position of the override", "overrides", "[", "0", "]", ",", "overrides", "[", "i", "]", "=", "targetGV", ",", "overrides", "[", "0", "]", "\n", "break", "\n", "}", "\n", "}", "\n\n", "// attempt a conversion to the sole encode version", "if", "!", "ok", "&&", "len", "(", "c", ".", "encodeVersion", ")", "==", "1", "{", "ok", "=", "true", "\n", "for", "_", ",", "v", ":=", "range", "c", ".", "encodeVersion", "{", "targetGV", "=", "v", "\n", "}", "\n", "// ensure the target override is first", "overrides", "=", "promoteOrPrependGroupVersion", "(", "targetGV", ",", "overrides", ")", "\n", "}", "\n\n", "// if no fallback is available, error", "if", "!", "ok", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "gvk", ".", "Group", ",", "gvk", ".", "Kind", ")", "\n", "}", "\n\n", "// Perform a conversion if necessary", "if", "gvk", ".", "GroupVersion", "(", ")", "!=", "targetGV", "{", "out", ",", "err", ":=", "c", ".", "convertor", ".", "ConvertToVersion", "(", "obj", ",", "targetGV", ".", "String", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "ok", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "obj", "=", "out", "\n", "}", "\n", "}", "else", "{", "old", ":=", "obj", ".", "GetObjectKind", "(", ")", ".", "GroupVersionKind", "(", ")", "\n", "defer", "obj", ".", "GetObjectKind", "(", ")", ".", "SetGroupVersionKind", "(", "old", ")", "\n", "obj", ".", "GetObjectKind", "(", ")", ".", "SetGroupVersionKind", "(", "&", "unversioned", ".", "GroupVersionKind", "{", "Group", ":", "targetGV", ".", "Group", ",", "Version", ":", "targetGV", ".", "Version", ",", "Kind", ":", "gvk", ".", "Kind", "}", ")", "\n", "}", "\n\n", "return", "c", ".", "serializer", ".", "EncodeToStream", "(", "obj", ",", "w", ",", "overrides", "...", ")", "\n", "}" ]
// EncodeToStream ensures the provided object is output in the right scheme. If overrides are specified, when // encoding the object the first override that matches the object's group is used. Other overrides are ignored.
[ "EncodeToStream", "ensures", "the", "provided", "object", "is", "output", "in", "the", "right", "scheme", ".", "If", "overrides", "are", "specified", "when", "encoding", "the", "object", "the", "first", "override", "that", "matches", "the", "object", "s", "group", "is", "used", ".", "Other", "overrides", "are", "ignored", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go#L214-L274
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go
promoteOrPrependGroupVersion
func promoteOrPrependGroupVersion(target unversioned.GroupVersion, gvs []unversioned.GroupVersion) []unversioned.GroupVersion { for i, gv := range gvs { if gv.Group == target.Group { gvs[0], gvs[i] = gvs[i], gvs[0] return gvs } } return append([]unversioned.GroupVersion{target}, gvs...) }
go
func promoteOrPrependGroupVersion(target unversioned.GroupVersion, gvs []unversioned.GroupVersion) []unversioned.GroupVersion { for i, gv := range gvs { if gv.Group == target.Group { gvs[0], gvs[i] = gvs[i], gvs[0] return gvs } } return append([]unversioned.GroupVersion{target}, gvs...) }
[ "func", "promoteOrPrependGroupVersion", "(", "target", "unversioned", ".", "GroupVersion", ",", "gvs", "[", "]", "unversioned", ".", "GroupVersion", ")", "[", "]", "unversioned", ".", "GroupVersion", "{", "for", "i", ",", "gv", ":=", "range", "gvs", "{", "if", "gv", ".", "Group", "==", "target", ".", "Group", "{", "gvs", "[", "0", "]", ",", "gvs", "[", "i", "]", "=", "gvs", "[", "i", "]", ",", "gvs", "[", "0", "]", "\n", "return", "gvs", "\n", "}", "\n", "}", "\n", "return", "append", "(", "[", "]", "unversioned", ".", "GroupVersion", "{", "target", "}", ",", "gvs", "...", ")", "\n", "}" ]
// promoteOrPrependGroupVersion finds the group version in the provided group versions that has the same group as target. // If the group is found the returned array will have that group version in the first position - if the group is not found // the returned array will have target in the first position.
[ "promoteOrPrependGroupVersion", "finds", "the", "group", "version", "in", "the", "provided", "group", "versions", "that", "has", "the", "same", "group", "as", "target", ".", "If", "the", "group", "is", "found", "the", "returned", "array", "will", "have", "that", "group", "version", "in", "the", "first", "position", "-", "if", "the", "group", "is", "not", "found", "the", "returned", "array", "will", "have", "target", "in", "the", "first", "position", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/serializer/versioning/versioning.go#L279-L287
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
add
func (c *chanList) add(ch *channel) uint32 { c.Lock() defer c.Unlock() for i := range c.chans { if c.chans[i] == nil { c.chans[i] = ch return uint32(i) + c.offset } } c.chans = append(c.chans, ch) return uint32(len(c.chans)-1) + c.offset }
go
func (c *chanList) add(ch *channel) uint32 { c.Lock() defer c.Unlock() for i := range c.chans { if c.chans[i] == nil { c.chans[i] = ch return uint32(i) + c.offset } } c.chans = append(c.chans, ch) return uint32(len(c.chans)-1) + c.offset }
[ "func", "(", "c", "*", "chanList", ")", "add", "(", "ch", "*", "channel", ")", "uint32", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "for", "i", ":=", "range", "c", ".", "chans", "{", "if", "c", ".", "chans", "[", "i", "]", "==", "nil", "{", "c", ".", "chans", "[", "i", "]", "=", "ch", "\n", "return", "uint32", "(", "i", ")", "+", "c", ".", "offset", "\n", "}", "\n", "}", "\n", "c", ".", "chans", "=", "append", "(", "c", ".", "chans", ",", "ch", ")", "\n", "return", "uint32", "(", "len", "(", "c", ".", "chans", ")", "-", "1", ")", "+", "c", ".", "offset", "\n", "}" ]
// Assigns a channel ID to the given channel.
[ "Assigns", "a", "channel", "ID", "to", "the", "given", "channel", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L36-L47
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
getChan
func (c *chanList) getChan(id uint32) *channel { id -= c.offset c.Lock() defer c.Unlock() if id < uint32(len(c.chans)) { return c.chans[id] } return nil }
go
func (c *chanList) getChan(id uint32) *channel { id -= c.offset c.Lock() defer c.Unlock() if id < uint32(len(c.chans)) { return c.chans[id] } return nil }
[ "func", "(", "c", "*", "chanList", ")", "getChan", "(", "id", "uint32", ")", "*", "channel", "{", "id", "-=", "c", ".", "offset", "\n\n", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "if", "id", "<", "uint32", "(", "len", "(", "c", ".", "chans", ")", ")", "{", "return", "c", ".", "chans", "[", "id", "]", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// getChan returns the channel for the given ID.
[ "getChan", "returns", "the", "channel", "for", "the", "given", "ID", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L50-L59
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
dropAll
func (c *chanList) dropAll() []*channel { c.Lock() defer c.Unlock() var r []*channel for _, ch := range c.chans { if ch == nil { continue } r = append(r, ch) } c.chans = nil return r }
go
func (c *chanList) dropAll() []*channel { c.Lock() defer c.Unlock() var r []*channel for _, ch := range c.chans { if ch == nil { continue } r = append(r, ch) } c.chans = nil return r }
[ "func", "(", "c", "*", "chanList", ")", "dropAll", "(", ")", "[", "]", "*", "channel", "{", "c", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "Unlock", "(", ")", "\n", "var", "r", "[", "]", "*", "channel", "\n\n", "for", "_", ",", "ch", ":=", "range", "c", ".", "chans", "{", "if", "ch", "==", "nil", "{", "continue", "\n", "}", "\n", "r", "=", "append", "(", "r", ",", "ch", ")", "\n", "}", "\n", "c", ".", "chans", "=", "nil", "\n", "return", "r", "\n", "}" ]
// dropAll forgets all channels it knows, returning them in a slice.
[ "dropAll", "forgets", "all", "channels", "it", "knows", "returning", "them", "in", "a", "slice", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L71-L84
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
newMux
func newMux(p packetConn) *mux { m := &mux{ conn: p, incomingChannels: make(chan NewChannel, 16), globalResponses: make(chan interface{}, 1), incomingRequests: make(chan *Request, 16), errCond: newCond(), } if debugMux { m.chanList.offset = atomic.AddUint32(&globalOff, 1) } go m.loop() return m }
go
func newMux(p packetConn) *mux { m := &mux{ conn: p, incomingChannels: make(chan NewChannel, 16), globalResponses: make(chan interface{}, 1), incomingRequests: make(chan *Request, 16), errCond: newCond(), } if debugMux { m.chanList.offset = atomic.AddUint32(&globalOff, 1) } go m.loop() return m }
[ "func", "newMux", "(", "p", "packetConn", ")", "*", "mux", "{", "m", ":=", "&", "mux", "{", "conn", ":", "p", ",", "incomingChannels", ":", "make", "(", "chan", "NewChannel", ",", "16", ")", ",", "globalResponses", ":", "make", "(", "chan", "interface", "{", "}", ",", "1", ")", ",", "incomingRequests", ":", "make", "(", "chan", "*", "Request", ",", "16", ")", ",", "errCond", ":", "newCond", "(", ")", ",", "}", "\n", "if", "debugMux", "{", "m", ".", "chanList", ".", "offset", "=", "atomic", ".", "AddUint32", "(", "&", "globalOff", ",", "1", ")", "\n", "}", "\n\n", "go", "m", ".", "loop", "(", ")", "\n", "return", "m", "\n", "}" ]
// newMux returns a mux that runs over the given connection.
[ "newMux", "returns", "a", "mux", "that", "runs", "over", "the", "given", "connection", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L116-L130
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
ackRequest
func (m *mux) ackRequest(ok bool, data []byte) error { if ok { return m.sendMessage(globalRequestSuccessMsg{Data: data}) } return m.sendMessage(globalRequestFailureMsg{Data: data}) }
go
func (m *mux) ackRequest(ok bool, data []byte) error { if ok { return m.sendMessage(globalRequestSuccessMsg{Data: data}) } return m.sendMessage(globalRequestFailureMsg{Data: data}) }
[ "func", "(", "m", "*", "mux", ")", "ackRequest", "(", "ok", "bool", ",", "data", "[", "]", "byte", ")", "error", "{", "if", "ok", "{", "return", "m", ".", "sendMessage", "(", "globalRequestSuccessMsg", "{", "Data", ":", "data", "}", ")", "\n", "}", "\n", "return", "m", ".", "sendMessage", "(", "globalRequestFailureMsg", "{", "Data", ":", "data", "}", ")", "\n", "}" ]
// ackRequest must be called after processing a global request that // has WantReply set.
[ "ackRequest", "must", "be", "called", "after", "processing", "a", "global", "request", "that", "has", "WantReply", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L171-L176
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
loop
func (m *mux) loop() { var err error for err == nil { err = m.onePacket() } for _, ch := range m.chanList.dropAll() { ch.close() } close(m.incomingChannels) close(m.incomingRequests) close(m.globalResponses) m.conn.Close() m.errCond.L.Lock() m.err = err m.errCond.Broadcast() m.errCond.L.Unlock() if debugMux { log.Println("loop exit", err) } }
go
func (m *mux) loop() { var err error for err == nil { err = m.onePacket() } for _, ch := range m.chanList.dropAll() { ch.close() } close(m.incomingChannels) close(m.incomingRequests) close(m.globalResponses) m.conn.Close() m.errCond.L.Lock() m.err = err m.errCond.Broadcast() m.errCond.L.Unlock() if debugMux { log.Println("loop exit", err) } }
[ "func", "(", "m", "*", "mux", ")", "loop", "(", ")", "{", "var", "err", "error", "\n", "for", "err", "==", "nil", "{", "err", "=", "m", ".", "onePacket", "(", ")", "\n", "}", "\n\n", "for", "_", ",", "ch", ":=", "range", "m", ".", "chanList", ".", "dropAll", "(", ")", "{", "ch", ".", "close", "(", ")", "\n", "}", "\n\n", "close", "(", "m", ".", "incomingChannels", ")", "\n", "close", "(", "m", ".", "incomingRequests", ")", "\n", "close", "(", "m", ".", "globalResponses", ")", "\n\n", "m", ".", "conn", ".", "Close", "(", ")", "\n\n", "m", ".", "errCond", ".", "L", ".", "Lock", "(", ")", "\n", "m", ".", "err", "=", "err", "\n", "m", ".", "errCond", ".", "Broadcast", "(", ")", "\n", "m", ".", "errCond", ".", "L", ".", "Unlock", "(", ")", "\n\n", "if", "debugMux", "{", "log", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}" ]
// loop runs the connection machine. It will process packets until an // error is encountered. To synchronize on loop exit, use mux.Wait.
[ "loop", "runs", "the", "connection", "machine", ".", "It", "will", "process", "packets", "until", "an", "error", "is", "encountered", ".", "To", "synchronize", "on", "loop", "exit", "use", "mux", ".", "Wait", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L196-L220
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go
onePacket
func (m *mux) onePacket() error { packet, err := m.conn.readPacket() if err != nil { return err } if debugMux { if packet[0] == msgChannelData || packet[0] == msgChannelExtendedData { log.Printf("decoding(%d): data packet - %d bytes", m.chanList.offset, len(packet)) } else { p, _ := decode(packet) log.Printf("decoding(%d): %d %#v - %d bytes", m.chanList.offset, packet[0], p, len(packet)) } } switch packet[0] { case msgNewKeys: // Ignore notification of key change. return nil case msgDisconnect: return m.handleDisconnect(packet) case msgChannelOpen: return m.handleChannelOpen(packet) case msgGlobalRequest, msgRequestSuccess, msgRequestFailure: return m.handleGlobalPacket(packet) } // assume a channel packet. if len(packet) < 5 { return parseError(packet[0]) } id := binary.BigEndian.Uint32(packet[1:]) ch := m.chanList.getChan(id) if ch == nil { return fmt.Errorf("ssh: invalid channel %d", id) } return ch.handlePacket(packet) }
go
func (m *mux) onePacket() error { packet, err := m.conn.readPacket() if err != nil { return err } if debugMux { if packet[0] == msgChannelData || packet[0] == msgChannelExtendedData { log.Printf("decoding(%d): data packet - %d bytes", m.chanList.offset, len(packet)) } else { p, _ := decode(packet) log.Printf("decoding(%d): %d %#v - %d bytes", m.chanList.offset, packet[0], p, len(packet)) } } switch packet[0] { case msgNewKeys: // Ignore notification of key change. return nil case msgDisconnect: return m.handleDisconnect(packet) case msgChannelOpen: return m.handleChannelOpen(packet) case msgGlobalRequest, msgRequestSuccess, msgRequestFailure: return m.handleGlobalPacket(packet) } // assume a channel packet. if len(packet) < 5 { return parseError(packet[0]) } id := binary.BigEndian.Uint32(packet[1:]) ch := m.chanList.getChan(id) if ch == nil { return fmt.Errorf("ssh: invalid channel %d", id) } return ch.handlePacket(packet) }
[ "func", "(", "m", "*", "mux", ")", "onePacket", "(", ")", "error", "{", "packet", ",", "err", ":=", "m", ".", "conn", ".", "readPacket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "debugMux", "{", "if", "packet", "[", "0", "]", "==", "msgChannelData", "||", "packet", "[", "0", "]", "==", "msgChannelExtendedData", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "m", ".", "chanList", ".", "offset", ",", "len", "(", "packet", ")", ")", "\n", "}", "else", "{", "p", ",", "_", ":=", "decode", "(", "packet", ")", "\n", "log", ".", "Printf", "(", "\"", "\"", ",", "m", ".", "chanList", ".", "offset", ",", "packet", "[", "0", "]", ",", "p", ",", "len", "(", "packet", ")", ")", "\n", "}", "\n", "}", "\n\n", "switch", "packet", "[", "0", "]", "{", "case", "msgNewKeys", ":", "// Ignore notification of key change.", "return", "nil", "\n", "case", "msgDisconnect", ":", "return", "m", ".", "handleDisconnect", "(", "packet", ")", "\n", "case", "msgChannelOpen", ":", "return", "m", ".", "handleChannelOpen", "(", "packet", ")", "\n", "case", "msgGlobalRequest", ",", "msgRequestSuccess", ",", "msgRequestFailure", ":", "return", "m", ".", "handleGlobalPacket", "(", "packet", ")", "\n", "}", "\n\n", "// assume a channel packet.", "if", "len", "(", "packet", ")", "<", "5", "{", "return", "parseError", "(", "packet", "[", "0", "]", ")", "\n", "}", "\n", "id", ":=", "binary", ".", "BigEndian", ".", "Uint32", "(", "packet", "[", "1", ":", "]", ")", "\n", "ch", ":=", "m", ".", "chanList", ".", "getChan", "(", "id", ")", "\n", "if", "ch", "==", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n\n", "return", "ch", ".", "handlePacket", "(", "packet", ")", "\n", "}" ]
// onePacket reads and processes one packet.
[ "onePacket", "reads", "and", "processes", "one", "packet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/mux.go#L223-L261
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go
Add
func (q *Type) Add(item interface{}) { q.cond.L.Lock() defer q.cond.L.Unlock() if q.shuttingDown { return } if q.dirty.has(item) { return } q.dirty.insert(item) if q.processing.has(item) { return } q.queue = append(q.queue, item) q.cond.Signal() }
go
func (q *Type) Add(item interface{}) { q.cond.L.Lock() defer q.cond.L.Unlock() if q.shuttingDown { return } if q.dirty.has(item) { return } q.dirty.insert(item) if q.processing.has(item) { return } q.queue = append(q.queue, item) q.cond.Signal() }
[ "func", "(", "q", "*", "Type", ")", "Add", "(", "item", "interface", "{", "}", ")", "{", "q", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n", "if", "q", ".", "shuttingDown", "{", "return", "\n", "}", "\n", "if", "q", ".", "dirty", ".", "has", "(", "item", ")", "{", "return", "\n", "}", "\n", "q", ".", "dirty", ".", "insert", "(", "item", ")", "\n", "if", "q", ".", "processing", ".", "has", "(", "item", ")", "{", "return", "\n", "}", "\n", "q", ".", "queue", "=", "append", "(", "q", ".", "queue", ",", "item", ")", "\n", "q", ".", "cond", ".", "Signal", "(", ")", "\n", "}" ]
// Add marks item as needing processing.
[ "Add", "marks", "item", "as", "needing", "processing", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go#L71-L86
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go
Get
func (q *Type) Get() (item interface{}, shutdown bool) { q.cond.L.Lock() defer q.cond.L.Unlock() for len(q.queue) == 0 && !q.shuttingDown { q.cond.Wait() } if len(q.queue) == 0 { // We must be shutting down. return nil, true } item, q.queue = q.queue[0], q.queue[1:] q.processing.insert(item) q.dirty.delete(item) return item, false }
go
func (q *Type) Get() (item interface{}, shutdown bool) { q.cond.L.Lock() defer q.cond.L.Unlock() for len(q.queue) == 0 && !q.shuttingDown { q.cond.Wait() } if len(q.queue) == 0 { // We must be shutting down. return nil, true } item, q.queue = q.queue[0], q.queue[1:] q.processing.insert(item) q.dirty.delete(item) return item, false }
[ "func", "(", "q", "*", "Type", ")", "Get", "(", ")", "(", "item", "interface", "{", "}", ",", "shutdown", "bool", ")", "{", "q", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n", "for", "len", "(", "q", ".", "queue", ")", "==", "0", "&&", "!", "q", ".", "shuttingDown", "{", "q", ".", "cond", ".", "Wait", "(", ")", "\n", "}", "\n", "if", "len", "(", "q", ".", "queue", ")", "==", "0", "{", "// We must be shutting down.", "return", "nil", ",", "true", "\n", "}", "\n", "item", ",", "q", ".", "queue", "=", "q", ".", "queue", "[", "0", "]", ",", "q", ".", "queue", "[", "1", ":", "]", "\n", "q", ".", "processing", ".", "insert", "(", "item", ")", "\n", "q", ".", "dirty", ".", "delete", "(", "item", ")", "\n", "return", "item", ",", "false", "\n", "}" ]
// Get blocks until it can return an item to be processed. If shutdown = true, // the caller should end their goroutine. You must call Done with item when you // have finished processing it.
[ "Get", "blocks", "until", "it", "can", "return", "an", "item", "to", "be", "processed", ".", "If", "shutdown", "=", "true", "the", "caller", "should", "end", "their", "goroutine", ".", "You", "must", "call", "Done", "with", "item", "when", "you", "have", "finished", "processing", "it", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go#L100-L114
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go
Done
func (q *Type) Done(item interface{}) { q.cond.L.Lock() defer q.cond.L.Unlock() q.processing.delete(item) if q.dirty.has(item) { q.queue = append(q.queue, item) q.cond.Signal() } }
go
func (q *Type) Done(item interface{}) { q.cond.L.Lock() defer q.cond.L.Unlock() q.processing.delete(item) if q.dirty.has(item) { q.queue = append(q.queue, item) q.cond.Signal() } }
[ "func", "(", "q", "*", "Type", ")", "Done", "(", "item", "interface", "{", "}", ")", "{", "q", ".", "cond", ".", "L", ".", "Lock", "(", ")", "\n", "defer", "q", ".", "cond", ".", "L", ".", "Unlock", "(", ")", "\n", "q", ".", "processing", ".", "delete", "(", "item", ")", "\n", "if", "q", ".", "dirty", ".", "has", "(", "item", ")", "{", "q", ".", "queue", "=", "append", "(", "q", ".", "queue", ",", "item", ")", "\n", "q", ".", "cond", ".", "Signal", "(", ")", "\n", "}", "\n", "}" ]
// Done marks item as done processing, and if it has been marked as dirty again // while it was being processed, it will be re-added to the queue for // re-processing.
[ "Done", "marks", "item", "as", "done", "processing", "and", "if", "it", "has", "been", "marked", "as", "dirty", "again", "while", "it", "was", "being", "processed", "it", "will", "be", "re", "-", "added", "to", "the", "queue", "for", "re", "-", "processing", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/workqueue/queue.go#L119-L127
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/types.go
Object
func Object(encoder runtime.Encoder, event *watch.Event) (interface{}, error) { obj, ok := event.Object.(runtime.Object) if !ok { return nil, fmt.Errorf("the event object cannot be safely converted to JSON: %v", reflect.TypeOf(event.Object).Name()) } data, err := runtime.Encode(encoder, obj) if err != nil { return nil, err } return &WatchEvent{event.Type, runtime.RawExtension{RawJSON: json.RawMessage(data)}}, nil }
go
func Object(encoder runtime.Encoder, event *watch.Event) (interface{}, error) { obj, ok := event.Object.(runtime.Object) if !ok { return nil, fmt.Errorf("the event object cannot be safely converted to JSON: %v", reflect.TypeOf(event.Object).Name()) } data, err := runtime.Encode(encoder, obj) if err != nil { return nil, err } return &WatchEvent{event.Type, runtime.RawExtension{RawJSON: json.RawMessage(data)}}, nil }
[ "func", "Object", "(", "encoder", "runtime", ".", "Encoder", ",", "event", "*", "watch", ".", "Event", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "obj", ",", "ok", ":=", "event", ".", "Object", ".", "(", "runtime", ".", "Object", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "event", ".", "Object", ")", ".", "Name", "(", ")", ")", "\n", "}", "\n", "data", ",", "err", ":=", "runtime", ".", "Encode", "(", "encoder", ",", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "WatchEvent", "{", "event", ".", "Type", ",", "runtime", ".", "RawExtension", "{", "RawJSON", ":", "json", ".", "RawMessage", "(", "data", ")", "}", "}", ",", "nil", "\n", "}" ]
// Object converts a watch.Event into an appropriately serializable JSON object
[ "Object", "converts", "a", "watch", ".", "Event", "into", "an", "appropriately", "serializable", "JSON", "object" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/types.go#L43-L53
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/sdk.go
Client
func (c *SDKConfig) Client(ctx context.Context) *http.Client { return &http.Client{ Transport: &oauth2.Transport{ Source: c.TokenSource(ctx), }, } }
go
func (c *SDKConfig) Client(ctx context.Context) *http.Client { return &http.Client{ Transport: &oauth2.Transport{ Source: c.TokenSource(ctx), }, } }
[ "func", "(", "c", "*", "SDKConfig", ")", "Client", "(", "ctx", "context", ".", "Context", ")", "*", "http", ".", "Client", "{", "return", "&", "http", ".", "Client", "{", "Transport", ":", "&", "oauth2", ".", "Transport", "{", "Source", ":", "c", ".", "TokenSource", "(", "ctx", ")", ",", "}", ",", "}", "\n", "}" ]
// Client returns an HTTP client using Google Cloud SDK credentials to // authorize requests. The token will auto-refresh as necessary. The // underlying http.RoundTripper will be obtained using the provided // context. The returned client and its Transport should not be // modified.
[ "Client", "returns", "an", "HTTP", "client", "using", "Google", "Cloud", "SDK", "credentials", "to", "authorize", "requests", ".", "The", "token", "will", "auto", "-", "refresh", "as", "necessary", ".", "The", "underlying", "http", ".", "RoundTripper", "will", "be", "obtained", "using", "the", "provided", "context", ".", "The", "returned", "client", "and", "its", "Transport", "should", "not", "be", "modified", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/sdk.go#L127-L133
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/sdk.go
TokenSource
func (c *SDKConfig) TokenSource(ctx context.Context) oauth2.TokenSource { return c.conf.TokenSource(ctx, c.initialToken) }
go
func (c *SDKConfig) TokenSource(ctx context.Context) oauth2.TokenSource { return c.conf.TokenSource(ctx, c.initialToken) }
[ "func", "(", "c", "*", "SDKConfig", ")", "TokenSource", "(", "ctx", "context", ".", "Context", ")", "oauth2", ".", "TokenSource", "{", "return", "c", ".", "conf", ".", "TokenSource", "(", "ctx", ",", "c", ".", "initialToken", ")", "\n", "}" ]
// TokenSource returns an oauth2.TokenSource that retrieve tokens from // Google Cloud SDK credentials using the provided context. // It will returns the current access token stored in the credentials, // and refresh it when it expires, but it won't update the credentials // with the new access token.
[ "TokenSource", "returns", "an", "oauth2", ".", "TokenSource", "that", "retrieve", "tokens", "from", "Google", "Cloud", "SDK", "credentials", "using", "the", "provided", "context", ".", "It", "will", "returns", "the", "current", "access", "token", "stored", "in", "the", "credentials", "and", "refresh", "it", "when", "it", "expires", "but", "it", "won", "t", "update", "the", "credentials", "with", "the", "new", "access", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/google/sdk.go#L140-L142
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
skip
func skip(parser *yaml_parser_t) { parser.mark.index++ parser.mark.column++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) }
go
func skip(parser *yaml_parser_t) { parser.mark.index++ parser.mark.column++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) }
[ "func", "skip", "(", "parser", "*", "yaml_parser_t", ")", "{", "parser", ".", "mark", ".", "index", "++", "\n", "parser", ".", "mark", ".", "column", "++", "\n", "parser", ".", "unread", "--", "\n", "parser", ".", "buffer_pos", "+=", "width", "(", "parser", ".", "buffer", "[", "parser", ".", "buffer_pos", "]", ")", "\n", "}" ]
// Advance the buffer pointer.
[ "Advance", "the", "buffer", "pointer", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L491-L496
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
read
func read(parser *yaml_parser_t, s []byte) []byte { w := width(parser.buffer[parser.buffer_pos]) if w == 0 { panic("invalid character sequence") } if len(s) == 0 { s = make([]byte, 0, 32) } if w == 1 && len(s)+w <= cap(s) { s = s[:len(s)+1] s[len(s)-1] = parser.buffer[parser.buffer_pos] parser.buffer_pos++ } else { s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) parser.buffer_pos += w } parser.mark.index++ parser.mark.column++ parser.unread-- return s }
go
func read(parser *yaml_parser_t, s []byte) []byte { w := width(parser.buffer[parser.buffer_pos]) if w == 0 { panic("invalid character sequence") } if len(s) == 0 { s = make([]byte, 0, 32) } if w == 1 && len(s)+w <= cap(s) { s = s[:len(s)+1] s[len(s)-1] = parser.buffer[parser.buffer_pos] parser.buffer_pos++ } else { s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) parser.buffer_pos += w } parser.mark.index++ parser.mark.column++ parser.unread-- return s }
[ "func", "read", "(", "parser", "*", "yaml_parser_t", ",", "s", "[", "]", "byte", ")", "[", "]", "byte", "{", "w", ":=", "width", "(", "parser", ".", "buffer", "[", "parser", ".", "buffer_pos", "]", ")", "\n", "if", "w", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "s", ")", "==", "0", "{", "s", "=", "make", "(", "[", "]", "byte", ",", "0", ",", "32", ")", "\n", "}", "\n", "if", "w", "==", "1", "&&", "len", "(", "s", ")", "+", "w", "<=", "cap", "(", "s", ")", "{", "s", "=", "s", "[", ":", "len", "(", "s", ")", "+", "1", "]", "\n", "s", "[", "len", "(", "s", ")", "-", "1", "]", "=", "parser", ".", "buffer", "[", "parser", ".", "buffer_pos", "]", "\n", "parser", ".", "buffer_pos", "++", "\n", "}", "else", "{", "s", "=", "append", "(", "s", ",", "parser", ".", "buffer", "[", "parser", ".", "buffer_pos", ":", "parser", ".", "buffer_pos", "+", "w", "]", "...", ")", "\n", "parser", ".", "buffer_pos", "+=", "w", "\n", "}", "\n", "parser", ".", "mark", ".", "index", "++", "\n", "parser", ".", "mark", ".", "column", "++", "\n", "parser", ".", "unread", "--", "\n", "return", "s", "\n", "}" ]
// Copy a character to a string buffer and advance pointers.
[ "Copy", "a", "character", "to", "a", "string", "buffer", "and", "advance", "pointers", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L515-L535
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
read_line
func read_line(parser *yaml_parser_t, s []byte) []byte { buf := parser.buffer pos := parser.buffer_pos switch { case buf[pos] == '\r' && buf[pos+1] == '\n': // CR LF . LF s = append(s, '\n') parser.buffer_pos += 2 parser.mark.index++ parser.unread-- case buf[pos] == '\r' || buf[pos] == '\n': // CR|LF . LF s = append(s, '\n') parser.buffer_pos += 1 case buf[pos] == '\xC2' && buf[pos+1] == '\x85': // NEL . LF s = append(s, '\n') parser.buffer_pos += 2 case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): // LS|PS . LS|PS s = append(s, buf[parser.buffer_pos:pos+3]...) parser.buffer_pos += 3 default: return s } parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- return s }
go
func read_line(parser *yaml_parser_t, s []byte) []byte { buf := parser.buffer pos := parser.buffer_pos switch { case buf[pos] == '\r' && buf[pos+1] == '\n': // CR LF . LF s = append(s, '\n') parser.buffer_pos += 2 parser.mark.index++ parser.unread-- case buf[pos] == '\r' || buf[pos] == '\n': // CR|LF . LF s = append(s, '\n') parser.buffer_pos += 1 case buf[pos] == '\xC2' && buf[pos+1] == '\x85': // NEL . LF s = append(s, '\n') parser.buffer_pos += 2 case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): // LS|PS . LS|PS s = append(s, buf[parser.buffer_pos:pos+3]...) parser.buffer_pos += 3 default: return s } parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- return s }
[ "func", "read_line", "(", "parser", "*", "yaml_parser_t", ",", "s", "[", "]", "byte", ")", "[", "]", "byte", "{", "buf", ":=", "parser", ".", "buffer", "\n", "pos", ":=", "parser", ".", "buffer_pos", "\n", "switch", "{", "case", "buf", "[", "pos", "]", "==", "'\\r'", "&&", "buf", "[", "pos", "+", "1", "]", "==", "'\\n'", ":", "// CR LF . LF", "s", "=", "append", "(", "s", ",", "'\\n'", ")", "\n", "parser", ".", "buffer_pos", "+=", "2", "\n", "parser", ".", "mark", ".", "index", "++", "\n", "parser", ".", "unread", "--", "\n", "case", "buf", "[", "pos", "]", "==", "'\\r'", "||", "buf", "[", "pos", "]", "==", "'\\n'", ":", "// CR|LF . LF", "s", "=", "append", "(", "s", ",", "'\\n'", ")", "\n", "parser", ".", "buffer_pos", "+=", "1", "\n", "case", "buf", "[", "pos", "]", "==", "'\\xC2'", "&&", "buf", "[", "pos", "+", "1", "]", "==", "'\\x85'", ":", "// NEL . LF", "s", "=", "append", "(", "s", ",", "'\\n'", ")", "\n", "parser", ".", "buffer_pos", "+=", "2", "\n", "case", "buf", "[", "pos", "]", "==", "'\\xE2'", "&&", "buf", "[", "pos", "+", "1", "]", "==", "'\\x80'", "&&", "(", "buf", "[", "pos", "+", "2", "]", "==", "'\\xA8'", "||", "buf", "[", "pos", "+", "2", "]", "==", "'\\xA9'", ")", ":", "// LS|PS . LS|PS", "s", "=", "append", "(", "s", ",", "buf", "[", "parser", ".", "buffer_pos", ":", "pos", "+", "3", "]", "...", ")", "\n", "parser", ".", "buffer_pos", "+=", "3", "\n", "default", ":", "return", "s", "\n", "}", "\n", "parser", ".", "mark", ".", "index", "++", "\n", "parser", ".", "mark", ".", "column", "=", "0", "\n", "parser", ".", "mark", ".", "line", "++", "\n", "parser", ".", "unread", "--", "\n", "return", "s", "\n", "}" ]
// Copy a line break character to a string buffer and advance pointers.
[ "Copy", "a", "line", "break", "character", "to", "a", "string", "buffer", "and", "advance", "pointers", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L538-L568
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_scan
func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { // Erase the token object. *token = yaml_token_t{} // [Go] Is this necessary? // No tokens after STREAM-END or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR { return true } // Ensure that the tokens queue contains enough tokens. if !parser.token_available { if !yaml_parser_fetch_more_tokens(parser) { return false } } // Fetch the next token from the queue. *token = parser.tokens[parser.tokens_head] parser.tokens_head++ parser.tokens_parsed++ parser.token_available = false if token.typ == yaml_STREAM_END_TOKEN { parser.stream_end_produced = true } return true }
go
func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { // Erase the token object. *token = yaml_token_t{} // [Go] Is this necessary? // No tokens after STREAM-END or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR { return true } // Ensure that the tokens queue contains enough tokens. if !parser.token_available { if !yaml_parser_fetch_more_tokens(parser) { return false } } // Fetch the next token from the queue. *token = parser.tokens[parser.tokens_head] parser.tokens_head++ parser.tokens_parsed++ parser.token_available = false if token.typ == yaml_STREAM_END_TOKEN { parser.stream_end_produced = true } return true }
[ "func", "yaml_parser_scan", "(", "parser", "*", "yaml_parser_t", ",", "token", "*", "yaml_token_t", ")", "bool", "{", "// Erase the token object.", "*", "token", "=", "yaml_token_t", "{", "}", "// [Go] Is this necessary?", "\n\n", "// No tokens after STREAM-END or error.", "if", "parser", ".", "stream_end_produced", "||", "parser", ".", "error", "!=", "yaml_NO_ERROR", "{", "return", "true", "\n", "}", "\n\n", "// Ensure that the tokens queue contains enough tokens.", "if", "!", "parser", ".", "token_available", "{", "if", "!", "yaml_parser_fetch_more_tokens", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "// Fetch the next token from the queue.", "*", "token", "=", "parser", ".", "tokens", "[", "parser", ".", "tokens_head", "]", "\n", "parser", ".", "tokens_head", "++", "\n", "parser", ".", "tokens_parsed", "++", "\n", "parser", ".", "token_available", "=", "false", "\n\n", "if", "token", ".", "typ", "==", "yaml_STREAM_END_TOKEN", "{", "parser", ".", "stream_end_produced", "=", "true", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Get the next token.
[ "Get", "the", "next", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L571-L597
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_set_scanner_error
func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { parser.error = yaml_SCANNER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = parser.mark return false }
go
func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { parser.error = yaml_SCANNER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = parser.mark return false }
[ "func", "yaml_parser_set_scanner_error", "(", "parser", "*", "yaml_parser_t", ",", "context", "string", ",", "context_mark", "yaml_mark_t", ",", "problem", "string", ")", "bool", "{", "parser", ".", "error", "=", "yaml_SCANNER_ERROR", "\n", "parser", ".", "context", "=", "context", "\n", "parser", ".", "context_mark", "=", "context_mark", "\n", "parser", ".", "problem", "=", "problem", "\n", "parser", ".", "problem_mark", "=", "parser", ".", "mark", "\n", "return", "false", "\n", "}" ]
// Set the scanner error and return false.
[ "Set", "the", "scanner", "error", "and", "return", "false", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L600-L607
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_more_tokens
func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { // Check if we really need to fetch more tokens. need_more_tokens := false if parser.tokens_head == len(parser.tokens) { // Queue is empty. need_more_tokens = true } else { // Check if any potential simple key may occupy the head position. if !yaml_parser_stale_simple_keys(parser) { return false } for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] if simple_key.possible && simple_key.token_number == parser.tokens_parsed { need_more_tokens = true break } } } // We are finished. if !need_more_tokens { break } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false } } parser.token_available = true return true }
go
func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { // Check if we really need to fetch more tokens. need_more_tokens := false if parser.tokens_head == len(parser.tokens) { // Queue is empty. need_more_tokens = true } else { // Check if any potential simple key may occupy the head position. if !yaml_parser_stale_simple_keys(parser) { return false } for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] if simple_key.possible && simple_key.token_number == parser.tokens_parsed { need_more_tokens = true break } } } // We are finished. if !need_more_tokens { break } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false } } parser.token_available = true return true }
[ "func", "yaml_parser_fetch_more_tokens", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// While we need more tokens to fetch, do it.", "for", "{", "// Check if we really need to fetch more tokens.", "need_more_tokens", ":=", "false", "\n\n", "if", "parser", ".", "tokens_head", "==", "len", "(", "parser", ".", "tokens", ")", "{", "// Queue is empty.", "need_more_tokens", "=", "true", "\n", "}", "else", "{", "// Check if any potential simple key may occupy the head position.", "if", "!", "yaml_parser_stale_simple_keys", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "for", "i", ":=", "range", "parser", ".", "simple_keys", "{", "simple_key", ":=", "&", "parser", ".", "simple_keys", "[", "i", "]", "\n", "if", "simple_key", ".", "possible", "&&", "simple_key", ".", "token_number", "==", "parser", ".", "tokens_parsed", "{", "need_more_tokens", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// We are finished.", "if", "!", "need_more_tokens", "{", "break", "\n", "}", "\n", "// Fetch the next token.", "if", "!", "yaml_parser_fetch_next_token", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "parser", ".", "token_available", "=", "true", "\n", "return", "true", "\n", "}" ]
// Ensure that the tokens queue contains at least one token which can be // returned to the Parser.
[ "Ensure", "that", "the", "tokens", "queue", "contains", "at", "least", "one", "token", "which", "can", "be", "returned", "to", "the", "Parser", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L626-L662
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_stale_simple_keys
func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { // Check for a potential simple key for each flow level. for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] // The specification requires that a simple key // // - is limited to a single line, // - is shorter than 1024 characters. if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { // Check if the potential simple key to be removed is required. if simple_key.required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", simple_key.mark, "could not find expected ':'") } simple_key.possible = false } } return true }
go
func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { // Check for a potential simple key for each flow level. for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] // The specification requires that a simple key // // - is limited to a single line, // - is shorter than 1024 characters. if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { // Check if the potential simple key to be removed is required. if simple_key.required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", simple_key.mark, "could not find expected ':'") } simple_key.possible = false } } return true }
[ "func", "yaml_parser_stale_simple_keys", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Check for a potential simple key for each flow level.", "for", "i", ":=", "range", "parser", ".", "simple_keys", "{", "simple_key", ":=", "&", "parser", ".", "simple_keys", "[", "i", "]", "\n\n", "// The specification requires that a simple key", "//", "// - is limited to a single line,", "// - is shorter than 1024 characters.", "if", "simple_key", ".", "possible", "&&", "(", "simple_key", ".", "mark", ".", "line", "<", "parser", ".", "mark", ".", "line", "||", "simple_key", ".", "mark", ".", "index", "+", "1024", "<", "parser", ".", "mark", ".", "index", ")", "{", "// Check if the potential simple key to be removed is required.", "if", "simple_key", ".", "required", "{", "return", "yaml_parser_set_scanner_error", "(", "parser", ",", "\"", "\"", ",", "simple_key", ".", "mark", ",", "\"", "\"", ")", "\n", "}", "\n", "simple_key", ".", "possible", "=", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Check the list of potential simple keys and remove the positions that // cannot contain simple keys anymore.
[ "Check", "the", "list", "of", "potential", "simple", "keys", "and", "remove", "the", "positions", "that", "cannot", "contain", "simple", "keys", "anymore", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L842-L863
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_remove_simple_key
func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { i := len(parser.simple_keys) - 1 if parser.simple_keys[i].possible { // If the key is required, it is an error. if parser.simple_keys[i].required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } } // Remove the key from the stack. parser.simple_keys[i].possible = false return true }
go
func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { i := len(parser.simple_keys) - 1 if parser.simple_keys[i].possible { // If the key is required, it is an error. if parser.simple_keys[i].required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } } // Remove the key from the stack. parser.simple_keys[i].possible = false return true }
[ "func", "yaml_parser_remove_simple_key", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "i", ":=", "len", "(", "parser", ".", "simple_keys", ")", "-", "1", "\n", "if", "parser", ".", "simple_keys", "[", "i", "]", ".", "possible", "{", "// If the key is required, it is an error.", "if", "parser", ".", "simple_keys", "[", "i", "]", ".", "required", "{", "return", "yaml_parser_set_scanner_error", "(", "parser", ",", "\"", "\"", ",", "parser", ".", "simple_keys", "[", "i", "]", ".", "mark", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "// Remove the key from the stack.", "parser", ".", "simple_keys", "[", "i", "]", ".", "possible", "=", "false", "\n", "return", "true", "\n", "}" ]
// Remove a potential simple key at the current flow level.
[ "Remove", "a", "potential", "simple", "key", "at", "the", "current", "flow", "level", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L900-L913
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_increase_flow_level
func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // Increase the flow level. parser.flow_level++ return true }
go
func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // Increase the flow level. parser.flow_level++ return true }
[ "func", "yaml_parser_increase_flow_level", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Reset the simple key on the next level.", "parser", ".", "simple_keys", "=", "append", "(", "parser", ".", "simple_keys", ",", "yaml_simple_key_t", "{", "}", ")", "\n\n", "// Increase the flow level.", "parser", ".", "flow_level", "++", "\n", "return", "true", "\n", "}" ]
// Increase the flow level and resize the simple key list if needed.
[ "Increase", "the", "flow", "level", "and", "resize", "the", "simple", "key", "list", "if", "needed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L916-L923
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_decrease_flow_level
func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] } return true }
go
func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] } return true }
[ "func", "yaml_parser_decrease_flow_level", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "if", "parser", ".", "flow_level", ">", "0", "{", "parser", ".", "flow_level", "--", "\n", "parser", ".", "simple_keys", "=", "parser", ".", "simple_keys", "[", ":", "len", "(", "parser", ".", "simple_keys", ")", "-", "1", "]", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Decrease the flow level.
[ "Decrease", "the", "flow", "level", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L926-L932
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_roll_indent
func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } if parser.indent < column { // Push the current indentation level to the stack and set the new // indentation level. parser.indents = append(parser.indents, parser.indent) parser.indent = column // Create a token and insert it into the queue. token := yaml_token_t{ typ: typ, start_mark: mark, end_mark: mark, } if number > -1 { number -= parser.tokens_parsed } yaml_insert_token(parser, number, &token) } return true }
go
func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } if parser.indent < column { // Push the current indentation level to the stack and set the new // indentation level. parser.indents = append(parser.indents, parser.indent) parser.indent = column // Create a token and insert it into the queue. token := yaml_token_t{ typ: typ, start_mark: mark, end_mark: mark, } if number > -1 { number -= parser.tokens_parsed } yaml_insert_token(parser, number, &token) } return true }
[ "func", "yaml_parser_roll_indent", "(", "parser", "*", "yaml_parser_t", ",", "column", ",", "number", "int", ",", "typ", "yaml_token_type_t", ",", "mark", "yaml_mark_t", ")", "bool", "{", "// In the flow context, do nothing.", "if", "parser", ".", "flow_level", ">", "0", "{", "return", "true", "\n", "}", "\n\n", "if", "parser", ".", "indent", "<", "column", "{", "// Push the current indentation level to the stack and set the new", "// indentation level.", "parser", ".", "indents", "=", "append", "(", "parser", ".", "indents", ",", "parser", ".", "indent", ")", "\n", "parser", ".", "indent", "=", "column", "\n\n", "// Create a token and insert it into the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "typ", ",", "start_mark", ":", "mark", ",", "end_mark", ":", "mark", ",", "}", "\n", "if", "number", ">", "-", "1", "{", "number", "-=", "parser", ".", "tokens_parsed", "\n", "}", "\n", "yaml_insert_token", "(", "parser", ",", "number", ",", "&", "token", ")", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Push the current indentation level to the stack and set the new level // the current column is greater than the indentation level. In this case, // append or insert the specified token into the token queue.
[ "Push", "the", "current", "indentation", "level", "to", "the", "stack", "and", "set", "the", "new", "level", "the", "current", "column", "is", "greater", "than", "the", "indentation", "level", ".", "In", "this", "case", "append", "or", "insert", "the", "specified", "token", "into", "the", "token", "queue", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L937-L961
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_unroll_indent
func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } // Loop through the intendation levels in the stack. for parser.indent > column { // Create a token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) // Pop the indentation level. parser.indent = parser.indents[len(parser.indents)-1] parser.indents = parser.indents[:len(parser.indents)-1] } return true }
go
func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } // Loop through the intendation levels in the stack. for parser.indent > column { // Create a token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) // Pop the indentation level. parser.indent = parser.indents[len(parser.indents)-1] parser.indents = parser.indents[:len(parser.indents)-1] } return true }
[ "func", "yaml_parser_unroll_indent", "(", "parser", "*", "yaml_parser_t", ",", "column", "int", ")", "bool", "{", "// In the flow context, do nothing.", "if", "parser", ".", "flow_level", ">", "0", "{", "return", "true", "\n", "}", "\n\n", "// Loop through the intendation levels in the stack.", "for", "parser", ".", "indent", ">", "column", "{", "// Create a token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_BLOCK_END_TOKEN", ",", "start_mark", ":", "parser", ".", "mark", ",", "end_mark", ":", "parser", ".", "mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n\n", "// Pop the indentation level.", "parser", ".", "indent", "=", "parser", ".", "indents", "[", "len", "(", "parser", ".", "indents", ")", "-", "1", "]", "\n", "parser", ".", "indents", "=", "parser", ".", "indents", "[", ":", "len", "(", "parser", ".", "indents", ")", "-", "1", "]", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Pop indentation levels from the indents stack until the current level // becomes less or equal to the column. For each intendation level, append // the BLOCK-END token.
[ "Pop", "indentation", "levels", "from", "the", "indents", "stack", "until", "the", "current", "level", "becomes", "less", "or", "equal", "to", "the", "column", ".", "For", "each", "intendation", "level", "append", "the", "BLOCK", "-", "END", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L966-L987
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_stream_start
func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { // Set the initial indentation. parser.indent = -1 // Initialize the simple key stack. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // A simple key is allowed at the beginning of the stream. parser.simple_key_allowed = true // We have started. parser.stream_start_produced = true // Create the STREAM-START token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_START_TOKEN, start_mark: parser.mark, end_mark: parser.mark, encoding: parser.encoding, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { // Set the initial indentation. parser.indent = -1 // Initialize the simple key stack. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // A simple key is allowed at the beginning of the stream. parser.simple_key_allowed = true // We have started. parser.stream_start_produced = true // Create the STREAM-START token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_START_TOKEN, start_mark: parser.mark, end_mark: parser.mark, encoding: parser.encoding, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_stream_start", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Set the initial indentation.", "parser", ".", "indent", "=", "-", "1", "\n\n", "// Initialize the simple key stack.", "parser", ".", "simple_keys", "=", "append", "(", "parser", ".", "simple_keys", ",", "yaml_simple_key_t", "{", "}", ")", "\n\n", "// A simple key is allowed at the beginning of the stream.", "parser", ".", "simple_key_allowed", "=", "true", "\n\n", "// We have started.", "parser", ".", "stream_start_produced", "=", "true", "\n\n", "// Create the STREAM-START token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_STREAM_START_TOKEN", ",", "start_mark", ":", "parser", ".", "mark", ",", "end_mark", ":", "parser", ".", "mark", ",", "encoding", ":", "parser", ".", "encoding", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Initialize the scanner and produce the STREAM-START token.
[ "Initialize", "the", "scanner", "and", "produce", "the", "STREAM", "-", "START", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L990-L1013
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_stream_end
func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { // Force new line. if parser.mark.column != 0 { parser.mark.column = 0 parser.mark.line++ } // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the STREAM-END token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { // Force new line. if parser.mark.column != 0 { parser.mark.column = 0 parser.mark.line++ } // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the STREAM-END token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_stream_end", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Force new line.", "if", "parser", ".", "mark", ".", "column", "!=", "0", "{", "parser", ".", "mark", ".", "column", "=", "0", "\n", "parser", ".", "mark", ".", "line", "++", "\n", "}", "\n\n", "// Reset the indentation level.", "if", "!", "yaml_parser_unroll_indent", "(", "parser", ",", "-", "1", ")", "{", "return", "false", "\n", "}", "\n\n", "// Reset simple keys.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "parser", ".", "simple_key_allowed", "=", "false", "\n\n", "// Create the STREAM-END token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_STREAM_END_TOKEN", ",", "start_mark", ":", "parser", ".", "mark", ",", "end_mark", ":", "parser", ".", "mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the STREAM-END token and shut down the scanner.
[ "Produce", "the", "STREAM", "-", "END", "token", "and", "shut", "down", "the", "scanner", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1016-L1044
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_directive
func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. token := yaml_token_t{} if !yaml_parser_scan_directive(parser, &token) { return false } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. token := yaml_token_t{} if !yaml_parser_scan_directive(parser, &token) { return false } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_directive", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Reset the indentation level.", "if", "!", "yaml_parser_unroll_indent", "(", "parser", ",", "-", "1", ")", "{", "return", "false", "\n", "}", "\n\n", "// Reset simple keys.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "parser", ".", "simple_key_allowed", "=", "false", "\n\n", "// Create the YAML-DIRECTIVE or TAG-DIRECTIVE token.", "token", ":=", "yaml_token_t", "{", "}", "\n", "if", "!", "yaml_parser_scan_directive", "(", "parser", ",", "&", "token", ")", "{", "return", "false", "\n", "}", "\n", "// Append the token to the queue.", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
[ "Produce", "a", "VERSION", "-", "DIRECTIVE", "or", "TAG", "-", "DIRECTIVE", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1047-L1068
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_document_indicator
func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Consume the token. start_mark := parser.mark skip(parser) skip(parser) skip(parser) end_mark := parser.mark // Create the DOCUMENT-START or DOCUMENT-END token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Consume the token. start_mark := parser.mark skip(parser) skip(parser) skip(parser) end_mark := parser.mark // Create the DOCUMENT-START or DOCUMENT-END token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_document_indicator", "(", "parser", "*", "yaml_parser_t", ",", "typ", "yaml_token_type_t", ")", "bool", "{", "// Reset the indentation level.", "if", "!", "yaml_parser_unroll_indent", "(", "parser", ",", "-", "1", ")", "{", "return", "false", "\n", "}", "\n\n", "// Reset simple keys.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "parser", ".", "simple_key_allowed", "=", "false", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n\n", "skip", "(", "parser", ")", "\n", "skip", "(", "parser", ")", "\n", "skip", "(", "parser", ")", "\n\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the DOCUMENT-START or DOCUMENT-END token.", "token", ":=", "yaml_token_t", "{", "typ", ":", "typ", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "// Append the token to the queue.", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the DOCUMENT-START or DOCUMENT-END token.
[ "Produce", "the", "DOCUMENT", "-", "START", "or", "DOCUMENT", "-", "END", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1071-L1102
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_flow_collection_start
func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { // The indicators '[' and '{' may start a simple key. if !yaml_parser_save_simple_key(parser) { return false } // Increase the flow level. if !yaml_parser_increase_flow_level(parser) { return false } // A simple key may follow the indicators '[' and '{'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { // The indicators '[' and '{' may start a simple key. if !yaml_parser_save_simple_key(parser) { return false } // Increase the flow level. if !yaml_parser_increase_flow_level(parser) { return false } // A simple key may follow the indicators '[' and '{'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_flow_collection_start", "(", "parser", "*", "yaml_parser_t", ",", "typ", "yaml_token_type_t", ")", "bool", "{", "// The indicators '[' and '{' may start a simple key.", "if", "!", "yaml_parser_save_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "// Increase the flow level.", "if", "!", "yaml_parser_increase_flow_level", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "// A simple key may follow the indicators '[' and '{'.", "parser", ".", "simple_key_allowed", "=", "true", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n", "skip", "(", "parser", ")", "\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token.", "token", ":=", "yaml_token_t", "{", "typ", ":", "typ", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "// Append the token to the queue.", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
[ "Produce", "the", "FLOW", "-", "SEQUENCE", "-", "START", "or", "FLOW", "-", "MAPPING", "-", "START", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1105-L1133
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_flow_entry
func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after ','. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_FLOW_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after ','. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_FLOW_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_flow_entry", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Reset any potential simple keys on the current flow level.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "// Simple keys are allowed after ','.", "parser", ".", "simple_key_allowed", "=", "true", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n", "skip", "(", "parser", ")", "\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the FLOW-ENTRY token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_FLOW_ENTRY_TOKEN", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the FLOW-ENTRY token.
[ "Produce", "the", "FLOW", "-", "ENTRY", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1168-L1190
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_block_entry
func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { // Check if the scanner is in the block context. if parser.flow_level == 0 { // Check if we are allowed to start a new entry. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "block sequence entries are not allowed in this context") } // Add the BLOCK-SEQUENCE-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { return false } } else { // It is an error for the '-' indicator to occur in the flow context, // but we let the Parser detect and report about it because the Parser // is able to point to the context. } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '-'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the BLOCK-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { // Check if the scanner is in the block context. if parser.flow_level == 0 { // Check if we are allowed to start a new entry. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "block sequence entries are not allowed in this context") } // Add the BLOCK-SEQUENCE-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { return false } } else { // It is an error for the '-' indicator to occur in the flow context, // but we let the Parser detect and report about it because the Parser // is able to point to the context. } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '-'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the BLOCK-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_block_entry", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// Check if the scanner is in the block context.", "if", "parser", ".", "flow_level", "==", "0", "{", "// Check if we are allowed to start a new entry.", "if", "!", "parser", ".", "simple_key_allowed", "{", "return", "yaml_parser_set_scanner_error", "(", "parser", ",", "\"", "\"", ",", "parser", ".", "mark", ",", "\"", "\"", ")", "\n", "}", "\n", "// Add the BLOCK-SEQUENCE-START token if needed.", "if", "!", "yaml_parser_roll_indent", "(", "parser", ",", "parser", ".", "mark", ".", "column", ",", "-", "1", ",", "yaml_BLOCK_SEQUENCE_START_TOKEN", ",", "parser", ".", "mark", ")", "{", "return", "false", "\n", "}", "\n", "}", "else", "{", "// It is an error for the '-' indicator to occur in the flow context,", "// but we let the Parser detect and report about it because the Parser", "// is able to point to the context.", "}", "\n\n", "// Reset any potential simple keys on the current flow level.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "// Simple keys are allowed after '-'.", "parser", ".", "simple_key_allowed", "=", "true", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n", "skip", "(", "parser", ")", "\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the BLOCK-ENTRY token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_BLOCK_ENTRY_TOKEN", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the BLOCK-ENTRY token.
[ "Produce", "the", "BLOCK", "-", "ENTRY", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1193-L1232
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_key
func yaml_parser_fetch_key(parser *yaml_parser_t) bool { // In the block context, additional checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a new key (not nessesary simple). if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping keys are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '?' in the block context. parser.simple_key_allowed = parser.flow_level == 0 // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the KEY token and append it to the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_key(parser *yaml_parser_t) bool { // In the block context, additional checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a new key (not nessesary simple). if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping keys are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '?' in the block context. parser.simple_key_allowed = parser.flow_level == 0 // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the KEY token and append it to the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_key", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "// In the block context, additional checks are required.", "if", "parser", ".", "flow_level", "==", "0", "{", "// Check if we are allowed to start a new key (not nessesary simple).", "if", "!", "parser", ".", "simple_key_allowed", "{", "return", "yaml_parser_set_scanner_error", "(", "parser", ",", "\"", "\"", ",", "parser", ".", "mark", ",", "\"", "\"", ")", "\n", "}", "\n", "// Add the BLOCK-MAPPING-START token if needed.", "if", "!", "yaml_parser_roll_indent", "(", "parser", ",", "parser", ".", "mark", ".", "column", ",", "-", "1", ",", "yaml_BLOCK_MAPPING_START_TOKEN", ",", "parser", ".", "mark", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "// Reset any potential simple keys on the current flow level.", "if", "!", "yaml_parser_remove_simple_key", "(", "parser", ")", "{", "return", "false", "\n", "}", "\n\n", "// Simple keys are allowed after '?' in the block context.", "parser", ".", "simple_key_allowed", "=", "parser", ".", "flow_level", "==", "0", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n", "skip", "(", "parser", ")", "\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the KEY token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_KEY_TOKEN", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the KEY token.
[ "Produce", "the", "KEY", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1235-L1271
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go
yaml_parser_fetch_value
func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? if simple_key.possible { // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: simple_key.mark, end_mark: simple_key.mark, } yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) // In the block context, we may need to add the BLOCK-MAPPING-START token. if !yaml_parser_roll_indent(parser, simple_key.mark.column, simple_key.token_number, yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { return false } // Remove the simple key. simple_key.possible = false // A simple key cannot follow another simple key. parser.simple_key_allowed = false } else { // The ':' indicator follows a complex key. // In the block context, extra checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a complex value. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping values are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Simple keys after ':' are allowed in the block context. parser.simple_key_allowed = parser.flow_level == 0 } // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the VALUE token and append it to the queue. token := yaml_token_t{ typ: yaml_VALUE_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
go
func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? if simple_key.possible { // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: simple_key.mark, end_mark: simple_key.mark, } yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) // In the block context, we may need to add the BLOCK-MAPPING-START token. if !yaml_parser_roll_indent(parser, simple_key.mark.column, simple_key.token_number, yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { return false } // Remove the simple key. simple_key.possible = false // A simple key cannot follow another simple key. parser.simple_key_allowed = false } else { // The ':' indicator follows a complex key. // In the block context, extra checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a complex value. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping values are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Simple keys after ':' are allowed in the block context. parser.simple_key_allowed = parser.flow_level == 0 } // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the VALUE token and append it to the queue. token := yaml_token_t{ typ: yaml_VALUE_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true }
[ "func", "yaml_parser_fetch_value", "(", "parser", "*", "yaml_parser_t", ")", "bool", "{", "simple_key", ":=", "&", "parser", ".", "simple_keys", "[", "len", "(", "parser", ".", "simple_keys", ")", "-", "1", "]", "\n\n", "// Have we found a simple key?", "if", "simple_key", ".", "possible", "{", "// Create the KEY token and insert it into the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_KEY_TOKEN", ",", "start_mark", ":", "simple_key", ".", "mark", ",", "end_mark", ":", "simple_key", ".", "mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "simple_key", ".", "token_number", "-", "parser", ".", "tokens_parsed", ",", "&", "token", ")", "\n\n", "// In the block context, we may need to add the BLOCK-MAPPING-START token.", "if", "!", "yaml_parser_roll_indent", "(", "parser", ",", "simple_key", ".", "mark", ".", "column", ",", "simple_key", ".", "token_number", ",", "yaml_BLOCK_MAPPING_START_TOKEN", ",", "simple_key", ".", "mark", ")", "{", "return", "false", "\n", "}", "\n\n", "// Remove the simple key.", "simple_key", ".", "possible", "=", "false", "\n\n", "// A simple key cannot follow another simple key.", "parser", ".", "simple_key_allowed", "=", "false", "\n\n", "}", "else", "{", "// The ':' indicator follows a complex key.", "// In the block context, extra checks are required.", "if", "parser", ".", "flow_level", "==", "0", "{", "// Check if we are allowed to start a complex value.", "if", "!", "parser", ".", "simple_key_allowed", "{", "return", "yaml_parser_set_scanner_error", "(", "parser", ",", "\"", "\"", ",", "parser", ".", "mark", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Add the BLOCK-MAPPING-START token if needed.", "if", "!", "yaml_parser_roll_indent", "(", "parser", ",", "parser", ".", "mark", ".", "column", ",", "-", "1", ",", "yaml_BLOCK_MAPPING_START_TOKEN", ",", "parser", ".", "mark", ")", "{", "return", "false", "\n", "}", "\n", "}", "\n\n", "// Simple keys after ':' are allowed in the block context.", "parser", ".", "simple_key_allowed", "=", "parser", ".", "flow_level", "==", "0", "\n", "}", "\n\n", "// Consume the token.", "start_mark", ":=", "parser", ".", "mark", "\n", "skip", "(", "parser", ")", "\n", "end_mark", ":=", "parser", ".", "mark", "\n\n", "// Create the VALUE token and append it to the queue.", "token", ":=", "yaml_token_t", "{", "typ", ":", "yaml_VALUE_TOKEN", ",", "start_mark", ":", "start_mark", ",", "end_mark", ":", "end_mark", ",", "}", "\n", "yaml_insert_token", "(", "parser", ",", "-", "1", ",", "&", "token", ")", "\n", "return", "true", "\n", "}" ]
// Produce the VALUE token.
[ "Produce", "the", "VALUE", "token", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/scannerc.go#L1274-L1336
train