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
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go
ConvertFieldLabel
func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { if s.fieldLabelConversionFuncs[version] == nil { return "", "", fmt.Errorf("No field label conversion function found for version: %s", version) } conversionFunc, ok := s.fieldLabelConversionFuncs[version][kind] if !ok { return "", "", fmt.Errorf("No field label conversion function found for version %s and kind %s", version, kind) } return conversionFunc(label, value) }
go
func (s *Scheme) ConvertFieldLabel(version, kind, label, value string) (string, string, error) { if s.fieldLabelConversionFuncs[version] == nil { return "", "", fmt.Errorf("No field label conversion function found for version: %s", version) } conversionFunc, ok := s.fieldLabelConversionFuncs[version][kind] if !ok { return "", "", fmt.Errorf("No field label conversion function found for version %s and kind %s", version, kind) } return conversionFunc(label, value) }
[ "func", "(", "s", "*", "Scheme", ")", "ConvertFieldLabel", "(", "version", ",", "kind", ",", "label", ",", "value", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "if", "s", ".", "fieldLabelConversionFuncs", "[", "version", "]", "==", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "version", ")", "\n", "}", "\n", "conversionFunc", ",", "ok", ":=", "s", ".", "fieldLabelConversionFuncs", "[", "version", "]", "[", "kind", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "version", ",", "kind", ")", "\n", "}", "\n", "return", "conversionFunc", "(", "label", ",", "value", ")", "\n", "}" ]
// Converts the given field label and value for an kind field selector from // versioned representation to an unversioned one.
[ "Converts", "the", "given", "field", "label", "and", "value", "for", "an", "kind", "field", "selector", "from", "versioned", "representation", "to", "an", "unversioned", "one", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/scheme.go#L455-L464
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/factory.go
BindFlags
func (f *Factory) BindFlags(flags *pflag.FlagSet) { // any flags defined by external projects (not part of pflags) flags.AddGoFlagSet(flag.CommandLine) // Merge factory's flags flags.AddFlagSet(f.flags) // Globally persistent flags across all subcommands. // TODO Change flag names to consts to allow safer lookup from subcommands. // TODO Add a verbose flag that turns on glog logging. Probably need a way // to do that automatically for every subcommand. flags.BoolVar(&f.clients.matchVersion, FlagMatchBinaryVersion, false, "Require server version to match client version") // Normalize all flags that are coming from other packages or pre-configurations // a.k.a. change all "_" to "-". e.g. glog package flags.SetNormalizeFunc(util.WordSepNormalizeFunc) }
go
func (f *Factory) BindFlags(flags *pflag.FlagSet) { // any flags defined by external projects (not part of pflags) flags.AddGoFlagSet(flag.CommandLine) // Merge factory's flags flags.AddFlagSet(f.flags) // Globally persistent flags across all subcommands. // TODO Change flag names to consts to allow safer lookup from subcommands. // TODO Add a verbose flag that turns on glog logging. Probably need a way // to do that automatically for every subcommand. flags.BoolVar(&f.clients.matchVersion, FlagMatchBinaryVersion, false, "Require server version to match client version") // Normalize all flags that are coming from other packages or pre-configurations // a.k.a. change all "_" to "-". e.g. glog package flags.SetNormalizeFunc(util.WordSepNormalizeFunc) }
[ "func", "(", "f", "*", "Factory", ")", "BindFlags", "(", "flags", "*", "pflag", ".", "FlagSet", ")", "{", "// any flags defined by external projects (not part of pflags)", "flags", ".", "AddGoFlagSet", "(", "flag", ".", "CommandLine", ")", "\n\n", "// Merge factory's flags", "flags", ".", "AddFlagSet", "(", "f", ".", "flags", ")", "\n\n", "// Globally persistent flags across all subcommands.", "// TODO Change flag names to consts to allow safer lookup from subcommands.", "// TODO Add a verbose flag that turns on glog logging. Probably need a way", "// to do that automatically for every subcommand.", "flags", ".", "BoolVar", "(", "&", "f", ".", "clients", ".", "matchVersion", ",", "FlagMatchBinaryVersion", ",", "false", ",", "\"", "\"", ")", "\n\n", "// Normalize all flags that are coming from other packages or pre-configurations", "// a.k.a. change all \"_\" to \"-\". e.g. glog package", "flags", ".", "SetNormalizeFunc", "(", "util", ".", "WordSepNormalizeFunc", ")", "\n", "}" ]
// BindFlags adds any flags that are common to all kubectl sub commands.
[ "BindFlags", "adds", "any", "flags", "that", "are", "common", "to", "all", "kubectl", "sub", "commands", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/factory.go#L569-L585
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/factory.go
NewBuilder
func (f *Factory) NewBuilder() *resource.Builder { mapper, typer := f.Object() return resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)) }
go
func (f *Factory) NewBuilder() *resource.Builder { mapper, typer := f.Object() return resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)) }
[ "func", "(", "f", "*", "Factory", ")", "NewBuilder", "(", ")", "*", "resource", ".", "Builder", "{", "mapper", ",", "typer", ":=", "f", ".", "Object", "(", ")", "\n\n", "return", "resource", ".", "NewBuilder", "(", "mapper", ",", "typer", ",", "resource", ".", "ClientMapperFunc", "(", "f", ".", "ClientForMapping", ")", ",", "f", ".", "Decoder", "(", "true", ")", ")", "\n", "}" ]
// One stop shopping for a Builder
[ "One", "stop", "shopping", "for", "a", "Builder" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/factory.go#L848-L852
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
List
func (s storePodsNamespacer) List(selector labels.Selector) (pods api.PodList, err error) { list := api.PodList{} for _, m := range s.store.List() { pod := m.(*api.Pod) if s.namespace == api.NamespaceAll || s.namespace == pod.Namespace { if selector.Matches(labels.Set(pod.Labels)) { list.Items = append(list.Items, *pod) } } } return list, nil }
go
func (s storePodsNamespacer) List(selector labels.Selector) (pods api.PodList, err error) { list := api.PodList{} for _, m := range s.store.List() { pod := m.(*api.Pod) if s.namespace == api.NamespaceAll || s.namespace == pod.Namespace { if selector.Matches(labels.Set(pod.Labels)) { list.Items = append(list.Items, *pod) } } } return list, nil }
[ "func", "(", "s", "storePodsNamespacer", ")", "List", "(", "selector", "labels", ".", "Selector", ")", "(", "pods", "api", ".", "PodList", ",", "err", "error", ")", "{", "list", ":=", "api", ".", "PodList", "{", "}", "\n", "for", "_", ",", "m", ":=", "range", "s", ".", "store", ".", "List", "(", ")", "{", "pod", ":=", "m", ".", "(", "*", "api", ".", "Pod", ")", "\n", "if", "s", ".", "namespace", "==", "api", ".", "NamespaceAll", "||", "s", ".", "namespace", "==", "pod", ".", "Namespace", "{", "if", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "pod", ".", "Labels", ")", ")", "{", "list", ".", "Items", "=", "append", "(", "list", ".", "Items", ",", "*", "pod", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "list", ",", "nil", "\n", "}" ]
// Please note that selector is filtering among the pods that have gotten into // the store; there may have been some filtering that already happened before // that.
[ "Please", "note", "that", "selector", "is", "filtering", "among", "the", "pods", "that", "have", "gotten", "into", "the", "store", ";", "there", "may", "have", "been", "some", "filtering", "that", "already", "happened", "before", "that", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L77-L88
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
NodeCondition
func (s *StoreToNodeLister) NodeCondition(predicate NodeConditionPredicate) storeToNodeConditionLister { // TODO: Move this filtering server side. Currently our selectors don't facilitate searching through a list so we // have the reflector filter out the Unschedulable field and sift through node conditions in the lister. return storeToNodeConditionLister{s.Store, predicate} }
go
func (s *StoreToNodeLister) NodeCondition(predicate NodeConditionPredicate) storeToNodeConditionLister { // TODO: Move this filtering server side. Currently our selectors don't facilitate searching through a list so we // have the reflector filter out the Unschedulable field and sift through node conditions in the lister. return storeToNodeConditionLister{s.Store, predicate} }
[ "func", "(", "s", "*", "StoreToNodeLister", ")", "NodeCondition", "(", "predicate", "NodeConditionPredicate", ")", "storeToNodeConditionLister", "{", "// TODO: Move this filtering server side. Currently our selectors don't facilitate searching through a list so we", "// have the reflector filter out the Unschedulable field and sift through node conditions in the lister.", "return", "storeToNodeConditionLister", "{", "s", ".", "Store", ",", "predicate", "}", "\n", "}" ]
// NodeCondition returns a storeToNodeConditionLister
[ "NodeCondition", "returns", "a", "storeToNodeConditionLister" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L117-L121
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
List
func (s storeToNodeConditionLister) List() (nodes api.NodeList, err error) { for _, m := range s.store.List() { node := *m.(*api.Node) if s.predicate(node) { nodes.Items = append(nodes.Items, node) } else { glog.V(5).Infof("Node %s matches none of the conditions", node.Name) } } return }
go
func (s storeToNodeConditionLister) List() (nodes api.NodeList, err error) { for _, m := range s.store.List() { node := *m.(*api.Node) if s.predicate(node) { nodes.Items = append(nodes.Items, node) } else { glog.V(5).Infof("Node %s matches none of the conditions", node.Name) } } return }
[ "func", "(", "s", "storeToNodeConditionLister", ")", "List", "(", ")", "(", "nodes", "api", ".", "NodeList", ",", "err", "error", ")", "{", "for", "_", ",", "m", ":=", "range", "s", ".", "store", ".", "List", "(", ")", "{", "node", ":=", "*", "m", ".", "(", "*", "api", ".", "Node", ")", "\n", "if", "s", ".", "predicate", "(", "node", ")", "{", "nodes", ".", "Items", "=", "append", "(", "nodes", ".", "Items", ",", "node", ")", "\n", "}", "else", "{", "glog", ".", "V", "(", "5", ")", ".", "Infof", "(", "\"", "\"", ",", "node", ".", "Name", ")", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// List returns a list of nodes that match the conditions defined by the predicate functions in the storeToNodeConditionLister.
[ "List", "returns", "a", "list", "of", "nodes", "that", "match", "the", "conditions", "defined", "by", "the", "predicate", "functions", "in", "the", "storeToNodeConditionLister", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L130-L140
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
Exists
func (s *StoreToReplicationControllerLister) Exists(controller *api.ReplicationController) (bool, error) { _, exists, err := s.Store.Get(controller) if err != nil { return false, err } return exists, nil }
go
func (s *StoreToReplicationControllerLister) Exists(controller *api.ReplicationController) (bool, error) { _, exists, err := s.Store.Get(controller) if err != nil { return false, err } return exists, nil }
[ "func", "(", "s", "*", "StoreToReplicationControllerLister", ")", "Exists", "(", "controller", "*", "api", ".", "ReplicationController", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "exists", ",", "err", ":=", "s", ".", "Store", ".", "Get", "(", "controller", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "exists", ",", "nil", "\n", "}" ]
// Exists checks if the given rc exists in the store.
[ "Exists", "checks", "if", "the", "given", "rc", "exists", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L148-L154
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPodControllers
func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (controllers []api.ReplicationController, err error) { var selector labels.Selector var rc api.ReplicationController if len(pod.Labels) == 0 { err = fmt.Errorf("no controllers found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { rc = *m.(*api.ReplicationController) if rc.Namespace != pod.Namespace { continue } labelSet := labels.Set(rc.Spec.Selector) selector = labels.Set(rc.Spec.Selector).AsSelector() // If an rc with a nil or empty selector creeps in, it should match nothing, not everything. if labelSet.AsSelector().Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } controllers = append(controllers, rc) } if len(controllers) == 0 { err = fmt.Errorf("could not find controller for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
go
func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (controllers []api.ReplicationController, err error) { var selector labels.Selector var rc api.ReplicationController if len(pod.Labels) == 0 { err = fmt.Errorf("no controllers found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { rc = *m.(*api.ReplicationController) if rc.Namespace != pod.Namespace { continue } labelSet := labels.Set(rc.Spec.Selector) selector = labels.Set(rc.Spec.Selector).AsSelector() // If an rc with a nil or empty selector creeps in, it should match nothing, not everything. if labelSet.AsSelector().Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } controllers = append(controllers, rc) } if len(controllers) == 0 { err = fmt.Errorf("could not find controller for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
[ "func", "(", "s", "*", "StoreToReplicationControllerLister", ")", "GetPodControllers", "(", "pod", "*", "api", ".", "Pod", ")", "(", "controllers", "[", "]", "api", ".", "ReplicationController", ",", "err", "error", ")", "{", "var", "selector", "labels", ".", "Selector", "\n", "var", "rc", "api", ".", "ReplicationController", "\n\n", "if", "len", "(", "pod", ".", "Labels", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "rc", "=", "*", "m", ".", "(", "*", "api", ".", "ReplicationController", ")", "\n", "if", "rc", ".", "Namespace", "!=", "pod", ".", "Namespace", "{", "continue", "\n", "}", "\n", "labelSet", ":=", "labels", ".", "Set", "(", "rc", ".", "Spec", ".", "Selector", ")", "\n", "selector", "=", "labels", ".", "Set", "(", "rc", ".", "Spec", ".", "Selector", ")", ".", "AsSelector", "(", ")", "\n\n", "// If an rc with a nil or empty selector creeps in, it should match nothing, not everything.", "if", "labelSet", ".", "AsSelector", "(", ")", ".", "Empty", "(", ")", "||", "!", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "pod", ".", "Labels", ")", ")", "{", "continue", "\n", "}", "\n", "controllers", "=", "append", "(", "controllers", ",", "rc", ")", "\n", "}", "\n", "if", "len", "(", "controllers", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ",", "pod", ".", "Namespace", ",", "pod", ".", "Labels", ")", "\n", "}", "\n", "return", "\n", "}" ]
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
[ "GetPodControllers", "returns", "a", "list", "of", "replication", "controllers", "managing", "a", "pod", ".", "Returns", "an", "error", "only", "if", "no", "matching", "controllers", "are", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L187-L214
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
Exists
func (s *StoreToDeploymentLister) Exists(deployment *extensions.Deployment) (bool, error) { _, exists, err := s.Store.Get(deployment) if err != nil { return false, err } return exists, nil }
go
func (s *StoreToDeploymentLister) Exists(deployment *extensions.Deployment) (bool, error) { _, exists, err := s.Store.Get(deployment) if err != nil { return false, err } return exists, nil }
[ "func", "(", "s", "*", "StoreToDeploymentLister", ")", "Exists", "(", "deployment", "*", "extensions", ".", "Deployment", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "exists", ",", "err", ":=", "s", ".", "Store", ".", "Get", "(", "deployment", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "exists", ",", "nil", "\n", "}" ]
// Exists checks if the given deployment exists in the store.
[ "Exists", "checks", "if", "the", "given", "deployment", "exists", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L222-L228
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetDeploymentsForReplicaSet
func (s *StoreToDeploymentLister) GetDeploymentsForReplicaSet(rs *extensions.ReplicaSet) (deployments []extensions.Deployment, err error) { var d extensions.Deployment if len(rs.Labels) == 0 { err = fmt.Errorf("no deployments found for ReplicaSet %v because it has no labels", rs.Name) return } // TODO: MODIFY THIS METHOD so that it checks for the podTemplateSpecHash label for _, m := range s.Store.List() { d = *m.(*extensions.Deployment) if d.Namespace != rs.Namespace { continue } selector, err := unversioned.LabelSelectorAsSelector(d.Spec.Selector) if err != nil { return nil, fmt.Errorf("invalid label selector: %v", err) } // If a deployment with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(rs.Labels)) { continue } deployments = append(deployments, d) } if len(deployments) == 0 { err = fmt.Errorf("could not find deployments set for ReplicaSet %s in namespace %s with labels: %v", rs.Name, rs.Namespace, rs.Labels) } return }
go
func (s *StoreToDeploymentLister) GetDeploymentsForReplicaSet(rs *extensions.ReplicaSet) (deployments []extensions.Deployment, err error) { var d extensions.Deployment if len(rs.Labels) == 0 { err = fmt.Errorf("no deployments found for ReplicaSet %v because it has no labels", rs.Name) return } // TODO: MODIFY THIS METHOD so that it checks for the podTemplateSpecHash label for _, m := range s.Store.List() { d = *m.(*extensions.Deployment) if d.Namespace != rs.Namespace { continue } selector, err := unversioned.LabelSelectorAsSelector(d.Spec.Selector) if err != nil { return nil, fmt.Errorf("invalid label selector: %v", err) } // If a deployment with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(rs.Labels)) { continue } deployments = append(deployments, d) } if len(deployments) == 0 { err = fmt.Errorf("could not find deployments set for ReplicaSet %s in namespace %s with labels: %v", rs.Name, rs.Namespace, rs.Labels) } return }
[ "func", "(", "s", "*", "StoreToDeploymentLister", ")", "GetDeploymentsForReplicaSet", "(", "rs", "*", "extensions", ".", "ReplicaSet", ")", "(", "deployments", "[", "]", "extensions", ".", "Deployment", ",", "err", "error", ")", "{", "var", "d", "extensions", ".", "Deployment", "\n\n", "if", "len", "(", "rs", ".", "Labels", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "rs", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "// TODO: MODIFY THIS METHOD so that it checks for the podTemplateSpecHash label", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "d", "=", "*", "m", ".", "(", "*", "extensions", ".", "Deployment", ")", "\n", "if", "d", ".", "Namespace", "!=", "rs", ".", "Namespace", "{", "continue", "\n", "}", "\n\n", "selector", ",", "err", ":=", "unversioned", ".", "LabelSelectorAsSelector", "(", "d", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// If a deployment with a nil or empty selector creeps in, it should match nothing, not everything.", "if", "selector", ".", "Empty", "(", ")", "||", "!", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "rs", ".", "Labels", ")", ")", "{", "continue", "\n", "}", "\n", "deployments", "=", "append", "(", "deployments", ",", "d", ")", "\n", "}", "\n", "if", "len", "(", "deployments", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "rs", ".", "Name", ",", "rs", ".", "Namespace", ",", "rs", ".", "Labels", ")", "\n", "}", "\n", "return", "\n", "}" ]
// GetDeploymentsForReplicaSet returns a list of deployments managing a replica set. Returns an error only if no matching deployments are found.
[ "GetDeploymentsForReplicaSet", "returns", "a", "list", "of", "deployments", "managing", "a", "replica", "set", ".", "Returns", "an", "error", "only", "if", "no", "matching", "deployments", "are", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L240-L269
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
Exists
func (s *StoreToReplicaSetLister) Exists(rs *extensions.ReplicaSet) (bool, error) { _, exists, err := s.Store.Get(rs) if err != nil { return false, err } return exists, nil }
go
func (s *StoreToReplicaSetLister) Exists(rs *extensions.ReplicaSet) (bool, error) { _, exists, err := s.Store.Get(rs) if err != nil { return false, err } return exists, nil }
[ "func", "(", "s", "*", "StoreToReplicaSetLister", ")", "Exists", "(", "rs", "*", "extensions", ".", "ReplicaSet", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "exists", ",", "err", ":=", "s", ".", "Store", ".", "Get", "(", "rs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "exists", ",", "nil", "\n", "}" ]
// Exists checks if the given ReplicaSet exists in the store.
[ "Exists", "checks", "if", "the", "given", "ReplicaSet", "exists", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L277-L283
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPodReplicaSets
func (s *StoreToReplicaSetLister) GetPodReplicaSets(pod *api.Pod) (rss []extensions.ReplicaSet, err error) { var selector labels.Selector var rs extensions.ReplicaSet if len(pod.Labels) == 0 { err = fmt.Errorf("no ReplicaSets found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { rs = *m.(*extensions.ReplicaSet) if rs.Namespace != pod.Namespace { continue } selector, err = unversioned.LabelSelectorAsSelector(rs.Spec.Selector) if err != nil { err = fmt.Errorf("invalid selector: %v", err) return } // If a ReplicaSet with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } rss = append(rss, rs) } if len(rss) == 0 { err = fmt.Errorf("could not find ReplicaSet for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
go
func (s *StoreToReplicaSetLister) GetPodReplicaSets(pod *api.Pod) (rss []extensions.ReplicaSet, err error) { var selector labels.Selector var rs extensions.ReplicaSet if len(pod.Labels) == 0 { err = fmt.Errorf("no ReplicaSets found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { rs = *m.(*extensions.ReplicaSet) if rs.Namespace != pod.Namespace { continue } selector, err = unversioned.LabelSelectorAsSelector(rs.Spec.Selector) if err != nil { err = fmt.Errorf("invalid selector: %v", err) return } // If a ReplicaSet with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } rss = append(rss, rs) } if len(rss) == 0 { err = fmt.Errorf("could not find ReplicaSet for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
[ "func", "(", "s", "*", "StoreToReplicaSetLister", ")", "GetPodReplicaSets", "(", "pod", "*", "api", ".", "Pod", ")", "(", "rss", "[", "]", "extensions", ".", "ReplicaSet", ",", "err", "error", ")", "{", "var", "selector", "labels", ".", "Selector", "\n", "var", "rs", "extensions", ".", "ReplicaSet", "\n\n", "if", "len", "(", "pod", ".", "Labels", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "rs", "=", "*", "m", ".", "(", "*", "extensions", ".", "ReplicaSet", ")", "\n", "if", "rs", ".", "Namespace", "!=", "pod", ".", "Namespace", "{", "continue", "\n", "}", "\n", "selector", ",", "err", "=", "unversioned", ".", "LabelSelectorAsSelector", "(", "rs", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\n", "}", "\n\n", "// If a ReplicaSet with a nil or empty selector creeps in, it should match nothing, not everything.", "if", "selector", ".", "Empty", "(", ")", "||", "!", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "pod", ".", "Labels", ")", ")", "{", "continue", "\n", "}", "\n", "rss", "=", "append", "(", "rss", ",", "rs", ")", "\n", "}", "\n", "if", "len", "(", "rss", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ",", "pod", ".", "Namespace", ",", "pod", ".", "Labels", ")", "\n", "}", "\n", "return", "\n", "}" ]
// GetPodReplicaSets returns a list of ReplicaSets managing a pod. Returns an error only if no matching ReplicaSets are found.
[ "GetPodReplicaSets", "returns", "a", "list", "of", "ReplicaSets", "managing", "a", "pod", ".", "Returns", "an", "error", "only", "if", "no", "matching", "ReplicaSets", "are", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L316-L346
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
Exists
func (s *StoreToDaemonSetLister) Exists(ds *extensions.DaemonSet) (bool, error) { _, exists, err := s.Store.Get(ds) if err != nil { return false, err } return exists, nil }
go
func (s *StoreToDaemonSetLister) Exists(ds *extensions.DaemonSet) (bool, error) { _, exists, err := s.Store.Get(ds) if err != nil { return false, err } return exists, nil }
[ "func", "(", "s", "*", "StoreToDaemonSetLister", ")", "Exists", "(", "ds", "*", "extensions", ".", "DaemonSet", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "exists", ",", "err", ":=", "s", ".", "Store", ".", "Get", "(", "ds", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "exists", ",", "nil", "\n", "}" ]
// Exists checks if the given daemon set exists in the store.
[ "Exists", "checks", "if", "the", "given", "daemon", "set", "exists", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L354-L360
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPodDaemonSets
func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []extensions.DaemonSet, err error) { var selector labels.Selector var daemonSet extensions.DaemonSet if len(pod.Labels) == 0 { err = fmt.Errorf("no daemon sets found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { daemonSet = *m.(*extensions.DaemonSet) if daemonSet.Namespace != pod.Namespace { continue } selector, err = unversioned.LabelSelectorAsSelector(daemonSet.Spec.Selector) if err != nil { // this should not happen if the DaemonSet passed validation return nil, err } // If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } daemonSets = append(daemonSets, daemonSet) } if len(daemonSets) == 0 { err = fmt.Errorf("could not find daemon set for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
go
func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []extensions.DaemonSet, err error) { var selector labels.Selector var daemonSet extensions.DaemonSet if len(pod.Labels) == 0 { err = fmt.Errorf("no daemon sets found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { daemonSet = *m.(*extensions.DaemonSet) if daemonSet.Namespace != pod.Namespace { continue } selector, err = unversioned.LabelSelectorAsSelector(daemonSet.Spec.Selector) if err != nil { // this should not happen if the DaemonSet passed validation return nil, err } // If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything. if selector.Empty() || !selector.Matches(labels.Set(pod.Labels)) { continue } daemonSets = append(daemonSets, daemonSet) } if len(daemonSets) == 0 { err = fmt.Errorf("could not find daemon set for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
[ "func", "(", "s", "*", "StoreToDaemonSetLister", ")", "GetPodDaemonSets", "(", "pod", "*", "api", ".", "Pod", ")", "(", "daemonSets", "[", "]", "extensions", ".", "DaemonSet", ",", "err", "error", ")", "{", "var", "selector", "labels", ".", "Selector", "\n", "var", "daemonSet", "extensions", ".", "DaemonSet", "\n\n", "if", "len", "(", "pod", ".", "Labels", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "daemonSet", "=", "*", "m", ".", "(", "*", "extensions", ".", "DaemonSet", ")", "\n", "if", "daemonSet", ".", "Namespace", "!=", "pod", ".", "Namespace", "{", "continue", "\n", "}", "\n", "selector", ",", "err", "=", "unversioned", ".", "LabelSelectorAsSelector", "(", "daemonSet", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "// this should not happen if the DaemonSet passed validation", "return", "nil", ",", "err", "\n", "}", "\n\n", "// If a daemonSet with a nil or empty selector creeps in, it should match nothing, not everything.", "if", "selector", ".", "Empty", "(", ")", "||", "!", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "pod", ".", "Labels", ")", ")", "{", "continue", "\n", "}", "\n", "daemonSets", "=", "append", "(", "daemonSets", ",", "daemonSet", ")", "\n", "}", "\n", "if", "len", "(", "daemonSets", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ",", "pod", ".", "Namespace", ",", "pod", ".", "Labels", ")", "\n", "}", "\n", "return", "\n", "}" ]
// GetPodDaemonSets returns a list of daemon sets managing a pod. // Returns an error if and only if no matching daemon sets are found.
[ "GetPodDaemonSets", "returns", "a", "list", "of", "daemon", "sets", "managing", "a", "pod", ".", "Returns", "an", "error", "if", "and", "only", "if", "no", "matching", "daemon", "sets", "are", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L373-L403
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
List
func (s *StoreToEndpointsLister) List() (services api.EndpointsList, err error) { for _, m := range s.Store.List() { services.Items = append(services.Items, *(m.(*api.Endpoints))) } return services, nil }
go
func (s *StoreToEndpointsLister) List() (services api.EndpointsList, err error) { for _, m := range s.Store.List() { services.Items = append(services.Items, *(m.(*api.Endpoints))) } return services, nil }
[ "func", "(", "s", "*", "StoreToEndpointsLister", ")", "List", "(", ")", "(", "services", "api", ".", "EndpointsList", ",", "err", "error", ")", "{", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "services", ".", "Items", "=", "append", "(", "services", ".", "Items", ",", "*", "(", "m", ".", "(", "*", "api", ".", "Endpoints", ")", ")", ")", "\n", "}", "\n", "return", "services", ",", "nil", "\n", "}" ]
// List lists all endpoints in the store.
[ "List", "lists", "all", "endpoints", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L452-L457
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetServiceEndpoints
func (s *StoreToEndpointsLister) GetServiceEndpoints(svc *api.Service) (ep api.Endpoints, err error) { for _, m := range s.Store.List() { ep = *m.(*api.Endpoints) if svc.Name == ep.Name && svc.Namespace == ep.Namespace { return ep, nil } } err = fmt.Errorf("could not find endpoints for service: %v", svc.Name) return }
go
func (s *StoreToEndpointsLister) GetServiceEndpoints(svc *api.Service) (ep api.Endpoints, err error) { for _, m := range s.Store.List() { ep = *m.(*api.Endpoints) if svc.Name == ep.Name && svc.Namespace == ep.Namespace { return ep, nil } } err = fmt.Errorf("could not find endpoints for service: %v", svc.Name) return }
[ "func", "(", "s", "*", "StoreToEndpointsLister", ")", "GetServiceEndpoints", "(", "svc", "*", "api", ".", "Service", ")", "(", "ep", "api", ".", "Endpoints", ",", "err", "error", ")", "{", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "ep", "=", "*", "m", ".", "(", "*", "api", ".", "Endpoints", ")", "\n", "if", "svc", ".", "Name", "==", "ep", ".", "Name", "&&", "svc", ".", "Namespace", "==", "ep", ".", "Namespace", "{", "return", "ep", ",", "nil", "\n", "}", "\n", "}", "\n", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "svc", ".", "Name", ")", "\n", "return", "\n", "}" ]
// GetServiceEndpoints returns the endpoints of a service, matched on service name.
[ "GetServiceEndpoints", "returns", "the", "endpoints", "of", "a", "service", "matched", "on", "service", "name", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L460-L469
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
Exists
func (s *StoreToJobLister) Exists(job *extensions.Job) (bool, error) { _, exists, err := s.Store.Get(job) if err != nil { return false, err } return exists, nil }
go
func (s *StoreToJobLister) Exists(job *extensions.Job) (bool, error) { _, exists, err := s.Store.Get(job) if err != nil { return false, err } return exists, nil }
[ "func", "(", "s", "*", "StoreToJobLister", ")", "Exists", "(", "job", "*", "extensions", ".", "Job", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "exists", ",", "err", ":=", "s", ".", "Store", ".", "Get", "(", "job", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "exists", ",", "nil", "\n", "}" ]
// Exists checks if the given job exists in the store.
[ "Exists", "checks", "if", "the", "given", "job", "exists", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L477-L483
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
List
func (s *StoreToJobLister) List() (jobs extensions.JobList, err error) { for _, c := range s.Store.List() { jobs.Items = append(jobs.Items, *(c.(*extensions.Job))) } return jobs, nil }
go
func (s *StoreToJobLister) List() (jobs extensions.JobList, err error) { for _, c := range s.Store.List() { jobs.Items = append(jobs.Items, *(c.(*extensions.Job))) } return jobs, nil }
[ "func", "(", "s", "*", "StoreToJobLister", ")", "List", "(", ")", "(", "jobs", "extensions", ".", "JobList", ",", "err", "error", ")", "{", "for", "_", ",", "c", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "jobs", ".", "Items", "=", "append", "(", "jobs", ".", "Items", ",", "*", "(", "c", ".", "(", "*", "extensions", ".", "Job", ")", ")", ")", "\n", "}", "\n", "return", "jobs", ",", "nil", "\n", "}" ]
// StoreToJobLister lists all jobs in the store.
[ "StoreToJobLister", "lists", "all", "jobs", "in", "the", "store", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L486-L491
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPodJobs
func (s *StoreToJobLister) GetPodJobs(pod *api.Pod) (jobs []extensions.Job, err error) { var selector labels.Selector var job extensions.Job if len(pod.Labels) == 0 { err = fmt.Errorf("no jobs found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { job = *m.(*extensions.Job) if job.Namespace != pod.Namespace { continue } selector, _ = unversioned.LabelSelectorAsSelector(job.Spec.Selector) if !selector.Matches(labels.Set(pod.Labels)) { continue } jobs = append(jobs, job) } if len(jobs) == 0 { err = fmt.Errorf("could not find jobs for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
go
func (s *StoreToJobLister) GetPodJobs(pod *api.Pod) (jobs []extensions.Job, err error) { var selector labels.Selector var job extensions.Job if len(pod.Labels) == 0 { err = fmt.Errorf("no jobs found for pod %v because it has no labels", pod.Name) return } for _, m := range s.Store.List() { job = *m.(*extensions.Job) if job.Namespace != pod.Namespace { continue } selector, _ = unversioned.LabelSelectorAsSelector(job.Spec.Selector) if !selector.Matches(labels.Set(pod.Labels)) { continue } jobs = append(jobs, job) } if len(jobs) == 0 { err = fmt.Errorf("could not find jobs for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) } return }
[ "func", "(", "s", "*", "StoreToJobLister", ")", "GetPodJobs", "(", "pod", "*", "api", ".", "Pod", ")", "(", "jobs", "[", "]", "extensions", ".", "Job", ",", "err", "error", ")", "{", "var", "selector", "labels", ".", "Selector", "\n", "var", "job", "extensions", ".", "Job", "\n\n", "if", "len", "(", "pod", ".", "Labels", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ")", "\n", "return", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "s", ".", "Store", ".", "List", "(", ")", "{", "job", "=", "*", "m", ".", "(", "*", "extensions", ".", "Job", ")", "\n", "if", "job", ".", "Namespace", "!=", "pod", ".", "Namespace", "{", "continue", "\n", "}", "\n\n", "selector", ",", "_", "=", "unversioned", ".", "LabelSelectorAsSelector", "(", "job", ".", "Spec", ".", "Selector", ")", "\n", "if", "!", "selector", ".", "Matches", "(", "labels", ".", "Set", "(", "pod", ".", "Labels", ")", ")", "{", "continue", "\n", "}", "\n", "jobs", "=", "append", "(", "jobs", ",", "job", ")", "\n", "}", "\n", "if", "len", "(", "jobs", ")", "==", "0", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "pod", ".", "Name", ",", "pod", ".", "Namespace", ",", "pod", ".", "Labels", ")", "\n", "}", "\n", "return", "\n", "}" ]
// GetPodJobs returns a list of jobs managing a pod. Returns an error only if no matching jobs are found.
[ "GetPodJobs", "returns", "a", "list", "of", "jobs", "managing", "a", "pod", ".", "Returns", "an", "error", "only", "if", "no", "matching", "jobs", "are", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L494-L519
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPersistentVolumeInfo
func (s *StoreToPVFetcher) GetPersistentVolumeInfo(id string) (*api.PersistentVolume, error) { o, exists, err := s.Get(&api.PersistentVolume{ObjectMeta: api.ObjectMeta{Name: id}}) if err != nil { return nil, fmt.Errorf("error retrieving PersistentVolume '%v' from cache: %v", id, err) } if !exists { return nil, fmt.Errorf("PersistentVolume '%v' is not in cache", id) } return o.(*api.PersistentVolume), nil }
go
func (s *StoreToPVFetcher) GetPersistentVolumeInfo(id string) (*api.PersistentVolume, error) { o, exists, err := s.Get(&api.PersistentVolume{ObjectMeta: api.ObjectMeta{Name: id}}) if err != nil { return nil, fmt.Errorf("error retrieving PersistentVolume '%v' from cache: %v", id, err) } if !exists { return nil, fmt.Errorf("PersistentVolume '%v' is not in cache", id) } return o.(*api.PersistentVolume), nil }
[ "func", "(", "s", "*", "StoreToPVFetcher", ")", "GetPersistentVolumeInfo", "(", "id", "string", ")", "(", "*", "api", ".", "PersistentVolume", ",", "error", ")", "{", "o", ",", "exists", ",", "err", ":=", "s", ".", "Get", "(", "&", "api", ".", "PersistentVolume", "{", "ObjectMeta", ":", "api", ".", "ObjectMeta", "{", "Name", ":", "id", "}", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ",", "err", ")", "\n", "}", "\n\n", "if", "!", "exists", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n\n", "return", "o", ".", "(", "*", "api", ".", "PersistentVolume", ")", ",", "nil", "\n", "}" ]
// GetPersistentVolumeInfo returns cached data for the PersistentVolume 'id'.
[ "GetPersistentVolumeInfo", "returns", "cached", "data", "for", "the", "PersistentVolume", "id", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L527-L539
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go
GetPersistentVolumeClaimInfo
func (s *StoreToPVCFetcher) GetPersistentVolumeClaimInfo(namespace string, id string) (*api.PersistentVolumeClaim, error) { o, exists, err := s.Get(&api.PersistentVolumeClaim{ObjectMeta: api.ObjectMeta{Namespace: namespace, Name: id}}) if err != nil { return nil, fmt.Errorf("error retrieving PersistentVolumeClaim '%s/%s' from cache: %v", namespace, id, err) } if !exists { return nil, fmt.Errorf("PersistentVolumeClaim '%s/%s' is not in cache", namespace, id) } return o.(*api.PersistentVolumeClaim), nil }
go
func (s *StoreToPVCFetcher) GetPersistentVolumeClaimInfo(namespace string, id string) (*api.PersistentVolumeClaim, error) { o, exists, err := s.Get(&api.PersistentVolumeClaim{ObjectMeta: api.ObjectMeta{Namespace: namespace, Name: id}}) if err != nil { return nil, fmt.Errorf("error retrieving PersistentVolumeClaim '%s/%s' from cache: %v", namespace, id, err) } if !exists { return nil, fmt.Errorf("PersistentVolumeClaim '%s/%s' is not in cache", namespace, id) } return o.(*api.PersistentVolumeClaim), nil }
[ "func", "(", "s", "*", "StoreToPVCFetcher", ")", "GetPersistentVolumeClaimInfo", "(", "namespace", "string", ",", "id", "string", ")", "(", "*", "api", ".", "PersistentVolumeClaim", ",", "error", ")", "{", "o", ",", "exists", ",", "err", ":=", "s", ".", "Get", "(", "&", "api", ".", "PersistentVolumeClaim", "{", "ObjectMeta", ":", "api", ".", "ObjectMeta", "{", "Namespace", ":", "namespace", ",", "Name", ":", "id", "}", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "namespace", ",", "id", ",", "err", ")", "\n", "}", "\n\n", "if", "!", "exists", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "namespace", ",", "id", ")", "\n", "}", "\n\n", "return", "o", ".", "(", "*", "api", ".", "PersistentVolumeClaim", ")", ",", "nil", "\n", "}" ]
// GetPersistentVolumeClaimInfo returns cached data for the PersistentVolumeClaim 'id'.
[ "GetPersistentVolumeClaimInfo", "returns", "cached", "data", "for", "the", "PersistentVolumeClaim", "id", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/listers.go#L547-L558
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/client_config.go
NewInteractiveClientConfig
func NewInteractiveClientConfig(config clientcmdapi.Config, contextName string, overrides *ConfigOverrides, fallbackReader io.Reader) ClientConfig { return DirectClientConfig{config, contextName, overrides, fallbackReader} }
go
func NewInteractiveClientConfig(config clientcmdapi.Config, contextName string, overrides *ConfigOverrides, fallbackReader io.Reader) ClientConfig { return DirectClientConfig{config, contextName, overrides, fallbackReader} }
[ "func", "NewInteractiveClientConfig", "(", "config", "clientcmdapi", ".", "Config", ",", "contextName", "string", ",", "overrides", "*", "ConfigOverrides", ",", "fallbackReader", "io", ".", "Reader", ")", "ClientConfig", "{", "return", "DirectClientConfig", "{", "config", ",", "contextName", ",", "overrides", ",", "fallbackReader", "}", "\n", "}" ]
// NewInteractiveClientConfig creates a DirectClientConfig using the passed context name and a reader in case auth information is not provided via files or flags
[ "NewInteractiveClientConfig", "creates", "a", "DirectClientConfig", "using", "the", "passed", "context", "name", "and", "a", "reader", "in", "case", "auth", "information", "is", "not", "provided", "via", "files", "or", "flags" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/client_config.go#L77-L79
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/client_config.go
makeServerIdentificationConfig
func makeServerIdentificationConfig(info clientauth.Info) client.Config { config := client.Config{} config.CAFile = info.CAFile if info.Insecure != nil { config.Insecure = *info.Insecure } return config }
go
func makeServerIdentificationConfig(info clientauth.Info) client.Config { config := client.Config{} config.CAFile = info.CAFile if info.Insecure != nil { config.Insecure = *info.Insecure } return config }
[ "func", "makeServerIdentificationConfig", "(", "info", "clientauth", ".", "Info", ")", "client", ".", "Config", "{", "config", ":=", "client", ".", "Config", "{", "}", "\n", "config", ".", "CAFile", "=", "info", ".", "CAFile", "\n", "if", "info", ".", "Insecure", "!=", "nil", "{", "config", ".", "Insecure", "=", "*", "info", ".", "Insecure", "\n", "}", "\n", "return", "config", "\n", "}" ]
// makeUserIdentificationFieldsConfig returns a client.Config capable of being merged using mergo for only server identification information
[ "makeUserIdentificationFieldsConfig", "returns", "a", "client", ".", "Config", "capable", "of", "being", "merged", "using", "mergo", "for", "only", "server", "identification", "information" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/client_config.go#L203-L210
train
kubernetes-retired/contrib
rescheduler/rescheduler.go
getTaintsFromNodeAnnotations
func getTaintsFromNodeAnnotations(annotations map[string]string) ([]v1.Taint, error) { var taints []v1.Taint if len(annotations) > 0 && annotations[TaintsAnnotationKey] != "" { err := json.Unmarshal([]byte(annotations[TaintsAnnotationKey]), &taints) if err != nil { return []v1.Taint{}, err } } return taints, nil }
go
func getTaintsFromNodeAnnotations(annotations map[string]string) ([]v1.Taint, error) { var taints []v1.Taint if len(annotations) > 0 && annotations[TaintsAnnotationKey] != "" { err := json.Unmarshal([]byte(annotations[TaintsAnnotationKey]), &taints) if err != nil { return []v1.Taint{}, err } } return taints, nil }
[ "func", "getTaintsFromNodeAnnotations", "(", "annotations", "map", "[", "string", "]", "string", ")", "(", "[", "]", "v1", ".", "Taint", ",", "error", ")", "{", "var", "taints", "[", "]", "v1", ".", "Taint", "\n", "if", "len", "(", "annotations", ")", ">", "0", "&&", "annotations", "[", "TaintsAnnotationKey", "]", "!=", "\"", "\"", "{", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "annotations", "[", "TaintsAnnotationKey", "]", ")", ",", "&", "taints", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "v1", ".", "Taint", "{", "}", ",", "err", "\n", "}", "\n", "}", "\n", "return", "taints", ",", "nil", "\n", "}" ]
// copied from Kubernetes 1.5.4
[ "copied", "from", "Kubernetes", "1", ".", "5", ".", "4" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/rescheduler.go#L237-L246
train
kubernetes-retired/contrib
rescheduler/rescheduler.go
prepareNodeForPod
func prepareNodeForPod(client kube_client.Interface, recorder kube_record.EventRecorder, predicateChecker *ca_simulator.PredicateChecker, originalNode *v1.Node, criticalPod *v1.Pod) error { // Operate on a copy of the node to ensure pods running on the node will pass CheckPredicates below. node := originalNode.DeepCopy() err := addTaint(client, originalNode, podId(criticalPod)) if err != nil { return fmt.Errorf("Error while adding taint: %v", err) } requiredPods, otherPods, err := groupPods(client, node) if err != nil { return err } nodeInfo := schedulercache.NewNodeInfo(requiredPods...) nodeInfo.SetNode(node) // check whether critical pod still fit if err := predicateChecker.CheckPredicates(criticalPod, nil, nodeInfo, true); err != nil { return fmt.Errorf("Pod %s doesn't fit to node %v: %v", podId(criticalPod), node.Name, err) } requiredPods = append(requiredPods, criticalPod) nodeInfo = schedulercache.NewNodeInfo(requiredPods...) nodeInfo.SetNode(node) for _, p := range otherPods { if err := predicateChecker.CheckPredicates(p, nil, nodeInfo, true); err != nil { glog.Infof("Pod %s will be deleted in order to schedule critical pod %s.", podId(p), podId(criticalPod)) recorder.Eventf(p, v1.EventTypeNormal, "DeletedByRescheduler", "Deleted by rescheduler in order to schedule critical pod %s.", podId(criticalPod)) deleteOptions := metav1.DeleteOptions{} gracePeriodSeconds := int64(gracePeriod.Seconds()) if gracePeriodSeconds >= 0 && (p.Spec.TerminationGracePeriodSeconds == nil || *p.Spec.TerminationGracePeriodSeconds > gracePeriodSeconds) { deleteOptions.GracePeriodSeconds = &gracePeriodSeconds } delErr := client.CoreV1().Pods(p.Namespace).Delete(p.Name, &deleteOptions) if delErr != nil { return fmt.Errorf("Failed to delete pod %s: %v", podId(p), delErr) } metrics.DeletedPodsCount.Inc() } else { newPods := append(nodeInfo.Pods(), p) nodeInfo = schedulercache.NewNodeInfo(newPods...) nodeInfo.SetNode(node) } } // TODO(piosz): how to reset scheduler backoff? return nil }
go
func prepareNodeForPod(client kube_client.Interface, recorder kube_record.EventRecorder, predicateChecker *ca_simulator.PredicateChecker, originalNode *v1.Node, criticalPod *v1.Pod) error { // Operate on a copy of the node to ensure pods running on the node will pass CheckPredicates below. node := originalNode.DeepCopy() err := addTaint(client, originalNode, podId(criticalPod)) if err != nil { return fmt.Errorf("Error while adding taint: %v", err) } requiredPods, otherPods, err := groupPods(client, node) if err != nil { return err } nodeInfo := schedulercache.NewNodeInfo(requiredPods...) nodeInfo.SetNode(node) // check whether critical pod still fit if err := predicateChecker.CheckPredicates(criticalPod, nil, nodeInfo, true); err != nil { return fmt.Errorf("Pod %s doesn't fit to node %v: %v", podId(criticalPod), node.Name, err) } requiredPods = append(requiredPods, criticalPod) nodeInfo = schedulercache.NewNodeInfo(requiredPods...) nodeInfo.SetNode(node) for _, p := range otherPods { if err := predicateChecker.CheckPredicates(p, nil, nodeInfo, true); err != nil { glog.Infof("Pod %s will be deleted in order to schedule critical pod %s.", podId(p), podId(criticalPod)) recorder.Eventf(p, v1.EventTypeNormal, "DeletedByRescheduler", "Deleted by rescheduler in order to schedule critical pod %s.", podId(criticalPod)) deleteOptions := metav1.DeleteOptions{} gracePeriodSeconds := int64(gracePeriod.Seconds()) if gracePeriodSeconds >= 0 && (p.Spec.TerminationGracePeriodSeconds == nil || *p.Spec.TerminationGracePeriodSeconds > gracePeriodSeconds) { deleteOptions.GracePeriodSeconds = &gracePeriodSeconds } delErr := client.CoreV1().Pods(p.Namespace).Delete(p.Name, &deleteOptions) if delErr != nil { return fmt.Errorf("Failed to delete pod %s: %v", podId(p), delErr) } metrics.DeletedPodsCount.Inc() } else { newPods := append(nodeInfo.Pods(), p) nodeInfo = schedulercache.NewNodeInfo(newPods...) nodeInfo.SetNode(node) } } // TODO(piosz): how to reset scheduler backoff? return nil }
[ "func", "prepareNodeForPod", "(", "client", "kube_client", ".", "Interface", ",", "recorder", "kube_record", ".", "EventRecorder", ",", "predicateChecker", "*", "ca_simulator", ".", "PredicateChecker", ",", "originalNode", "*", "v1", ".", "Node", ",", "criticalPod", "*", "v1", ".", "Pod", ")", "error", "{", "// Operate on a copy of the node to ensure pods running on the node will pass CheckPredicates below.", "node", ":=", "originalNode", ".", "DeepCopy", "(", ")", "\n", "err", ":=", "addTaint", "(", "client", ",", "originalNode", ",", "podId", "(", "criticalPod", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "requiredPods", ",", "otherPods", ",", "err", ":=", "groupPods", "(", "client", ",", "node", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "nodeInfo", ":=", "schedulercache", ".", "NewNodeInfo", "(", "requiredPods", "...", ")", "\n", "nodeInfo", ".", "SetNode", "(", "node", ")", "\n\n", "// check whether critical pod still fit", "if", "err", ":=", "predicateChecker", ".", "CheckPredicates", "(", "criticalPod", ",", "nil", ",", "nodeInfo", ",", "true", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "podId", "(", "criticalPod", ")", ",", "node", ".", "Name", ",", "err", ")", "\n", "}", "\n", "requiredPods", "=", "append", "(", "requiredPods", ",", "criticalPod", ")", "\n", "nodeInfo", "=", "schedulercache", ".", "NewNodeInfo", "(", "requiredPods", "...", ")", "\n", "nodeInfo", ".", "SetNode", "(", "node", ")", "\n\n", "for", "_", ",", "p", ":=", "range", "otherPods", "{", "if", "err", ":=", "predicateChecker", ".", "CheckPredicates", "(", "p", ",", "nil", ",", "nodeInfo", ",", "true", ")", ";", "err", "!=", "nil", "{", "glog", ".", "Infof", "(", "\"", "\"", ",", "podId", "(", "p", ")", ",", "podId", "(", "criticalPod", ")", ")", "\n", "recorder", ".", "Eventf", "(", "p", ",", "v1", ".", "EventTypeNormal", ",", "\"", "\"", ",", "\"", "\"", ",", "podId", "(", "criticalPod", ")", ")", "\n", "deleteOptions", ":=", "metav1", ".", "DeleteOptions", "{", "}", "\n", "gracePeriodSeconds", ":=", "int64", "(", "gracePeriod", ".", "Seconds", "(", ")", ")", "\n", "if", "gracePeriodSeconds", ">=", "0", "&&", "(", "p", ".", "Spec", ".", "TerminationGracePeriodSeconds", "==", "nil", "||", "*", "p", ".", "Spec", ".", "TerminationGracePeriodSeconds", ">", "gracePeriodSeconds", ")", "{", "deleteOptions", ".", "GracePeriodSeconds", "=", "&", "gracePeriodSeconds", "\n", "}", "\n", "delErr", ":=", "client", ".", "CoreV1", "(", ")", ".", "Pods", "(", "p", ".", "Namespace", ")", ".", "Delete", "(", "p", ".", "Name", ",", "&", "deleteOptions", ")", "\n", "if", "delErr", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "podId", "(", "p", ")", ",", "delErr", ")", "\n", "}", "\n", "metrics", ".", "DeletedPodsCount", ".", "Inc", "(", ")", "\n", "}", "else", "{", "newPods", ":=", "append", "(", "nodeInfo", ".", "Pods", "(", ")", ",", "p", ")", "\n", "nodeInfo", "=", "schedulercache", ".", "NewNodeInfo", "(", "newPods", "...", ")", "\n", "nodeInfo", ".", "SetNode", "(", "node", ")", "\n", "}", "\n", "}", "\n\n", "// TODO(piosz): how to reset scheduler backoff?", "return", "nil", "\n", "}" ]
// The caller of this function must remove the taint if this function returns error.
[ "The", "caller", "of", "this", "function", "must", "remove", "the", "taint", "if", "this", "function", "returns", "error", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/rescheduler.go#L326-L374
train
kubernetes-retired/contrib
rescheduler/rescheduler.go
isCritical
func isCritical(annotations map[string]string) bool { val, ok := annotations[criticalPodAnnotation] if ok && val == "" { return true } return false }
go
func isCritical(annotations map[string]string) bool { val, ok := annotations[criticalPodAnnotation] if ok && val == "" { return true } return false }
[ "func", "isCritical", "(", "annotations", "map", "[", "string", "]", "string", ")", "bool", "{", "val", ",", "ok", ":=", "annotations", "[", "criticalPodAnnotation", "]", "\n", "if", "ok", "&&", "val", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// isCritical returns true if parameters bear the critical pod annotation
[ "isCritical", "returns", "true", "if", "parameters", "bear", "the", "critical", "pod", "annotation" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/rescheduler.go#L467-L473
train
kubernetes-retired/contrib
rescheduler/rescheduler.go
isMirrorPod
func isMirrorPod(pod *v1.Pod) bool { _, found := pod.ObjectMeta.Annotations[types.ConfigMirrorAnnotationKey] return found }
go
func isMirrorPod(pod *v1.Pod) bool { _, found := pod.ObjectMeta.Annotations[types.ConfigMirrorAnnotationKey] return found }
[ "func", "isMirrorPod", "(", "pod", "*", "v1", ".", "Pod", ")", "bool", "{", "_", ",", "found", ":=", "pod", ".", "ObjectMeta", ".", "Annotations", "[", "types", ".", "ConfigMirrorAnnotationKey", "]", "\n", "return", "found", "\n", "}" ]
// isMirrorPod checks whether the pod is a mirror pod.
[ "isMirrorPod", "checks", "whether", "the", "pod", "is", "a", "mirror", "pod", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/rescheduler.go#L484-L487
train
kubernetes-retired/contrib
rescheduler/rescheduler.go
isDaemonsetPod
func isDaemonsetPod(pod *v1.Pod) bool { ownerRefList := pod.ObjectMeta.GetOwnerReferences() for _, ownerRef := range ownerRefList { if ownerRef.Kind == "DaemonSet" { return true } } return false }
go
func isDaemonsetPod(pod *v1.Pod) bool { ownerRefList := pod.ObjectMeta.GetOwnerReferences() for _, ownerRef := range ownerRefList { if ownerRef.Kind == "DaemonSet" { return true } } return false }
[ "func", "isDaemonsetPod", "(", "pod", "*", "v1", ".", "Pod", ")", "bool", "{", "ownerRefList", ":=", "pod", ".", "ObjectMeta", ".", "GetOwnerReferences", "(", ")", "\n", "for", "_", ",", "ownerRef", ":=", "range", "ownerRefList", "{", "if", "ownerRef", ".", "Kind", "==", "\"", "\"", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// isDaemonSetPod checks where the pod is a daemonset pod.
[ "isDaemonSetPod", "checks", "where", "the", "pod", "is", "a", "daemonset", "pod", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/rescheduler.go#L490-L498
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/register.go
SetGroupVersionKind
func (obj *PluginBase) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { _, obj.Kind = gvk.ToAPIVersionAndKind() }
go
func (obj *PluginBase) SetGroupVersionKind(gvk *unversioned.GroupVersionKind) { _, obj.Kind = gvk.ToAPIVersionAndKind() }
[ "func", "(", "obj", "*", "PluginBase", ")", "SetGroupVersionKind", "(", "gvk", "*", "unversioned", ".", "GroupVersionKind", ")", "{", "_", ",", "obj", ".", "Kind", "=", "gvk", ".", "ToAPIVersionAndKind", "(", ")", "\n", "}" ]
// SetGroupVersionKind satisfies the ObjectKind interface for all objects that embed PluginBase
[ "SetGroupVersionKind", "satisfies", "the", "ObjectKind", "interface", "for", "all", "objects", "that", "embed", "PluginBase" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/register.go#L24-L26
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/help.go
IsListType
func IsListType(obj runtime.Object) bool { _, err := GetItemsPtr(obj) return err == nil }
go
func IsListType(obj runtime.Object) bool { _, err := GetItemsPtr(obj) return err == nil }
[ "func", "IsListType", "(", "obj", "runtime", ".", "Object", ")", "bool", "{", "_", ",", "err", ":=", "GetItemsPtr", "(", "obj", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsListType returns true if the provided Object has a slice called Items
[ "IsListType", "returns", "true", "if", "the", "provided", "Object", "has", "a", "slice", "called", "Items" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/help.go#L28-L31
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/help.go
GetItemsPtr
func GetItemsPtr(list runtime.Object) (interface{}, error) { v, err := conversion.EnforcePtr(list) if err != nil { return nil, err } items := v.FieldByName("Items") if !items.IsValid() { return nil, fmt.Errorf("no Items field in %#v", list) } switch items.Kind() { case reflect.Interface, reflect.Ptr: target := reflect.TypeOf(items.Interface()).Elem() if target.Kind() != reflect.Slice { return nil, fmt.Errorf("items: Expected slice, got %s", target.Kind()) } return items.Interface(), nil case reflect.Slice: return items.Addr().Interface(), nil default: return nil, fmt.Errorf("items: Expected slice, got %s", items.Kind()) } }
go
func GetItemsPtr(list runtime.Object) (interface{}, error) { v, err := conversion.EnforcePtr(list) if err != nil { return nil, err } items := v.FieldByName("Items") if !items.IsValid() { return nil, fmt.Errorf("no Items field in %#v", list) } switch items.Kind() { case reflect.Interface, reflect.Ptr: target := reflect.TypeOf(items.Interface()).Elem() if target.Kind() != reflect.Slice { return nil, fmt.Errorf("items: Expected slice, got %s", target.Kind()) } return items.Interface(), nil case reflect.Slice: return items.Addr().Interface(), nil default: return nil, fmt.Errorf("items: Expected slice, got %s", items.Kind()) } }
[ "func", "GetItemsPtr", "(", "list", "runtime", ".", "Object", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "v", ",", "err", ":=", "conversion", ".", "EnforcePtr", "(", "list", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "items", ":=", "v", ".", "FieldByName", "(", "\"", "\"", ")", "\n", "if", "!", "items", ".", "IsValid", "(", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "list", ")", "\n", "}", "\n", "switch", "items", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Interface", ",", "reflect", ".", "Ptr", ":", "target", ":=", "reflect", ".", "TypeOf", "(", "items", ".", "Interface", "(", ")", ")", ".", "Elem", "(", ")", "\n", "if", "target", ".", "Kind", "(", ")", "!=", "reflect", ".", "Slice", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "target", ".", "Kind", "(", ")", ")", "\n", "}", "\n", "return", "items", ".", "Interface", "(", ")", ",", "nil", "\n", "case", "reflect", ".", "Slice", ":", "return", "items", ".", "Addr", "(", ")", ".", "Interface", "(", ")", ",", "nil", "\n", "default", ":", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "items", ".", "Kind", "(", ")", ")", "\n", "}", "\n", "}" ]
// GetItemsPtr returns a pointer to the list object's Items member. // If 'list' doesn't have an Items member, it's not really a list type // and an error will be returned. // This function will either return a pointer to a slice, or an error, but not both.
[ "GetItemsPtr", "returns", "a", "pointer", "to", "the", "list", "object", "s", "Items", "member", ".", "If", "list", "doesn", "t", "have", "an", "Items", "member", "it", "s", "not", "really", "a", "list", "type", "and", "an", "error", "will", "be", "returned", ".", "This", "function", "will", "either", "return", "a", "pointer", "to", "a", "slice", "or", "an", "error", "but", "not", "both", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/help.go#L37-L58
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/resource_quotas.go
newResourceQuotas
func newResourceQuotas(c *Client, namespace string) *resourceQuotas { return &resourceQuotas{ r: c, ns: namespace, } }
go
func newResourceQuotas(c *Client, namespace string) *resourceQuotas { return &resourceQuotas{ r: c, ns: namespace, } }
[ "func", "newResourceQuotas", "(", "c", "*", "Client", ",", "namespace", "string", ")", "*", "resourceQuotas", "{", "return", "&", "resourceQuotas", "{", "r", ":", "c", ",", "ns", ":", "namespace", ",", "}", "\n", "}" ]
// newResourceQuotas returns a resourceQuotas
[ "newResourceQuotas", "returns", "a", "resourceQuotas" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/resource_quotas.go#L47-L52
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/resource_quotas.go
Create
func (c *resourceQuotas) Create(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { result = &api.ResourceQuota{} err = c.r.Post().Namespace(c.ns).Resource("resourceQuotas").Body(resourceQuota).Do().Into(result) return }
go
func (c *resourceQuotas) Create(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { result = &api.ResourceQuota{} err = c.r.Post().Namespace(c.ns).Resource("resourceQuotas").Body(resourceQuota).Do().Into(result) return }
[ "func", "(", "c", "*", "resourceQuotas", ")", "Create", "(", "resourceQuota", "*", "api", ".", "ResourceQuota", ")", "(", "result", "*", "api", ".", "ResourceQuota", ",", "err", "error", ")", "{", "result", "=", "&", "api", ".", "ResourceQuota", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "resourceQuota", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create takes the representation of a resourceQuota. Returns the server's representation of the resourceQuota, and an error, if it occurs.
[ "Create", "takes", "the", "representation", "of", "a", "resourceQuota", ".", "Returns", "the", "server", "s", "representation", "of", "the", "resourceQuota", "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/resource_quotas.go#L74-L78
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/resource_quotas.go
Update
func (c *resourceQuotas) Update(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { result = &api.ResourceQuota{} err = c.r.Put().Namespace(c.ns).Resource("resourceQuotas").Name(resourceQuota.Name).Body(resourceQuota).Do().Into(result) return }
go
func (c *resourceQuotas) Update(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) { result = &api.ResourceQuota{} err = c.r.Put().Namespace(c.ns).Resource("resourceQuotas").Name(resourceQuota.Name).Body(resourceQuota).Do().Into(result) return }
[ "func", "(", "c", "*", "resourceQuotas", ")", "Update", "(", "resourceQuota", "*", "api", ".", "ResourceQuota", ")", "(", "result", "*", "api", ".", "ResourceQuota", ",", "err", "error", ")", "{", "result", "=", "&", "api", ".", "ResourceQuota", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Put", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "resourceQuota", ".", "Name", ")", ".", "Body", "(", "resourceQuota", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Update takes the representation of a resourceQuota to update spec. Returns the server's representation of the resourceQuota, and an error, if it occurs.
[ "Update", "takes", "the", "representation", "of", "a", "resourceQuota", "to", "update", "spec", ".", "Returns", "the", "server", "s", "representation", "of", "the", "resourceQuota", "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/resource_quotas.go#L81-L85
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go
PostForm
func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) }
go
func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) }
[ "func", "PostForm", "(", "ctx", "context", ".", "Context", ",", "client", "*", "http", ".", "Client", ",", "url", "string", ",", "data", "url", ".", "Values", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "return", "Post", "(", "ctx", ",", "client", ",", "url", ",", "\"", "\"", ",", "strings", ".", "NewReader", "(", "data", ".", "Encode", "(", ")", ")", ")", "\n", "}" ]
// PostForm issues a POST request via the Do function.
[ "PostForm", "issues", "a", "POST", "request", "via", "the", "Do", "function", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go#L77-L79
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/codec.go
CodecFor
func CodecFor(codec ObjectCodec, version unversioned.GroupVersion) Codec { return &codecWrapper{codec, version} }
go
func CodecFor(codec ObjectCodec, version unversioned.GroupVersion) Codec { return &codecWrapper{codec, version} }
[ "func", "CodecFor", "(", "codec", "ObjectCodec", ",", "version", "unversioned", ".", "GroupVersion", ")", "Codec", "{", "return", "&", "codecWrapper", "{", "codec", ",", "version", "}", "\n", "}" ]
// CodecFor returns a Codec that invokes Encode with the provided version.
[ "CodecFor", "returns", "a", "Codec", "that", "invokes", "Encode", "with", "the", "provided", "version", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/codec.go#L45-L47
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/codec.go
Encode
func (c *codecWrapper) Encode(obj Object) ([]byte, error) { return c.EncodeToVersion(obj, c.version.String()) }
go
func (c *codecWrapper) Encode(obj Object) ([]byte, error) { return c.EncodeToVersion(obj, c.version.String()) }
[ "func", "(", "c", "*", "codecWrapper", ")", "Encode", "(", "obj", "Object", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "c", ".", "EncodeToVersion", "(", "obj", ",", "c", ".", "version", ".", "String", "(", ")", ")", "\n", "}" ]
// Encode implements Codec
[ "Encode", "implements", "Codec" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/runtime/codec.go#L102-L104
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go
NewInfo
func NewInfo(client RESTClient, mapping *meta.RESTMapping, namespace, name string, export bool) *Info { return &Info{ Client: client, Mapping: mapping, Namespace: namespace, Name: name, Export: export, } }
go
func NewInfo(client RESTClient, mapping *meta.RESTMapping, namespace, name string, export bool) *Info { return &Info{ Client: client, Mapping: mapping, Namespace: namespace, Name: name, Export: export, } }
[ "func", "NewInfo", "(", "client", "RESTClient", ",", "mapping", "*", "meta", ".", "RESTMapping", ",", "namespace", ",", "name", "string", ",", "export", "bool", ")", "*", "Info", "{", "return", "&", "Info", "{", "Client", ":", "client", ",", "Mapping", ":", "mapping", ",", "Namespace", ":", "namespace", ",", "Name", ":", "name", ",", "Export", ":", "export", ",", "}", "\n", "}" ]
// NewInfo returns a new info object
[ "NewInfo", "returns", "a", "new", "info", "object" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go#L93-L101
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go
Namespaced
func (i *Info) Namespaced() bool { return i.Mapping != nil && i.Mapping.Scope.Name() == meta.RESTScopeNameNamespace }
go
func (i *Info) Namespaced() bool { return i.Mapping != nil && i.Mapping.Scope.Name() == meta.RESTScopeNameNamespace }
[ "func", "(", "i", "*", "Info", ")", "Namespaced", "(", ")", "bool", "{", "return", "i", ".", "Mapping", "!=", "nil", "&&", "i", ".", "Mapping", ".", "Scope", ".", "Name", "(", ")", "==", "meta", ".", "RESTScopeNameNamespace", "\n", "}" ]
// Namespaced returns true if the object belongs to a namespace
[ "Namespaced", "returns", "true", "if", "the", "object", "belongs", "to", "a", "namespace" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go#L152-L154
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount_linux.go
doMount
func doMount(source string, target string, fstype string, options []string) error { glog.V(5).Infof("Mounting %s %s %s %v", source, target, fstype, options) mountArgs := makeMountArgs(source, target, fstype, options) command := exec.Command("mount", mountArgs...) output, err := command.CombinedOutput() if err != nil { return fmt.Errorf("Mount failed: %v\nMounting arguments: %s %s %s %v\nOutput: %s\n", err, source, target, fstype, options, string(output)) } return err }
go
func doMount(source string, target string, fstype string, options []string) error { glog.V(5).Infof("Mounting %s %s %s %v", source, target, fstype, options) mountArgs := makeMountArgs(source, target, fstype, options) command := exec.Command("mount", mountArgs...) output, err := command.CombinedOutput() if err != nil { return fmt.Errorf("Mount failed: %v\nMounting arguments: %s %s %s %v\nOutput: %s\n", err, source, target, fstype, options, string(output)) } return err }
[ "func", "doMount", "(", "source", "string", ",", "target", "string", ",", "fstype", "string", ",", "options", "[", "]", "string", ")", "error", "{", "glog", ".", "V", "(", "5", ")", ".", "Infof", "(", "\"", "\"", ",", "source", ",", "target", ",", "fstype", ",", "options", ")", "\n", "mountArgs", ":=", "makeMountArgs", "(", "source", ",", "target", ",", "fstype", ",", "options", ")", "\n", "command", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "mountArgs", "...", ")", "\n", "output", ",", "err", ":=", "command", ".", "CombinedOutput", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\\n", "\\n", "\\n", "\"", ",", "err", ",", "source", ",", "target", ",", "fstype", ",", "options", ",", "string", "(", "output", ")", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// doMount runs the mount command.
[ "doMount", "runs", "the", "mount", "command", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount_linux.go#L96-L106
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount_linux.go
diskLooksUnformatted
func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, error) { args := []string{"-nd", "-o", "FSTYPE", disk} cmd := mounter.Runner.Command("lsblk", args...) dataOut, err := cmd.CombinedOutput() output := strings.TrimSpace(string(dataOut)) // TODO (#13212): check if this disk has partitions and return false, and // an error if so. if err != nil { return false, err } return output == "", nil }
go
func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, error) { args := []string{"-nd", "-o", "FSTYPE", disk} cmd := mounter.Runner.Command("lsblk", args...) dataOut, err := cmd.CombinedOutput() output := strings.TrimSpace(string(dataOut)) // TODO (#13212): check if this disk has partitions and return false, and // an error if so. if err != nil { return false, err } return output == "", nil }
[ "func", "(", "mounter", "*", "SafeFormatAndMount", ")", "diskLooksUnformatted", "(", "disk", "string", ")", "(", "bool", ",", "error", ")", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "disk", "}", "\n", "cmd", ":=", "mounter", ".", "Runner", ".", "Command", "(", "\"", "\"", ",", "args", "...", ")", "\n", "dataOut", ",", "err", ":=", "cmd", ".", "CombinedOutput", "(", ")", "\n", "output", ":=", "strings", ".", "TrimSpace", "(", "string", "(", "dataOut", ")", ")", "\n\n", "// TODO (#13212): check if this disk has partitions and return false, and", "// an error if so.", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "return", "output", "==", "\"", "\"", ",", "nil", "\n", "}" ]
// diskLooksUnformatted uses 'lsblk' to see if the given disk is unformated
[ "diskLooksUnformatted", "uses", "lsblk", "to", "see", "if", "the", "given", "disk", "is", "unformated" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/mount/mount_linux.go#L271-L285
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/endpoints.go
Get
func (c *endpoints) Get(name string) (result *api.Endpoints, err error) { result = &api.Endpoints{} err = c.r.Get().Namespace(c.ns).Resource("endpoints").Name(name).Do().Into(result) return }
go
func (c *endpoints) Get(name string) (result *api.Endpoints, err error) { result = &api.Endpoints{} err = c.r.Get().Namespace(c.ns).Resource("endpoints").Name(name).Do().Into(result) return }
[ "func", "(", "c", "*", "endpoints", ")", "Get", "(", "name", "string", ")", "(", "result", "*", "api", ".", "Endpoints", ",", "err", "error", ")", "{", "result", "=", "&", "api", ".", "Endpoints", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Get", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Get returns information about the endpoints for a particular service.
[ "Get", "returns", "information", "about", "the", "endpoints", "for", "a", "particular", "service", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/endpoints.go#L72-L76
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/jwt/jwt.go
TokenSource
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource { return oauth2.ReuseTokenSource(nil, jwtSource{ctx, c}) }
go
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource { return oauth2.ReuseTokenSource(nil, jwtSource{ctx, c}) }
[ "func", "(", "c", "*", "Config", ")", "TokenSource", "(", "ctx", "context", ".", "Context", ")", "oauth2", ".", "TokenSource", "{", "return", "oauth2", ".", "ReuseTokenSource", "(", "nil", ",", "jwtSource", "{", "ctx", ",", "c", "}", ")", "\n", "}" ]
// TokenSource returns a JWT TokenSource using the configuration // in c and the HTTP client from the provided context.
[ "TokenSource", "returns", "a", "JWT", "TokenSource", "using", "the", "configuration", "in", "c", "and", "the", "HTTP", "client", "from", "the", "provided", "context", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/jwt/jwt.go#L61-L63
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/jwt/jwt.go
Client
func (c *Config) Client(ctx context.Context) *http.Client { return oauth2.NewClient(ctx, c.TokenSource(ctx)) }
go
func (c *Config) Client(ctx context.Context) *http.Client { return oauth2.NewClient(ctx, c.TokenSource(ctx)) }
[ "func", "(", "c", "*", "Config", ")", "Client", "(", "ctx", "context", ".", "Context", ")", "*", "http", ".", "Client", "{", "return", "oauth2", ".", "NewClient", "(", "ctx", ",", "c", ".", "TokenSource", "(", "ctx", ")", ")", "\n", "}" ]
// Client returns an HTTP client wrapping the context's // HTTP transport and adding Authorization headers with tokens // obtained from c. // // The returned client and its Transport should not be modified.
[ "Client", "returns", "an", "HTTP", "client", "wrapping", "the", "context", "s", "HTTP", "transport", "and", "adding", "Authorization", "headers", "with", "tokens", "obtained", "from", "c", ".", "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/jwt/jwt.go#L70-L72
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go
NewOrDie
func NewOrDie(c *Config) *Client { client, err := New(c) if err != nil { panic(err) } return client }
go
func NewOrDie(c *Config) *Client { client, err := New(c) if err != nil { panic(err) } return client }
[ "func", "NewOrDie", "(", "c", "*", "Config", ")", "*", "Client", "{", "client", ",", "err", ":=", "New", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "client", "\n", "}" ]
// NewOrDie creates a Kubernetes client and panics if the provided API version is not recognized.
[ "NewOrDie", "creates", "a", "Kubernetes", "client", "and", "panics", "if", "the", "provided", "API", "version", "is", "not", "recognized", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go#L352-L358
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go
InClusterConfig
func InClusterConfig() (*Config, error) { host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT") if len(host) == 0 || len(port) == 0 { return nil, fmt.Errorf("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined") } token, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountTokenKey) if err != nil { return nil, err } tlsClientConfig := TLSClientConfig{} rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountRootCAKey if _, err := util.CertPoolFromFile(rootCAFile); err != nil { glog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err) } else { tlsClientConfig.CAFile = rootCAFile } return &Config{ // TODO: switch to using cluster DNS. Host: "https://" + net.JoinHostPort(host, port), BearerToken: string(token), TLSClientConfig: tlsClientConfig, }, nil }
go
func InClusterConfig() (*Config, error) { host, port := os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT") if len(host) == 0 || len(port) == 0 { return nil, fmt.Errorf("unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined") } token, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountTokenKey) if err != nil { return nil, err } tlsClientConfig := TLSClientConfig{} rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountRootCAKey if _, err := util.CertPoolFromFile(rootCAFile); err != nil { glog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err) } else { tlsClientConfig.CAFile = rootCAFile } return &Config{ // TODO: switch to using cluster DNS. Host: "https://" + net.JoinHostPort(host, port), BearerToken: string(token), TLSClientConfig: tlsClientConfig, }, nil }
[ "func", "InClusterConfig", "(", ")", "(", "*", "Config", ",", "error", ")", "{", "host", ",", "port", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", ",", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "len", "(", "host", ")", "==", "0", "||", "len", "(", "port", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "token", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "\"", "\"", "+", "api", ".", "ServiceAccountTokenKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "tlsClientConfig", ":=", "TLSClientConfig", "{", "}", "\n", "rootCAFile", ":=", "\"", "\"", "+", "api", ".", "ServiceAccountRootCAKey", "\n", "if", "_", ",", "err", ":=", "util", ".", "CertPoolFromFile", "(", "rootCAFile", ")", ";", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "rootCAFile", ",", "err", ")", "\n", "}", "else", "{", "tlsClientConfig", ".", "CAFile", "=", "rootCAFile", "\n", "}", "\n\n", "return", "&", "Config", "{", "// TODO: switch to using cluster DNS.", "Host", ":", "\"", "\"", "+", "net", ".", "JoinHostPort", "(", "host", ",", "port", ")", ",", "BearerToken", ":", "string", "(", "token", ")", ",", "TLSClientConfig", ":", "tlsClientConfig", ",", "}", ",", "nil", "\n", "}" ]
// InClusterConfig returns a config object which uses the service account // kubernetes gives to pods. It's intended for clients that expect to be // running inside a pod running on kuberenetes. It will return an error if // called from a process not running in a kubernetes environment.
[ "InClusterConfig", "returns", "a", "config", "object", "which", "uses", "the", "service", "account", "kubernetes", "gives", "to", "pods", ".", "It", "s", "intended", "for", "clients", "that", "expect", "to", "be", "running", "inside", "a", "pod", "running", "on", "kuberenetes", ".", "It", "will", "return", "an", "error", "if", "called", "from", "a", "process", "not", "running", "in", "a", "kubernetes", "environment", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go#L364-L388
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go
DefaultKubernetesUserAgent
func DefaultKubernetesUserAgent() string { commit := version.Get().GitCommit if len(commit) > 7 { commit = commit[:7] } if len(commit) == 0 { commit = "unknown" } version := version.Get().GitVersion seg := strings.SplitN(version, "-", 2) version = seg[0] return fmt.Sprintf("%s/%s (%s/%s) kubernetes/%s", path.Base(os.Args[0]), version, gruntime.GOOS, gruntime.GOARCH, commit) }
go
func DefaultKubernetesUserAgent() string { commit := version.Get().GitCommit if len(commit) > 7 { commit = commit[:7] } if len(commit) == 0 { commit = "unknown" } version := version.Get().GitVersion seg := strings.SplitN(version, "-", 2) version = seg[0] return fmt.Sprintf("%s/%s (%s/%s) kubernetes/%s", path.Base(os.Args[0]), version, gruntime.GOOS, gruntime.GOARCH, commit) }
[ "func", "DefaultKubernetesUserAgent", "(", ")", "string", "{", "commit", ":=", "version", ".", "Get", "(", ")", ".", "GitCommit", "\n", "if", "len", "(", "commit", ")", ">", "7", "{", "commit", "=", "commit", "[", ":", "7", "]", "\n", "}", "\n", "if", "len", "(", "commit", ")", "==", "0", "{", "commit", "=", "\"", "\"", "\n", "}", "\n", "version", ":=", "version", ".", "Get", "(", ")", ".", "GitVersion", "\n", "seg", ":=", "strings", ".", "SplitN", "(", "version", ",", "\"", "\"", ",", "2", ")", "\n", "version", "=", "seg", "[", "0", "]", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "path", ".", "Base", "(", "os", ".", "Args", "[", "0", "]", ")", ",", "version", ",", "gruntime", ".", "GOOS", ",", "gruntime", ".", "GOARCH", ",", "commit", ")", "\n", "}" ]
// DefaultKubernetesUserAgent returns the default user agent that clients can use.
[ "DefaultKubernetesUserAgent", "returns", "the", "default", "user", "agent", "that", "clients", "can", "use", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/helper.go#L592-L604
train
kubernetes-retired/contrib
keepalived-vip/utils.go
getNetworkInfo
func getNetworkInfo(ip string) (*nodeInfo, error) { iface, mask, err := interfaceByIP(ip) if err != nil { return nil, err } return &nodeInfo{ iface: iface, ip: ip, netmask: mask, }, nil }
go
func getNetworkInfo(ip string) (*nodeInfo, error) { iface, mask, err := interfaceByIP(ip) if err != nil { return nil, err } return &nodeInfo{ iface: iface, ip: ip, netmask: mask, }, nil }
[ "func", "getNetworkInfo", "(", "ip", "string", ")", "(", "*", "nodeInfo", ",", "error", ")", "{", "iface", ",", "mask", ",", "err", ":=", "interfaceByIP", "(", "ip", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "nodeInfo", "{", "iface", ":", "iface", ",", "ip", ":", "ip", ",", "netmask", ":", "mask", ",", "}", ",", "nil", "\n", "}" ]
// getNetworkInfo returns information of the node where the pod is running
[ "getNetworkInfo", "returns", "information", "of", "the", "node", "where", "the", "pod", "is", "running" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L55-L65
train
kubernetes-retired/contrib
keepalived-vip/utils.go
netInterfaces
func netInterfaces() ([]net.Interface, error) { validIfaces := []net.Interface{} ifaces, err := net.Interfaces() if err != nil { return nil, err } for _, iface := range ifaces { if !vethRegex.MatchString(iface.Name) && stringSlice(invalidIfaces).pos(iface.Name) == -1 { validIfaces = append(validIfaces, iface) } } return validIfaces, nil }
go
func netInterfaces() ([]net.Interface, error) { validIfaces := []net.Interface{} ifaces, err := net.Interfaces() if err != nil { return nil, err } for _, iface := range ifaces { if !vethRegex.MatchString(iface.Name) && stringSlice(invalidIfaces).pos(iface.Name) == -1 { validIfaces = append(validIfaces, iface) } } return validIfaces, nil }
[ "func", "netInterfaces", "(", ")", "(", "[", "]", "net", ".", "Interface", ",", "error", ")", "{", "validIfaces", ":=", "[", "]", "net", ".", "Interface", "{", "}", "\n", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "iface", ":=", "range", "ifaces", "{", "if", "!", "vethRegex", ".", "MatchString", "(", "iface", ".", "Name", ")", "&&", "stringSlice", "(", "invalidIfaces", ")", ".", "pos", "(", "iface", ".", "Name", ")", "==", "-", "1", "{", "validIfaces", "=", "append", "(", "validIfaces", ",", "iface", ")", "\n", "}", "\n", "}", "\n\n", "return", "validIfaces", ",", "nil", "\n", "}" ]
// netInterfaces returns a slice containing the local network interfaces // excluding lo, docker0, flannel.1 and veth interfaces.
[ "netInterfaces", "returns", "a", "slice", "containing", "the", "local", "network", "interfaces", "excluding", "lo", "docker0", "flannel", ".", "1", "and", "veth", "interfaces", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L120-L134
train
kubernetes-retired/contrib
keepalived-vip/utils.go
interfaceByIP
func interfaceByIP(ip string) (string, int, error) { ifaces, err := netInterfaces() if err != nil { return "", 0, err } for _, iface := range ifaces { ifaceIP, mask, err := ipByInterface(iface.Name) if err == nil && ip == ifaceIP { return iface.Name, mask, nil } } return "", 0, fmt.Errorf("no matching interface found for IP %s", ip) }
go
func interfaceByIP(ip string) (string, int, error) { ifaces, err := netInterfaces() if err != nil { return "", 0, err } for _, iface := range ifaces { ifaceIP, mask, err := ipByInterface(iface.Name) if err == nil && ip == ifaceIP { return iface.Name, mask, nil } } return "", 0, fmt.Errorf("no matching interface found for IP %s", ip) }
[ "func", "interfaceByIP", "(", "ip", "string", ")", "(", "string", ",", "int", ",", "error", ")", "{", "ifaces", ",", "err", ":=", "netInterfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "0", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "iface", ":=", "range", "ifaces", "{", "ifaceIP", ",", "mask", ",", "err", ":=", "ipByInterface", "(", "iface", ".", "Name", ")", "\n", "if", "err", "==", "nil", "&&", "ip", "==", "ifaceIP", "{", "return", "iface", ".", "Name", ",", "mask", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "\"", "\"", ",", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ip", ")", "\n", "}" ]
// interfaceByIP returns the local network interface name that is using the // specified IP address. Returns an error if no matching interface is found.
[ "interfaceByIP", "returns", "the", "local", "network", "interface", "name", "that", "is", "using", "the", "specified", "IP", "address", ".", "Returns", "an", "error", "if", "no", "matching", "interface", "is", "found", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L138-L152
train
kubernetes-retired/contrib
keepalived-vip/utils.go
pos
func (slice stringSlice) pos(value string) int { for p, v := range slice { if v == value { return p } } return -1 }
go
func (slice stringSlice) pos(value string) int { for p, v := range slice { if v == value { return p } } return -1 }
[ "func", "(", "slice", "stringSlice", ")", "pos", "(", "value", "string", ")", "int", "{", "for", "p", ",", "v", ":=", "range", "slice", "{", "if", "v", "==", "value", "{", "return", "p", "\n", "}", "\n", "}", "\n\n", "return", "-", "1", "\n", "}" ]
// pos returns the position of a string in a slice. // If it does not exists in the slice returns -1.
[ "pos", "returns", "the", "position", "of", "a", "string", "in", "a", "slice", ".", "If", "it", "does", "not", "exists", "in", "the", "slice", "returns", "-", "1", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L183-L191
train
kubernetes-retired/contrib
keepalived-vip/utils.go
getClusterNodesIP
func getClusterNodesIP(kubeClient *unversioned.Client, nodeSelector string) (clusterNodes []string) { listOpts := api.ListOptions{} if nodeSelector != "" { label, err := labels.Parse(nodeSelector) if err != nil { glog.Fatalf("'%v' is not a valid selector: %v", nodeSelector, err) } listOpts.LabelSelector = label } nodes, err := kubeClient.Nodes().List(listOpts) if err != nil { glog.Fatalf("Error getting running nodes: %v", err) } for _, nodo := range nodes.Items { nodeIP, err := node.GetNodeHostIP(&nodo) if err == nil { clusterNodes = append(clusterNodes, nodeIP.String()) } } sort.Strings(clusterNodes) return }
go
func getClusterNodesIP(kubeClient *unversioned.Client, nodeSelector string) (clusterNodes []string) { listOpts := api.ListOptions{} if nodeSelector != "" { label, err := labels.Parse(nodeSelector) if err != nil { glog.Fatalf("'%v' is not a valid selector: %v", nodeSelector, err) } listOpts.LabelSelector = label } nodes, err := kubeClient.Nodes().List(listOpts) if err != nil { glog.Fatalf("Error getting running nodes: %v", err) } for _, nodo := range nodes.Items { nodeIP, err := node.GetNodeHostIP(&nodo) if err == nil { clusterNodes = append(clusterNodes, nodeIP.String()) } } sort.Strings(clusterNodes) return }
[ "func", "getClusterNodesIP", "(", "kubeClient", "*", "unversioned", ".", "Client", ",", "nodeSelector", "string", ")", "(", "clusterNodes", "[", "]", "string", ")", "{", "listOpts", ":=", "api", ".", "ListOptions", "{", "}", "\n\n", "if", "nodeSelector", "!=", "\"", "\"", "{", "label", ",", "err", ":=", "labels", ".", "Parse", "(", "nodeSelector", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Fatalf", "(", "\"", "\"", ",", "nodeSelector", ",", "err", ")", "\n", "}", "\n", "listOpts", ".", "LabelSelector", "=", "label", "\n", "}", "\n\n", "nodes", ",", "err", ":=", "kubeClient", ".", "Nodes", "(", ")", ".", "List", "(", "listOpts", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Fatalf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "_", ",", "nodo", ":=", "range", "nodes", ".", "Items", "{", "nodeIP", ",", "err", ":=", "node", ".", "GetNodeHostIP", "(", "&", "nodo", ")", "\n", "if", "err", "==", "nil", "{", "clusterNodes", "=", "append", "(", "clusterNodes", ",", "nodeIP", ".", "String", "(", ")", ")", "\n", "}", "\n", "}", "\n", "sort", ".", "Strings", "(", "clusterNodes", ")", "\n\n", "return", "\n", "}" ]
// getClusterNodesIP returns the IP address of each node in the kubernetes cluster
[ "getClusterNodesIP", "returns", "the", "IP", "address", "of", "each", "node", "in", "the", "kubernetes", "cluster" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L194-L219
train
kubernetes-retired/contrib
keepalived-vip/utils.go
getNodeNeighbors
func getNodeNeighbors(nodeInfo *nodeInfo, clusterNodes []string) (neighbors []string) { for _, neighbor := range clusterNodes { if nodeInfo.ip != neighbor { neighbors = append(neighbors, neighbor) } } sort.Strings(neighbors) return }
go
func getNodeNeighbors(nodeInfo *nodeInfo, clusterNodes []string) (neighbors []string) { for _, neighbor := range clusterNodes { if nodeInfo.ip != neighbor { neighbors = append(neighbors, neighbor) } } sort.Strings(neighbors) return }
[ "func", "getNodeNeighbors", "(", "nodeInfo", "*", "nodeInfo", ",", "clusterNodes", "[", "]", "string", ")", "(", "neighbors", "[", "]", "string", ")", "{", "for", "_", ",", "neighbor", ":=", "range", "clusterNodes", "{", "if", "nodeInfo", ".", "ip", "!=", "neighbor", "{", "neighbors", "=", "append", "(", "neighbors", ",", "neighbor", ")", "\n", "}", "\n", "}", "\n", "sort", ".", "Strings", "(", "neighbors", ")", "\n", "return", "\n", "}" ]
// getNodeNeighbors returns a list of IP address of the nodes
[ "getNodeNeighbors", "returns", "a", "list", "of", "IP", "address", "of", "the", "nodes" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L222-L230
train
kubernetes-retired/contrib
keepalived-vip/utils.go
getNodePriority
func getNodePriority(ip string, nodes []string) int { return 100 + stringSlice(nodes).pos(ip) }
go
func getNodePriority(ip string, nodes []string) int { return 100 + stringSlice(nodes).pos(ip) }
[ "func", "getNodePriority", "(", "ip", "string", ",", "nodes", "[", "]", "string", ")", "int", "{", "return", "100", "+", "stringSlice", "(", "nodes", ")", ".", "pos", "(", "ip", ")", "\n", "}" ]
// getPriority returns the priority of one node using the // IP address as key. It starts in 100
[ "getPriority", "returns", "the", "priority", "of", "one", "node", "using", "the", "IP", "address", "as", "key", ".", "It", "starts", "in", "100" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L234-L236
train
kubernetes-retired/contrib
keepalived-vip/utils.go
loadIPVModule
func loadIPVModule() error { out, err := k8sexec.New().Command("modprobe", "ip_vs").CombinedOutput() if err != nil { glog.V(2).Infof("Error loading ip_vip: %s, %v", string(out), err) return err } _, err = os.Stat("/proc/net/ip_vs") return err }
go
func loadIPVModule() error { out, err := k8sexec.New().Command("modprobe", "ip_vs").CombinedOutput() if err != nil { glog.V(2).Infof("Error loading ip_vip: %s, %v", string(out), err) return err } _, err = os.Stat("/proc/net/ip_vs") return err }
[ "func", "loadIPVModule", "(", ")", "error", "{", "out", ",", "err", ":=", "k8sexec", ".", "New", "(", ")", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ")", ".", "CombinedOutput", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "string", "(", "out", ")", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n\n", "_", ",", "err", "=", "os", ".", "Stat", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}" ]
// loadIPVModule load module require to use keepalived
[ "loadIPVModule", "load", "module", "require", "to", "use", "keepalived" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L239-L248
train
kubernetes-retired/contrib
keepalived-vip/utils.go
worker
func (t *taskQueue) worker() { for { key, quit := t.queue.Get() if quit { close(t.workerDone) return } glog.V(3).Infof("syncing %v", key) if err := t.sync(key.(string)); err != nil { glog.V(3).Infof("requeuing %v, err %v", key, err) t.requeue(key.(string)) } else { t.queue.Forget(key) } t.queue.Done(key) } }
go
func (t *taskQueue) worker() { for { key, quit := t.queue.Get() if quit { close(t.workerDone) return } glog.V(3).Infof("syncing %v", key) if err := t.sync(key.(string)); err != nil { glog.V(3).Infof("requeuing %v, err %v", key, err) t.requeue(key.(string)) } else { t.queue.Forget(key) } t.queue.Done(key) } }
[ "func", "(", "t", "*", "taskQueue", ")", "worker", "(", ")", "{", "for", "{", "key", ",", "quit", ":=", "t", ".", "queue", ".", "Get", "(", ")", "\n", "if", "quit", "{", "close", "(", "t", ".", "workerDone", ")", "\n", "return", "\n", "}", "\n", "glog", ".", "V", "(", "3", ")", ".", "Infof", "(", "\"", "\"", ",", "key", ")", "\n", "if", "err", ":=", "t", ".", "sync", "(", "key", ".", "(", "string", ")", ")", ";", "err", "!=", "nil", "{", "glog", ".", "V", "(", "3", ")", ".", "Infof", "(", "\"", "\"", ",", "key", ",", "err", ")", "\n", "t", ".", "requeue", "(", "key", ".", "(", "string", ")", ")", "\n", "}", "else", "{", "t", ".", "queue", ".", "Forget", "(", "key", ")", "\n", "}", "\n\n", "t", ".", "queue", ".", "Done", "(", "key", ")", "\n", "}", "\n", "}" ]
// worker processes work in the queue through sync.
[ "worker", "processes", "work", "in", "the", "queue", "through", "sync", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L395-L412
train
kubernetes-retired/contrib
keepalived-vip/utils.go
NewTaskQueue
func NewTaskQueue(syncFn func(string) error) *taskQueue { return &taskQueue{ queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()), sync: syncFn, workerDone: make(chan struct{}), } }
go
func NewTaskQueue(syncFn func(string) error) *taskQueue { return &taskQueue{ queue: workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()), sync: syncFn, workerDone: make(chan struct{}), } }
[ "func", "NewTaskQueue", "(", "syncFn", "func", "(", "string", ")", "error", ")", "*", "taskQueue", "{", "return", "&", "taskQueue", "{", "queue", ":", "workqueue", ".", "NewRateLimitingQueue", "(", "workqueue", ".", "DefaultControllerRateLimiter", "(", ")", ")", ",", "sync", ":", "syncFn", ",", "workerDone", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "}" ]
// NewTaskQueue creates a new task queue with the given sync function. // The sync function is called for every element inserted into the queue.
[ "NewTaskQueue", "creates", "a", "new", "task", "queue", "with", "the", "given", "sync", "function", ".", "The", "sync", "function", "is", "called", "for", "every", "element", "inserted", "into", "the", "queue", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/utils.go#L422-L428
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/ingress.go
Get
func (c *ingress) Get(name string) (result *extensions.Ingress, err error) { result = &extensions.Ingress{} err = c.r.Get().Namespace(c.ns).Resource("ingresses").Name(name).Do().Into(result) return }
go
func (c *ingress) Get(name string) (result *extensions.Ingress, err error) { result = &extensions.Ingress{} err = c.r.Get().Namespace(c.ns).Resource("ingresses").Name(name).Do().Into(result) return }
[ "func", "(", "c", "*", "ingress", ")", "Get", "(", "name", "string", ")", "(", "result", "*", "extensions", ".", "Ingress", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "Ingress", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Get", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Get returns information about a particular ingress.
[ "Get", "returns", "information", "about", "a", "particular", "ingress", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/ingress.go#L60-L64
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/rest/types.go
AllFuncs
func AllFuncs(fns ...ObjectFunc) ObjectFunc { return func(obj runtime.Object) error { for _, fn := range fns { if fn == nil { continue } if err := fn(obj); err != nil { return err } } return nil } }
go
func AllFuncs(fns ...ObjectFunc) ObjectFunc { return func(obj runtime.Object) error { for _, fn := range fns { if fn == nil { continue } if err := fn(obj); err != nil { return err } } return nil } }
[ "func", "AllFuncs", "(", "fns", "...", "ObjectFunc", ")", "ObjectFunc", "{", "return", "func", "(", "obj", "runtime", ".", "Object", ")", "error", "{", "for", "_", ",", "fn", ":=", "range", "fns", "{", "if", "fn", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "err", ":=", "fn", "(", "obj", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// AllFuncs returns an ObjectFunc that attempts to run all of the provided functions // in order, returning early if there are any errors.
[ "AllFuncs", "returns", "an", "ObjectFunc", "that", "attempts", "to", "run", "all", "of", "the", "provided", "functions", "in", "order", "returning", "early", "if", "there", "are", "any", "errors", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/rest/types.go#L30-L42
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/replication_controllers.go
Create
func (c *replicationControllers) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) { result = &api.ReplicationController{} err = c.r.Post().Namespace(c.ns).Resource("replicationControllers").Body(controller).Do().Into(result) return }
go
func (c *replicationControllers) Create(controller *api.ReplicationController) (result *api.ReplicationController, err error) { result = &api.ReplicationController{} err = c.r.Post().Namespace(c.ns).Resource("replicationControllers").Body(controller).Do().Into(result) return }
[ "func", "(", "c", "*", "replicationControllers", ")", "Create", "(", "controller", "*", "api", ".", "ReplicationController", ")", "(", "result", "*", "api", ".", "ReplicationController", ",", "err", "error", ")", "{", "result", "=", "&", "api", ".", "ReplicationController", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "controller", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create creates a new replication controller.
[ "Create", "creates", "a", "new", "replication", "controller", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/replication_controllers.go#L66-L70
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go
isBase60Float
func isBase60Float(s string) (result bool) { // Fast path. if s == "" { return false } c := s[0] if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { return false } // Do the full match. return base60float.MatchString(s) }
go
func isBase60Float(s string) (result bool) { // Fast path. if s == "" { return false } c := s[0] if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { return false } // Do the full match. return base60float.MatchString(s) }
[ "func", "isBase60Float", "(", "s", "string", ")", "(", "result", "bool", ")", "{", "// Fast path.", "if", "s", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "c", ":=", "s", "[", "0", "]", "\n", "if", "!", "(", "c", "==", "'+'", "||", "c", "==", "'-'", "||", "c", ">=", "'0'", "&&", "c", "<=", "'9'", ")", "||", "strings", ".", "IndexByte", "(", "s", ",", "':'", ")", "<", "0", "{", "return", "false", "\n", "}", "\n", "// Do the full match.", "return", "base60float", ".", "MatchString", "(", "s", ")", "\n", "}" ]
// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. // // The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported // in YAML 1.2 and by this package, but these should be marshalled quoted for // the time being for compatibility with other parsers.
[ "isBase60", "returns", "whether", "s", "is", "in", "base", "60", "notation", "as", "defined", "in", "YAML", "1", ".", "1", ".", "The", "base", "60", "float", "notation", "in", "YAML", "1", ".", "1", "is", "a", "terrible", "idea", "and", "is", "unsupported", "in", "YAML", "1", ".", "2", "and", "by", "this", "package", "but", "these", "should", "be", "marshalled", "quoted", "for", "the", "time", "being", "for", "compatibility", "with", "other", "parsers", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/encode.go#L207-L218
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/secrets.go
newSecrets
func newSecrets(c *Client, ns string) *secrets { return &secrets{ client: c, namespace: ns, } }
go
func newSecrets(c *Client, ns string) *secrets { return &secrets{ client: c, namespace: ns, } }
[ "func", "newSecrets", "(", "c", "*", "Client", ",", "ns", "string", ")", "*", "secrets", "{", "return", "&", "secrets", "{", "client", ":", "c", ",", "namespace", ":", "ns", ",", "}", "\n", "}" ]
// newSecrets returns a new secrets object.
[ "newSecrets", "returns", "a", "new", "secrets", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/secrets.go#L44-L49
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/secrets.go
Get
func (s *secrets) Get(name string) (*api.Secret, error) { result := &api.Secret{} err := s.client.Get(). Namespace(s.namespace). Resource("secrets"). Name(name). Do(). Into(result) return result, err }
go
func (s *secrets) Get(name string) (*api.Secret, error) { result := &api.Secret{} err := s.client.Get(). Namespace(s.namespace). Resource("secrets"). Name(name). Do(). Into(result) return result, err }
[ "func", "(", "s", "*", "secrets", ")", "Get", "(", "name", "string", ")", "(", "*", "api", ".", "Secret", ",", "error", ")", "{", "result", ":=", "&", "api", ".", "Secret", "{", "}", "\n", "err", ":=", "s", ".", "client", ".", "Get", "(", ")", ".", "Namespace", "(", "s", ".", "namespace", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n\n", "return", "result", ",", "err", "\n", "}" ]
// Get returns the given secret, or an error.
[ "Get", "returns", "the", "given", "secret", "or", "an", "error", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/secrets.go#L78-L88
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/daemon_sets.go
Create
func (c *daemonSets) Create(daemon *extensions.DaemonSet) (result *extensions.DaemonSet, err error) { result = &extensions.DaemonSet{} err = c.r.Post().Namespace(c.ns).Resource("daemonsets").Body(daemon).Do().Into(result) return }
go
func (c *daemonSets) Create(daemon *extensions.DaemonSet) (result *extensions.DaemonSet, err error) { result = &extensions.DaemonSet{} err = c.r.Post().Namespace(c.ns).Resource("daemonsets").Body(daemon).Do().Into(result) return }
[ "func", "(", "c", "*", "daemonSets", ")", "Create", "(", "daemon", "*", "extensions", ".", "DaemonSet", ")", "(", "result", "*", "extensions", ".", "DaemonSet", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "DaemonSet", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "daemon", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create creates a new daemon set.
[ "Create", "creates", "a", "new", "daemon", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/daemon_sets.go#L67-L71
train
kubernetes-retired/contrib
scale-demo/vegeta/loader.go
GetMetrics
func (h *HTTPReporter) GetMetrics() *vegeta.Metrics { h.Lock() defer h.Unlock() return h.metrics }
go
func (h *HTTPReporter) GetMetrics() *vegeta.Metrics { h.Lock() defer h.Unlock() return h.metrics }
[ "func", "(", "h", "*", "HTTPReporter", ")", "GetMetrics", "(", ")", "*", "vegeta", ".", "Metrics", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "return", "h", ".", "metrics", "\n", "}" ]
// GetMetrics returns the current metrics for this reporter
[ "GetMetrics", "returns", "the", "current", "metrics", "for", "this", "reporter" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/vegeta/loader.go#L57-L61
train
kubernetes-retired/contrib
scale-demo/vegeta/loader.go
SetMetrics
func (h *HTTPReporter) SetMetrics(metrics *vegeta.Metrics) { h.Lock() defer h.Unlock() h.metrics = metrics }
go
func (h *HTTPReporter) SetMetrics(metrics *vegeta.Metrics) { h.Lock() defer h.Unlock() h.metrics = metrics }
[ "func", "(", "h", "*", "HTTPReporter", ")", "SetMetrics", "(", "metrics", "*", "vegeta", ".", "Metrics", ")", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "h", ".", "metrics", "=", "metrics", "\n", "}" ]
// SetMetrics sets the current metrics for this reporter
[ "SetMetrics", "sets", "the", "current", "metrics", "for", "this", "reporter" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/vegeta/loader.go#L64-L68
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go
Get
func (c *thirdPartyResources) Get(name string) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.r.Get().Namespace(c.ns).Resource("thirdpartyresources").Name(name).Do().Into(result) return }
go
func (c *thirdPartyResources) Get(name string) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.r.Get().Namespace(c.ns).Resource("thirdpartyresources").Name(name).Do().Into(result) return }
[ "func", "(", "c", "*", "thirdPartyResources", ")", "Get", "(", "name", "string", ")", "(", "result", "*", "extensions", ".", "ThirdPartyResource", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "ThirdPartyResource", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Get", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Get returns information about a particular daemon set.
[ "Get", "returns", "information", "about", "a", "particular", "daemon", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go#L60-L64
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go
Delete
func (c *thirdPartyResources) Delete(name string) error { return c.r.Delete().Namespace(c.ns).Resource("thirdpartyresources").Name(name).Do().Error() }
go
func (c *thirdPartyResources) Delete(name string) error { return c.r.Delete().Namespace(c.ns).Resource("thirdpartyresources").Name(name).Do().Error() }
[ "func", "(", "c", "*", "thirdPartyResources", ")", "Delete", "(", "name", "string", ")", "error", "{", "return", "c", ".", "r", ".", "Delete", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Error", "(", ")", "\n", "}" ]
// Delete deletes an existing daemon set.
[ "Delete", "deletes", "an", "existing", "daemon", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go#L88-L90
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go
clientAuthenticate
func (c *connection) clientAuthenticate(config *ClientConfig) error { // initiate user auth session if err := c.transport.writePacket(Marshal(&serviceRequestMsg{serviceUserAuth})); err != nil { return err } packet, err := c.transport.readPacket() if err != nil { return err } var serviceAccept serviceAcceptMsg if err := Unmarshal(packet, &serviceAccept); err != nil { return err } // during the authentication phase the client first attempts the "none" method // then any untried methods suggested by the server. tried := make(map[string]bool) var lastMethods []string for auth := AuthMethod(new(noneAuth)); auth != nil; { ok, methods, err := auth.auth(c.transport.getSessionID(), config.User, c.transport, config.Rand) if err != nil { return err } if ok { // success return nil } tried[auth.method()] = true if methods == nil { methods = lastMethods } lastMethods = methods auth = nil findNext: for _, a := range config.Auth { candidateMethod := a.method() if tried[candidateMethod] { continue } for _, meth := range methods { if meth == candidateMethod { auth = a break findNext } } } } return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", keys(tried)) }
go
func (c *connection) clientAuthenticate(config *ClientConfig) error { // initiate user auth session if err := c.transport.writePacket(Marshal(&serviceRequestMsg{serviceUserAuth})); err != nil { return err } packet, err := c.transport.readPacket() if err != nil { return err } var serviceAccept serviceAcceptMsg if err := Unmarshal(packet, &serviceAccept); err != nil { return err } // during the authentication phase the client first attempts the "none" method // then any untried methods suggested by the server. tried := make(map[string]bool) var lastMethods []string for auth := AuthMethod(new(noneAuth)); auth != nil; { ok, methods, err := auth.auth(c.transport.getSessionID(), config.User, c.transport, config.Rand) if err != nil { return err } if ok { // success return nil } tried[auth.method()] = true if methods == nil { methods = lastMethods } lastMethods = methods auth = nil findNext: for _, a := range config.Auth { candidateMethod := a.method() if tried[candidateMethod] { continue } for _, meth := range methods { if meth == candidateMethod { auth = a break findNext } } } } return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", keys(tried)) }
[ "func", "(", "c", "*", "connection", ")", "clientAuthenticate", "(", "config", "*", "ClientConfig", ")", "error", "{", "// initiate user auth session", "if", "err", ":=", "c", ".", "transport", ".", "writePacket", "(", "Marshal", "(", "&", "serviceRequestMsg", "{", "serviceUserAuth", "}", ")", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "packet", ",", "err", ":=", "c", ".", "transport", ".", "readPacket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "serviceAccept", "serviceAcceptMsg", "\n", "if", "err", ":=", "Unmarshal", "(", "packet", ",", "&", "serviceAccept", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// during the authentication phase the client first attempts the \"none\" method", "// then any untried methods suggested by the server.", "tried", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "var", "lastMethods", "[", "]", "string", "\n", "for", "auth", ":=", "AuthMethod", "(", "new", "(", "noneAuth", ")", ")", ";", "auth", "!=", "nil", ";", "{", "ok", ",", "methods", ",", "err", ":=", "auth", ".", "auth", "(", "c", ".", "transport", ".", "getSessionID", "(", ")", ",", "config", ".", "User", ",", "c", ".", "transport", ",", "config", ".", "Rand", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "ok", "{", "// success", "return", "nil", "\n", "}", "\n", "tried", "[", "auth", ".", "method", "(", ")", "]", "=", "true", "\n", "if", "methods", "==", "nil", "{", "methods", "=", "lastMethods", "\n", "}", "\n", "lastMethods", "=", "methods", "\n\n", "auth", "=", "nil", "\n\n", "findNext", ":", "for", "_", ",", "a", ":=", "range", "config", ".", "Auth", "{", "candidateMethod", ":=", "a", ".", "method", "(", ")", "\n", "if", "tried", "[", "candidateMethod", "]", "{", "continue", "\n", "}", "\n", "for", "_", ",", "meth", ":=", "range", "methods", "{", "if", "meth", "==", "candidateMethod", "{", "auth", "=", "a", "\n", "break", "findNext", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "keys", "(", "tried", ")", ")", "\n", "}" ]
// clientAuthenticate authenticates with the remote server. See RFC 4252.
[ "clientAuthenticate", "authenticates", "with", "the", "remote", "server", ".", "See", "RFC", "4252", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go#L15-L65
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go
validateKey
func validateKey(key PublicKey, user string, c packetConn) (bool, error) { pubKey := key.Marshal() msg := publickeyAuthMsg{ User: user, Service: serviceSSH, Method: "publickey", HasSig: false, Algoname: key.Type(), PubKey: pubKey, } if err := c.writePacket(Marshal(&msg)); err != nil { return false, err } return confirmKeyAck(key, c) }
go
func validateKey(key PublicKey, user string, c packetConn) (bool, error) { pubKey := key.Marshal() msg := publickeyAuthMsg{ User: user, Service: serviceSSH, Method: "publickey", HasSig: false, Algoname: key.Type(), PubKey: pubKey, } if err := c.writePacket(Marshal(&msg)); err != nil { return false, err } return confirmKeyAck(key, c) }
[ "func", "validateKey", "(", "key", "PublicKey", ",", "user", "string", ",", "c", "packetConn", ")", "(", "bool", ",", "error", ")", "{", "pubKey", ":=", "key", ".", "Marshal", "(", ")", "\n", "msg", ":=", "publickeyAuthMsg", "{", "User", ":", "user", ",", "Service", ":", "serviceSSH", ",", "Method", ":", "\"", "\"", ",", "HasSig", ":", "false", ",", "Algoname", ":", "key", ".", "Type", "(", ")", ",", "PubKey", ":", "pubKey", ",", "}", "\n", "if", "err", ":=", "c", ".", "writePacket", "(", "Marshal", "(", "&", "msg", ")", ")", ";", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "return", "confirmKeyAck", "(", "key", ",", "c", ")", "\n", "}" ]
// validateKey validates the key provided is acceptable to the server.
[ "validateKey", "validates", "the", "key", "provided", "is", "acceptable", "to", "the", "server", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go#L245-L260
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go
handleAuthResponse
func handleAuthResponse(c packetConn) (bool, []string, error) { for { packet, err := c.readPacket() if err != nil { return false, nil, err } switch packet[0] { case msgUserAuthBanner: // TODO: add callback to present the banner to the user case msgUserAuthFailure: var msg userAuthFailureMsg if err := Unmarshal(packet, &msg); err != nil { return false, nil, err } return false, msg.Methods, nil case msgUserAuthSuccess: return true, nil, nil case msgDisconnect: return false, nil, io.EOF default: return false, nil, unexpectedMessageError(msgUserAuthSuccess, packet[0]) } } }
go
func handleAuthResponse(c packetConn) (bool, []string, error) { for { packet, err := c.readPacket() if err != nil { return false, nil, err } switch packet[0] { case msgUserAuthBanner: // TODO: add callback to present the banner to the user case msgUserAuthFailure: var msg userAuthFailureMsg if err := Unmarshal(packet, &msg); err != nil { return false, nil, err } return false, msg.Methods, nil case msgUserAuthSuccess: return true, nil, nil case msgDisconnect: return false, nil, io.EOF default: return false, nil, unexpectedMessageError(msgUserAuthSuccess, packet[0]) } } }
[ "func", "handleAuthResponse", "(", "c", "packetConn", ")", "(", "bool", ",", "[", "]", "string", ",", "error", ")", "{", "for", "{", "packet", ",", "err", ":=", "c", ".", "readPacket", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "nil", ",", "err", "\n", "}", "\n\n", "switch", "packet", "[", "0", "]", "{", "case", "msgUserAuthBanner", ":", "// TODO: add callback to present the banner to the user", "case", "msgUserAuthFailure", ":", "var", "msg", "userAuthFailureMsg", "\n", "if", "err", ":=", "Unmarshal", "(", "packet", ",", "&", "msg", ")", ";", "err", "!=", "nil", "{", "return", "false", ",", "nil", ",", "err", "\n", "}", "\n", "return", "false", ",", "msg", ".", "Methods", ",", "nil", "\n", "case", "msgUserAuthSuccess", ":", "return", "true", ",", "nil", ",", "nil", "\n", "case", "msgDisconnect", ":", "return", "false", ",", "nil", ",", "io", ".", "EOF", "\n", "default", ":", "return", "false", ",", "nil", ",", "unexpectedMessageError", "(", "msgUserAuthSuccess", ",", "packet", "[", "0", "]", ")", "\n", "}", "\n", "}", "\n", "}" ]
// handleAuthResponse returns whether the preceding authentication request succeeded // along with a list of remaining authentication methods to try next and // an error if an unexpected response was received.
[ "handleAuthResponse", "returns", "whether", "the", "preceding", "authentication", "request", "succeeded", "along", "with", "a", "list", "of", "remaining", "authentication", "methods", "to", "try", "next", "and", "an", "error", "if", "an", "unexpected", "response", "was", "received", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_auth.go#L306-L330
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go
newThirdPartyResources
func newThirdPartyResources(c *ExtensionsClient, namespace string) *thirdPartyResources { return &thirdPartyResources{ client: c, ns: namespace, } }
go
func newThirdPartyResources(c *ExtensionsClient, namespace string) *thirdPartyResources { return &thirdPartyResources{ client: c, ns: namespace, } }
[ "func", "newThirdPartyResources", "(", "c", "*", "ExtensionsClient", ",", "namespace", "string", ")", "*", "thirdPartyResources", "{", "return", "&", "thirdPartyResources", "{", "client", ":", "c", ",", "ns", ":", "namespace", ",", "}", "\n", "}" ]
// newThirdPartyResources returns a ThirdPartyResources
[ "newThirdPartyResources", "returns", "a", "ThirdPartyResources" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go#L48-L53
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go
Create
func (c *thirdPartyResources) Create(thirdPartyResource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.client.Post(). Namespace(c.ns). Resource("thirdPartyResources"). Body(thirdPartyResource). Do(). Into(result) return }
go
func (c *thirdPartyResources) Create(thirdPartyResource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.client.Post(). Namespace(c.ns). Resource("thirdPartyResources"). Body(thirdPartyResource). Do(). Into(result) return }
[ "func", "(", "c", "*", "thirdPartyResources", ")", "Create", "(", "thirdPartyResource", "*", "extensions", ".", "ThirdPartyResource", ")", "(", "result", "*", "extensions", ".", "ThirdPartyResource", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "ThirdPartyResource", "{", "}", "\n", "err", "=", "c", ".", "client", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "thirdPartyResource", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create takes the representation of a thirdPartyResource and creates it. Returns the server's representation of the thirdPartyResource, and an error, if there is any.
[ "Create", "takes", "the", "representation", "of", "a", "thirdPartyResource", "and", "creates", "it", ".", "Returns", "the", "server", "s", "representation", "of", "the", "thirdPartyResource", "and", "an", "error", "if", "there", "is", "any", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go#L56-L65
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go
Update
func (c *thirdPartyResources) Update(thirdPartyResource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.client.Put(). Namespace(c.ns). Resource("thirdPartyResources"). Name(thirdPartyResource.Name). Body(thirdPartyResource). Do(). Into(result) return }
go
func (c *thirdPartyResources) Update(thirdPartyResource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.client.Put(). Namespace(c.ns). Resource("thirdPartyResources"). Name(thirdPartyResource.Name). Body(thirdPartyResource). Do(). Into(result) return }
[ "func", "(", "c", "*", "thirdPartyResources", ")", "Update", "(", "thirdPartyResource", "*", "extensions", ".", "ThirdPartyResource", ")", "(", "result", "*", "extensions", ".", "ThirdPartyResource", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "ThirdPartyResource", "{", "}", "\n", "err", "=", "c", ".", "client", ".", "Put", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "thirdPartyResource", ".", "Name", ")", ".", "Body", "(", "thirdPartyResource", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Update takes the representation of a thirdPartyResource and updates it. Returns the server's representation of the thirdPartyResource, and an error, if there is any.
[ "Update", "takes", "the", "representation", "of", "a", "thirdPartyResource", "and", "updates", "it", ".", "Returns", "the", "server", "s", "representation", "of", "the", "thirdPartyResource", "and", "an", "error", "if", "there", "is", "any", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned/thirdpartyresource.go#L68-L78
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go
unmarshalECKey
func unmarshalECKey(curve elliptic.Curve, pubkey []byte) (x, y *big.Int, err error) { x, y = elliptic.Unmarshal(curve, pubkey) if x == nil { return nil, nil, errors.New("ssh: elliptic.Unmarshal failure") } if !validateECPublicKey(curve, x, y) { return nil, nil, errors.New("ssh: public key not on curve") } return x, y, nil }
go
func unmarshalECKey(curve elliptic.Curve, pubkey []byte) (x, y *big.Int, err error) { x, y = elliptic.Unmarshal(curve, pubkey) if x == nil { return nil, nil, errors.New("ssh: elliptic.Unmarshal failure") } if !validateECPublicKey(curve, x, y) { return nil, nil, errors.New("ssh: public key not on curve") } return x, y, nil }
[ "func", "unmarshalECKey", "(", "curve", "elliptic", ".", "Curve", ",", "pubkey", "[", "]", "byte", ")", "(", "x", ",", "y", "*", "big", ".", "Int", ",", "err", "error", ")", "{", "x", ",", "y", "=", "elliptic", ".", "Unmarshal", "(", "curve", ",", "pubkey", ")", "\n", "if", "x", "==", "nil", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "validateECPublicKey", "(", "curve", ",", "x", ",", "y", ")", "{", "return", "nil", ",", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "x", ",", "y", ",", "nil", "\n", "}" ]
// unmarshalECKey parses and checks an EC key.
[ "unmarshalECKey", "parses", "and", "checks", "an", "EC", "key", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex.go#L252-L261
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/encoder.go
NewEncoder
func NewEncoder(w io.Writer, codec runtime.Codec) *Encoder { return &Encoder{ w: w, encoder: json.NewEncoder(w), codec: codec, } }
go
func NewEncoder(w io.Writer, codec runtime.Codec) *Encoder { return &Encoder{ w: w, encoder: json.NewEncoder(w), codec: codec, } }
[ "func", "NewEncoder", "(", "w", "io", ".", "Writer", ",", "codec", "runtime", ".", "Codec", ")", "*", "Encoder", "{", "return", "&", "Encoder", "{", "w", ":", "w", ",", "encoder", ":", "json", ".", "NewEncoder", "(", "w", ")", ",", "codec", ":", "codec", ",", "}", "\n", "}" ]
// NewEncoder creates an Encoder for the given writer and codec
[ "NewEncoder", "creates", "an", "Encoder", "for", "the", "given", "writer", "and", "codec" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/encoder.go#L37-L43
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go
Create
func (c *thirdPartyResources) Create(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.r.Post().Namespace(c.ns).Resource("thirdpartyresources").Body(resource).Do().Into(result) return }
go
func (c *thirdPartyResources) Create(resource *extensions.ThirdPartyResource) (result *extensions.ThirdPartyResource, err error) { result = &extensions.ThirdPartyResource{} err = c.r.Post().Namespace(c.ns).Resource("thirdpartyresources").Body(resource).Do().Into(result) return }
[ "func", "(", "c", "*", "thirdPartyResources", ")", "Create", "(", "resource", "*", "extensions", ".", "ThirdPartyResource", ")", "(", "result", "*", "extensions", ".", "ThirdPartyResource", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "ThirdPartyResource", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "resource", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create creates a new third party resource.
[ "Create", "creates", "a", "new", "third", "party", "resource", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/thirdpartyresources.go#L67-L71
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/crypto.go
certificatesFromFile
func certificatesFromFile(file string) ([]*x509.Certificate, error) { if len(file) == 0 { return nil, errors.New("error reading certificates from an empty filename") } pemBlock, err := ioutil.ReadFile(file) if err != nil { return nil, err } certs, err := CertsFromPEM(pemBlock) if err != nil { return nil, fmt.Errorf("error reading %s: %s", file, err) } return certs, nil }
go
func certificatesFromFile(file string) ([]*x509.Certificate, error) { if len(file) == 0 { return nil, errors.New("error reading certificates from an empty filename") } pemBlock, err := ioutil.ReadFile(file) if err != nil { return nil, err } certs, err := CertsFromPEM(pemBlock) if err != nil { return nil, fmt.Errorf("error reading %s: %s", file, err) } return certs, nil }
[ "func", "certificatesFromFile", "(", "file", "string", ")", "(", "[", "]", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "if", "len", "(", "file", ")", "==", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "pemBlock", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "certs", ",", "err", ":=", "CertsFromPEM", "(", "pemBlock", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "file", ",", "err", ")", "\n", "}", "\n", "return", "certs", ",", "nil", "\n", "}" ]
// certificatesFromFile returns the x509.Certificates contained in the given PEM-encoded file. // Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates
[ "certificatesFromFile", "returns", "the", "x509", ".", "Certificates", "contained", "in", "the", "given", "PEM", "-", "encoded", "file", ".", "Returns", "an", "error", "if", "the", "file", "could", "not", "be", "read", "a", "certificate", "could", "not", "be", "parsed", "or", "if", "the", "file", "does", "not", "contain", "any", "certificates" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/crypto.go#L123-L136
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/clock.go
Step
func (f *FakeClock) Step(d time.Duration) { f.Time = f.Time.Add(d) }
go
func (f *FakeClock) Step(d time.Duration) { f.Time = f.Time.Add(d) }
[ "func", "(", "f", "*", "FakeClock", ")", "Step", "(", "d", "time", ".", "Duration", ")", "{", "f", ".", "Time", "=", "f", ".", "Time", ".", "Add", "(", "d", ")", "\n", "}" ]
// Move clock by Duration
[ "Move", "clock", "by", "Duration" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/clock.go#L59-L61
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/extensions.go
NewExtensions
func NewExtensions(c *Config) (*ExtensionsClient, error) { config := *c if err := setExtensionsDefaults(&config); err != nil { return nil, err } client, err := RESTClientFor(&config) if err != nil { return nil, err } return &ExtensionsClient{client}, nil }
go
func NewExtensions(c *Config) (*ExtensionsClient, error) { config := *c if err := setExtensionsDefaults(&config); err != nil { return nil, err } client, err := RESTClientFor(&config) if err != nil { return nil, err } return &ExtensionsClient{client}, nil }
[ "func", "NewExtensions", "(", "c", "*", "Config", ")", "(", "*", "ExtensionsClient", ",", "error", ")", "{", "config", ":=", "*", "c", "\n", "if", "err", ":=", "setExtensionsDefaults", "(", "&", "config", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "client", ",", "err", ":=", "RESTClientFor", "(", "&", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "ExtensionsClient", "{", "client", "}", ",", "nil", "\n", "}" ]
// NewExtensions creates a new ExtensionsClient for the given config. This client // provides access to experimental Kubernetes features. // Features of Extensions group are not supported and may be changed or removed in // incompatible ways at any time.
[ "NewExtensions", "creates", "a", "new", "ExtensionsClient", "for", "the", "given", "config", ".", "This", "client", "provides", "access", "to", "experimental", "Kubernetes", "features", ".", "Features", "of", "Extensions", "group", "are", "not", "supported", "and", "may", "be", "changed", "or", "removed", "in", "incompatible", "ways", "at", "any", "time", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/extensions.go#L101-L111
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/extensions.go
NewExtensionsOrDie
func NewExtensionsOrDie(c *Config) *ExtensionsClient { client, err := NewExtensions(c) if err != nil { panic(err) } return client }
go
func NewExtensionsOrDie(c *Config) *ExtensionsClient { client, err := NewExtensions(c) if err != nil { panic(err) } return client }
[ "func", "NewExtensionsOrDie", "(", "c", "*", "Config", ")", "*", "ExtensionsClient", "{", "client", ",", "err", ":=", "NewExtensions", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "client", "\n", "}" ]
// NewExtensionsOrDie creates a new ExtensionsClient for the given config and // panics if there is an error in the config. // Features of Extensions group are not supported and may be changed or removed in // incompatible ways at any time.
[ "NewExtensionsOrDie", "creates", "a", "new", "ExtensionsClient", "for", "the", "given", "config", "and", "panics", "if", "there", "is", "an", "error", "in", "the", "config", ".", "Features", "of", "Extensions", "group", "are", "not", "supported", "and", "may", "be", "changed", "or", "removed", "in", "incompatible", "ways", "at", "any", "time", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/extensions.go#L117-L123
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/configmap.go
ParamNames
func (s ConfigMapGeneratorV1) ParamNames() []GeneratorParam { return []GeneratorParam{ {"name", true}, {"type", false}, {"from-file", false}, {"from-literal", false}, {"force", false}, } }
go
func (s ConfigMapGeneratorV1) ParamNames() []GeneratorParam { return []GeneratorParam{ {"name", true}, {"type", false}, {"from-file", false}, {"from-literal", false}, {"force", false}, } }
[ "func", "(", "s", "ConfigMapGeneratorV1", ")", "ParamNames", "(", ")", "[", "]", "GeneratorParam", "{", "return", "[", "]", "GeneratorParam", "{", "{", "\"", "\"", ",", "true", "}", ",", "{", "\"", "\"", ",", "false", "}", ",", "{", "\"", "\"", ",", "false", "}", ",", "{", "\"", "\"", ",", "false", "}", ",", "{", "\"", "\"", ",", "false", "}", ",", "}", "\n", "}" ]
// ParamNames returns the set of supported input parameters when using the parameter injection generator pattern.
[ "ParamNames", "returns", "the", "set", "of", "supported", "input", "parameters", "when", "using", "the", "parameter", "injection", "generator", "pattern", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/configmap.go#L88-L96
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/thread_safe_store.go
ByIndex
func (c *threadSafeMap) ByIndex(indexName, indexKey string) ([]interface{}, error) { c.lock.RLock() defer c.lock.RUnlock() indexFunc := c.indexers[indexName] if indexFunc == nil { return nil, fmt.Errorf("Index with name %s does not exist", indexName) } index := c.indices[indexName] set := index[indexKey] list := make([]interface{}, 0, set.Len()) for _, key := range set.List() { list = append(list, c.items[key]) } return list, nil }
go
func (c *threadSafeMap) ByIndex(indexName, indexKey string) ([]interface{}, error) { c.lock.RLock() defer c.lock.RUnlock() indexFunc := c.indexers[indexName] if indexFunc == nil { return nil, fmt.Errorf("Index with name %s does not exist", indexName) } index := c.indices[indexName] set := index[indexKey] list := make([]interface{}, 0, set.Len()) for _, key := range set.List() { list = append(list, c.items[key]) } return list, nil }
[ "func", "(", "c", "*", "threadSafeMap", ")", "ByIndex", "(", "indexName", ",", "indexKey", "string", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "c", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "lock", ".", "RUnlock", "(", ")", "\n\n", "indexFunc", ":=", "c", ".", "indexers", "[", "indexName", "]", "\n", "if", "indexFunc", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "indexName", ")", "\n", "}", "\n\n", "index", ":=", "c", ".", "indices", "[", "indexName", "]", "\n\n", "set", ":=", "index", "[", "indexKey", "]", "\n", "list", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ",", "set", ".", "Len", "(", ")", ")", "\n", "for", "_", ",", "key", ":=", "range", "set", ".", "List", "(", ")", "{", "list", "=", "append", "(", "list", ",", "c", ".", "items", "[", "key", "]", ")", "\n", "}", "\n\n", "return", "list", ",", "nil", "\n", "}" ]
// ByIndex returns a list of items that match an exact value on the index function
[ "ByIndex", "returns", "a", "list", "of", "items", "that", "match", "an", "exact", "value", "on", "the", "index", "function" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/thread_safe_store.go#L161-L179
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go
New
func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}) (*PortForwarder, error) { if len(ports) == 0 { return nil, errors.New("You must specify at least 1 port") } parsedPorts, err := parsePorts(ports) if err != nil { return nil, err } return &PortForwarder{ dialer: dialer, ports: parsedPorts, stopChan: stopChan, Ready: make(chan struct{}), }, nil }
go
func New(dialer httpstream.Dialer, ports []string, stopChan <-chan struct{}) (*PortForwarder, error) { if len(ports) == 0 { return nil, errors.New("You must specify at least 1 port") } parsedPorts, err := parsePorts(ports) if err != nil { return nil, err } return &PortForwarder{ dialer: dialer, ports: parsedPorts, stopChan: stopChan, Ready: make(chan struct{}), }, nil }
[ "func", "New", "(", "dialer", "httpstream", ".", "Dialer", ",", "ports", "[", "]", "string", ",", "stopChan", "<-", "chan", "struct", "{", "}", ")", "(", "*", "PortForwarder", ",", "error", ")", "{", "if", "len", "(", "ports", ")", "==", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "parsedPorts", ",", "err", ":=", "parsePorts", "(", "ports", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "PortForwarder", "{", "dialer", ":", "dialer", ",", "ports", ":", "parsedPorts", ",", "stopChan", ":", "stopChan", ",", "Ready", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", ",", "nil", "\n", "}" ]
// New creates a new PortForwarder.
[ "New", "creates", "a", "new", "PortForwarder", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go#L110-L124
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go
listenOnPort
func (pf *PortForwarder) listenOnPort(port *ForwardedPort) error { errTcp4 := pf.listenOnPortAndAddress(port, "tcp4", "127.0.0.1") errTcp6 := pf.listenOnPortAndAddress(port, "tcp6", "[::1]") if errTcp4 != nil && errTcp6 != nil { return fmt.Errorf("All listeners failed to create with the following errors: %s, %s", errTcp4, errTcp6) } return nil }
go
func (pf *PortForwarder) listenOnPort(port *ForwardedPort) error { errTcp4 := pf.listenOnPortAndAddress(port, "tcp4", "127.0.0.1") errTcp6 := pf.listenOnPortAndAddress(port, "tcp6", "[::1]") if errTcp4 != nil && errTcp6 != nil { return fmt.Errorf("All listeners failed to create with the following errors: %s, %s", errTcp4, errTcp6) } return nil }
[ "func", "(", "pf", "*", "PortForwarder", ")", "listenOnPort", "(", "port", "*", "ForwardedPort", ")", "error", "{", "errTcp4", ":=", "pf", ".", "listenOnPortAndAddress", "(", "port", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "errTcp6", ":=", "pf", ".", "listenOnPortAndAddress", "(", "port", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "errTcp4", "!=", "nil", "&&", "errTcp6", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "errTcp4", ",", "errTcp6", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// listenOnPort delegates tcp4 and tcp6 listener creation and waits for connections on both of these addresses. // If both listener creation fail, an error is raised.
[ "listenOnPort", "delegates", "tcp4", "and", "tcp6", "listener", "creation", "and", "waits", "for", "connections", "on", "both", "of", "these", "addresses", ".", "If", "both", "listener", "creation", "fail", "an", "error", "is", "raised", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go#L176-L183
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go
handleConnection
func (pf *PortForwarder) handleConnection(conn net.Conn, port ForwardedPort) { defer conn.Close() glog.Infof("Handling connection for %d", port.Local) requestID := pf.nextRequestID() // create error stream headers := http.Header{} headers.Set(api.StreamType, api.StreamTypeError) headers.Set(api.PortHeader, fmt.Sprintf("%d", port.Remote)) headers.Set(api.PortForwardRequestIDHeader, strconv.Itoa(requestID)) errorStream, err := pf.streamConn.CreateStream(headers) if err != nil { util.HandleError(fmt.Errorf("error creating error stream for port %d -> %d: %v", port.Local, port.Remote, err)) return } // we're not writing to this stream errorStream.Close() errorChan := make(chan error) go func() { message, err := ioutil.ReadAll(errorStream) switch { case err != nil: errorChan <- fmt.Errorf("error reading from error stream for port %d -> %d: %v", port.Local, port.Remote, err) case len(message) > 0: errorChan <- fmt.Errorf("an error occurred forwarding %d -> %d: %v", port.Local, port.Remote, string(message)) } close(errorChan) }() // create data stream headers.Set(api.StreamType, api.StreamTypeData) dataStream, err := pf.streamConn.CreateStream(headers) if err != nil { util.HandleError(fmt.Errorf("error creating forwarding stream for port %d -> %d: %v", port.Local, port.Remote, err)) return } localError := make(chan struct{}) remoteDone := make(chan struct{}) go func() { // Copy from the remote side to the local port. if _, err := io.Copy(conn, dataStream); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { util.HandleError(fmt.Errorf("error copying from remote stream to local connection: %v", err)) } // inform the select below that the remote copy is done close(remoteDone) }() go func() { // inform server we're not sending any more data after copy unblocks defer dataStream.Close() // Copy from the local port to the remote side. if _, err := io.Copy(dataStream, conn); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { util.HandleError(fmt.Errorf("error copying from local connection to remote stream: %v", err)) // break out of the select below without waiting for the other copy to finish close(localError) } }() // wait for either a local->remote error or for copying from remote->local to finish select { case <-remoteDone: case <-localError: } // always expect something on errorChan (it may be nil) err = <-errorChan if err != nil { util.HandleError(err) } }
go
func (pf *PortForwarder) handleConnection(conn net.Conn, port ForwardedPort) { defer conn.Close() glog.Infof("Handling connection for %d", port.Local) requestID := pf.nextRequestID() // create error stream headers := http.Header{} headers.Set(api.StreamType, api.StreamTypeError) headers.Set(api.PortHeader, fmt.Sprintf("%d", port.Remote)) headers.Set(api.PortForwardRequestIDHeader, strconv.Itoa(requestID)) errorStream, err := pf.streamConn.CreateStream(headers) if err != nil { util.HandleError(fmt.Errorf("error creating error stream for port %d -> %d: %v", port.Local, port.Remote, err)) return } // we're not writing to this stream errorStream.Close() errorChan := make(chan error) go func() { message, err := ioutil.ReadAll(errorStream) switch { case err != nil: errorChan <- fmt.Errorf("error reading from error stream for port %d -> %d: %v", port.Local, port.Remote, err) case len(message) > 0: errorChan <- fmt.Errorf("an error occurred forwarding %d -> %d: %v", port.Local, port.Remote, string(message)) } close(errorChan) }() // create data stream headers.Set(api.StreamType, api.StreamTypeData) dataStream, err := pf.streamConn.CreateStream(headers) if err != nil { util.HandleError(fmt.Errorf("error creating forwarding stream for port %d -> %d: %v", port.Local, port.Remote, err)) return } localError := make(chan struct{}) remoteDone := make(chan struct{}) go func() { // Copy from the remote side to the local port. if _, err := io.Copy(conn, dataStream); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { util.HandleError(fmt.Errorf("error copying from remote stream to local connection: %v", err)) } // inform the select below that the remote copy is done close(remoteDone) }() go func() { // inform server we're not sending any more data after copy unblocks defer dataStream.Close() // Copy from the local port to the remote side. if _, err := io.Copy(dataStream, conn); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { util.HandleError(fmt.Errorf("error copying from local connection to remote stream: %v", err)) // break out of the select below without waiting for the other copy to finish close(localError) } }() // wait for either a local->remote error or for copying from remote->local to finish select { case <-remoteDone: case <-localError: } // always expect something on errorChan (it may be nil) err = <-errorChan if err != nil { util.HandleError(err) } }
[ "func", "(", "pf", "*", "PortForwarder", ")", "handleConnection", "(", "conn", "net", ".", "Conn", ",", "port", "ForwardedPort", ")", "{", "defer", "conn", ".", "Close", "(", ")", "\n\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "port", ".", "Local", ")", "\n\n", "requestID", ":=", "pf", ".", "nextRequestID", "(", ")", "\n\n", "// create error stream", "headers", ":=", "http", ".", "Header", "{", "}", "\n", "headers", ".", "Set", "(", "api", ".", "StreamType", ",", "api", ".", "StreamTypeError", ")", "\n", "headers", ".", "Set", "(", "api", ".", "PortHeader", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "port", ".", "Remote", ")", ")", "\n", "headers", ".", "Set", "(", "api", ".", "PortForwardRequestIDHeader", ",", "strconv", ".", "Itoa", "(", "requestID", ")", ")", "\n", "errorStream", ",", "err", ":=", "pf", ".", "streamConn", ".", "CreateStream", "(", "headers", ")", "\n", "if", "err", "!=", "nil", "{", "util", ".", "HandleError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "port", ".", "Local", ",", "port", ".", "Remote", ",", "err", ")", ")", "\n", "return", "\n", "}", "\n", "// we're not writing to this stream", "errorStream", ".", "Close", "(", ")", "\n\n", "errorChan", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "message", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "errorStream", ")", "\n", "switch", "{", "case", "err", "!=", "nil", ":", "errorChan", "<-", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "port", ".", "Local", ",", "port", ".", "Remote", ",", "err", ")", "\n", "case", "len", "(", "message", ")", ">", "0", ":", "errorChan", "<-", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "port", ".", "Local", ",", "port", ".", "Remote", ",", "string", "(", "message", ")", ")", "\n", "}", "\n", "close", "(", "errorChan", ")", "\n", "}", "(", ")", "\n\n", "// create data stream", "headers", ".", "Set", "(", "api", ".", "StreamType", ",", "api", ".", "StreamTypeData", ")", "\n", "dataStream", ",", "err", ":=", "pf", ".", "streamConn", ".", "CreateStream", "(", "headers", ")", "\n", "if", "err", "!=", "nil", "{", "util", ".", "HandleError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "port", ".", "Local", ",", "port", ".", "Remote", ",", "err", ")", ")", "\n", "return", "\n", "}", "\n\n", "localError", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "remoteDone", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n\n", "go", "func", "(", ")", "{", "// Copy from the remote side to the local port.", "if", "_", ",", "err", ":=", "io", ".", "Copy", "(", "conn", ",", "dataStream", ")", ";", "err", "!=", "nil", "&&", "!", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "\"", "\"", ")", "{", "util", ".", "HandleError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n\n", "// inform the select below that the remote copy is done", "close", "(", "remoteDone", ")", "\n", "}", "(", ")", "\n\n", "go", "func", "(", ")", "{", "// inform server we're not sending any more data after copy unblocks", "defer", "dataStream", ".", "Close", "(", ")", "\n\n", "// Copy from the local port to the remote side.", "if", "_", ",", "err", ":=", "io", ".", "Copy", "(", "dataStream", ",", "conn", ")", ";", "err", "!=", "nil", "&&", "!", "strings", ".", "Contains", "(", "err", ".", "Error", "(", ")", ",", "\"", "\"", ")", "{", "util", ".", "HandleError", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "// break out of the select below without waiting for the other copy to finish", "close", "(", "localError", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "// wait for either a local->remote error or for copying from remote->local to finish", "select", "{", "case", "<-", "remoteDone", ":", "case", "<-", "localError", ":", "}", "\n\n", "// always expect something on errorChan (it may be nil)", "err", "=", "<-", "errorChan", "\n", "if", "err", "!=", "nil", "{", "util", ".", "HandleError", "(", "err", ")", "\n", "}", "\n", "}" ]
// handleConnection copies data between the local connection and the stream to // the remote server.
[ "handleConnection", "copies", "data", "between", "the", "local", "connection", "and", "the", "stream", "to", "the", "remote", "server", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/portforward/portforward.go#L244-L320
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go
Error
func (c *ConversionError) Error() string { return spew.Sprintf( "Conversion error: %s. (in: %v(%+v) out: %v)", c.Message, reflect.TypeOf(c.In), c.In, reflect.TypeOf(c.Out), ) }
go
func (c *ConversionError) Error() string { return spew.Sprintf( "Conversion error: %s. (in: %v(%+v) out: %v)", c.Message, reflect.TypeOf(c.In), c.In, reflect.TypeOf(c.Out), ) }
[ "func", "(", "c", "*", "ConversionError", ")", "Error", "(", ")", "string", "{", "return", "spew", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Message", ",", "reflect", ".", "TypeOf", "(", "c", ".", "In", ")", ",", "c", ".", "In", ",", "reflect", ".", "TypeOf", "(", "c", ".", "Out", ")", ",", ")", "\n", "}" ]
// Return a helpful string about the error
[ "Return", "a", "helpful", "string", "about", "the", "error" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go#L44-L49
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go
IsServiceIPSet
func IsServiceIPSet(service *Service) bool { return service.Spec.ClusterIP != ClusterIPNone && service.Spec.ClusterIP != "" }
go
func IsServiceIPSet(service *Service) bool { return service.Spec.ClusterIP != ClusterIPNone && service.Spec.ClusterIP != "" }
[ "func", "IsServiceIPSet", "(", "service", "*", "Service", ")", "bool", "{", "return", "service", ".", "Spec", ".", "ClusterIP", "!=", "ClusterIPNone", "&&", "service", ".", "Spec", ".", "ClusterIP", "!=", "\"", "\"", "\n", "}" ]
// this function aims to check if the service's ClusterIP is set or not // the objective is not to perform validation here
[ "this", "function", "aims", "to", "check", "if", "the", "service", "s", "ClusterIP", "is", "set", "or", "not", "the", "objective", "is", "not", "to", "perform", "validation", "here" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go#L122-L124
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go
removeDuplicateAccessModes
func removeDuplicateAccessModes(modes []PersistentVolumeAccessMode) []PersistentVolumeAccessMode { accessModes := []PersistentVolumeAccessMode{} for _, m := range modes { if !containsAccessMode(accessModes, m) { accessModes = append(accessModes, m) } } return accessModes }
go
func removeDuplicateAccessModes(modes []PersistentVolumeAccessMode) []PersistentVolumeAccessMode { accessModes := []PersistentVolumeAccessMode{} for _, m := range modes { if !containsAccessMode(accessModes, m) { accessModes = append(accessModes, m) } } return accessModes }
[ "func", "removeDuplicateAccessModes", "(", "modes", "[", "]", "PersistentVolumeAccessMode", ")", "[", "]", "PersistentVolumeAccessMode", "{", "accessModes", ":=", "[", "]", "PersistentVolumeAccessMode", "{", "}", "\n", "for", "_", ",", "m", ":=", "range", "modes", "{", "if", "!", "containsAccessMode", "(", "accessModes", ",", "m", ")", "{", "accessModes", "=", "append", "(", "accessModes", ",", "m", ")", "\n", "}", "\n", "}", "\n", "return", "accessModes", "\n", "}" ]
// removeDuplicateAccessModes returns an array of access modes without any duplicates
[ "removeDuplicateAccessModes", "returns", "an", "array", "of", "access", "modes", "without", "any", "duplicates" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/helpers.go#L236-L244
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go
Modify
func (f *FakeControllerSource) Modify(obj runtime.Object) { f.Change(watch.Event{Type: watch.Modified, Object: obj}, 1) }
go
func (f *FakeControllerSource) Modify(obj runtime.Object) { f.Change(watch.Event{Type: watch.Modified, Object: obj}, 1) }
[ "func", "(", "f", "*", "FakeControllerSource", ")", "Modify", "(", "obj", "runtime", ".", "Object", ")", "{", "f", ".", "Change", "(", "watch", ".", "Event", "{", "Type", ":", "watch", ".", "Modified", ",", "Object", ":", "obj", "}", ",", "1", ")", "\n", "}" ]
// Modify updates an object in the set and sends a modified event to watchers. // obj's ResourceVersion is set.
[ "Modify", "updates", "an", "object", "in", "the", "set", "and", "sends", "a", "modified", "event", "to", "watchers", ".", "obj", "s", "ResourceVersion", "is", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go#L61-L63
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go
Delete
func (f *FakeControllerSource) Delete(lastValue runtime.Object) { f.Change(watch.Event{Type: watch.Deleted, Object: lastValue}, 1) }
go
func (f *FakeControllerSource) Delete(lastValue runtime.Object) { f.Change(watch.Event{Type: watch.Deleted, Object: lastValue}, 1) }
[ "func", "(", "f", "*", "FakeControllerSource", ")", "Delete", "(", "lastValue", "runtime", ".", "Object", ")", "{", "f", ".", "Change", "(", "watch", ".", "Event", "{", "Type", ":", "watch", ".", "Deleted", ",", "Object", ":", "lastValue", "}", ",", "1", ")", "\n", "}" ]
// Delete deletes an object from the set and sends a delete event to watchers. // obj's ResourceVersion is set.
[ "Delete", "deletes", "an", "object", "from", "the", "set", "and", "sends", "a", "delete", "event", "to", "watchers", ".", "obj", "s", "ResourceVersion", "is", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go#L67-L69
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go
AddDropWatch
func (f *FakeControllerSource) AddDropWatch(obj runtime.Object) { f.Change(watch.Event{Type: watch.Added, Object: obj}, 0) }
go
func (f *FakeControllerSource) AddDropWatch(obj runtime.Object) { f.Change(watch.Event{Type: watch.Added, Object: obj}, 0) }
[ "func", "(", "f", "*", "FakeControllerSource", ")", "AddDropWatch", "(", "obj", "runtime", ".", "Object", ")", "{", "f", ".", "Change", "(", "watch", ".", "Event", "{", "Type", ":", "watch", ".", "Added", ",", "Object", ":", "obj", "}", ",", "0", ")", "\n", "}" ]
// AddDropWatch adds an object to the set but forgets to send an add event to // watchers. // obj's ResourceVersion is set.
[ "AddDropWatch", "adds", "an", "object", "to", "the", "set", "but", "forgets", "to", "send", "an", "add", "event", "to", "watchers", ".", "obj", "s", "ResourceVersion", "is", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go#L74-L76
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go
List
func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error) { f.lock.RLock() defer f.lock.RUnlock() list := make([]runtime.Object, 0, len(f.items)) for _, obj := range f.items { // Must make a copy to allow clients to modify the object. // Otherwise, if they make a change and write it back, they // will inadvertently change our canonical copy (in // addition to racing with other clients). objCopy, err := api.Scheme.DeepCopy(obj) if err != nil { return nil, err } list = append(list, objCopy.(runtime.Object)) } listObj := &api.List{} if err := meta.SetList(listObj, list); err != nil { return nil, err } objMeta, err := api.ListMetaFor(listObj) if err != nil { return nil, err } resourceVersion := len(f.changes) objMeta.ResourceVersion = strconv.Itoa(resourceVersion) return listObj, nil }
go
func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error) { f.lock.RLock() defer f.lock.RUnlock() list := make([]runtime.Object, 0, len(f.items)) for _, obj := range f.items { // Must make a copy to allow clients to modify the object. // Otherwise, if they make a change and write it back, they // will inadvertently change our canonical copy (in // addition to racing with other clients). objCopy, err := api.Scheme.DeepCopy(obj) if err != nil { return nil, err } list = append(list, objCopy.(runtime.Object)) } listObj := &api.List{} if err := meta.SetList(listObj, list); err != nil { return nil, err } objMeta, err := api.ListMetaFor(listObj) if err != nil { return nil, err } resourceVersion := len(f.changes) objMeta.ResourceVersion = strconv.Itoa(resourceVersion) return listObj, nil }
[ "func", "(", "f", "*", "FakeControllerSource", ")", "List", "(", "options", "api", ".", "ListOptions", ")", "(", "runtime", ".", "Object", ",", "error", ")", "{", "f", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "f", ".", "lock", ".", "RUnlock", "(", ")", "\n", "list", ":=", "make", "(", "[", "]", "runtime", ".", "Object", ",", "0", ",", "len", "(", "f", ".", "items", ")", ")", "\n", "for", "_", ",", "obj", ":=", "range", "f", ".", "items", "{", "// Must make a copy to allow clients to modify the object.", "// Otherwise, if they make a change and write it back, they", "// will inadvertently change our canonical copy (in", "// addition to racing with other clients).", "objCopy", ",", "err", ":=", "api", ".", "Scheme", ".", "DeepCopy", "(", "obj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "list", "=", "append", "(", "list", ",", "objCopy", ".", "(", "runtime", ".", "Object", ")", ")", "\n", "}", "\n", "listObj", ":=", "&", "api", ".", "List", "{", "}", "\n", "if", "err", ":=", "meta", ".", "SetList", "(", "listObj", ",", "list", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "objMeta", ",", "err", ":=", "api", ".", "ListMetaFor", "(", "listObj", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "resourceVersion", ":=", "len", "(", "f", ".", "changes", ")", "\n", "objMeta", ".", "ResourceVersion", "=", "strconv", ".", "Itoa", "(", "resourceVersion", ")", "\n", "return", "listObj", ",", "nil", "\n", "}" ]
// List returns a list object, with its resource version set.
[ "List", "returns", "a", "list", "object", "with", "its", "resource", "version", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go#L124-L150
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go
Watch
func (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error) { f.lock.RLock() defer f.lock.RUnlock() rc, err := strconv.Atoi(options.ResourceVersion) if err != nil { return nil, err } if rc < len(f.changes) { changes := []watch.Event{} for _, c := range f.changes[rc:] { // Must make a copy to allow clients to modify the // object. Otherwise, if they make a change and write // it back, they will inadvertently change the our // canonical copy (in addition to racing with other // clients). objCopy, err := api.Scheme.DeepCopy(c.Object) if err != nil { return nil, err } changes = append(changes, watch.Event{Type: c.Type, Object: objCopy.(runtime.Object)}) } return f.broadcaster.WatchWithPrefix(changes), nil } else if rc > len(f.changes) { return nil, errors.New("resource version in the future not supported by this fake") } return f.broadcaster.Watch(), nil }
go
func (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error) { f.lock.RLock() defer f.lock.RUnlock() rc, err := strconv.Atoi(options.ResourceVersion) if err != nil { return nil, err } if rc < len(f.changes) { changes := []watch.Event{} for _, c := range f.changes[rc:] { // Must make a copy to allow clients to modify the // object. Otherwise, if they make a change and write // it back, they will inadvertently change the our // canonical copy (in addition to racing with other // clients). objCopy, err := api.Scheme.DeepCopy(c.Object) if err != nil { return nil, err } changes = append(changes, watch.Event{Type: c.Type, Object: objCopy.(runtime.Object)}) } return f.broadcaster.WatchWithPrefix(changes), nil } else if rc > len(f.changes) { return nil, errors.New("resource version in the future not supported by this fake") } return f.broadcaster.Watch(), nil }
[ "func", "(", "f", "*", "FakeControllerSource", ")", "Watch", "(", "options", "api", ".", "ListOptions", ")", "(", "watch", ".", "Interface", ",", "error", ")", "{", "f", ".", "lock", ".", "RLock", "(", ")", "\n", "defer", "f", ".", "lock", ".", "RUnlock", "(", ")", "\n", "rc", ",", "err", ":=", "strconv", ".", "Atoi", "(", "options", ".", "ResourceVersion", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "rc", "<", "len", "(", "f", ".", "changes", ")", "{", "changes", ":=", "[", "]", "watch", ".", "Event", "{", "}", "\n", "for", "_", ",", "c", ":=", "range", "f", ".", "changes", "[", "rc", ":", "]", "{", "// Must make a copy to allow clients to modify the", "// object. Otherwise, if they make a change and write", "// it back, they will inadvertently change the our", "// canonical copy (in addition to racing with other", "// clients).", "objCopy", ",", "err", ":=", "api", ".", "Scheme", ".", "DeepCopy", "(", "c", ".", "Object", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "changes", "=", "append", "(", "changes", ",", "watch", ".", "Event", "{", "Type", ":", "c", ".", "Type", ",", "Object", ":", "objCopy", ".", "(", "runtime", ".", "Object", ")", "}", ")", "\n", "}", "\n", "return", "f", ".", "broadcaster", ".", "WatchWithPrefix", "(", "changes", ")", ",", "nil", "\n", "}", "else", "if", "rc", ">", "len", "(", "f", ".", "changes", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "f", ".", "broadcaster", ".", "Watch", "(", ")", ",", "nil", "\n", "}" ]
// Watch returns a watch, which will be pre-populated with all changes // after resourceVersion.
[ "Watch", "returns", "a", "watch", "which", "will", "be", "pre", "-", "populated", "with", "all", "changes", "after", "resourceVersion", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/controller/framework/fake_controller_source.go#L154-L180
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go
NewReflector
func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector { return NewNamedReflector(getDefaultReflectorName(internalPackages...), lw, expectedType, store, resyncPeriod) }
go
func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector { return NewNamedReflector(getDefaultReflectorName(internalPackages...), lw, expectedType, store, resyncPeriod) }
[ "func", "NewReflector", "(", "lw", "ListerWatcher", ",", "expectedType", "interface", "{", "}", ",", "store", "Store", ",", "resyncPeriod", "time", ".", "Duration", ")", "*", "Reflector", "{", "return", "NewNamedReflector", "(", "getDefaultReflectorName", "(", "internalPackages", "...", ")", ",", "lw", ",", "expectedType", ",", "store", ",", "resyncPeriod", ")", "\n", "}" ]
// NewReflector creates a new Reflector object which will keep the given store up to // date with the server's contents for the given resource. Reflector promises to // only put things in the store that have the type of expectedType, unless expectedType // is nil. If resyncPeriod is non-zero, then lists will be executed after every // resyncPeriod, so that you can use reflectors to periodically process everything as // well as incrementally processing the things that change.
[ "NewReflector", "creates", "a", "new", "Reflector", "object", "which", "will", "keep", "the", "given", "store", "up", "to", "date", "with", "the", "server", "s", "contents", "for", "the", "given", "resource", ".", "Reflector", "promises", "to", "only", "put", "things", "in", "the", "store", "that", "have", "the", "type", "of", "expectedType", "unless", "expectedType", "is", "nil", ".", "If", "resyncPeriod", "is", "non", "-", "zero", "then", "lists", "will", "be", "executed", "after", "every", "resyncPeriod", "so", "that", "you", "can", "use", "reflectors", "to", "periodically", "process", "everything", "as", "well", "as", "incrementally", "processing", "the", "things", "that", "change", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go#L107-L109
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go
Run
func (r *Reflector) Run() { go wait.Until(func() { r.ListAndWatch(wait.NeverStop) }, r.period, wait.NeverStop) }
go
func (r *Reflector) Run() { go wait.Until(func() { r.ListAndWatch(wait.NeverStop) }, r.period, wait.NeverStop) }
[ "func", "(", "r", "*", "Reflector", ")", "Run", "(", ")", "{", "go", "wait", ".", "Until", "(", "func", "(", ")", "{", "r", ".", "ListAndWatch", "(", "wait", ".", "NeverStop", ")", "}", ",", "r", ".", "period", ",", "wait", ".", "NeverStop", ")", "\n", "}" ]
// Run starts a watch and handles watch events. Will restart the watch if it is closed. // Run starts a goroutine and returns immediately.
[ "Run", "starts", "a", "watch", "and", "handles", "watch", "events", ".", "Will", "restart", "the", "watch", "if", "it", "is", "closed", ".", "Run", "starts", "a", "goroutine", "and", "returns", "immediately", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go#L159-L161
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go
RunUntil
func (r *Reflector) RunUntil(stopCh <-chan struct{}) { go wait.Until(func() { r.ListAndWatch(stopCh) }, r.period, stopCh) }
go
func (r *Reflector) RunUntil(stopCh <-chan struct{}) { go wait.Until(func() { r.ListAndWatch(stopCh) }, r.period, stopCh) }
[ "func", "(", "r", "*", "Reflector", ")", "RunUntil", "(", "stopCh", "<-", "chan", "struct", "{", "}", ")", "{", "go", "wait", ".", "Until", "(", "func", "(", ")", "{", "r", ".", "ListAndWatch", "(", "stopCh", ")", "}", ",", "r", ".", "period", ",", "stopCh", ")", "\n", "}" ]
// RunUntil starts a watch and handles watch events. Will restart the watch if it is closed. // RunUntil starts a goroutine and returns immediately. It will exit when stopCh is closed.
[ "RunUntil", "starts", "a", "watch", "and", "handles", "watch", "events", ".", "Will", "restart", "the", "watch", "if", "it", "is", "closed", ".", "RunUntil", "starts", "a", "goroutine", "and", "returns", "immediately", ".", "It", "will", "exit", "when", "stopCh", "is", "closed", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go#L165-L167
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go
canForceResyncNow
func (r *Reflector) canForceResyncNow() bool { if r.nextResync.IsZero() { return false } return r.now().Add(forceResyncThreshold).After(r.nextResync) }
go
func (r *Reflector) canForceResyncNow() bool { if r.nextResync.IsZero() { return false } return r.now().Add(forceResyncThreshold).After(r.nextResync) }
[ "func", "(", "r", "*", "Reflector", ")", "canForceResyncNow", "(", ")", "bool", "{", "if", "r", ".", "nextResync", ".", "IsZero", "(", ")", "{", "return", "false", "\n", "}", "\n", "return", "r", ".", "now", "(", ")", ".", "Add", "(", "forceResyncThreshold", ")", ".", "After", "(", "r", ".", "nextResync", ")", "\n", "}" ]
// Returns true if we are close enough to next planned periodic resync // and we can force resyncing ourself now.
[ "Returns", "true", "if", "we", "are", "close", "enough", "to", "next", "planned", "periodic", "resync", "and", "we", "can", "force", "resyncing", "ourself", "now", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go#L219-L224
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/rand/rand.go
String
func String(length int) string { b := make([]rune, length) for i := range b { b[i] = letters[Intn(numLetters)] } return string(b) }
go
func String(length int) string { b := make([]rune, length) for i := range b { b[i] = letters[Intn(numLetters)] } return string(b) }
[ "func", "String", "(", "length", "int", ")", "string", "{", "b", ":=", "make", "(", "[", "]", "rune", ",", "length", ")", "\n", "for", "i", ":=", "range", "b", "{", "b", "[", "i", "]", "=", "letters", "[", "Intn", "(", "numLetters", ")", "]", "\n", "}", "\n", "return", "string", "(", "b", ")", "\n", "}" ]
// String generates a random alphanumeric string n characters long. This will // panic if n is less than zero.
[ "String", "generates", "a", "random", "alphanumeric", "string", "n", "characters", "long", ".", "This", "will", "panic", "if", "n", "is", "less", "than", "zero", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/rand/rand.go#L61-L67
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/watchloop.go
WatchLoop
func WatchLoop(w watch.Interface, fn func(watch.Event) error) { signals := make(chan os.Signal, 1) signal.Notify(signals, os.Interrupt) defer signal.Stop(signals) for { select { case event, ok := <-w.ResultChan(): if !ok { return } if err := fn(event); err != nil { w.Stop() } case <-signals: w.Stop() } } }
go
func WatchLoop(w watch.Interface, fn func(watch.Event) error) { signals := make(chan os.Signal, 1) signal.Notify(signals, os.Interrupt) defer signal.Stop(signals) for { select { case event, ok := <-w.ResultChan(): if !ok { return } if err := fn(event); err != nil { w.Stop() } case <-signals: w.Stop() } } }
[ "func", "WatchLoop", "(", "w", "watch", ".", "Interface", ",", "fn", "func", "(", "watch", ".", "Event", ")", "error", ")", "{", "signals", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "1", ")", "\n", "signal", ".", "Notify", "(", "signals", ",", "os", ".", "Interrupt", ")", "\n", "defer", "signal", ".", "Stop", "(", "signals", ")", "\n", "for", "{", "select", "{", "case", "event", ",", "ok", ":=", "<-", "w", ".", "ResultChan", "(", ")", ":", "if", "!", "ok", "{", "return", "\n", "}", "\n", "if", "err", ":=", "fn", "(", "event", ")", ";", "err", "!=", "nil", "{", "w", ".", "Stop", "(", ")", "\n", "}", "\n", "case", "<-", "signals", ":", "w", ".", "Stop", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
// WatchLoop loops, passing events in w to fn. // If user sends interrupt signal, shut down cleanly. Otherwise, never return.
[ "WatchLoop", "loops", "passing", "events", "in", "w", "to", "fn", ".", "If", "user", "sends", "interrupt", "signal", "shut", "down", "cleanly", ".", "Otherwise", "never", "return", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/watchloop.go#L28-L45
train