id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
165,200 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go | ScaleSimple | func (scaler *DeploymentScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error {
deployment, err := scaler.c.Deployments(namespace).Get(name)
if err != nil {
return ScaleError{ScaleGetFailure, "Unknown", err}
}
if preconditions != nil {
if err := preconditions.ValidateDeployment(deployment); err != nil {
return err
}
}
// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528).
// For now I'm falling back to regular Deployment update operation.
deployment.Spec.Replicas = int(newSize)
if _, err := scaler.c.Deployments(namespace).Update(deployment); err != nil {
if errors.IsInvalid(err) {
return ScaleError{ScaleUpdateInvalidFailure, deployment.ResourceVersion, err}
}
return ScaleError{ScaleUpdateFailure, deployment.ResourceVersion, err}
}
return nil
} | go | func (scaler *DeploymentScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error {
deployment, err := scaler.c.Deployments(namespace).Get(name)
if err != nil {
return ScaleError{ScaleGetFailure, "Unknown", err}
}
if preconditions != nil {
if err := preconditions.ValidateDeployment(deployment); err != nil {
return err
}
}
// TODO(madhusudancs): Fix this when Scale group issues are resolved (see issue #18528).
// For now I'm falling back to regular Deployment update operation.
deployment.Spec.Replicas = int(newSize)
if _, err := scaler.c.Deployments(namespace).Update(deployment); err != nil {
if errors.IsInvalid(err) {
return ScaleError{ScaleUpdateInvalidFailure, deployment.ResourceVersion, err}
}
return ScaleError{ScaleUpdateFailure, deployment.ResourceVersion, err}
}
return nil
} | [
"func",
"(",
"scaler",
"*",
"DeploymentScaler",
")",
"ScaleSimple",
"(",
"namespace",
",",
"name",
"string",
",",
"preconditions",
"*",
"ScalePrecondition",
",",
"newSize",
"uint",
")",
"error",
"{",
"deployment",
",",
"err",
":=",
"scaler",
".",
"c",
".",
... | // ScaleSimple is responsible for updating a deployment's desired replicas count. | [
"ScaleSimple",
"is",
"responsible",
"for",
"updating",
"a",
"deployment",
"s",
"desired",
"replicas",
"count",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L336-L357 |
165,201 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/conditions.go | ReplicaSetHasDesiredReplicas | func ReplicaSetHasDesiredReplicas(c ExtensionsInterface, replicaSet *extensions.ReplicaSet) wait.ConditionFunc {
// If we're given a ReplicaSet where the status lags the spec, it either means that the
// ReplicaSet is stale, or that the ReplicaSet manager hasn't noticed the update yet.
// Polling status.Replicas is not safe in the latter case.
desiredGeneration := replicaSet.Generation
return func() (bool, error) {
rs, err := c.ReplicaSets(replicaSet.Namespace).Get(replicaSet.Name)
if err != nil {
return false, err
}
// There's a chance a concurrent update modifies the Spec.Replicas causing this check to
// pass, or, after this check has passed, a modification causes the ReplicaSet manager to
// create more pods. This will not be an issue once we've implemented graceful delete for
// ReplicaSets, but till then concurrent stop operations on the same ReplicaSet might have
// unintended side effects.
return rs.Status.ObservedGeneration >= desiredGeneration && rs.Status.Replicas == rs.Spec.Replicas, nil
}
} | go | func ReplicaSetHasDesiredReplicas(c ExtensionsInterface, replicaSet *extensions.ReplicaSet) wait.ConditionFunc {
// If we're given a ReplicaSet where the status lags the spec, it either means that the
// ReplicaSet is stale, or that the ReplicaSet manager hasn't noticed the update yet.
// Polling status.Replicas is not safe in the latter case.
desiredGeneration := replicaSet.Generation
return func() (bool, error) {
rs, err := c.ReplicaSets(replicaSet.Namespace).Get(replicaSet.Name)
if err != nil {
return false, err
}
// There's a chance a concurrent update modifies the Spec.Replicas causing this check to
// pass, or, after this check has passed, a modification causes the ReplicaSet manager to
// create more pods. This will not be an issue once we've implemented graceful delete for
// ReplicaSets, but till then concurrent stop operations on the same ReplicaSet might have
// unintended side effects.
return rs.Status.ObservedGeneration >= desiredGeneration && rs.Status.Replicas == rs.Spec.Replicas, nil
}
} | [
"func",
"ReplicaSetHasDesiredReplicas",
"(",
"c",
"ExtensionsInterface",
",",
"replicaSet",
"*",
"extensions",
".",
"ReplicaSet",
")",
"wait",
".",
"ConditionFunc",
"{",
"// If we're given a ReplicaSet where the status lags the spec, it either means that the",
"// ReplicaSet is sta... | // ReplicaSetHasDesiredReplicas returns a condition that will be true if and only if
// the desired replica count for a ReplicaSet's ReplicaSelector equals the Replicas count. | [
"ReplicaSetHasDesiredReplicas",
"returns",
"a",
"condition",
"that",
"will",
"be",
"true",
"if",
"and",
"only",
"if",
"the",
"desired",
"replica",
"count",
"for",
"a",
"ReplicaSet",
"s",
"ReplicaSelector",
"equals",
"the",
"Replicas",
"count",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/conditions.go#L106-L125 |
165,202 | kubernetes-retired/contrib | exec-healthz/cmd/exechealthz/exechealthz.go | getResults | func (h *execWorker) getResults() execResult {
h.mutex.Lock()
defer h.mutex.Unlock()
return h.result
} | go | func (h *execWorker) getResults() execResult {
h.mutex.Lock()
defer h.mutex.Unlock()
return h.result
} | [
"func",
"(",
"h",
"*",
"execWorker",
")",
"getResults",
"(",
")",
"execResult",
"{",
"h",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"h",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n",
"return",
"h",
".",
"result",
"\n",
"}"
] | // getResults returns the results of the latest execWorker run.
// The caller should treat returned results as read-only. | [
"getResults",
"returns",
"the",
"results",
"of",
"the",
"latest",
"execWorker",
"run",
".",
"The",
"caller",
"should",
"treat",
"returned",
"results",
"as",
"read",
"-",
"only",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/exec-healthz/cmd/exechealthz/exechealthz.go#L116-L120 |
165,203 | kubernetes-retired/contrib | exec-healthz/cmd/exechealthz/exechealthz.go | start | func (h *execWorker) start() {
ticker := h.clock.Tick(h.period)
h.readyCh <- struct{}{} // For testing.
for {
select {
// If the command takes > period, the command runs continuously.
case <-ticker:
logf("Worker running %v to serve %v", h.probeCmd, h.probePath)
output, err := h.exec.Command("sh", "-c", h.probeCmd).CombinedOutput()
ts := h.clock.Now()
func() {
h.mutex.Lock()
defer h.mutex.Unlock()
h.result = execResult{output, err, ts}
}()
case <-h.stopCh:
return
}
}
} | go | func (h *execWorker) start() {
ticker := h.clock.Tick(h.period)
h.readyCh <- struct{}{} // For testing.
for {
select {
// If the command takes > period, the command runs continuously.
case <-ticker:
logf("Worker running %v to serve %v", h.probeCmd, h.probePath)
output, err := h.exec.Command("sh", "-c", h.probeCmd).CombinedOutput()
ts := h.clock.Now()
func() {
h.mutex.Lock()
defer h.mutex.Unlock()
h.result = execResult{output, err, ts}
}()
case <-h.stopCh:
return
}
}
} | [
"func",
"(",
"h",
"*",
"execWorker",
")",
"start",
"(",
")",
"{",
"ticker",
":=",
"h",
".",
"clock",
".",
"Tick",
"(",
"h",
".",
"period",
")",
"\n",
"h",
".",
"readyCh",
"<-",
"struct",
"{",
"}",
"{",
"}",
"// For testing.",
"\n\n",
"for",
"{",
... | // start attempts to run the probeCmd every `period` seconds.
// Meant to be called as a goroutine. | [
"start",
"attempts",
"to",
"run",
"the",
"probeCmd",
"every",
"period",
"seconds",
".",
"Meant",
"to",
"be",
"called",
"as",
"a",
"goroutine",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/exec-healthz/cmd/exechealthz/exechealthz.go#L131-L151 |
165,204 | kubernetes-retired/contrib | exec-healthz/cmd/exechealthz/exechealthz.go | newExecWorker | func newExecWorker(probeCmd, probePath string, execPeriod time.Duration, exec utilexec.Interface, clock clock.Clock, readyCh chan<- struct{}) *execWorker {
return &execWorker{
// Initializing the result with a timestamp here allows us to
// wait maxLatency for the worker goroutine to start, and for each
// iteration of the worker to complete.
exec: exec,
clock: clock,
result: execResult{[]byte{}, nil, clock.Now()},
period: execPeriod,
probeCmd: probeCmd,
probePath: probePath,
stopCh: make(chan struct{}),
readyCh: readyCh,
}
} | go | func newExecWorker(probeCmd, probePath string, execPeriod time.Duration, exec utilexec.Interface, clock clock.Clock, readyCh chan<- struct{}) *execWorker {
return &execWorker{
// Initializing the result with a timestamp here allows us to
// wait maxLatency for the worker goroutine to start, and for each
// iteration of the worker to complete.
exec: exec,
clock: clock,
result: execResult{[]byte{}, nil, clock.Now()},
period: execPeriod,
probeCmd: probeCmd,
probePath: probePath,
stopCh: make(chan struct{}),
readyCh: readyCh,
}
} | [
"func",
"newExecWorker",
"(",
"probeCmd",
",",
"probePath",
"string",
",",
"execPeriod",
"time",
".",
"Duration",
",",
"exec",
"utilexec",
".",
"Interface",
",",
"clock",
"clock",
".",
"Clock",
",",
"readyCh",
"chan",
"<-",
"struct",
"{",
"}",
")",
"*",
... | // newExecWorker is a constructor for execWorker. | [
"newExecWorker",
"is",
"a",
"constructor",
"for",
"execWorker",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/exec-healthz/cmd/exechealthz/exechealthz.go#L154-L168 |
165,205 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go | numLess | func numLess(a, b reflect.Value) bool {
switch a.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return a.Int() < b.Int()
case reflect.Float32, reflect.Float64:
return a.Float() < b.Float()
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return a.Uint() < b.Uint()
case reflect.Bool:
return !a.Bool() && b.Bool()
}
panic("not a number")
} | go | func numLess(a, b reflect.Value) bool {
switch a.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return a.Int() < b.Int()
case reflect.Float32, reflect.Float64:
return a.Float() < b.Float()
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return a.Uint() < b.Uint()
case reflect.Bool:
return !a.Bool() && b.Bool()
}
panic("not a number")
} | [
"func",
"numLess",
"(",
"a",
",",
"b",
"reflect",
".",
"Value",
")",
"bool",
"{",
"switch",
"a",
".",
"Kind",
"(",
")",
"{",
"case",
"reflect",
".",
"Int",
",",
"reflect",
".",
"Int8",
",",
"reflect",
".",
"Int16",
",",
"reflect",
".",
"Int32",
"... | // numLess returns whether a < b.
// a and b must necessarily have the same kind. | [
"numLess",
"returns",
"whether",
"a",
"<",
"b",
".",
"a",
"and",
"b",
"must",
"necessarily",
"have",
"the",
"same",
"kind",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/sorter.go#L92-L104 |
165,206 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pods.go | newPods | func newPods(c *Client, namespace string) *pods {
return &pods{
r: c,
ns: namespace,
}
} | go | func newPods(c *Client, namespace string) *pods {
return &pods{
r: c,
ns: namespace,
}
} | [
"func",
"newPods",
"(",
"c",
"*",
"Client",
",",
"namespace",
"string",
")",
"*",
"pods",
"{",
"return",
"&",
"pods",
"{",
"r",
":",
"c",
",",
"ns",
":",
"namespace",
",",
"}",
"\n",
"}"
] | // newPods returns a pods | [
"newPods",
"returns",
"a",
"pods"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pods.go#L49-L54 |
165,207 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pods.go | UpdateStatus | func (c *pods) UpdateStatus(pod *api.Pod) (result *api.Pod, err error) {
result = &api.Pod{}
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result)
return
} | go | func (c *pods) UpdateStatus(pod *api.Pod) (result *api.Pod, err error) {
result = &api.Pod{}
err = c.r.Put().Namespace(c.ns).Resource("pods").Name(pod.Name).SubResource("status").Body(pod).Do().Into(result)
return
} | [
"func",
"(",
"c",
"*",
"pods",
")",
"UpdateStatus",
"(",
"pod",
"*",
"api",
".",
"Pod",
")",
"(",
"result",
"*",
"api",
".",
"Pod",
",",
"err",
"error",
")",
"{",
"result",
"=",
"&",
"api",
".",
"Pod",
"{",
"}",
"\n",
"err",
"=",
"c",
".",
... | // UpdateStatus takes the name of the pod and the new status. Returns the server's representation of the pod, and an error, if it occurs. | [
"UpdateStatus",
"takes",
"the",
"name",
"of",
"the",
"pod",
"and",
"the",
"new",
"status",
".",
"Returns",
"the",
"server",
"s",
"representation",
"of",
"the",
"pod",
"and",
"an",
"error",
"if",
"it",
"occurs",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pods.go#L105-L109 |
165,208 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go | BindStringFlag | func (f FlagInfo) BindStringFlag(flags *pflag.FlagSet, target *string) {
// you can't register a flag without a long name
if len(f.LongName) > 0 {
flags.StringVarP(target, f.LongName, f.ShortName, f.Default, f.Description)
}
} | go | func (f FlagInfo) BindStringFlag(flags *pflag.FlagSet, target *string) {
// you can't register a flag without a long name
if len(f.LongName) > 0 {
flags.StringVarP(target, f.LongName, f.ShortName, f.Default, f.Description)
}
} | [
"func",
"(",
"f",
"FlagInfo",
")",
"BindStringFlag",
"(",
"flags",
"*",
"pflag",
".",
"FlagSet",
",",
"target",
"*",
"string",
")",
"{",
"// you can't register a flag without a long name",
"if",
"len",
"(",
"f",
".",
"LongName",
")",
">",
"0",
"{",
"flags",
... | // BindStringFlag binds the flag based on the provided info. If LongName == "", nothing is registered | [
"BindStringFlag",
"binds",
"the",
"flag",
"based",
"on",
"the",
"provided",
"info",
".",
"If",
"LongName",
"==",
"nothing",
"is",
"registered"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go#L84-L89 |
165,209 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go | RecommendedConfigOverrideFlags | func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags {
return ConfigOverrideFlags{
AuthOverrideFlags: RecommendedAuthOverrideFlags(prefix),
ClusterOverrideFlags: RecommendedClusterOverrideFlags(prefix),
ContextOverrideFlags: RecommendedContextOverrideFlags(prefix),
CurrentContext: FlagInfo{prefix + FlagContext, "", "", "The name of the kubeconfig context to use"},
}
} | go | func RecommendedConfigOverrideFlags(prefix string) ConfigOverrideFlags {
return ConfigOverrideFlags{
AuthOverrideFlags: RecommendedAuthOverrideFlags(prefix),
ClusterOverrideFlags: RecommendedClusterOverrideFlags(prefix),
ContextOverrideFlags: RecommendedContextOverrideFlags(prefix),
CurrentContext: FlagInfo{prefix + FlagContext, "", "", "The name of the kubeconfig context to use"},
}
} | [
"func",
"RecommendedConfigOverrideFlags",
"(",
"prefix",
"string",
")",
"ConfigOverrideFlags",
"{",
"return",
"ConfigOverrideFlags",
"{",
"AuthOverrideFlags",
":",
"RecommendedAuthOverrideFlags",
"(",
"prefix",
")",
",",
"ClusterOverrideFlags",
":",
"RecommendedClusterOverrid... | // RecommendedConfigOverrideFlags is a convenience method to return recommended flag names prefixed with a string of your choosing | [
"RecommendedConfigOverrideFlags",
"is",
"a",
"convenience",
"method",
"to",
"return",
"recommended",
"flag",
"names",
"prefixed",
"with",
"a",
"string",
"of",
"your",
"choosing"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go#L144-L151 |
165,210 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go | BindClusterFlags | func BindClusterFlags(clusterInfo *clientcmdapi.Cluster, flags *pflag.FlagSet, flagNames ClusterOverrideFlags) {
flagNames.APIServer.BindStringFlag(flags, &clusterInfo.Server)
flagNames.APIVersion.BindStringFlag(flags, &clusterInfo.APIVersion)
flagNames.CertificateAuthority.BindStringFlag(flags, &clusterInfo.CertificateAuthority)
flagNames.InsecureSkipTLSVerify.BindBoolFlag(flags, &clusterInfo.InsecureSkipTLSVerify)
} | go | func BindClusterFlags(clusterInfo *clientcmdapi.Cluster, flags *pflag.FlagSet, flagNames ClusterOverrideFlags) {
flagNames.APIServer.BindStringFlag(flags, &clusterInfo.Server)
flagNames.APIVersion.BindStringFlag(flags, &clusterInfo.APIVersion)
flagNames.CertificateAuthority.BindStringFlag(flags, &clusterInfo.CertificateAuthority)
flagNames.InsecureSkipTLSVerify.BindBoolFlag(flags, &clusterInfo.InsecureSkipTLSVerify)
} | [
"func",
"BindClusterFlags",
"(",
"clusterInfo",
"*",
"clientcmdapi",
".",
"Cluster",
",",
"flags",
"*",
"pflag",
".",
"FlagSet",
",",
"flagNames",
"ClusterOverrideFlags",
")",
"{",
"flagNames",
".",
"APIServer",
".",
"BindStringFlag",
"(",
"flags",
",",
"&",
"... | // BindClusterFlags is a convenience method to bind the specified flags to their associated variables | [
"BindClusterFlags",
"is",
"a",
"convenience",
"method",
"to",
"bind",
"the",
"specified",
"flags",
"to",
"their",
"associated",
"variables"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go#L172-L177 |
165,211 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go | BindOverrideFlags | func BindOverrideFlags(overrides *ConfigOverrides, flags *pflag.FlagSet, flagNames ConfigOverrideFlags) {
BindAuthInfoFlags(&overrides.AuthInfo, flags, flagNames.AuthOverrideFlags)
BindClusterFlags(&overrides.ClusterInfo, flags, flagNames.ClusterOverrideFlags)
BindContextFlags(&overrides.Context, flags, flagNames.ContextOverrideFlags)
flagNames.CurrentContext.BindStringFlag(flags, &overrides.CurrentContext)
} | go | func BindOverrideFlags(overrides *ConfigOverrides, flags *pflag.FlagSet, flagNames ConfigOverrideFlags) {
BindAuthInfoFlags(&overrides.AuthInfo, flags, flagNames.AuthOverrideFlags)
BindClusterFlags(&overrides.ClusterInfo, flags, flagNames.ClusterOverrideFlags)
BindContextFlags(&overrides.Context, flags, flagNames.ContextOverrideFlags)
flagNames.CurrentContext.BindStringFlag(flags, &overrides.CurrentContext)
} | [
"func",
"BindOverrideFlags",
"(",
"overrides",
"*",
"ConfigOverrides",
",",
"flags",
"*",
"pflag",
".",
"FlagSet",
",",
"flagNames",
"ConfigOverrideFlags",
")",
"{",
"BindAuthInfoFlags",
"(",
"&",
"overrides",
".",
"AuthInfo",
",",
"flags",
",",
"flagNames",
"."... | // BindOverrideFlags is a convenience method to bind the specified flags to their associated variables | [
"BindOverrideFlags",
"is",
"a",
"convenience",
"method",
"to",
"bind",
"the",
"specified",
"flags",
"to",
"their",
"associated",
"variables"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/clientcmd/overrides.go#L180-L185 |
165,212 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/printing.go | PrintSuccess | func PrintSuccess(mapper meta.RESTMapper, shortOutput bool, out io.Writer, resource string, name string, operation string) {
resource, _ = mapper.ResourceSingularizer(resource)
if shortOutput {
// -o name: prints resource/name
if len(resource) > 0 {
fmt.Fprintf(out, "%s/%s\n", resource, name)
} else {
fmt.Fprintf(out, "%s\n", name)
}
} else {
// understandable output by default
if len(resource) > 0 {
fmt.Fprintf(out, "%s \"%s\" %s\n", resource, name, operation)
} else {
fmt.Fprintf(out, "\"%s\" %s\n", name, operation)
}
}
} | go | func PrintSuccess(mapper meta.RESTMapper, shortOutput bool, out io.Writer, resource string, name string, operation string) {
resource, _ = mapper.ResourceSingularizer(resource)
if shortOutput {
// -o name: prints resource/name
if len(resource) > 0 {
fmt.Fprintf(out, "%s/%s\n", resource, name)
} else {
fmt.Fprintf(out, "%s\n", name)
}
} else {
// understandable output by default
if len(resource) > 0 {
fmt.Fprintf(out, "%s \"%s\" %s\n", resource, name, operation)
} else {
fmt.Fprintf(out, "\"%s\" %s\n", name, operation)
}
}
} | [
"func",
"PrintSuccess",
"(",
"mapper",
"meta",
".",
"RESTMapper",
",",
"shortOutput",
"bool",
",",
"out",
"io",
".",
"Writer",
",",
"resource",
"string",
",",
"name",
"string",
",",
"operation",
"string",
")",
"{",
"resource",
",",
"_",
"=",
"mapper",
".... | // PrintSuccess prints message after finishing mutating operations | [
"PrintSuccess",
"prints",
"message",
"after",
"finishing",
"mutating",
"operations"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/printing.go#L51-L68 |
165,213 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/printing.go | ValidateOutputArgs | func ValidateOutputArgs(cmd *cobra.Command) error {
outputMode := GetFlagString(cmd, "output")
if outputMode != "" && outputMode != "name" {
return UsageError(cmd, "Unexpected -o output mode: %v. We only support '-o name'.", outputMode)
}
return nil
} | go | func ValidateOutputArgs(cmd *cobra.Command) error {
outputMode := GetFlagString(cmd, "output")
if outputMode != "" && outputMode != "name" {
return UsageError(cmd, "Unexpected -o output mode: %v. We only support '-o name'.", outputMode)
}
return nil
} | [
"func",
"ValidateOutputArgs",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
")",
"error",
"{",
"outputMode",
":=",
"GetFlagString",
"(",
"cmd",
",",
"\"",
"\"",
")",
"\n",
"if",
"outputMode",
"!=",
"\"",
"\"",
"&&",
"outputMode",
"!=",
"\"",
"\"",
"{",
"re... | // ValidateOutputArgs validates -o flag args for mutations | [
"ValidateOutputArgs",
"validates",
"-",
"o",
"flag",
"args",
"for",
"mutations"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/printing.go#L71-L77 |
165,214 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/discovery_client.go | ServerResources | func (d *DiscoveryClient) ServerResources() (map[string]*unversioned.APIResourceList, error) {
apiGroups, err := d.ServerGroups()
if err != nil {
return nil, err
}
groupVersions := ExtractGroupVersions(apiGroups)
result := map[string]*unversioned.APIResourceList{}
for _, groupVersion := range groupVersions {
resources, err := d.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
return nil, err
}
result[groupVersion] = resources
}
return result, nil
} | go | func (d *DiscoveryClient) ServerResources() (map[string]*unversioned.APIResourceList, error) {
apiGroups, err := d.ServerGroups()
if err != nil {
return nil, err
}
groupVersions := ExtractGroupVersions(apiGroups)
result := map[string]*unversioned.APIResourceList{}
for _, groupVersion := range groupVersions {
resources, err := d.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
return nil, err
}
result[groupVersion] = resources
}
return result, nil
} | [
"func",
"(",
"d",
"*",
"DiscoveryClient",
")",
"ServerResources",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"unversioned",
".",
"APIResourceList",
",",
"error",
")",
"{",
"apiGroups",
",",
"err",
":=",
"d",
".",
"ServerGroups",
"(",
")",
"\n",
"if... | // ServerResources returns the supported resources for all groups and versions. | [
"ServerResources",
"returns",
"the",
"supported",
"resources",
"for",
"all",
"groups",
"and",
"versions",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/discovery_client.go#L124-L139 |
165,215 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go | propagateCancel | func propagateCancel(parent Context, child canceler) {
if parent.Done() == nil {
return // parent is never canceled
}
if p, ok := parentCancelCtx(parent); ok {
p.mu.Lock()
if p.err != nil {
// parent has already been canceled
child.cancel(false, p.err)
} else {
if p.children == nil {
p.children = make(map[canceler]bool)
}
p.children[child] = true
}
p.mu.Unlock()
} else {
go func() {
select {
case <-parent.Done():
child.cancel(false, parent.Err())
case <-child.Done():
}
}()
}
} | go | func propagateCancel(parent Context, child canceler) {
if parent.Done() == nil {
return // parent is never canceled
}
if p, ok := parentCancelCtx(parent); ok {
p.mu.Lock()
if p.err != nil {
// parent has already been canceled
child.cancel(false, p.err)
} else {
if p.children == nil {
p.children = make(map[canceler]bool)
}
p.children[child] = true
}
p.mu.Unlock()
} else {
go func() {
select {
case <-parent.Done():
child.cancel(false, parent.Err())
case <-child.Done():
}
}()
}
} | [
"func",
"propagateCancel",
"(",
"parent",
"Context",
",",
"child",
"canceler",
")",
"{",
"if",
"parent",
".",
"Done",
"(",
")",
"==",
"nil",
"{",
"return",
"// parent is never canceled",
"\n",
"}",
"\n",
"if",
"p",
",",
"ok",
":=",
"parentCancelCtx",
"(",
... | // propagateCancel arranges for child to be canceled when parent is. | [
"propagateCancel",
"arranges",
"for",
"child",
"to",
"be",
"canceled",
"when",
"parent",
"is",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go#L226-L251 |
165,216 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go | removeChild | func removeChild(parent Context, child canceler) {
p, ok := parentCancelCtx(parent)
if !ok {
return
}
p.mu.Lock()
if p.children != nil {
delete(p.children, child)
}
p.mu.Unlock()
} | go | func removeChild(parent Context, child canceler) {
p, ok := parentCancelCtx(parent)
if !ok {
return
}
p.mu.Lock()
if p.children != nil {
delete(p.children, child)
}
p.mu.Unlock()
} | [
"func",
"removeChild",
"(",
"parent",
"Context",
",",
"child",
"canceler",
")",
"{",
"p",
",",
"ok",
":=",
"parentCancelCtx",
"(",
"parent",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
... | // removeChild removes a context from its parent. | [
"removeChild",
"removes",
"a",
"context",
"from",
"its",
"parent",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go#L272-L282 |
165,217 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go | cancel | func (c *cancelCtx) cancel(removeFromParent bool, err error) {
if err == nil {
panic("context: internal error: missing cancel error")
}
c.mu.Lock()
if c.err != nil {
c.mu.Unlock()
return // already canceled
}
c.err = err
close(c.done)
for child := range c.children {
// NOTE: acquiring the child's lock while holding parent's lock.
child.cancel(false, err)
}
c.children = nil
c.mu.Unlock()
if removeFromParent {
removeChild(c.Context, c)
}
} | go | func (c *cancelCtx) cancel(removeFromParent bool, err error) {
if err == nil {
panic("context: internal error: missing cancel error")
}
c.mu.Lock()
if c.err != nil {
c.mu.Unlock()
return // already canceled
}
c.err = err
close(c.done)
for child := range c.children {
// NOTE: acquiring the child's lock while holding parent's lock.
child.cancel(false, err)
}
c.children = nil
c.mu.Unlock()
if removeFromParent {
removeChild(c.Context, c)
}
} | [
"func",
"(",
"c",
"*",
"cancelCtx",
")",
"cancel",
"(",
"removeFromParent",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"c",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"if",... | // cancel closes c.done, cancels each of c's children, and, if
// removeFromParent is true, removes c from its parent's children. | [
"cancel",
"closes",
"c",
".",
"done",
"cancels",
"each",
"of",
"c",
"s",
"children",
"and",
"if",
"removeFromParent",
"is",
"true",
"removes",
"c",
"from",
"its",
"parent",
"s",
"children",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/net/context/context.go#L319-L340 |
165,218 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetOldRCs | func GetOldRCs(deployment extensions.Deployment, c client.Interface) ([]*api.ReplicationController, error) {
return GetOldRCsFromLists(deployment, c,
func(namespace string, options api.ListOptions) (*api.PodList, error) {
return c.Pods(namespace).List(options)
},
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
rcList, err := c.ReplicationControllers(namespace).List(options)
return rcList.Items, err
})
} | go | func GetOldRCs(deployment extensions.Deployment, c client.Interface) ([]*api.ReplicationController, error) {
return GetOldRCsFromLists(deployment, c,
func(namespace string, options api.ListOptions) (*api.PodList, error) {
return c.Pods(namespace).List(options)
},
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
rcList, err := c.ReplicationControllers(namespace).List(options)
return rcList.Items, err
})
} | [
"func",
"GetOldRCs",
"(",
"deployment",
"extensions",
".",
"Deployment",
",",
"c",
"client",
".",
"Interface",
")",
"(",
"[",
"]",
"*",
"api",
".",
"ReplicationController",
",",
"error",
")",
"{",
"return",
"GetOldRCsFromLists",
"(",
"deployment",
",",
"c",
... | // GetOldRCs returns the old RCs targeted by the given Deployment; get PodList and RCList from client interface. | [
"GetOldRCs",
"returns",
"the",
"old",
"RCs",
"targeted",
"by",
"the",
"given",
"Deployment",
";",
"get",
"PodList",
"and",
"RCList",
"from",
"client",
"interface",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L32-L41 |
165,219 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetNewRC | func GetNewRC(deployment extensions.Deployment, c client.Interface) (*api.ReplicationController, error) {
return GetNewRCFromList(deployment, c,
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
rcList, err := c.ReplicationControllers(namespace).List(options)
return rcList.Items, err
})
} | go | func GetNewRC(deployment extensions.Deployment, c client.Interface) (*api.ReplicationController, error) {
return GetNewRCFromList(deployment, c,
func(namespace string, options api.ListOptions) ([]api.ReplicationController, error) {
rcList, err := c.ReplicationControllers(namespace).List(options)
return rcList.Items, err
})
} | [
"func",
"GetNewRC",
"(",
"deployment",
"extensions",
".",
"Deployment",
",",
"c",
"client",
".",
"Interface",
")",
"(",
"*",
"api",
".",
"ReplicationController",
",",
"error",
")",
"{",
"return",
"GetNewRCFromList",
"(",
"deployment",
",",
"c",
",",
"func",
... | // GetNewRC returns an RC that matches the intent of the given deployment; get RCList from client interface.
// Returns nil if the new RC doesnt exist yet. | [
"GetNewRC",
"returns",
"an",
"RC",
"that",
"matches",
"the",
"intent",
"of",
"the",
"given",
"deployment",
";",
"get",
"RCList",
"from",
"client",
"interface",
".",
"Returns",
"nil",
"if",
"the",
"new",
"RC",
"doesnt",
"exist",
"yet",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L84-L90 |
165,220 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetNewRCFromList | func GetNewRCFromList(deployment extensions.Deployment, c client.Interface, getRcList func(string, api.ListOptions) ([]api.ReplicationController, error)) (*api.ReplicationController, error) {
namespace := deployment.ObjectMeta.Namespace
rcList, err := getRcList(namespace, api.ListOptions{})
if err != nil {
return nil, fmt.Errorf("error listing replication controllers: %v", err)
}
newRCTemplate := GetNewRCTemplate(deployment)
for i := range rcList {
if api.Semantic.DeepEqual(rcList[i].Spec.Template, &newRCTemplate) {
// This is the new RC.
return &rcList[i], nil
}
}
// new RC does not exist.
return nil, nil
} | go | func GetNewRCFromList(deployment extensions.Deployment, c client.Interface, getRcList func(string, api.ListOptions) ([]api.ReplicationController, error)) (*api.ReplicationController, error) {
namespace := deployment.ObjectMeta.Namespace
rcList, err := getRcList(namespace, api.ListOptions{})
if err != nil {
return nil, fmt.Errorf("error listing replication controllers: %v", err)
}
newRCTemplate := GetNewRCTemplate(deployment)
for i := range rcList {
if api.Semantic.DeepEqual(rcList[i].Spec.Template, &newRCTemplate) {
// This is the new RC.
return &rcList[i], nil
}
}
// new RC does not exist.
return nil, nil
} | [
"func",
"GetNewRCFromList",
"(",
"deployment",
"extensions",
".",
"Deployment",
",",
"c",
"client",
".",
"Interface",
",",
"getRcList",
"func",
"(",
"string",
",",
"api",
".",
"ListOptions",
")",
"(",
"[",
"]",
"api",
".",
"ReplicationController",
",",
"erro... | // GetNewRCFromList returns an RC that matches the intent of the given deployment; get RCList with the input function.
// Returns nil if the new RC doesnt exist yet. | [
"GetNewRCFromList",
"returns",
"an",
"RC",
"that",
"matches",
"the",
"intent",
"of",
"the",
"given",
"deployment",
";",
"get",
"RCList",
"with",
"the",
"input",
"function",
".",
"Returns",
"nil",
"if",
"the",
"new",
"RC",
"doesnt",
"exist",
"yet",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L94-L110 |
165,221 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetNewRCTemplate | func GetNewRCTemplate(deployment extensions.Deployment) api.PodTemplateSpec {
// newRC will have the same template as in deployment spec, plus a unique label in some cases.
newRCTemplate := api.PodTemplateSpec{
ObjectMeta: deployment.Spec.Template.ObjectMeta,
Spec: deployment.Spec.Template.Spec,
}
newRCTemplate.ObjectMeta.Labels = CloneAndAddLabel(
deployment.Spec.Template.ObjectMeta.Labels,
deployment.Spec.UniqueLabelKey,
GetPodTemplateSpecHash(newRCTemplate))
return newRCTemplate
} | go | func GetNewRCTemplate(deployment extensions.Deployment) api.PodTemplateSpec {
// newRC will have the same template as in deployment spec, plus a unique label in some cases.
newRCTemplate := api.PodTemplateSpec{
ObjectMeta: deployment.Spec.Template.ObjectMeta,
Spec: deployment.Spec.Template.Spec,
}
newRCTemplate.ObjectMeta.Labels = CloneAndAddLabel(
deployment.Spec.Template.ObjectMeta.Labels,
deployment.Spec.UniqueLabelKey,
GetPodTemplateSpecHash(newRCTemplate))
return newRCTemplate
} | [
"func",
"GetNewRCTemplate",
"(",
"deployment",
"extensions",
".",
"Deployment",
")",
"api",
".",
"PodTemplateSpec",
"{",
"// newRC will have the same template as in deployment spec, plus a unique label in some cases.",
"newRCTemplate",
":=",
"api",
".",
"PodTemplateSpec",
"{",
... | // Returns the desired PodTemplateSpec for the new RC corresponding to the given RC. | [
"Returns",
"the",
"desired",
"PodTemplateSpec",
"for",
"the",
"new",
"RC",
"corresponding",
"to",
"the",
"given",
"RC",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L113-L124 |
165,222 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetReplicaCountForRCs | func GetReplicaCountForRCs(replicationControllers []*api.ReplicationController) int {
totalReplicaCount := 0
for _, rc := range replicationControllers {
totalReplicaCount += rc.Spec.Replicas
}
return totalReplicaCount
} | go | func GetReplicaCountForRCs(replicationControllers []*api.ReplicationController) int {
totalReplicaCount := 0
for _, rc := range replicationControllers {
totalReplicaCount += rc.Spec.Replicas
}
return totalReplicaCount
} | [
"func",
"GetReplicaCountForRCs",
"(",
"replicationControllers",
"[",
"]",
"*",
"api",
".",
"ReplicationController",
")",
"int",
"{",
"totalReplicaCount",
":=",
"0",
"\n",
"for",
"_",
",",
"rc",
":=",
"range",
"replicationControllers",
"{",
"totalReplicaCount",
"+=... | // Returns the sum of Replicas of the given replication controllers. | [
"Returns",
"the",
"sum",
"of",
"Replicas",
"of",
"the",
"given",
"replication",
"controllers",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L149-L155 |
165,223 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go | GetAvailablePodsForRCs | func GetAvailablePodsForRCs(c client.Interface, rcs []*api.ReplicationController, minReadySeconds int) (int, error) {
allPods, err := getPodsForRCs(c, rcs)
if err != nil {
return 0, err
}
return getReadyPodsCount(allPods, minReadySeconds), nil
} | go | func GetAvailablePodsForRCs(c client.Interface, rcs []*api.ReplicationController, minReadySeconds int) (int, error) {
allPods, err := getPodsForRCs(c, rcs)
if err != nil {
return 0, err
}
return getReadyPodsCount(allPods, minReadySeconds), nil
} | [
"func",
"GetAvailablePodsForRCs",
"(",
"c",
"client",
".",
"Interface",
",",
"rcs",
"[",
"]",
"*",
"api",
".",
"ReplicationController",
",",
"minReadySeconds",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"allPods",
",",
"err",
":=",
"getPodsForRCs",
"(... | // Returns the number of available pods corresponding to the given RCs. | [
"Returns",
"the",
"number",
"of",
"available",
"pods",
"corresponding",
"to",
"the",
"given",
"RCs",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L158-L164 |
165,224 | kubernetes-retired/contrib | keepalived-vip/keepalived.go | WriteCfg | func (k *keepalived) WriteCfg(svcs []vip) error {
w, err := os.Create(keepalivedCfg)
if err != nil {
return err
}
defer w.Close()
k.vips = getVIPs(svcs)
conf := make(map[string]interface{})
conf["iptablesChain"] = iptablesChain
conf["iface"] = k.iface
conf["myIP"] = k.ip
conf["netmask"] = k.netmask
conf["svcs"] = svcs
conf["vips"] = getVIPs(svcs)
conf["nodes"] = k.neighbors
conf["priority"] = k.priority
conf["useUnicast"] = k.useUnicast
conf["vrid"] = k.vrid
conf["vrrpVersion"] = k.vrrpVersion
conf["notify"] = k.notify
if glog.V(2) {
b, _ := json.Marshal(conf)
glog.Infof("%v", string(b))
}
return k.tmpl.Execute(w, conf)
} | go | func (k *keepalived) WriteCfg(svcs []vip) error {
w, err := os.Create(keepalivedCfg)
if err != nil {
return err
}
defer w.Close()
k.vips = getVIPs(svcs)
conf := make(map[string]interface{})
conf["iptablesChain"] = iptablesChain
conf["iface"] = k.iface
conf["myIP"] = k.ip
conf["netmask"] = k.netmask
conf["svcs"] = svcs
conf["vips"] = getVIPs(svcs)
conf["nodes"] = k.neighbors
conf["priority"] = k.priority
conf["useUnicast"] = k.useUnicast
conf["vrid"] = k.vrid
conf["vrrpVersion"] = k.vrrpVersion
conf["notify"] = k.notify
if glog.V(2) {
b, _ := json.Marshal(conf)
glog.Infof("%v", string(b))
}
return k.tmpl.Execute(w, conf)
} | [
"func",
"(",
"k",
"*",
"keepalived",
")",
"WriteCfg",
"(",
"svcs",
"[",
"]",
"vip",
")",
"error",
"{",
"w",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"keepalivedCfg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
... | // WriteCfg creates a new keepalived configuration file.
// In case of an error with the generation it returns the error | [
"WriteCfg",
"creates",
"a",
"new",
"keepalived",
"configuration",
"file",
".",
"In",
"case",
"of",
"an",
"error",
"with",
"the",
"generation",
"it",
"returns",
"the",
"error"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/keepalived.go#L59-L88 |
165,225 | kubernetes-retired/contrib | keepalived-vip/keepalived.go | Start | func (k *keepalived) Start() {
ae, err := k.ipt.EnsureChain(iptables.TableFilter, iptables.Chain(iptablesChain))
if err != nil {
glog.Fatalf("unexpected error: %v", err)
}
if ae {
glog.V(2).Infof("chain %v already existed", iptablesChain)
}
k.cmd = exec.Command("keepalived",
"--dont-fork",
"--log-console",
"--release-vips",
"--pid", "/keepalived.pid")
k.cmd.Stdout = os.Stdout
k.cmd.Stderr = os.Stderr
k.started = true
if err := k.cmd.Start(); err != nil {
glog.Errorf("keepalived error: %v", err)
}
if err := k.cmd.Wait(); err != nil {
glog.Fatalf("keepalived error: %v", err)
}
} | go | func (k *keepalived) Start() {
ae, err := k.ipt.EnsureChain(iptables.TableFilter, iptables.Chain(iptablesChain))
if err != nil {
glog.Fatalf("unexpected error: %v", err)
}
if ae {
glog.V(2).Infof("chain %v already existed", iptablesChain)
}
k.cmd = exec.Command("keepalived",
"--dont-fork",
"--log-console",
"--release-vips",
"--pid", "/keepalived.pid")
k.cmd.Stdout = os.Stdout
k.cmd.Stderr = os.Stderr
k.started = true
if err := k.cmd.Start(); err != nil {
glog.Errorf("keepalived error: %v", err)
}
if err := k.cmd.Wait(); err != nil {
glog.Fatalf("keepalived error: %v", err)
}
} | [
"func",
"(",
"k",
"*",
"keepalived",
")",
"Start",
"(",
")",
"{",
"ae",
",",
"err",
":=",
"k",
".",
"ipt",
".",
"EnsureChain",
"(",
"iptables",
".",
"TableFilter",
",",
"iptables",
".",
"Chain",
"(",
"iptablesChain",
")",
")",
"\n",
"if",
"err",
"!... | // Start starts a keepalived process in foreground.
// In case of any error it will terminate the execution with a fatal error | [
"Start",
"starts",
"a",
"keepalived",
"process",
"in",
"foreground",
".",
"In",
"case",
"of",
"any",
"error",
"it",
"will",
"terminate",
"the",
"execution",
"with",
"a",
"fatal",
"error"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/keepalived.go#L103-L130 |
165,226 | kubernetes-retired/contrib | keepalived-vip/keepalived.go | Reload | func (k *keepalived) Reload() error {
if !k.started {
// TODO: add a warning indicating that keepalived is not started?
return nil
}
glog.Info("reloading keepalived")
err := syscall.Kill(k.cmd.Process.Pid, syscall.SIGHUP)
if err != nil {
return fmt.Errorf("error reloading keepalived: %v", err)
}
return nil
} | go | func (k *keepalived) Reload() error {
if !k.started {
// TODO: add a warning indicating that keepalived is not started?
return nil
}
glog.Info("reloading keepalived")
err := syscall.Kill(k.cmd.Process.Pid, syscall.SIGHUP)
if err != nil {
return fmt.Errorf("error reloading keepalived: %v", err)
}
return nil
} | [
"func",
"(",
"k",
"*",
"keepalived",
")",
"Reload",
"(",
")",
"error",
"{",
"if",
"!",
"k",
".",
"started",
"{",
"// TODO: add a warning indicating that keepalived is not started?",
"return",
"nil",
"\n",
"}",
"\n\n",
"glog",
".",
"Info",
"(",
"\"",
"\"",
")... | // Reload sends SIGHUP to keepalived to reload the configuration. | [
"Reload",
"sends",
"SIGHUP",
"to",
"keepalived",
"to",
"reload",
"the",
"configuration",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/keepalived.go#L133-L146 |
165,227 | kubernetes-retired/contrib | keepalived-vip/keepalived.go | Stop | func (k *keepalived) Stop() {
for _, vip := range k.vips {
k.removeVIP(vip)
}
err := k.ipt.FlushChain(iptables.TableFilter, iptables.Chain(iptablesChain))
if err != nil {
glog.V(2).Infof("unexpected error flushing iptables chain %v: %v", err, iptablesChain)
}
err = syscall.Kill(k.cmd.Process.Pid, syscall.SIGTERM)
if err != nil {
glog.Errorf("error stopping keepalived: %v", err)
}
} | go | func (k *keepalived) Stop() {
for _, vip := range k.vips {
k.removeVIP(vip)
}
err := k.ipt.FlushChain(iptables.TableFilter, iptables.Chain(iptablesChain))
if err != nil {
glog.V(2).Infof("unexpected error flushing iptables chain %v: %v", err, iptablesChain)
}
err = syscall.Kill(k.cmd.Process.Pid, syscall.SIGTERM)
if err != nil {
glog.Errorf("error stopping keepalived: %v", err)
}
} | [
"func",
"(",
"k",
"*",
"keepalived",
")",
"Stop",
"(",
")",
"{",
"for",
"_",
",",
"vip",
":=",
"range",
"k",
".",
"vips",
"{",
"k",
".",
"removeVIP",
"(",
"vip",
")",
"\n",
"}",
"\n\n",
"err",
":=",
"k",
".",
"ipt",
".",
"FlushChain",
"(",
"i... | // Stop stop keepalived process | [
"Stop",
"stop",
"keepalived",
"process"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/keepalived.go#L149-L163 |
165,228 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/parser.go | parseQuote | func (p *Parser) parseQuote(cur *ListNode) error {
Loop:
for {
switch p.next() {
case eof, '\n':
return fmt.Errorf("unterminated quoted string")
case '"':
break Loop
}
}
value := p.consumeText()
s, err := strconv.Unquote(value)
if err != nil {
return fmt.Errorf("unquote string %s error %v", value, err)
}
cur.append(newText(s))
return p.parseInsideAction(cur)
} | go | func (p *Parser) parseQuote(cur *ListNode) error {
Loop:
for {
switch p.next() {
case eof, '\n':
return fmt.Errorf("unterminated quoted string")
case '"':
break Loop
}
}
value := p.consumeText()
s, err := strconv.Unquote(value)
if err != nil {
return fmt.Errorf("unquote string %s error %v", value, err)
}
cur.append(newText(s))
return p.parseInsideAction(cur)
} | [
"func",
"(",
"p",
"*",
"Parser",
")",
"parseQuote",
"(",
"cur",
"*",
"ListNode",
")",
"error",
"{",
"Loop",
":",
"for",
"{",
"switch",
"p",
".",
"next",
"(",
")",
"{",
"case",
"eof",
",",
"'\\n'",
":",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
... | // parseQuote unquotes string inside double quote | [
"parseQuote",
"unquotes",
"string",
"inside",
"double",
"quote"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/jsonpath/parser.go#L363-L380 |
165,229 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/v1/defaults.go | defaultHostNetworkPorts | func defaultHostNetworkPorts(containers *[]Container) {
for i := range *containers {
for j := range (*containers)[i].Ports {
if (*containers)[i].Ports[j].HostPort == 0 {
(*containers)[i].Ports[j].HostPort = (*containers)[i].Ports[j].ContainerPort
}
}
}
} | go | func defaultHostNetworkPorts(containers *[]Container) {
for i := range *containers {
for j := range (*containers)[i].Ports {
if (*containers)[i].Ports[j].HostPort == 0 {
(*containers)[i].Ports[j].HostPort = (*containers)[i].Ports[j].ContainerPort
}
}
}
} | [
"func",
"defaultHostNetworkPorts",
"(",
"containers",
"*",
"[",
"]",
"Container",
")",
"{",
"for",
"i",
":=",
"range",
"*",
"containers",
"{",
"for",
"j",
":=",
"range",
"(",
"*",
"containers",
")",
"[",
"i",
"]",
".",
"Ports",
"{",
"if",
"(",
"*",
... | // With host networking default all container ports to host ports. | [
"With",
"host",
"networking",
"default",
"all",
"container",
"ports",
"to",
"host",
"ports",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/v1/defaults.go#L255-L263 |
165,230 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/schema.go | validateList | func (s *SwaggerSchema) validateList(obj map[string]interface{}) []error {
allErrs := []error{}
items, exists := obj["items"]
if !exists {
return append(allErrs, fmt.Errorf("no items field in %#v", obj))
}
itemList, ok := items.([]interface{})
if !ok {
return append(allErrs, fmt.Errorf("items isn't a slice"))
}
for i, item := range itemList {
fields, ok := item.(map[string]interface{})
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d] isn't a map[string]interface{}", i))
continue
}
groupVersion := fields["apiVersion"]
if groupVersion == nil {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion not set", i))
continue
}
itemVersion, ok := groupVersion.(string)
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion isn't string type", i))
continue
}
if len(itemVersion) == 0 {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion is empty", i))
}
kind := fields["kind"]
if kind == nil {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind not set", i))
continue
}
itemKind, ok := kind.(string)
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind isn't string type", i))
continue
}
if len(itemKind) == 0 {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind is empty", i))
}
version := apiutil.GetVersion(itemVersion)
errs := s.ValidateObject(item, "", version+"."+itemKind)
if len(errs) >= 1 {
allErrs = append(allErrs, errs...)
}
}
return allErrs
} | go | func (s *SwaggerSchema) validateList(obj map[string]interface{}) []error {
allErrs := []error{}
items, exists := obj["items"]
if !exists {
return append(allErrs, fmt.Errorf("no items field in %#v", obj))
}
itemList, ok := items.([]interface{})
if !ok {
return append(allErrs, fmt.Errorf("items isn't a slice"))
}
for i, item := range itemList {
fields, ok := item.(map[string]interface{})
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d] isn't a map[string]interface{}", i))
continue
}
groupVersion := fields["apiVersion"]
if groupVersion == nil {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion not set", i))
continue
}
itemVersion, ok := groupVersion.(string)
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion isn't string type", i))
continue
}
if len(itemVersion) == 0 {
allErrs = append(allErrs, fmt.Errorf("items[%d].apiVersion is empty", i))
}
kind := fields["kind"]
if kind == nil {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind not set", i))
continue
}
itemKind, ok := kind.(string)
if !ok {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind isn't string type", i))
continue
}
if len(itemKind) == 0 {
allErrs = append(allErrs, fmt.Errorf("items[%d].kind is empty", i))
}
version := apiutil.GetVersion(itemVersion)
errs := s.ValidateObject(item, "", version+"."+itemKind)
if len(errs) >= 1 {
allErrs = append(allErrs, errs...)
}
}
return allErrs
} | [
"func",
"(",
"s",
"*",
"SwaggerSchema",
")",
"validateList",
"(",
"obj",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"error",
"{",
"allErrs",
":=",
"[",
"]",
"error",
"{",
"}",
"\n",
"items",
",",
"exists",
":=",
"obj",
"[",
... | // validateList unpacks a list and validate every item in the list.
// It return nil if every item is ok.
// Otherwise it return an error list contain errors of every item. | [
"validateList",
"unpacks",
"a",
"list",
"and",
"validate",
"every",
"item",
"in",
"the",
"list",
".",
"It",
"return",
"nil",
"if",
"every",
"item",
"is",
"ok",
".",
"Otherwise",
"it",
"return",
"an",
"error",
"list",
"contain",
"errors",
"of",
"every",
"... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/validation/schema.go#L72-L121 |
165,231 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go | AllPtrFieldsNil | func AllPtrFieldsNil(obj interface{}) bool {
v := reflect.ValueOf(obj)
if !v.IsValid() {
panic(fmt.Sprintf("reflect.ValueOf() produced a non-valid Value for %#v", obj))
}
if v.Kind() == reflect.Ptr {
if v.IsNil() {
return true
}
v = v.Elem()
}
for i := 0; i < v.NumField(); i++ {
if v.Field(i).Kind() == reflect.Ptr && !v.Field(i).IsNil() {
return false
}
}
return true
} | go | func AllPtrFieldsNil(obj interface{}) bool {
v := reflect.ValueOf(obj)
if !v.IsValid() {
panic(fmt.Sprintf("reflect.ValueOf() produced a non-valid Value for %#v", obj))
}
if v.Kind() == reflect.Ptr {
if v.IsNil() {
return true
}
v = v.Elem()
}
for i := 0; i < v.NumField(); i++ {
if v.Field(i).Kind() == reflect.Ptr && !v.Field(i).IsNil() {
return false
}
}
return true
} | [
"func",
"AllPtrFieldsNil",
"(",
"obj",
"interface",
"{",
"}",
")",
"bool",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"obj",
")",
"\n",
"if",
"!",
"v",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",... | // Tests whether all pointer fields in a struct are nil. This is useful when,
// for example, an API struct is handled by plugins which need to distinguish
// "no plugin accepted this spec" from "this spec is empty".
//
// This function is only valid for structs and pointers to structs. Any other
// type will cause a panic. Passing a typed nil pointer will return true. | [
"Tests",
"whether",
"all",
"pointer",
"fields",
"in",
"a",
"struct",
"are",
"nil",
".",
"This",
"is",
"useful",
"when",
"for",
"example",
"an",
"API",
"struct",
"is",
"handled",
"by",
"plugins",
"which",
"need",
"to",
"distinguish",
"no",
"plugin",
"accept... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L59-L76 |
165,232 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go | ReadDirNoExit | func ReadDirNoExit(dirname string) ([]os.FileInfo, []error, error) {
if dirname == "" {
dirname = "."
}
f, err := os.Open(dirname)
if err != nil {
return nil, nil, err
}
defer f.Close()
names, err := f.Readdirnames(-1)
list := make([]os.FileInfo, 0, len(names))
errs := make([]error, 0, len(names))
for _, filename := range names {
fip, lerr := os.Lstat(dirname + "/" + filename)
if os.IsNotExist(lerr) {
// File disappeared between readdir + stat.
// Just treat it as if it didn't exist.
continue
}
list = append(list, fip)
errs = append(errs, lerr)
}
return list, errs, nil
} | go | func ReadDirNoExit(dirname string) ([]os.FileInfo, []error, error) {
if dirname == "" {
dirname = "."
}
f, err := os.Open(dirname)
if err != nil {
return nil, nil, err
}
defer f.Close()
names, err := f.Readdirnames(-1)
list := make([]os.FileInfo, 0, len(names))
errs := make([]error, 0, len(names))
for _, filename := range names {
fip, lerr := os.Lstat(dirname + "/" + filename)
if os.IsNotExist(lerr) {
// File disappeared between readdir + stat.
// Just treat it as if it didn't exist.
continue
}
list = append(list, fip)
errs = append(errs, lerr)
}
return list, errs, nil
} | [
"func",
"ReadDirNoExit",
"(",
"dirname",
"string",
")",
"(",
"[",
"]",
"os",
".",
"FileInfo",
",",
"[",
"]",
"error",
",",
"error",
")",
"{",
"if",
"dirname",
"==",
"\"",
"\"",
"{",
"dirname",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"f",
",",
"err",
... | // borrowed from ioutil.ReadDir
// ReadDir reads the directory named by dirname and returns
// a list of directory entries, minus those with lstat errors | [
"borrowed",
"from",
"ioutil",
".",
"ReadDir",
"ReadDir",
"reads",
"the",
"directory",
"named",
"by",
"dirname",
"and",
"returns",
"a",
"list",
"of",
"directory",
"entries",
"minus",
"those",
"with",
"lstat",
"errors"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L90-L117 |
165,233 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go | IntPtrDerefOr | func IntPtrDerefOr(ptr *int, def int) int {
if ptr != nil {
return *ptr
}
return def
} | go | func IntPtrDerefOr(ptr *int, def int) int {
if ptr != nil {
return *ptr
}
return def
} | [
"func",
"IntPtrDerefOr",
"(",
"ptr",
"*",
"int",
",",
"def",
"int",
")",
"int",
"{",
"if",
"ptr",
"!=",
"nil",
"{",
"return",
"*",
"ptr",
"\n",
"}",
"\n",
"return",
"def",
"\n",
"}"
] | // IntPtrDerefOr dereference the int ptr and returns it i not nil,
// else returns def. | [
"IntPtrDerefOr",
"dereference",
"the",
"int",
"ptr",
"and",
"returns",
"it",
"i",
"not",
"nil",
"else",
"returns",
"def",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/util.go#L127-L132 |
165,234 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go | Create | func (e *events) Create(event *api.Event) (*api.Event, error) {
if e.namespace != "" && event.Namespace != e.namespace {
return nil, fmt.Errorf("can't create an event with namespace '%v' in namespace '%v'", event.Namespace, e.namespace)
}
result := &api.Event{}
err := e.client.Post().
Namespace(event.Namespace).
Resource("events").
Body(event).
Do().
Into(result)
return result, err
} | go | func (e *events) Create(event *api.Event) (*api.Event, error) {
if e.namespace != "" && event.Namespace != e.namespace {
return nil, fmt.Errorf("can't create an event with namespace '%v' in namespace '%v'", event.Namespace, e.namespace)
}
result := &api.Event{}
err := e.client.Post().
Namespace(event.Namespace).
Resource("events").
Body(event).
Do().
Into(result)
return result, err
} | [
"func",
"(",
"e",
"*",
"events",
")",
"Create",
"(",
"event",
"*",
"api",
".",
"Event",
")",
"(",
"*",
"api",
".",
"Event",
",",
"error",
")",
"{",
"if",
"e",
".",
"namespace",
"!=",
"\"",
"\"",
"&&",
"event",
".",
"Namespace",
"!=",
"e",
".",
... | // Create makes a new event. Returns the copy of the event the server returns,
// or an error. The namespace to create the event within is deduced from the
// event; it must either match this event client's namespace, or this event
// client must have been created with the "" namespace. | [
"Create",
"makes",
"a",
"new",
"event",
".",
"Returns",
"the",
"copy",
"of",
"the",
"event",
"the",
"server",
"returns",
"or",
"an",
"error",
".",
"The",
"namespace",
"to",
"create",
"the",
"event",
"within",
"is",
"deduced",
"from",
"the",
"event",
";",... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L69-L81 |
165,235 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go | Patch | func (e *events) Patch(incompleteEvent *api.Event, data []byte) (*api.Event, error) {
result := &api.Event{}
err := e.client.Patch(api.StrategicMergePatchType).
Namespace(incompleteEvent.Namespace).
Resource("events").
Name(incompleteEvent.Name).
Body(data).
Do().
Into(result)
return result, err
} | go | func (e *events) Patch(incompleteEvent *api.Event, data []byte) (*api.Event, error) {
result := &api.Event{}
err := e.client.Patch(api.StrategicMergePatchType).
Namespace(incompleteEvent.Namespace).
Resource("events").
Name(incompleteEvent.Name).
Body(data).
Do().
Into(result)
return result, err
} | [
"func",
"(",
"e",
"*",
"events",
")",
"Patch",
"(",
"incompleteEvent",
"*",
"api",
".",
"Event",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"api",
".",
"Event",
",",
"error",
")",
"{",
"result",
":=",
"&",
"api",
".",
"Event",
"{",
"}",
"\n"... | // Patch modifies an existing event. It returns the copy of the event that the server returns, or an
// error. The namespace and name of the target event is deduced from the incompleteEvent. The
// namespace must either match this event client's namespace, or this event client must have been
// created with the "" namespace. | [
"Patch",
"modifies",
"an",
"existing",
"event",
".",
"It",
"returns",
"the",
"copy",
"of",
"the",
"event",
"that",
"the",
"server",
"returns",
"or",
"an",
"error",
".",
"The",
"namespace",
"and",
"name",
"of",
"the",
"target",
"event",
"is",
"deduced",
"... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L104-L114 |
165,236 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go | scaleDown | func (r *RollingUpdater) scaleDown(newRc, oldRc *api.ReplicationController, desired, minAvailable, maxUnavailable, maxSurge int, config *RollingUpdaterConfig) (*api.ReplicationController, error) {
// Already scaled down; do nothing.
if oldRc.Spec.Replicas == 0 {
return oldRc, nil
}
// Block until there are any pods ready.
_, newAvailable, err := r.waitForReadyPods(config.Interval, config.Timeout, oldRc, newRc)
if err != nil {
return nil, err
}
// The old controller is considered as part of the total because we want to
// maintain minimum availability even with a volatile old controller.
// Scale down as much as possible while maintaining minimum availability
decrement := oldRc.Spec.Replicas + newAvailable - minAvailable
// The decrement normally shouldn't drop below 0 because the available count
// always starts below the old replica count, but the old replica count can
// decrement due to externalities like pods death in the replica set. This
// will be considered a transient condition; do nothing and try again later
// with new readiness values.
//
// If the most we can scale is 0, it means we can't scale down without
// violating the minimum. Do nothing and try again later when conditions may
// have changed.
if decrement <= 0 {
return oldRc, nil
}
// Reduce the replica count, and deal with fenceposts.
oldRc.Spec.Replicas -= decrement
if oldRc.Spec.Replicas < 0 {
oldRc.Spec.Replicas = 0
}
// If the new is already fully scaled and available up to the desired size, go
// ahead and scale old all the way down.
if newRc.Spec.Replicas == desired && newAvailable == desired {
oldRc.Spec.Replicas = 0
}
// Perform the scale-down.
fmt.Fprintf(config.Out, "Scaling %s down to %d\n", oldRc.Name, oldRc.Spec.Replicas)
retryWait := &RetryParams{config.Interval, config.Timeout}
scaledRc, err := r.scaleAndWait(oldRc, retryWait, retryWait)
if err != nil {
return nil, err
}
return scaledRc, nil
} | go | func (r *RollingUpdater) scaleDown(newRc, oldRc *api.ReplicationController, desired, minAvailable, maxUnavailable, maxSurge int, config *RollingUpdaterConfig) (*api.ReplicationController, error) {
// Already scaled down; do nothing.
if oldRc.Spec.Replicas == 0 {
return oldRc, nil
}
// Block until there are any pods ready.
_, newAvailable, err := r.waitForReadyPods(config.Interval, config.Timeout, oldRc, newRc)
if err != nil {
return nil, err
}
// The old controller is considered as part of the total because we want to
// maintain minimum availability even with a volatile old controller.
// Scale down as much as possible while maintaining minimum availability
decrement := oldRc.Spec.Replicas + newAvailable - minAvailable
// The decrement normally shouldn't drop below 0 because the available count
// always starts below the old replica count, but the old replica count can
// decrement due to externalities like pods death in the replica set. This
// will be considered a transient condition; do nothing and try again later
// with new readiness values.
//
// If the most we can scale is 0, it means we can't scale down without
// violating the minimum. Do nothing and try again later when conditions may
// have changed.
if decrement <= 0 {
return oldRc, nil
}
// Reduce the replica count, and deal with fenceposts.
oldRc.Spec.Replicas -= decrement
if oldRc.Spec.Replicas < 0 {
oldRc.Spec.Replicas = 0
}
// If the new is already fully scaled and available up to the desired size, go
// ahead and scale old all the way down.
if newRc.Spec.Replicas == desired && newAvailable == desired {
oldRc.Spec.Replicas = 0
}
// Perform the scale-down.
fmt.Fprintf(config.Out, "Scaling %s down to %d\n", oldRc.Name, oldRc.Spec.Replicas)
retryWait := &RetryParams{config.Interval, config.Timeout}
scaledRc, err := r.scaleAndWait(oldRc, retryWait, retryWait)
if err != nil {
return nil, err
}
return scaledRc, nil
} | [
"func",
"(",
"r",
"*",
"RollingUpdater",
")",
"scaleDown",
"(",
"newRc",
",",
"oldRc",
"*",
"api",
".",
"ReplicationController",
",",
"desired",
",",
"minAvailable",
",",
"maxUnavailable",
",",
"maxSurge",
"int",
",",
"config",
"*",
"RollingUpdaterConfig",
")"... | // scaleDown scales down oldRc to 0 at whatever increment possible given the
// thresholds defined on the config. scaleDown will safely no-op as necessary
// when it detects redundancy or other relevant conditions. | [
"scaleDown",
"scales",
"down",
"oldRc",
"to",
"0",
"at",
"whatever",
"increment",
"possible",
"given",
"the",
"thresholds",
"defined",
"on",
"the",
"config",
".",
"scaleDown",
"will",
"safely",
"no",
"-",
"op",
"as",
"necessary",
"when",
"it",
"detects",
"re... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go#L305-L349 |
165,237 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go | extractMaxValue | func extractMaxValue(field intstr.IntOrString, name string, value int) (int, error) {
switch field.Type {
case intstr.Int:
if field.IntVal < 0 {
return 0, fmt.Errorf("%s must be >= 0", name)
}
return field.IntValue(), nil
case intstr.String:
s := strings.Replace(field.StrVal, "%", "", -1)
v, err := strconv.Atoi(s)
if err != nil {
return 0, fmt.Errorf("invalid %s value %q: %v", name, field.StrVal, err)
}
if v < 0 {
return 0, fmt.Errorf("%s must be >= 0", name)
}
return int(math.Ceil(float64(value) * (float64(v)) / 100)), nil
}
return 0, fmt.Errorf("invalid kind %q for %s", field.Type, name)
} | go | func extractMaxValue(field intstr.IntOrString, name string, value int) (int, error) {
switch field.Type {
case intstr.Int:
if field.IntVal < 0 {
return 0, fmt.Errorf("%s must be >= 0", name)
}
return field.IntValue(), nil
case intstr.String:
s := strings.Replace(field.StrVal, "%", "", -1)
v, err := strconv.Atoi(s)
if err != nil {
return 0, fmt.Errorf("invalid %s value %q: %v", name, field.StrVal, err)
}
if v < 0 {
return 0, fmt.Errorf("%s must be >= 0", name)
}
return int(math.Ceil(float64(value) * (float64(v)) / 100)), nil
}
return 0, fmt.Errorf("invalid kind %q for %s", field.Type, name)
} | [
"func",
"extractMaxValue",
"(",
"field",
"intstr",
".",
"IntOrString",
",",
"name",
"string",
",",
"value",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"switch",
"field",
".",
"Type",
"{",
"case",
"intstr",
".",
"Int",
":",
"if",
"field",
".",
"I... | // func extractMaxValue is a helper to extract config max values as either
// absolute numbers or based on percentages of the given value. | [
"func",
"extractMaxValue",
"is",
"a",
"helper",
"to",
"extract",
"config",
"max",
"values",
"as",
"either",
"absolute",
"numbers",
"or",
"based",
"on",
"percentages",
"of",
"the",
"given",
"value",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go#L495-L514 |
165,238 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go | updateWithRetries | func updateWithRetries(rcClient client.ReplicationControllerInterface, rc *api.ReplicationController, applyUpdate updateFunc) (*api.ReplicationController, error) {
var err error
oldRc := rc
err = wait.Poll(10*time.Millisecond, 1*time.Minute, func() (bool, error) {
// Apply the update, then attempt to push it to the apiserver.
applyUpdate(rc)
if rc, err = rcClient.Update(rc); err == nil {
// rc contains the latest controller post update
return true, nil
}
// Update the controller with the latest resource version, if the update failed we
// can't trust rc so use oldRc.Name.
if rc, err = rcClient.Get(oldRc.Name); err != nil {
// The Get failed: Value in rc cannot be trusted.
rc = oldRc
}
// The Get passed: rc contains the latest controller, expect a poll for the update.
return false, nil
})
// If the error is non-nil the returned controller cannot be trusted, if it is nil, the returned
// controller contains the applied update.
return rc, err
} | go | func updateWithRetries(rcClient client.ReplicationControllerInterface, rc *api.ReplicationController, applyUpdate updateFunc) (*api.ReplicationController, error) {
var err error
oldRc := rc
err = wait.Poll(10*time.Millisecond, 1*time.Minute, func() (bool, error) {
// Apply the update, then attempt to push it to the apiserver.
applyUpdate(rc)
if rc, err = rcClient.Update(rc); err == nil {
// rc contains the latest controller post update
return true, nil
}
// Update the controller with the latest resource version, if the update failed we
// can't trust rc so use oldRc.Name.
if rc, err = rcClient.Get(oldRc.Name); err != nil {
// The Get failed: Value in rc cannot be trusted.
rc = oldRc
}
// The Get passed: rc contains the latest controller, expect a poll for the update.
return false, nil
})
// If the error is non-nil the returned controller cannot be trusted, if it is nil, the returned
// controller contains the applied update.
return rc, err
} | [
"func",
"updateWithRetries",
"(",
"rcClient",
"client",
".",
"ReplicationControllerInterface",
",",
"rc",
"*",
"api",
".",
"ReplicationController",
",",
"applyUpdate",
"updateFunc",
")",
"(",
"*",
"api",
".",
"ReplicationController",
",",
"error",
")",
"{",
"var",... | // updateWithRetries updates applies the given rc as an update. | [
"updateWithRetries",
"updates",
"applies",
"the",
"given",
"rc",
"as",
"an",
"update",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go#L726-L748 |
165,239 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go | Create | func (c *nodes) Create(node *api.Node) (*api.Node, error) {
result := &api.Node{}
err := c.r.Post().Resource(c.resourceName()).Body(node).Do().Into(result)
return result, err
} | go | func (c *nodes) Create(node *api.Node) (*api.Node, error) {
result := &api.Node{}
err := c.r.Post().Resource(c.resourceName()).Body(node).Do().Into(result)
return result, err
} | [
"func",
"(",
"c",
"*",
"nodes",
")",
"Create",
"(",
"node",
"*",
"api",
".",
"Node",
")",
"(",
"*",
"api",
".",
"Node",
",",
"error",
")",
"{",
"result",
":=",
"&",
"api",
".",
"Node",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"r",
".",
"Post"... | // Create creates a new node. | [
"Create",
"creates",
"a",
"new",
"node",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go#L56-L60 |
165,240 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go | Get | func (c *nodes) Get(name string) (*api.Node, error) {
result := &api.Node{}
err := c.r.Get().Resource(c.resourceName()).Name(name).Do().Into(result)
return result, err
} | go | func (c *nodes) Get(name string) (*api.Node, error) {
result := &api.Node{}
err := c.r.Get().Resource(c.resourceName()).Name(name).Do().Into(result)
return result, err
} | [
"func",
"(",
"c",
"*",
"nodes",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"api",
".",
"Node",
",",
"error",
")",
"{",
"result",
":=",
"&",
"api",
".",
"Node",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"r",
".",
"Get",
"(",
")",
".",
... | // Get gets an existing node. | [
"Get",
"gets",
"an",
"existing",
"node",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go#L70-L74 |
165,241 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go | Delete | func (c *nodes) Delete(name string) error {
return c.r.Delete().Resource(c.resourceName()).Name(name).Do().Error()
} | go | func (c *nodes) Delete(name string) error {
return c.r.Delete().Resource(c.resourceName()).Name(name).Do().Error()
} | [
"func",
"(",
"c",
"*",
"nodes",
")",
"Delete",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"c",
".",
"r",
".",
"Delete",
"(",
")",
".",
"Resource",
"(",
"c",
".",
"resourceName",
"(",
")",
")",
".",
"Name",
"(",
"name",
")",
".",
"Do",
... | // Delete deletes an existing node. | [
"Delete",
"deletes",
"an",
"existing",
"node",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/nodes.go#L77-L79 |
165,242 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/validation/validation.go | IsValidIPv4 | func IsValidIPv4(value string) bool {
return net.ParseIP(value) != nil && net.ParseIP(value).To4() != nil
} | go | func IsValidIPv4(value string) bool {
return net.ParseIP(value) != nil && net.ParseIP(value).To4() != nil
} | [
"func",
"IsValidIPv4",
"(",
"value",
"string",
")",
"bool",
"{",
"return",
"net",
".",
"ParseIP",
"(",
"value",
")",
"!=",
"nil",
"&&",
"net",
".",
"ParseIP",
"(",
"value",
")",
".",
"To4",
"(",
")",
"!=",
"nil",
"\n",
"}"
] | // IsValidIPv4 tests that the argument is a valid IPv4 address. | [
"IsValidIPv4",
"tests",
"that",
"the",
"argument",
"is",
"a",
"valid",
"IPv4",
"address",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/validation/validation.go#L139-L141 |
165,243 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned/group_version.go | IsEmpty | func (gvk GroupVersionKind) IsEmpty() bool {
return len(gvk.Group) == 0 && len(gvk.Version) == 0 && len(gvk.Kind) == 0
} | go | func (gvk GroupVersionKind) IsEmpty() bool {
return len(gvk.Group) == 0 && len(gvk.Version) == 0 && len(gvk.Kind) == 0
} | [
"func",
"(",
"gvk",
"GroupVersionKind",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"gvk",
".",
"Group",
")",
"==",
"0",
"&&",
"len",
"(",
"gvk",
".",
"Version",
")",
"==",
"0",
"&&",
"len",
"(",
"gvk",
".",
"Kind",
")",
"==",
... | // IsEmpty returns true if group, version, and kind are empty | [
"IsEmpty",
"returns",
"true",
"if",
"group",
"version",
"and",
"kind",
"are",
"empty"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned/group_version.go#L102-L104 |
165,244 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned/group_version.go | IsEmpty | func (gv GroupVersion) IsEmpty() bool {
return len(gv.Group) == 0 && len(gv.Version) == 0
} | go | func (gv GroupVersion) IsEmpty() bool {
return len(gv.Group) == 0 && len(gv.Version) == 0
} | [
"func",
"(",
"gv",
"GroupVersion",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"len",
"(",
"gv",
".",
"Group",
")",
"==",
"0",
"&&",
"len",
"(",
"gv",
".",
"Version",
")",
"==",
"0",
"\n",
"}"
] | // IsEmpty returns true if group and version are empty | [
"IsEmpty",
"returns",
"true",
"if",
"group",
"and",
"version",
"are",
"empty"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/unversioned/group_version.go#L127-L129 |
165,245 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go | DescribableResources | func DescribableResources() []string {
keys := make([]string, 0)
for k := range describerMap(nil) {
resource := strings.ToLower(k.Kind)
keys = append(keys, resource)
}
return keys
} | go | func DescribableResources() []string {
keys := make([]string, 0)
for k := range describerMap(nil) {
resource := strings.ToLower(k.Kind)
keys = append(keys, resource)
}
return keys
} | [
"func",
"DescribableResources",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"for",
"k",
":=",
"range",
"describerMap",
"(",
"nil",
")",
"{",
"resource",
":=",
"strings",
".",
"ToLower",
"("... | // List of all resource types we can describe | [
"List",
"of",
"all",
"resource",
"types",
"we",
"can",
"describe"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go#L106-L114 |
165,246 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go | DescriberFor | func DescriberFor(kind unversioned.GroupKind, c *client.Client) (Describer, bool) {
f, ok := describerMap(c)[kind]
return f, ok
} | go | func DescriberFor(kind unversioned.GroupKind, c *client.Client) (Describer, bool) {
f, ok := describerMap(c)[kind]
return f, ok
} | [
"func",
"DescriberFor",
"(",
"kind",
"unversioned",
".",
"GroupKind",
",",
"c",
"*",
"client",
".",
"Client",
")",
"(",
"Describer",
",",
"bool",
")",
"{",
"f",
",",
"ok",
":=",
"describerMap",
"(",
"c",
")",
"[",
"kind",
"]",
"\n",
"return",
"f",
... | // Describer returns the default describe functions for each of the standard
// Kubernetes types. | [
"Describer",
"returns",
"the",
"default",
"describe",
"functions",
"for",
"each",
"of",
"the",
"standard",
"Kubernetes",
"types",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go#L118-L121 |
165,247 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go | DescribeContainers | func DescribeContainers(containers []api.Container, containerStatuses []api.ContainerStatus, resolverFn EnvVarResolverFunc, out io.Writer) {
statuses := map[string]api.ContainerStatus{}
for _, status := range containerStatuses {
statuses[status.Name] = status
}
for _, container := range containers {
status := statuses[container.Name]
state := status.State
fmt.Fprintf(out, " %v:\n", container.Name)
fmt.Fprintf(out, " Container ID:\t%s\n", status.ContainerID)
fmt.Fprintf(out, " Image:\t%s\n", container.Image)
fmt.Fprintf(out, " Image ID:\t%s\n", status.ImageID)
if len(container.Command) > 0 {
fmt.Fprintf(out, " Command:\n")
for _, c := range container.Command {
fmt.Fprintf(out, " %s\n", c)
}
}
if len(container.Args) > 0 {
fmt.Fprintf(out, " Args:\n")
for _, arg := range container.Args {
fmt.Fprintf(out, " %s\n", arg)
}
}
resourceToQoS := qosutil.GetQoS(&container)
if len(resourceToQoS) > 0 {
fmt.Fprintf(out, " QoS Tier:\n")
}
for resource, qos := range resourceToQoS {
fmt.Fprintf(out, " %s:\t%s\n", resource, qos)
}
if len(container.Resources.Limits) > 0 {
fmt.Fprintf(out, " Limits:\n")
}
for name, quantity := range container.Resources.Limits {
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
}
if len(container.Resources.Requests) > 0 {
fmt.Fprintf(out, " Requests:\n")
}
for name, quantity := range container.Resources.Requests {
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
}
describeStatus("State", state, out)
if status.LastTerminationState.Terminated != nil {
describeStatus("Last State", status.LastTerminationState, out)
}
fmt.Fprintf(out, " Ready:\t%v\n", printBool(status.Ready))
fmt.Fprintf(out, " Restart Count:\t%d\n", status.RestartCount)
if container.LivenessProbe != nil {
probe := DescribeProbe(container.LivenessProbe)
fmt.Fprintf(out, " Liveness:\t%s\n", probe)
}
if container.ReadinessProbe != nil {
probe := DescribeProbe(container.ReadinessProbe)
fmt.Fprintf(out, " Readiness:\t%s\n", probe)
}
fmt.Fprintf(out, " Environment Variables:\n")
for _, e := range container.Env {
if e.ValueFrom != nil && e.ValueFrom.FieldRef != nil {
var valueFrom string
if resolverFn != nil {
valueFrom = resolverFn(e)
}
fmt.Fprintf(out, " %s:\t%s (%s:%s)\n", e.Name, valueFrom, e.ValueFrom.FieldRef.APIVersion, e.ValueFrom.FieldRef.FieldPath)
} else {
fmt.Fprintf(out, " %s:\t%s\n", e.Name, e.Value)
}
}
}
} | go | func DescribeContainers(containers []api.Container, containerStatuses []api.ContainerStatus, resolverFn EnvVarResolverFunc, out io.Writer) {
statuses := map[string]api.ContainerStatus{}
for _, status := range containerStatuses {
statuses[status.Name] = status
}
for _, container := range containers {
status := statuses[container.Name]
state := status.State
fmt.Fprintf(out, " %v:\n", container.Name)
fmt.Fprintf(out, " Container ID:\t%s\n", status.ContainerID)
fmt.Fprintf(out, " Image:\t%s\n", container.Image)
fmt.Fprintf(out, " Image ID:\t%s\n", status.ImageID)
if len(container.Command) > 0 {
fmt.Fprintf(out, " Command:\n")
for _, c := range container.Command {
fmt.Fprintf(out, " %s\n", c)
}
}
if len(container.Args) > 0 {
fmt.Fprintf(out, " Args:\n")
for _, arg := range container.Args {
fmt.Fprintf(out, " %s\n", arg)
}
}
resourceToQoS := qosutil.GetQoS(&container)
if len(resourceToQoS) > 0 {
fmt.Fprintf(out, " QoS Tier:\n")
}
for resource, qos := range resourceToQoS {
fmt.Fprintf(out, " %s:\t%s\n", resource, qos)
}
if len(container.Resources.Limits) > 0 {
fmt.Fprintf(out, " Limits:\n")
}
for name, quantity := range container.Resources.Limits {
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
}
if len(container.Resources.Requests) > 0 {
fmt.Fprintf(out, " Requests:\n")
}
for name, quantity := range container.Resources.Requests {
fmt.Fprintf(out, " %s:\t%s\n", name, quantity.String())
}
describeStatus("State", state, out)
if status.LastTerminationState.Terminated != nil {
describeStatus("Last State", status.LastTerminationState, out)
}
fmt.Fprintf(out, " Ready:\t%v\n", printBool(status.Ready))
fmt.Fprintf(out, " Restart Count:\t%d\n", status.RestartCount)
if container.LivenessProbe != nil {
probe := DescribeProbe(container.LivenessProbe)
fmt.Fprintf(out, " Liveness:\t%s\n", probe)
}
if container.ReadinessProbe != nil {
probe := DescribeProbe(container.ReadinessProbe)
fmt.Fprintf(out, " Readiness:\t%s\n", probe)
}
fmt.Fprintf(out, " Environment Variables:\n")
for _, e := range container.Env {
if e.ValueFrom != nil && e.ValueFrom.FieldRef != nil {
var valueFrom string
if resolverFn != nil {
valueFrom = resolverFn(e)
}
fmt.Fprintf(out, " %s:\t%s (%s:%s)\n", e.Name, valueFrom, e.ValueFrom.FieldRef.APIVersion, e.ValueFrom.FieldRef.FieldPath)
} else {
fmt.Fprintf(out, " %s:\t%s\n", e.Name, e.Value)
}
}
}
} | [
"func",
"DescribeContainers",
"(",
"containers",
"[",
"]",
"api",
".",
"Container",
",",
"containerStatuses",
"[",
"]",
"api",
".",
"ContainerStatus",
",",
"resolverFn",
"EnvVarResolverFunc",
",",
"out",
"io",
".",
"Writer",
")",
"{",
"statuses",
":=",
"map",
... | // DescribeContainers is exported for consumers in other API groups that have container templates | [
"DescribeContainers",
"is",
"exported",
"for",
"consumers",
"in",
"other",
"API",
"groups",
"that",
"have",
"container",
"templates"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/describe.go#L718-L796 |
165,248 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/scale.go | Get | func (c *scales) Get(kind string, name string) (result *extensions.Scale, err error) {
result = &extensions.Scale{}
// TODO this method needs to take a proper unambiguous kind
fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind}
resource, _ := meta.KindToResource(fullyQualifiedKind)
err = c.client.Get().Namespace(c.ns).Resource(resource.Resource).Name(name).SubResource("scale").Do().Into(result)
return
} | go | func (c *scales) Get(kind string, name string) (result *extensions.Scale, err error) {
result = &extensions.Scale{}
// TODO this method needs to take a proper unambiguous kind
fullyQualifiedKind := unversioned.GroupVersionKind{Kind: kind}
resource, _ := meta.KindToResource(fullyQualifiedKind)
err = c.client.Get().Namespace(c.ns).Resource(resource.Resource).Name(name).SubResource("scale").Do().Into(result)
return
} | [
"func",
"(",
"c",
"*",
"scales",
")",
"Get",
"(",
"kind",
"string",
",",
"name",
"string",
")",
"(",
"result",
"*",
"extensions",
".",
"Scale",
",",
"err",
"error",
")",
"{",
"result",
"=",
"&",
"extensions",
".",
"Scale",
"{",
"}",
"\n\n",
"// TOD... | // Get takes the reference to scale subresource and returns the subresource or error, if one occurs. | [
"Get",
"takes",
"the",
"reference",
"to",
"scale",
"subresource",
"and",
"returns",
"the",
"subresource",
"or",
"error",
"if",
"one",
"occurs",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/scale.go#L50-L59 |
165,249 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | Getfunc | func (s *staticPageHandler) Getfunc(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(s.returnCode)
w.Write(s.pageContents)
} | go | func (s *staticPageHandler) Getfunc(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(s.returnCode)
w.Write(s.pageContents)
} | [
"func",
"(",
"s",
"*",
"staticPageHandler",
")",
"Getfunc",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"s",
".",
"returnCode",
")",
"\n",
"w",
".",
"Write",
"(",
"s",
".",... | // Get serves the error page | [
"Get",
"serves",
"the",
"error",
"page"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L252-L255 |
165,250 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | write | func (cfg *loadBalancerConfig) write(services map[string][]service, dryRun bool) (err error) {
var w io.Writer
if dryRun {
w = os.Stdout
} else {
w, err = os.Create(cfg.Config)
if err != nil {
return
}
}
var t *template.Template
t, err = template.ParseFiles(cfg.Template)
if err != nil {
return
}
conf := make(map[string]interface{})
conf["startSyslog"] = strconv.FormatBool(cfg.startSyslog)
conf["services"] = services
var sslConfig string
if cfg.sslCert != "" {
sslConfig = "crt " + cfg.sslCert
}
if cfg.sslCaCert != "" {
sslConfig += " ca-file " + cfg.sslCaCert
}
conf["sslCert"] = sslConfig
// default load balancer algorithm is roundrobin
conf["defLbAlgorithm"] = lbDefAlgorithm
if cfg.lbDefAlgorithm != "" {
conf["defLbAlgorithm"] = cfg.lbDefAlgorithm
}
err = t.Execute(w, conf)
return
} | go | func (cfg *loadBalancerConfig) write(services map[string][]service, dryRun bool) (err error) {
var w io.Writer
if dryRun {
w = os.Stdout
} else {
w, err = os.Create(cfg.Config)
if err != nil {
return
}
}
var t *template.Template
t, err = template.ParseFiles(cfg.Template)
if err != nil {
return
}
conf := make(map[string]interface{})
conf["startSyslog"] = strconv.FormatBool(cfg.startSyslog)
conf["services"] = services
var sslConfig string
if cfg.sslCert != "" {
sslConfig = "crt " + cfg.sslCert
}
if cfg.sslCaCert != "" {
sslConfig += " ca-file " + cfg.sslCaCert
}
conf["sslCert"] = sslConfig
// default load balancer algorithm is roundrobin
conf["defLbAlgorithm"] = lbDefAlgorithm
if cfg.lbDefAlgorithm != "" {
conf["defLbAlgorithm"] = cfg.lbDefAlgorithm
}
err = t.Execute(w, conf)
return
} | [
"func",
"(",
"cfg",
"*",
"loadBalancerConfig",
")",
"write",
"(",
"services",
"map",
"[",
"string",
"]",
"[",
"]",
"service",
",",
"dryRun",
"bool",
")",
"(",
"err",
"error",
")",
"{",
"var",
"w",
"io",
".",
"Writer",
"\n",
"if",
"dryRun",
"{",
"w"... | // write writes the configuration file, will write to stdout if dryRun == true | [
"write",
"writes",
"the",
"configuration",
"file",
"will",
"write",
"to",
"stdout",
"if",
"dryRun",
"==",
"true"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L292-L329 |
165,251 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | reload | func (cfg *loadBalancerConfig) reload() error {
output, err := exec.Command("sh", "-c", cfg.ReloadCmd).CombinedOutput()
msg := fmt.Sprintf("%v -- %v", cfg.Name, string(output))
if err != nil {
return fmt.Errorf("error restarting %v: %v", msg, err)
}
glog.Infof(msg)
return nil
} | go | func (cfg *loadBalancerConfig) reload() error {
output, err := exec.Command("sh", "-c", cfg.ReloadCmd).CombinedOutput()
msg := fmt.Sprintf("%v -- %v", cfg.Name, string(output))
if err != nil {
return fmt.Errorf("error restarting %v: %v", msg, err)
}
glog.Infof(msg)
return nil
} | [
"func",
"(",
"cfg",
"*",
"loadBalancerConfig",
")",
"reload",
"(",
")",
"error",
"{",
"output",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"cfg",
".",
"ReloadCmd",
")",
".",
"CombinedOutput",
"(",
")",
"\n",
"m... | // reload reloads the loadbalancer using the reload cmd specified in the json manifest. | [
"reload",
"reloads",
"the",
"loadbalancer",
"using",
"the",
"reload",
"cmd",
"specified",
"in",
"the",
"json",
"manifest",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L332-L340 |
165,252 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | sync | func (lbc *loadBalancerController) sync(dryRun bool) error {
if !lbc.epController.HasSynced() || !lbc.svcController.HasSynced() {
time.Sleep(100 * time.Millisecond)
return errDeferredSync
}
httpSvc, httpsTermSvc, tcpSvc := lbc.getServices()
if len(httpSvc) == 0 && len(httpsTermSvc) == 0 && len(tcpSvc) == 0 {
return nil
}
if err := lbc.cfg.write(
map[string][]service{
"http": httpSvc,
"httpsTerm": httpsTermSvc,
"tcp": tcpSvc,
}, dryRun); err != nil {
return err
}
if dryRun {
return nil
}
return lbc.cfg.reload()
} | go | func (lbc *loadBalancerController) sync(dryRun bool) error {
if !lbc.epController.HasSynced() || !lbc.svcController.HasSynced() {
time.Sleep(100 * time.Millisecond)
return errDeferredSync
}
httpSvc, httpsTermSvc, tcpSvc := lbc.getServices()
if len(httpSvc) == 0 && len(httpsTermSvc) == 0 && len(tcpSvc) == 0 {
return nil
}
if err := lbc.cfg.write(
map[string][]service{
"http": httpSvc,
"httpsTerm": httpsTermSvc,
"tcp": tcpSvc,
}, dryRun); err != nil {
return err
}
if dryRun {
return nil
}
return lbc.cfg.reload()
} | [
"func",
"(",
"lbc",
"*",
"loadBalancerController",
")",
"sync",
"(",
"dryRun",
"bool",
")",
"error",
"{",
"if",
"!",
"lbc",
".",
"epController",
".",
"HasSynced",
"(",
")",
"||",
"!",
"lbc",
".",
"svcController",
".",
"HasSynced",
"(",
")",
"{",
"time"... | // sync all services with the loadbalancer. | [
"sync",
"all",
"services",
"with",
"the",
"loadbalancer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L509-L530 |
165,253 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | worker | func (lbc *loadBalancerController) worker() {
for {
key, _ := lbc.queue.Get()
glog.Infof("Sync triggered by service %v", key)
if err := lbc.sync(false); err != nil {
glog.Warningf("Requeuing %v because of error: %v", key, err)
lbc.queue.Add(key)
}
lbc.queue.Done(key)
}
} | go | func (lbc *loadBalancerController) worker() {
for {
key, _ := lbc.queue.Get()
glog.Infof("Sync triggered by service %v", key)
if err := lbc.sync(false); err != nil {
glog.Warningf("Requeuing %v because of error: %v", key, err)
lbc.queue.Add(key)
}
lbc.queue.Done(key)
}
} | [
"func",
"(",
"lbc",
"*",
"loadBalancerController",
")",
"worker",
"(",
")",
"{",
"for",
"{",
"key",
",",
"_",
":=",
"lbc",
".",
"queue",
".",
"Get",
"(",
")",
"\n",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"key",
")",
"\n",
"if",
"err",
":="... | // worker handles the work queue. | [
"worker",
"handles",
"the",
"work",
"queue",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L533-L543 |
165,254 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | newLoadBalancerController | func newLoadBalancerController(cfg *loadBalancerConfig, kubeClient *unversioned.Client, namespace string, tcpServices map[string]int) *loadBalancerController {
lbc := loadBalancerController{
cfg: cfg,
client: kubeClient,
queue: workqueue.New(),
reloadRateLimiter: util.NewTokenBucketRateLimiter(
reloadQPS, int(reloadQPS)),
targetService: *targetService,
forwardServices: *forwardServices,
httpPort: *httpPort,
tcpServices: tcpServices,
}
enqueue := func(obj interface{}) {
key, err := keyFunc(obj)
if err != nil {
glog.Infof("Couldn't get key for object %+v: %v", obj, err)
return
}
lbc.queue.Add(key)
}
eventHandlers := framework.ResourceEventHandlerFuncs{
AddFunc: enqueue,
DeleteFunc: enqueue,
UpdateFunc: func(old, cur interface{}) {
if !reflect.DeepEqual(old, cur) {
enqueue(cur)
}
},
}
lbc.svcLister.Store, lbc.svcController = framework.NewInformer(
cache.NewListWatchFromClient(
lbc.client, "services", namespace, fields.Everything()),
&api.Service{}, resyncPeriod, eventHandlers)
lbc.epLister.Store, lbc.epController = framework.NewInformer(
cache.NewListWatchFromClient(
lbc.client, "endpoints", namespace, fields.Everything()),
&api.Endpoints{}, resyncPeriod, eventHandlers)
return &lbc
} | go | func newLoadBalancerController(cfg *loadBalancerConfig, kubeClient *unversioned.Client, namespace string, tcpServices map[string]int) *loadBalancerController {
lbc := loadBalancerController{
cfg: cfg,
client: kubeClient,
queue: workqueue.New(),
reloadRateLimiter: util.NewTokenBucketRateLimiter(
reloadQPS, int(reloadQPS)),
targetService: *targetService,
forwardServices: *forwardServices,
httpPort: *httpPort,
tcpServices: tcpServices,
}
enqueue := func(obj interface{}) {
key, err := keyFunc(obj)
if err != nil {
glog.Infof("Couldn't get key for object %+v: %v", obj, err)
return
}
lbc.queue.Add(key)
}
eventHandlers := framework.ResourceEventHandlerFuncs{
AddFunc: enqueue,
DeleteFunc: enqueue,
UpdateFunc: func(old, cur interface{}) {
if !reflect.DeepEqual(old, cur) {
enqueue(cur)
}
},
}
lbc.svcLister.Store, lbc.svcController = framework.NewInformer(
cache.NewListWatchFromClient(
lbc.client, "services", namespace, fields.Everything()),
&api.Service{}, resyncPeriod, eventHandlers)
lbc.epLister.Store, lbc.epController = framework.NewInformer(
cache.NewListWatchFromClient(
lbc.client, "endpoints", namespace, fields.Everything()),
&api.Endpoints{}, resyncPeriod, eventHandlers)
return &lbc
} | [
"func",
"newLoadBalancerController",
"(",
"cfg",
"*",
"loadBalancerConfig",
",",
"kubeClient",
"*",
"unversioned",
".",
"Client",
",",
"namespace",
"string",
",",
"tcpServices",
"map",
"[",
"string",
"]",
"int",
")",
"*",
"loadBalancerController",
"{",
"lbc",
":... | // newLoadBalancerController creates a new controller from the given config. | [
"newLoadBalancerController",
"creates",
"a",
"new",
"controller",
"from",
"the",
"given",
"config",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L546-L588 |
165,255 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | parseCfg | func parseCfg(configPath string, defLbAlgorithm string, sslCert string, sslCaCert string) *loadBalancerConfig {
jsonBlob, err := ioutil.ReadFile(configPath)
if err != nil {
glog.Fatalf("Could not parse lb config: %v", err)
}
var cfg loadBalancerConfig
err = json.Unmarshal(jsonBlob, &cfg)
if err != nil {
glog.Fatalf("Unable to unmarshal json blob: %v", string(jsonBlob))
}
cfg.sslCert = sslCert
cfg.sslCaCert = sslCaCert
cfg.lbDefAlgorithm = defLbAlgorithm
glog.Infof("Creating new loadbalancer: %+v", cfg)
return &cfg
} | go | func parseCfg(configPath string, defLbAlgorithm string, sslCert string, sslCaCert string) *loadBalancerConfig {
jsonBlob, err := ioutil.ReadFile(configPath)
if err != nil {
glog.Fatalf("Could not parse lb config: %v", err)
}
var cfg loadBalancerConfig
err = json.Unmarshal(jsonBlob, &cfg)
if err != nil {
glog.Fatalf("Unable to unmarshal json blob: %v", string(jsonBlob))
}
cfg.sslCert = sslCert
cfg.sslCaCert = sslCaCert
cfg.lbDefAlgorithm = defLbAlgorithm
glog.Infof("Creating new loadbalancer: %+v", cfg)
return &cfg
} | [
"func",
"parseCfg",
"(",
"configPath",
"string",
",",
"defLbAlgorithm",
"string",
",",
"sslCert",
"string",
",",
"sslCaCert",
"string",
")",
"*",
"loadBalancerConfig",
"{",
"jsonBlob",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"configPath",
")",
"\n",
... | // parseCfg parses the given configuration file.
// cmd line params take precedence over config directives. | [
"parseCfg",
"parses",
"the",
"given",
"configuration",
"file",
".",
"cmd",
"line",
"params",
"take",
"precedence",
"over",
"config",
"directives",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L592-L607 |
165,256 | kubernetes-retired/contrib | service-loadbalancer/service_loadbalancer.go | registerHandlers | func registerHandlers(s *staticPageHandler) {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
// Delegate a check to the haproxy stats service.
response, err := http.Get(fmt.Sprintf("http://localhost:%v", *statsPort))
if err != nil {
glog.Infof("Error %v", err)
w.WriteHeader(http.StatusInternalServerError)
} else {
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
glog.Infof("Error reading resonse on receiving status %v: %v",
response.StatusCode, err)
}
glog.Infof("%v\n", string(contents))
w.WriteHeader(response.StatusCode)
} else {
w.WriteHeader(200)
w.Write([]byte("ok"))
}
}
})
// handler for not matched traffic
http.HandleFunc("/", s.Getfunc)
glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", lbApiPort), nil))
} | go | func registerHandlers(s *staticPageHandler) {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
// Delegate a check to the haproxy stats service.
response, err := http.Get(fmt.Sprintf("http://localhost:%v", *statsPort))
if err != nil {
glog.Infof("Error %v", err)
w.WriteHeader(http.StatusInternalServerError)
} else {
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
contents, err := ioutil.ReadAll(response.Body)
if err != nil {
glog.Infof("Error reading resonse on receiving status %v: %v",
response.StatusCode, err)
}
glog.Infof("%v\n", string(contents))
w.WriteHeader(response.StatusCode)
} else {
w.WriteHeader(200)
w.Write([]byte("ok"))
}
}
})
// handler for not matched traffic
http.HandleFunc("/", s.Getfunc)
glog.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", lbApiPort), nil))
} | [
"func",
"registerHandlers",
"(",
"s",
"*",
"staticPageHandler",
")",
"{",
"http",
".",
"HandleFunc",
"(",
"\"",
"\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Delegate a check to the haproxy s... | // registerHandlers services liveness probes. | [
"registerHandlers",
"services",
"liveness",
"probes",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/service_loadbalancer.go#L610-L638 |
165,257 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned/event_expansion.go | UpdateWithEventNamespace | func (e *events) UpdateWithEventNamespace(event *api.Event) (*api.Event, error) {
result := &api.Event{}
err := e.client.Put().
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
Resource("events").
Name(event.Name).
Body(event).
Do().
Into(result)
return result, err
} | go | func (e *events) UpdateWithEventNamespace(event *api.Event) (*api.Event, error) {
result := &api.Event{}
err := e.client.Put().
NamespaceIfScoped(event.Namespace, len(event.Namespace) > 0).
Resource("events").
Name(event.Name).
Body(event).
Do().
Into(result)
return result, err
} | [
"func",
"(",
"e",
"*",
"events",
")",
"UpdateWithEventNamespace",
"(",
"event",
"*",
"api",
".",
"Event",
")",
"(",
"*",
"api",
".",
"Event",
",",
"error",
")",
"{",
"result",
":=",
"&",
"api",
".",
"Event",
"{",
"}",
"\n",
"err",
":=",
"e",
".",... | // UpdateWithEventNamespace modifies an existing event. It returns the copy of the event that the server returns,
// or an error. The namespace and key to update the event within is deduced from the event. The
// namespace must either match this event client's namespace, or this event client must have been
// created with the "" namespace. Update also requires the ResourceVersion to be set in the event
// object. | [
"UpdateWithEventNamespace",
"modifies",
"an",
"existing",
"event",
".",
"It",
"returns",
"the",
"copy",
"of",
"the",
"event",
"that",
"the",
"server",
"returns",
"or",
"an",
"error",
".",
"The",
"namespace",
"and",
"key",
"to",
"update",
"the",
"event",
"wit... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned/event_expansion.go#L64-L74 |
165,258 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pod_templates.go | newPodTemplates | func newPodTemplates(c *Client, namespace string) *podTemplates {
return &podTemplates{
r: c,
ns: namespace,
}
} | go | func newPodTemplates(c *Client, namespace string) *podTemplates {
return &podTemplates{
r: c,
ns: namespace,
}
} | [
"func",
"newPodTemplates",
"(",
"c",
"*",
"Client",
",",
"namespace",
"string",
")",
"*",
"podTemplates",
"{",
"return",
"&",
"podTemplates",
"{",
"r",
":",
"c",
",",
"ns",
":",
"namespace",
",",
"}",
"\n",
"}"
] | // newPodTemplates returns a podTemplates | [
"newPodTemplates",
"returns",
"a",
"podTemplates"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pod_templates.go#L46-L51 |
165,259 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/pod_templates.go | Update | func (c *podTemplates) Update(podTemplate *api.PodTemplate) (result *api.PodTemplate, err error) {
result = &api.PodTemplate{}
err = c.r.Put().Namespace(c.ns).Resource("podTemplates").Name(podTemplate.Name).Body(podTemplate).Do().Into(result)
return
} | go | func (c *podTemplates) Update(podTemplate *api.PodTemplate) (result *api.PodTemplate, err error) {
result = &api.PodTemplate{}
err = c.r.Put().Namespace(c.ns).Resource("podTemplates").Name(podTemplate.Name).Body(podTemplate).Do().Into(result)
return
} | [
"func",
"(",
"c",
"*",
"podTemplates",
")",
"Update",
"(",
"podTemplate",
"*",
"api",
".",
"PodTemplate",
")",
"(",
"result",
"*",
"api",
".",
"PodTemplate",
",",
"err",
"error",
")",
"{",
"result",
"=",
"&",
"api",
".",
"PodTemplate",
"{",
"}",
"\n"... | // Update takes the representation of a podTemplate to update. Returns the server's representation of the podTemplate, and an error, if it occurs. | [
"Update",
"takes",
"the",
"representation",
"of",
"a",
"podTemplate",
"to",
"update",
".",
"Returns",
"the",
"server",
"s",
"representation",
"of",
"the",
"podTemplate",
"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/pod_templates.go#L80-L84 |
165,260 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | bytesToKey | func bytesToKey(b []byte, pasteActive bool) (rune, []byte) {
if len(b) == 0 {
return utf8.RuneError, nil
}
if !pasteActive {
switch b[0] {
case 1: // ^A
return keyHome, b[1:]
case 5: // ^E
return keyEnd, b[1:]
case 8: // ^H
return keyBackspace, b[1:]
case 11: // ^K
return keyDeleteLine, b[1:]
case 12: // ^L
return keyClearScreen, b[1:]
case 23: // ^W
return keyDeleteWord, b[1:]
}
}
if b[0] != keyEscape {
if !utf8.FullRune(b) {
return utf8.RuneError, b
}
r, l := utf8.DecodeRune(b)
return r, b[l:]
}
if !pasteActive && len(b) >= 3 && b[0] == keyEscape && b[1] == '[' {
switch b[2] {
case 'A':
return keyUp, b[3:]
case 'B':
return keyDown, b[3:]
case 'C':
return keyRight, b[3:]
case 'D':
return keyLeft, b[3:]
case 'H':
return keyHome, b[3:]
case 'F':
return keyEnd, b[3:]
}
}
if !pasteActive && len(b) >= 6 && b[0] == keyEscape && b[1] == '[' && b[2] == '1' && b[3] == ';' && b[4] == '3' {
switch b[5] {
case 'C':
return keyAltRight, b[6:]
case 'D':
return keyAltLeft, b[6:]
}
}
if !pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteStart) {
return keyPasteStart, b[6:]
}
if pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteEnd) {
return keyPasteEnd, b[6:]
}
// If we get here then we have a key that we don't recognise, or a
// partial sequence. It's not clear how one should find the end of a
// sequence without knowing them all, but it seems that [a-zA-Z~] only
// appears at the end of a sequence.
for i, c := range b[0:] {
if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '~' {
return keyUnknown, b[i+1:]
}
}
return utf8.RuneError, b
} | go | func bytesToKey(b []byte, pasteActive bool) (rune, []byte) {
if len(b) == 0 {
return utf8.RuneError, nil
}
if !pasteActive {
switch b[0] {
case 1: // ^A
return keyHome, b[1:]
case 5: // ^E
return keyEnd, b[1:]
case 8: // ^H
return keyBackspace, b[1:]
case 11: // ^K
return keyDeleteLine, b[1:]
case 12: // ^L
return keyClearScreen, b[1:]
case 23: // ^W
return keyDeleteWord, b[1:]
}
}
if b[0] != keyEscape {
if !utf8.FullRune(b) {
return utf8.RuneError, b
}
r, l := utf8.DecodeRune(b)
return r, b[l:]
}
if !pasteActive && len(b) >= 3 && b[0] == keyEscape && b[1] == '[' {
switch b[2] {
case 'A':
return keyUp, b[3:]
case 'B':
return keyDown, b[3:]
case 'C':
return keyRight, b[3:]
case 'D':
return keyLeft, b[3:]
case 'H':
return keyHome, b[3:]
case 'F':
return keyEnd, b[3:]
}
}
if !pasteActive && len(b) >= 6 && b[0] == keyEscape && b[1] == '[' && b[2] == '1' && b[3] == ';' && b[4] == '3' {
switch b[5] {
case 'C':
return keyAltRight, b[6:]
case 'D':
return keyAltLeft, b[6:]
}
}
if !pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteStart) {
return keyPasteStart, b[6:]
}
if pasteActive && len(b) >= 6 && bytes.Equal(b[:6], pasteEnd) {
return keyPasteEnd, b[6:]
}
// If we get here then we have a key that we don't recognise, or a
// partial sequence. It's not clear how one should find the end of a
// sequence without knowing them all, but it seems that [a-zA-Z~] only
// appears at the end of a sequence.
for i, c := range b[0:] {
if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '~' {
return keyUnknown, b[i+1:]
}
}
return utf8.RuneError, b
} | [
"func",
"bytesToKey",
"(",
"b",
"[",
"]",
"byte",
",",
"pasteActive",
"bool",
")",
"(",
"rune",
",",
"[",
"]",
"byte",
")",
"{",
"if",
"len",
"(",
"b",
")",
"==",
"0",
"{",
"return",
"utf8",
".",
"RuneError",
",",
"nil",
"\n",
"}",
"\n\n",
"if"... | // bytesToKey tries to parse a key sequence from b. If successful, it returns
// the key and the remainder of the input. Otherwise it returns utf8.RuneError. | [
"bytesToKey",
"tries",
"to",
"parse",
"a",
"key",
"sequence",
"from",
"b",
".",
"If",
"successful",
"it",
"returns",
"the",
"key",
"and",
"the",
"remainder",
"of",
"the",
"input",
".",
"Otherwise",
"it",
"returns",
"utf8",
".",
"RuneError",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L140-L215 |
165,261 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | queue | func (t *Terminal) queue(data []rune) {
t.outBuf = append(t.outBuf, []byte(string(data))...)
} | go | func (t *Terminal) queue(data []rune) {
t.outBuf = append(t.outBuf, []byte(string(data))...)
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"queue",
"(",
"data",
"[",
"]",
"rune",
")",
"{",
"t",
".",
"outBuf",
"=",
"append",
"(",
"t",
".",
"outBuf",
",",
"[",
"]",
"byte",
"(",
"string",
"(",
"data",
")",
")",
"...",
")",
"\n",
"}"
] | // queue appends data to the end of t.outBuf | [
"queue",
"appends",
"data",
"to",
"the",
"end",
"of",
"t",
".",
"outBuf"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L218-L220 |
165,262 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | moveCursorToPos | func (t *Terminal) moveCursorToPos(pos int) {
if !t.echo {
return
}
x := visualLength(t.prompt) + pos
y := x / t.termWidth
x = x % t.termWidth
up := 0
if y < t.cursorY {
up = t.cursorY - y
}
down := 0
if y > t.cursorY {
down = y - t.cursorY
}
left := 0
if x < t.cursorX {
left = t.cursorX - x
}
right := 0
if x > t.cursorX {
right = x - t.cursorX
}
t.cursorX = x
t.cursorY = y
t.move(up, down, left, right)
} | go | func (t *Terminal) moveCursorToPos(pos int) {
if !t.echo {
return
}
x := visualLength(t.prompt) + pos
y := x / t.termWidth
x = x % t.termWidth
up := 0
if y < t.cursorY {
up = t.cursorY - y
}
down := 0
if y > t.cursorY {
down = y - t.cursorY
}
left := 0
if x < t.cursorX {
left = t.cursorX - x
}
right := 0
if x > t.cursorX {
right = x - t.cursorX
}
t.cursorX = x
t.cursorY = y
t.move(up, down, left, right)
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"moveCursorToPos",
"(",
"pos",
"int",
")",
"{",
"if",
"!",
"t",
".",
"echo",
"{",
"return",
"\n",
"}",
"\n\n",
"x",
":=",
"visualLength",
"(",
"t",
".",
"prompt",
")",
"+",
"pos",
"\n",
"y",
":=",
"x",
"/... | // moveCursorToPos appends data to t.outBuf which will move the cursor to the
// given, logical position in the text. | [
"moveCursorToPos",
"appends",
"data",
"to",
"t",
".",
"outBuf",
"which",
"will",
"move",
"the",
"cursor",
"to",
"the",
"given",
"logical",
"position",
"in",
"the",
"text",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L232-L264 |
165,263 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | countToLeftWord | func (t *Terminal) countToLeftWord() int {
if t.pos == 0 {
return 0
}
pos := t.pos - 1
for pos > 0 {
if t.line[pos] != ' ' {
break
}
pos--
}
for pos > 0 {
if t.line[pos] == ' ' {
pos++
break
}
pos--
}
return t.pos - pos
} | go | func (t *Terminal) countToLeftWord() int {
if t.pos == 0 {
return 0
}
pos := t.pos - 1
for pos > 0 {
if t.line[pos] != ' ' {
break
}
pos--
}
for pos > 0 {
if t.line[pos] == ' ' {
pos++
break
}
pos--
}
return t.pos - pos
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"countToLeftWord",
"(",
")",
"int",
"{",
"if",
"t",
".",
"pos",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"pos",
":=",
"t",
".",
"pos",
"-",
"1",
"\n",
"for",
"pos",
">",
"0",
"{",
"if",
"t",
... | // countToLeftWord returns then number of characters from the cursor to the
// start of the previous word. | [
"countToLeftWord",
"returns",
"then",
"number",
"of",
"characters",
"from",
"the",
"cursor",
"to",
"the",
"start",
"of",
"the",
"previous",
"word",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L365-L386 |
165,264 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | countToRightWord | func (t *Terminal) countToRightWord() int {
pos := t.pos
for pos < len(t.line) {
if t.line[pos] == ' ' {
break
}
pos++
}
for pos < len(t.line) {
if t.line[pos] != ' ' {
break
}
pos++
}
return pos - t.pos
} | go | func (t *Terminal) countToRightWord() int {
pos := t.pos
for pos < len(t.line) {
if t.line[pos] == ' ' {
break
}
pos++
}
for pos < len(t.line) {
if t.line[pos] != ' ' {
break
}
pos++
}
return pos - t.pos
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"countToRightWord",
"(",
")",
"int",
"{",
"pos",
":=",
"t",
".",
"pos",
"\n",
"for",
"pos",
"<",
"len",
"(",
"t",
".",
"line",
")",
"{",
"if",
"t",
".",
"line",
"[",
"pos",
"]",
"==",
"' '",
"{",
"break... | // countToRightWord returns then number of characters from the cursor to the
// start of the next word. | [
"countToRightWord",
"returns",
"then",
"number",
"of",
"characters",
"from",
"the",
"cursor",
"to",
"the",
"start",
"of",
"the",
"next",
"word",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L390-L405 |
165,265 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | visualLength | func visualLength(runes []rune) int {
inEscapeSeq := false
length := 0
for _, r := range runes {
switch {
case inEscapeSeq:
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
inEscapeSeq = false
}
case r == '\x1b':
inEscapeSeq = true
default:
length++
}
}
return length
} | go | func visualLength(runes []rune) int {
inEscapeSeq := false
length := 0
for _, r := range runes {
switch {
case inEscapeSeq:
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
inEscapeSeq = false
}
case r == '\x1b':
inEscapeSeq = true
default:
length++
}
}
return length
} | [
"func",
"visualLength",
"(",
"runes",
"[",
"]",
"rune",
")",
"int",
"{",
"inEscapeSeq",
":=",
"false",
"\n",
"length",
":=",
"0",
"\n\n",
"for",
"_",
",",
"r",
":=",
"range",
"runes",
"{",
"switch",
"{",
"case",
"inEscapeSeq",
":",
"if",
"(",
"r",
... | // visualLength returns the number of visible glyphs in s. | [
"visualLength",
"returns",
"the",
"number",
"of",
"visible",
"glyphs",
"in",
"s",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L408-L426 |
165,266 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | addKeyToLine | func (t *Terminal) addKeyToLine(key rune) {
if len(t.line) == cap(t.line) {
newLine := make([]rune, len(t.line), 2*(1+len(t.line)))
copy(newLine, t.line)
t.line = newLine
}
t.line = t.line[:len(t.line)+1]
copy(t.line[t.pos+1:], t.line[t.pos:])
t.line[t.pos] = key
if t.echo {
t.writeLine(t.line[t.pos:])
}
t.pos++
t.moveCursorToPos(t.pos)
} | go | func (t *Terminal) addKeyToLine(key rune) {
if len(t.line) == cap(t.line) {
newLine := make([]rune, len(t.line), 2*(1+len(t.line)))
copy(newLine, t.line)
t.line = newLine
}
t.line = t.line[:len(t.line)+1]
copy(t.line[t.pos+1:], t.line[t.pos:])
t.line[t.pos] = key
if t.echo {
t.writeLine(t.line[t.pos:])
}
t.pos++
t.moveCursorToPos(t.pos)
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"addKeyToLine",
"(",
"key",
"rune",
")",
"{",
"if",
"len",
"(",
"t",
".",
"line",
")",
"==",
"cap",
"(",
"t",
".",
"line",
")",
"{",
"newLine",
":=",
"make",
"(",
"[",
"]",
"rune",
",",
"len",
"(",
"t",... | // addKeyToLine inserts the given key at the current position in the current
// line. | [
"addKeyToLine",
"inserts",
"the",
"given",
"key",
"at",
"the",
"current",
"position",
"in",
"the",
"current",
"line",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L567-L581 |
165,267 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | ReadPassword | func (t *Terminal) ReadPassword(prompt string) (line string, err error) {
t.lock.Lock()
defer t.lock.Unlock()
oldPrompt := t.prompt
t.prompt = []rune(prompt)
t.echo = false
line, err = t.readLine()
t.prompt = oldPrompt
t.echo = true
return
} | go | func (t *Terminal) ReadPassword(prompt string) (line string, err error) {
t.lock.Lock()
defer t.lock.Unlock()
oldPrompt := t.prompt
t.prompt = []rune(prompt)
t.echo = false
line, err = t.readLine()
t.prompt = oldPrompt
t.echo = true
return
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"ReadPassword",
"(",
"prompt",
"string",
")",
"(",
"line",
"string",
",",
"err",
"error",
")",
"{",
"t",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",... | // ReadPassword temporarily changes the prompt and reads a password, without
// echo, from the terminal. | [
"ReadPassword",
"temporarily",
"changes",
"the",
"prompt",
"and",
"reads",
"a",
"password",
"without",
"echo",
"from",
"the",
"terminal",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L643-L657 |
165,268 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | ReadLine | func (t *Terminal) ReadLine() (line string, err error) {
t.lock.Lock()
defer t.lock.Unlock()
return t.readLine()
} | go | func (t *Terminal) ReadLine() (line string, err error) {
t.lock.Lock()
defer t.lock.Unlock()
return t.readLine()
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"ReadLine",
"(",
")",
"(",
"line",
"string",
",",
"err",
"error",
")",
"{",
"t",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"t",
".",
... | // ReadLine returns a line of input from the terminal. | [
"ReadLine",
"returns",
"a",
"line",
"of",
"input",
"from",
"the",
"terminal",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L660-L665 |
165,269 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | SetPrompt | func (t *Terminal) SetPrompt(prompt string) {
t.lock.Lock()
defer t.lock.Unlock()
t.prompt = []rune(prompt)
} | go | func (t *Terminal) SetPrompt(prompt string) {
t.lock.Lock()
defer t.lock.Unlock()
t.prompt = []rune(prompt)
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"SetPrompt",
"(",
"prompt",
"string",
")",
"{",
"t",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"t",
".",
"prompt",
"=",
"[",
"]",
"rune",
"(",
... | // SetPrompt sets the prompt to be used when reading subsequent lines. | [
"SetPrompt",
"sets",
"the",
"prompt",
"to",
"be",
"used",
"when",
"reading",
"subsequent",
"lines",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L748-L753 |
165,270 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | SetBracketedPasteMode | func (t *Terminal) SetBracketedPasteMode(on bool) {
if on {
io.WriteString(t.c, "\x1b[?2004h")
} else {
io.WriteString(t.c, "\x1b[?2004l")
}
} | go | func (t *Terminal) SetBracketedPasteMode(on bool) {
if on {
io.WriteString(t.c, "\x1b[?2004h")
} else {
io.WriteString(t.c, "\x1b[?2004l")
}
} | [
"func",
"(",
"t",
"*",
"Terminal",
")",
"SetBracketedPasteMode",
"(",
"on",
"bool",
")",
"{",
"if",
"on",
"{",
"io",
".",
"WriteString",
"(",
"t",
".",
"c",
",",
"\"",
"\\x1b",
"\"",
")",
"\n",
"}",
"else",
"{",
"io",
".",
"WriteString",
"(",
"t"... | // SetBracketedPasteMode requests that the terminal bracket paste operations
// with markers. Not all terminals support this but, if it is supported, then
// enabling this mode will stop any autocomplete callback from running due to
// pastes. Additionally, any lines that are completely pasted will be returned
// from ReadLine with the error set to ErrPasteIndicator. | [
"SetBracketedPasteMode",
"requests",
"that",
"the",
"terminal",
"bracket",
"paste",
"operations",
"with",
"markers",
".",
"Not",
"all",
"terminals",
"support",
"this",
"but",
"if",
"it",
"is",
"supported",
"then",
"enabling",
"this",
"mode",
"will",
"stop",
"any... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L846-L852 |
165,271 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go | NthPreviousEntry | func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) {
if n >= s.size {
return "", false
}
index := s.head - n
if index < 0 {
index += s.max
}
return s.entries[index], true
} | go | func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) {
if n >= s.size {
return "", false
}
index := s.head - n
if index < 0 {
index += s.max
}
return s.entries[index], true
} | [
"func",
"(",
"s",
"*",
"stRingBuffer",
")",
"NthPreviousEntry",
"(",
"n",
"int",
")",
"(",
"value",
"string",
",",
"ok",
"bool",
")",
"{",
"if",
"n",
">=",
"s",
".",
"size",
"{",
"return",
"\"",
"\"",
",",
"false",
"\n",
"}",
"\n",
"index",
":=",... | // NthPreviousEntry returns the value passed to the nth previous call to Add.
// If n is zero then the immediately prior value is returned, if one, then the
// next most recent, and so on. If such an element doesn't exist then ok is
// false. | [
"NthPreviousEntry",
"returns",
"the",
"value",
"passed",
"to",
"the",
"nth",
"previous",
"call",
"to",
"Add",
".",
"If",
"n",
"is",
"zero",
"then",
"the",
"immediately",
"prior",
"value",
"is",
"returned",
"if",
"one",
"then",
"the",
"next",
"most",
"recen... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go#L883-L892 |
165,272 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go | yaml_parser_parse | func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {
// Erase the event object.
*event = yaml_event_t{}
// No events after the end of the stream or error.
if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE {
return true
}
// Generate the next event.
return yaml_parser_state_machine(parser, event)
} | go | func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {
// Erase the event object.
*event = yaml_event_t{}
// No events after the end of the stream or error.
if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE {
return true
}
// Generate the next event.
return yaml_parser_state_machine(parser, event)
} | [
"func",
"yaml_parser_parse",
"(",
"parser",
"*",
"yaml_parser_t",
",",
"event",
"*",
"yaml_event_t",
")",
"bool",
"{",
"// Erase the event object.",
"*",
"event",
"=",
"yaml_event_t",
"{",
"}",
"\n\n",
"// No events after the end of the stream or error.",
"if",
"parser"... | // Get the next event. | [
"Get",
"the",
"next",
"event",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go#L62-L73 |
165,273 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go | yaml_parser_set_parser_error | func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool {
parser.error = yaml_PARSER_ERROR
parser.problem = problem
parser.problem_mark = problem_mark
return false
} | go | func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool {
parser.error = yaml_PARSER_ERROR
parser.problem = problem
parser.problem_mark = problem_mark
return false
} | [
"func",
"yaml_parser_set_parser_error",
"(",
"parser",
"*",
"yaml_parser_t",
",",
"problem",
"string",
",",
"problem_mark",
"yaml_mark_t",
")",
"bool",
"{",
"parser",
".",
"error",
"=",
"yaml_PARSER_ERROR",
"\n",
"parser",
".",
"problem",
"=",
"problem",
"\n",
"... | // Set parser error. | [
"Set",
"parser",
"error",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go#L76-L81 |
165,274 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go | yaml_parser_process_empty_scalar | func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool {
*event = yaml_event_t{
typ: yaml_SCALAR_EVENT,
start_mark: mark,
end_mark: mark,
value: nil, // Empty
implicit: true,
style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
}
return true
} | go | func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool {
*event = yaml_event_t{
typ: yaml_SCALAR_EVENT,
start_mark: mark,
end_mark: mark,
value: nil, // Empty
implicit: true,
style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE),
}
return true
} | [
"func",
"yaml_parser_process_empty_scalar",
"(",
"parser",
"*",
"yaml_parser_t",
",",
"event",
"*",
"yaml_event_t",
",",
"mark",
"yaml_mark_t",
")",
"bool",
"{",
"*",
"event",
"=",
"yaml_event_t",
"{",
"typ",
":",
"yaml_SCALAR_EVENT",
",",
"start_mark",
":",
"ma... | // Generate an empty scalar event. | [
"Generate",
"an",
"empty",
"scalar",
"event",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go#L996-L1006 |
165,275 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go | yaml_parser_process_directives | func yaml_parser_process_directives(parser *yaml_parser_t,
version_directive_ref **yaml_version_directive_t,
tag_directives_ref *[]yaml_tag_directive_t) bool {
var version_directive *yaml_version_directive_t
var tag_directives []yaml_tag_directive_t
token := peek_token(parser)
if token == nil {
return false
}
for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN {
if token.typ == yaml_VERSION_DIRECTIVE_TOKEN {
if version_directive != nil {
yaml_parser_set_parser_error(parser,
"found duplicate %YAML directive", token.start_mark)
return false
}
if token.major != 1 || token.minor != 1 {
yaml_parser_set_parser_error(parser,
"found incompatible YAML document", token.start_mark)
return false
}
version_directive = &yaml_version_directive_t{
major: token.major,
minor: token.minor,
}
} else if token.typ == yaml_TAG_DIRECTIVE_TOKEN {
value := yaml_tag_directive_t{
handle: token.value,
prefix: token.prefix,
}
if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {
return false
}
tag_directives = append(tag_directives, value)
}
skip_token(parser)
token = peek_token(parser)
if token == nil {
return false
}
}
for i := range default_tag_directives {
if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) {
return false
}
}
if version_directive_ref != nil {
*version_directive_ref = version_directive
}
if tag_directives_ref != nil {
*tag_directives_ref = tag_directives
}
return true
} | go | func yaml_parser_process_directives(parser *yaml_parser_t,
version_directive_ref **yaml_version_directive_t,
tag_directives_ref *[]yaml_tag_directive_t) bool {
var version_directive *yaml_version_directive_t
var tag_directives []yaml_tag_directive_t
token := peek_token(parser)
if token == nil {
return false
}
for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN {
if token.typ == yaml_VERSION_DIRECTIVE_TOKEN {
if version_directive != nil {
yaml_parser_set_parser_error(parser,
"found duplicate %YAML directive", token.start_mark)
return false
}
if token.major != 1 || token.minor != 1 {
yaml_parser_set_parser_error(parser,
"found incompatible YAML document", token.start_mark)
return false
}
version_directive = &yaml_version_directive_t{
major: token.major,
minor: token.minor,
}
} else if token.typ == yaml_TAG_DIRECTIVE_TOKEN {
value := yaml_tag_directive_t{
handle: token.value,
prefix: token.prefix,
}
if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {
return false
}
tag_directives = append(tag_directives, value)
}
skip_token(parser)
token = peek_token(parser)
if token == nil {
return false
}
}
for i := range default_tag_directives {
if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) {
return false
}
}
if version_directive_ref != nil {
*version_directive_ref = version_directive
}
if tag_directives_ref != nil {
*tag_directives_ref = tag_directives
}
return true
} | [
"func",
"yaml_parser_process_directives",
"(",
"parser",
"*",
"yaml_parser_t",
",",
"version_directive_ref",
"*",
"*",
"yaml_version_directive_t",
",",
"tag_directives_ref",
"*",
"[",
"]",
"yaml_tag_directive_t",
")",
"bool",
"{",
"var",
"version_directive",
"*",
"yaml_... | // Parse directives. | [
"Parse",
"directives",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go#L1014-L1073 |
165,276 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go | yaml_parser_append_tag_directive | func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool {
for i := range parser.tag_directives {
if bytes.Equal(value.handle, parser.tag_directives[i].handle) {
if allow_duplicates {
return true
}
return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark)
}
}
// [Go] I suspect the copy is unnecessary. This was likely done
// because there was no way to track ownership of the data.
value_copy := yaml_tag_directive_t{
handle: make([]byte, len(value.handle)),
prefix: make([]byte, len(value.prefix)),
}
copy(value_copy.handle, value.handle)
copy(value_copy.prefix, value.prefix)
parser.tag_directives = append(parser.tag_directives, value_copy)
return true
} | go | func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool {
for i := range parser.tag_directives {
if bytes.Equal(value.handle, parser.tag_directives[i].handle) {
if allow_duplicates {
return true
}
return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark)
}
}
// [Go] I suspect the copy is unnecessary. This was likely done
// because there was no way to track ownership of the data.
value_copy := yaml_tag_directive_t{
handle: make([]byte, len(value.handle)),
prefix: make([]byte, len(value.prefix)),
}
copy(value_copy.handle, value.handle)
copy(value_copy.prefix, value.prefix)
parser.tag_directives = append(parser.tag_directives, value_copy)
return true
} | [
"func",
"yaml_parser_append_tag_directive",
"(",
"parser",
"*",
"yaml_parser_t",
",",
"value",
"yaml_tag_directive_t",
",",
"allow_duplicates",
"bool",
",",
"mark",
"yaml_mark_t",
")",
"bool",
"{",
"for",
"i",
":=",
"range",
"parser",
".",
"tag_directives",
"{",
"... | // Append a tag directive to the directives stack. | [
"Append",
"a",
"tag",
"directive",
"to",
"the",
"directives",
"stack",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/parserc.go#L1076-L1096 |
165,277 | kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/secret.go | handleFromFileSources | func handleFromFileSources(secret *api.Secret, fileSources []string) error {
for _, fileSource := range fileSources {
keyName, filePath, err := parseFileSource(fileSource)
if err != nil {
return err
}
info, err := os.Stat(filePath)
if err != nil {
switch err := err.(type) {
case *os.PathError:
return fmt.Errorf("error reading %s: %v", filePath, err.Err)
default:
return fmt.Errorf("error reading %s: %v", filePath, err)
}
}
if info.IsDir() {
if strings.Contains(fileSource, "=") {
return fmt.Errorf("cannot give a key name for a directory path.")
}
fileList, err := ioutil.ReadDir(filePath)
if err != nil {
return fmt.Errorf("error listing files in %s: %v", filePath, err)
}
for _, item := range fileList {
itemPath := path.Join(filePath, item.Name())
if item.Mode().IsRegular() {
keyName = item.Name()
err = addKeyFromFileToSecret(secret, keyName, itemPath)
if err != nil {
return err
}
}
}
} else {
err = addKeyFromFileToSecret(secret, keyName, filePath)
if err != nil {
return err
}
}
}
return nil
} | go | func handleFromFileSources(secret *api.Secret, fileSources []string) error {
for _, fileSource := range fileSources {
keyName, filePath, err := parseFileSource(fileSource)
if err != nil {
return err
}
info, err := os.Stat(filePath)
if err != nil {
switch err := err.(type) {
case *os.PathError:
return fmt.Errorf("error reading %s: %v", filePath, err.Err)
default:
return fmt.Errorf("error reading %s: %v", filePath, err)
}
}
if info.IsDir() {
if strings.Contains(fileSource, "=") {
return fmt.Errorf("cannot give a key name for a directory path.")
}
fileList, err := ioutil.ReadDir(filePath)
if err != nil {
return fmt.Errorf("error listing files in %s: %v", filePath, err)
}
for _, item := range fileList {
itemPath := path.Join(filePath, item.Name())
if item.Mode().IsRegular() {
keyName = item.Name()
err = addKeyFromFileToSecret(secret, keyName, itemPath)
if err != nil {
return err
}
}
}
} else {
err = addKeyFromFileToSecret(secret, keyName, filePath)
if err != nil {
return err
}
}
}
return nil
} | [
"func",
"handleFromFileSources",
"(",
"secret",
"*",
"api",
".",
"Secret",
",",
"fileSources",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"fileSource",
":=",
"range",
"fileSources",
"{",
"keyName",
",",
"filePath",
",",
"err",
":=",
"parseFile... | // handleFromFileSources adds the specified file source information into the provided secret | [
"handleFromFileSources",
"adds",
"the",
"specified",
"file",
"source",
"information",
"into",
"the",
"provided",
"secret"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/secret.go#L146-L188 |
165,278 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/transport/transport.go | New | func New(config *Config) (http.RoundTripper, error) {
// Set transport level security
if config.Transport != nil && (config.HasCA() || config.HasCertAuth() || config.TLS.Insecure) {
return nil, fmt.Errorf("using a custom transport with TLS certificate options or the insecure flag is not allowed")
}
var (
rt http.RoundTripper
err error
)
if config.Transport != nil {
rt = config.Transport
} else {
rt, err = tlsCache.get(config)
if err != nil {
return nil, err
}
}
return HTTPWrappersForConfig(config, rt)
} | go | func New(config *Config) (http.RoundTripper, error) {
// Set transport level security
if config.Transport != nil && (config.HasCA() || config.HasCertAuth() || config.TLS.Insecure) {
return nil, fmt.Errorf("using a custom transport with TLS certificate options or the insecure flag is not allowed")
}
var (
rt http.RoundTripper
err error
)
if config.Transport != nil {
rt = config.Transport
} else {
rt, err = tlsCache.get(config)
if err != nil {
return nil, err
}
}
return HTTPWrappersForConfig(config, rt)
} | [
"func",
"New",
"(",
"config",
"*",
"Config",
")",
"(",
"http",
".",
"RoundTripper",
",",
"error",
")",
"{",
"// Set transport level security",
"if",
"config",
".",
"Transport",
"!=",
"nil",
"&&",
"(",
"config",
".",
"HasCA",
"(",
")",
"||",
"config",
"."... | // New returns an http.RoundTripper that will provide the authentication
// or transport level security defined by the provided Config. | [
"New",
"returns",
"an",
"http",
".",
"RoundTripper",
"that",
"will",
"provide",
"the",
"authentication",
"or",
"transport",
"level",
"security",
"defined",
"by",
"the",
"provided",
"Config",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/transport/transport.go#L29-L50 |
165,279 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go | Command | func (executor *executor) Command(cmd string, args ...string) Cmd {
return (*cmdWrapper)(osexec.Command(cmd, args...))
} | go | func (executor *executor) Command(cmd string, args ...string) Cmd {
return (*cmdWrapper)(osexec.Command(cmd, args...))
} | [
"func",
"(",
"executor",
"*",
"executor",
")",
"Command",
"(",
"cmd",
"string",
",",
"args",
"...",
"string",
")",
"Cmd",
"{",
"return",
"(",
"*",
"cmdWrapper",
")",
"(",
"osexec",
".",
"Command",
"(",
"cmd",
",",
"args",
"...",
")",
")",
"\n",
"}"... | // Command is part of the Interface interface. | [
"Command",
"is",
"part",
"of",
"the",
"Interface",
"interface",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go#L67-L69 |
165,280 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go | LookPath | func (executor *executor) LookPath(file string) (string, error) {
return osexec.LookPath(file)
} | go | func (executor *executor) LookPath(file string) (string, error) {
return osexec.LookPath(file)
} | [
"func",
"(",
"executor",
"*",
"executor",
")",
"LookPath",
"(",
"file",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"osexec",
".",
"LookPath",
"(",
"file",
")",
"\n",
"}"
] | // LookPath is part of the Interface interface | [
"LookPath",
"is",
"part",
"of",
"the",
"Interface",
"interface"
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go#L72-L74 |
165,281 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go | CombinedOutput | func (cmd *cmdWrapper) CombinedOutput() ([]byte, error) {
out, err := (*osexec.Cmd)(cmd).CombinedOutput()
if err != nil {
if ee, ok := err.(*osexec.ExitError); ok {
// Force a compile fail if exitErrorWrapper can't convert to ExitError.
var x ExitError = &exitErrorWrapper{ee}
return out, x
}
if ee, ok := err.(*osexec.Error); ok {
if ee.Err == osexec.ErrNotFound {
return out, ErrExecutableNotFound
}
}
return out, err
}
return out, nil
} | go | func (cmd *cmdWrapper) CombinedOutput() ([]byte, error) {
out, err := (*osexec.Cmd)(cmd).CombinedOutput()
if err != nil {
if ee, ok := err.(*osexec.ExitError); ok {
// Force a compile fail if exitErrorWrapper can't convert to ExitError.
var x ExitError = &exitErrorWrapper{ee}
return out, x
}
if ee, ok := err.(*osexec.Error); ok {
if ee.Err == osexec.ErrNotFound {
return out, ErrExecutableNotFound
}
}
return out, err
}
return out, nil
} | [
"func",
"(",
"cmd",
"*",
"cmdWrapper",
")",
"CombinedOutput",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"(",
"*",
"osexec",
".",
"Cmd",
")",
"(",
"cmd",
")",
".",
"CombinedOutput",
"(",
")",
"\n",
"if",
"... | // CombinedOutput is part of the Cmd interface. | [
"CombinedOutput",
"is",
"part",
"of",
"the",
"Cmd",
"interface",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go#L84-L100 |
165,282 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go | ExitStatus | func (eew exitErrorWrapper) ExitStatus() int {
ws, ok := eew.Sys().(syscall.WaitStatus)
if !ok {
panic("can't call ExitStatus() on a non-WaitStatus exitErrorWrapper")
}
return ws.ExitStatus()
} | go | func (eew exitErrorWrapper) ExitStatus() int {
ws, ok := eew.Sys().(syscall.WaitStatus)
if !ok {
panic("can't call ExitStatus() on a non-WaitStatus exitErrorWrapper")
}
return ws.ExitStatus()
} | [
"func",
"(",
"eew",
"exitErrorWrapper",
")",
"ExitStatus",
"(",
")",
"int",
"{",
"ws",
",",
"ok",
":=",
"eew",
".",
"Sys",
"(",
")",
".",
"(",
"syscall",
".",
"WaitStatus",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"... | // ExitStatus is part of the ExitError interface. | [
"ExitStatus",
"is",
"part",
"of",
"the",
"ExitError",
"interface",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/exec/exec.go#L109-L115 |
165,283 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wsstream/stream.go | NewReader | func NewReader(r io.Reader, ping bool) *Reader {
return &Reader{
r: r,
err: make(chan error),
ping: ping,
}
} | go | func NewReader(r io.Reader, ping bool) *Reader {
return &Reader{
r: r,
err: make(chan error),
ping: ping,
}
} | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
",",
"ping",
"bool",
")",
"*",
"Reader",
"{",
"return",
"&",
"Reader",
"{",
"r",
":",
"r",
",",
"err",
":",
"make",
"(",
"chan",
"error",
")",
",",
"ping",
":",
"ping",
",",
"}",
"\n",
"}"
] | // NewReader creates a WebSocket pipe that will copy the contents of r to a provided
// WebSocket connection. If ping is true, a zero length message will be sent to the client
// before the stream begins reading. | [
"NewReader",
"creates",
"a",
"WebSocket",
"pipe",
"that",
"will",
"copy",
"the",
"contents",
"of",
"r",
"to",
"a",
"provided",
"WebSocket",
"connection",
".",
"If",
"ping",
"is",
"true",
"a",
"zero",
"length",
"message",
"will",
"be",
"sent",
"to",
"the",
... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wsstream/stream.go#L52-L58 |
165,284 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wsstream/stream.go | Copy | func (r *Reader) Copy(w http.ResponseWriter, req *http.Request) error {
go func() {
defer util.HandleCrash()
websocket.Server{Handshake: r.handshake, Handler: r.handle}.ServeHTTP(w, req)
}()
return <-r.err
} | go | func (r *Reader) Copy(w http.ResponseWriter, req *http.Request) error {
go func() {
defer util.HandleCrash()
websocket.Server{Handshake: r.handshake, Handler: r.handle}.ServeHTTP(w, req)
}()
return <-r.err
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Copy",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"go",
"func",
"(",
")",
"{",
"defer",
"util",
".",
"HandleCrash",
"(",
")",
"\n",
"websocket",
".",
... | // Copy the reader to the response. The created WebSocket is closed after this
// method completes. | [
"Copy",
"the",
"reader",
"to",
"the",
"response",
".",
"The",
"created",
"WebSocket",
"is",
"closed",
"after",
"this",
"method",
"completes",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wsstream/stream.go#L72-L78 |
165,285 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | flush | func flush(emitter *yaml_emitter_t) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) {
return yaml_emitter_flush(emitter)
}
return true
} | go | func flush(emitter *yaml_emitter_t) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) {
return yaml_emitter_flush(emitter)
}
return true
} | [
"func",
"flush",
"(",
"emitter",
"*",
"yaml_emitter_t",
")",
"bool",
"{",
"if",
"emitter",
".",
"buffer_pos",
"+",
"5",
">=",
"len",
"(",
"emitter",
".",
"buffer",
")",
"{",
"return",
"yaml_emitter_flush",
"(",
"emitter",
")",
"\n",
"}",
"\n",
"return",
... | // Flush the buffer if needed. | [
"Flush",
"the",
"buffer",
"if",
"needed",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L8-L13 |
165,286 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | put | func put(emitter *yaml_emitter_t, value byte) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
emitter.buffer[emitter.buffer_pos] = value
emitter.buffer_pos++
emitter.column++
return true
} | go | func put(emitter *yaml_emitter_t, value byte) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
emitter.buffer[emitter.buffer_pos] = value
emitter.buffer_pos++
emitter.column++
return true
} | [
"func",
"put",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"value",
"byte",
")",
"bool",
"{",
"if",
"emitter",
".",
"buffer_pos",
"+",
"5",
">=",
"len",
"(",
"emitter",
".",
"buffer",
")",
"&&",
"!",
"yaml_emitter_flush",
"(",
"emitter",
")",
"{",
"ret... | // Put a character to the output buffer. | [
"Put",
"a",
"character",
"to",
"the",
"output",
"buffer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L16-L24 |
165,287 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | put_break | func put_break(emitter *yaml_emitter_t) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
switch emitter.line_break {
case yaml_CR_BREAK:
emitter.buffer[emitter.buffer_pos] = '\r'
emitter.buffer_pos += 1
case yaml_LN_BREAK:
emitter.buffer[emitter.buffer_pos] = '\n'
emitter.buffer_pos += 1
case yaml_CRLN_BREAK:
emitter.buffer[emitter.buffer_pos+0] = '\r'
emitter.buffer[emitter.buffer_pos+1] = '\n'
emitter.buffer_pos += 2
default:
panic("unknown line break setting")
}
emitter.column = 0
emitter.line++
return true
} | go | func put_break(emitter *yaml_emitter_t) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
switch emitter.line_break {
case yaml_CR_BREAK:
emitter.buffer[emitter.buffer_pos] = '\r'
emitter.buffer_pos += 1
case yaml_LN_BREAK:
emitter.buffer[emitter.buffer_pos] = '\n'
emitter.buffer_pos += 1
case yaml_CRLN_BREAK:
emitter.buffer[emitter.buffer_pos+0] = '\r'
emitter.buffer[emitter.buffer_pos+1] = '\n'
emitter.buffer_pos += 2
default:
panic("unknown line break setting")
}
emitter.column = 0
emitter.line++
return true
} | [
"func",
"put_break",
"(",
"emitter",
"*",
"yaml_emitter_t",
")",
"bool",
"{",
"if",
"emitter",
".",
"buffer_pos",
"+",
"5",
">=",
"len",
"(",
"emitter",
".",
"buffer",
")",
"&&",
"!",
"yaml_emitter_flush",
"(",
"emitter",
")",
"{",
"return",
"false",
"\n... | // Put a line break to the output buffer. | [
"Put",
"a",
"line",
"break",
"to",
"the",
"output",
"buffer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L27-L48 |
165,288 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | write | func write(emitter *yaml_emitter_t, s []byte, i *int) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
p := emitter.buffer_pos
w := width(s[*i])
switch w {
case 4:
emitter.buffer[p+3] = s[*i+3]
fallthrough
case 3:
emitter.buffer[p+2] = s[*i+2]
fallthrough
case 2:
emitter.buffer[p+1] = s[*i+1]
fallthrough
case 1:
emitter.buffer[p+0] = s[*i+0]
default:
panic("unknown character width")
}
emitter.column++
emitter.buffer_pos += w
*i += w
return true
} | go | func write(emitter *yaml_emitter_t, s []byte, i *int) bool {
if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) {
return false
}
p := emitter.buffer_pos
w := width(s[*i])
switch w {
case 4:
emitter.buffer[p+3] = s[*i+3]
fallthrough
case 3:
emitter.buffer[p+2] = s[*i+2]
fallthrough
case 2:
emitter.buffer[p+1] = s[*i+1]
fallthrough
case 1:
emitter.buffer[p+0] = s[*i+0]
default:
panic("unknown character width")
}
emitter.column++
emitter.buffer_pos += w
*i += w
return true
} | [
"func",
"write",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"s",
"[",
"]",
"byte",
",",
"i",
"*",
"int",
")",
"bool",
"{",
"if",
"emitter",
".",
"buffer_pos",
"+",
"5",
">=",
"len",
"(",
"emitter",
".",
"buffer",
")",
"&&",
"!",
"yaml_emitter_flush"... | // Copy a character from a string into buffer. | [
"Copy",
"a",
"character",
"from",
"a",
"string",
"into",
"buffer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L51-L76 |
165,289 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | write_all | func write_all(emitter *yaml_emitter_t, s []byte) bool {
for i := 0; i < len(s); {
if !write(emitter, s, &i) {
return false
}
}
return true
} | go | func write_all(emitter *yaml_emitter_t, s []byte) bool {
for i := 0; i < len(s); {
if !write(emitter, s, &i) {
return false
}
}
return true
} | [
"func",
"write_all",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"s",
"[",
"]",
"byte",
")",
"bool",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"{",
"if",
"!",
"write",
"(",
"emitter",
",",
"s",
",",
"&",
"i",
")",
... | // Write a whole string into buffer. | [
"Write",
"a",
"whole",
"string",
"into",
"buffer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L79-L86 |
165,290 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | write_break | func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool {
if s[*i] == '\n' {
if !put_break(emitter) {
return false
}
*i++
} else {
if !write(emitter, s, i) {
return false
}
emitter.column = 0
emitter.line++
}
return true
} | go | func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool {
if s[*i] == '\n' {
if !put_break(emitter) {
return false
}
*i++
} else {
if !write(emitter, s, i) {
return false
}
emitter.column = 0
emitter.line++
}
return true
} | [
"func",
"write_break",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"s",
"[",
"]",
"byte",
",",
"i",
"*",
"int",
")",
"bool",
"{",
"if",
"s",
"[",
"*",
"i",
"]",
"==",
"'\\n'",
"{",
"if",
"!",
"put_break",
"(",
"emitter",
")",
"{",
"return",
"fals... | // Copy a line break character from a string into buffer. | [
"Copy",
"a",
"line",
"break",
"character",
"from",
"a",
"string",
"into",
"buffer",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L89-L103 |
165,291 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_set_emitter_error | func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool {
emitter.error = yaml_EMITTER_ERROR
emitter.problem = problem
return false
} | go | func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool {
emitter.error = yaml_EMITTER_ERROR
emitter.problem = problem
return false
} | [
"func",
"yaml_emitter_set_emitter_error",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"problem",
"string",
")",
"bool",
"{",
"emitter",
".",
"error",
"=",
"yaml_EMITTER_ERROR",
"\n",
"emitter",
".",
"problem",
"=",
"problem",
"\n",
"return",
"false",
"\n",
"}"
] | // Set an emitter error and return false. | [
"Set",
"an",
"emitter",
"error",
"and",
"return",
"false",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L106-L110 |
165,292 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_emit | func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {
emitter.events = append(emitter.events, *event)
for !yaml_emitter_need_more_events(emitter) {
event := &emitter.events[emitter.events_head]
if !yaml_emitter_analyze_event(emitter, event) {
return false
}
if !yaml_emitter_state_machine(emitter, event) {
return false
}
yaml_event_delete(event)
emitter.events_head++
}
return true
} | go | func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool {
emitter.events = append(emitter.events, *event)
for !yaml_emitter_need_more_events(emitter) {
event := &emitter.events[emitter.events_head]
if !yaml_emitter_analyze_event(emitter, event) {
return false
}
if !yaml_emitter_state_machine(emitter, event) {
return false
}
yaml_event_delete(event)
emitter.events_head++
}
return true
} | [
"func",
"yaml_emitter_emit",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"event",
"*",
"yaml_event_t",
")",
"bool",
"{",
"emitter",
".",
"events",
"=",
"append",
"(",
"emitter",
".",
"events",
",",
"*",
"event",
")",
"\n",
"for",
"!",
"yaml_emitter_need_more... | // Emit an event. | [
"Emit",
"an",
"event",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L113-L127 |
165,293 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_need_more_events | func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
if emitter.events_head == len(emitter.events) {
return true
}
var accumulate int
switch emitter.events[emitter.events_head].typ {
case yaml_DOCUMENT_START_EVENT:
accumulate = 1
break
case yaml_SEQUENCE_START_EVENT:
accumulate = 2
break
case yaml_MAPPING_START_EVENT:
accumulate = 3
break
default:
return false
}
if len(emitter.events)-emitter.events_head > accumulate {
return false
}
var level int
for i := emitter.events_head; i < len(emitter.events); i++ {
switch emitter.events[i].typ {
case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:
level++
case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:
level--
}
if level == 0 {
return false
}
}
return true
} | go | func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
if emitter.events_head == len(emitter.events) {
return true
}
var accumulate int
switch emitter.events[emitter.events_head].typ {
case yaml_DOCUMENT_START_EVENT:
accumulate = 1
break
case yaml_SEQUENCE_START_EVENT:
accumulate = 2
break
case yaml_MAPPING_START_EVENT:
accumulate = 3
break
default:
return false
}
if len(emitter.events)-emitter.events_head > accumulate {
return false
}
var level int
for i := emitter.events_head; i < len(emitter.events); i++ {
switch emitter.events[i].typ {
case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:
level++
case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:
level--
}
if level == 0 {
return false
}
}
return true
} | [
"func",
"yaml_emitter_need_more_events",
"(",
"emitter",
"*",
"yaml_emitter_t",
")",
"bool",
"{",
"if",
"emitter",
".",
"events_head",
"==",
"len",
"(",
"emitter",
".",
"events",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"var",
"accumulate",
"int",
"\n",
... | // Check if we need to accumulate more events before emitting.
//
// We accumulate extra
// - 1 event for DOCUMENT-START
// - 2 events for SEQUENCE-START
// - 3 events for MAPPING-START
// | [
"Check",
"if",
"we",
"need",
"to",
"accumulate",
"more",
"events",
"before",
"emitting",
".",
"We",
"accumulate",
"extra",
"-",
"1",
"event",
"for",
"DOCUMENT",
"-",
"START",
"-",
"2",
"events",
"for",
"SEQUENCE",
"-",
"START",
"-",
"3",
"events",
"for",... | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L136-L170 |
165,294 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_append_tag_directive | func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {
for i := 0; i < len(emitter.tag_directives); i++ {
if bytes.Equal(value.handle, emitter.tag_directives[i].handle) {
if allow_duplicates {
return true
}
return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive")
}
}
// [Go] Do we actually need to copy this given garbage collection
// and the lack of deallocating destructors?
tag_copy := yaml_tag_directive_t{
handle: make([]byte, len(value.handle)),
prefix: make([]byte, len(value.prefix)),
}
copy(tag_copy.handle, value.handle)
copy(tag_copy.prefix, value.prefix)
emitter.tag_directives = append(emitter.tag_directives, tag_copy)
return true
} | go | func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {
for i := 0; i < len(emitter.tag_directives); i++ {
if bytes.Equal(value.handle, emitter.tag_directives[i].handle) {
if allow_duplicates {
return true
}
return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive")
}
}
// [Go] Do we actually need to copy this given garbage collection
// and the lack of deallocating destructors?
tag_copy := yaml_tag_directive_t{
handle: make([]byte, len(value.handle)),
prefix: make([]byte, len(value.prefix)),
}
copy(tag_copy.handle, value.handle)
copy(tag_copy.prefix, value.prefix)
emitter.tag_directives = append(emitter.tag_directives, tag_copy)
return true
} | [
"func",
"yaml_emitter_append_tag_directive",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"value",
"*",
"yaml_tag_directive_t",
",",
"allow_duplicates",
"bool",
")",
"bool",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"emitter",
".",
"tag_directives",
... | // Append a directive to the directives stack. | [
"Append",
"a",
"directive",
"to",
"the",
"directives",
"stack",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L173-L193 |
165,295 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_increase_indent | func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool {
emitter.indents = append(emitter.indents, emitter.indent)
if emitter.indent < 0 {
if flow {
emitter.indent = emitter.best_indent
} else {
emitter.indent = 0
}
} else if !indentless {
emitter.indent += emitter.best_indent
}
return true
} | go | func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool {
emitter.indents = append(emitter.indents, emitter.indent)
if emitter.indent < 0 {
if flow {
emitter.indent = emitter.best_indent
} else {
emitter.indent = 0
}
} else if !indentless {
emitter.indent += emitter.best_indent
}
return true
} | [
"func",
"yaml_emitter_increase_indent",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"flow",
",",
"indentless",
"bool",
")",
"bool",
"{",
"emitter",
".",
"indents",
"=",
"append",
"(",
"emitter",
".",
"indents",
",",
"emitter",
".",
"indent",
")",
"\n",
"if",... | // Increase the indentation level. | [
"Increase",
"the",
"indentation",
"level",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L196-L208 |
165,296 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_emit_stream_start | func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if event.typ != yaml_STREAM_START_EVENT {
return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START")
}
if emitter.encoding == yaml_ANY_ENCODING {
emitter.encoding = event.encoding
if emitter.encoding == yaml_ANY_ENCODING {
emitter.encoding = yaml_UTF8_ENCODING
}
}
if emitter.best_indent < 2 || emitter.best_indent > 9 {
emitter.best_indent = 2
}
if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {
emitter.best_width = 80
}
if emitter.best_width < 0 {
emitter.best_width = 1<<31 - 1
}
if emitter.line_break == yaml_ANY_BREAK {
emitter.line_break = yaml_LN_BREAK
}
emitter.indent = -1
emitter.line = 0
emitter.column = 0
emitter.whitespace = true
emitter.indention = true
if emitter.encoding != yaml_UTF8_ENCODING {
if !yaml_emitter_write_bom(emitter) {
return false
}
}
emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE
return true
} | go | func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if event.typ != yaml_STREAM_START_EVENT {
return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START")
}
if emitter.encoding == yaml_ANY_ENCODING {
emitter.encoding = event.encoding
if emitter.encoding == yaml_ANY_ENCODING {
emitter.encoding = yaml_UTF8_ENCODING
}
}
if emitter.best_indent < 2 || emitter.best_indent > 9 {
emitter.best_indent = 2
}
if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {
emitter.best_width = 80
}
if emitter.best_width < 0 {
emitter.best_width = 1<<31 - 1
}
if emitter.line_break == yaml_ANY_BREAK {
emitter.line_break = yaml_LN_BREAK
}
emitter.indent = -1
emitter.line = 0
emitter.column = 0
emitter.whitespace = true
emitter.indention = true
if emitter.encoding != yaml_UTF8_ENCODING {
if !yaml_emitter_write_bom(emitter) {
return false
}
}
emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE
return true
} | [
"func",
"yaml_emitter_emit_stream_start",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"event",
"*",
"yaml_event_t",
")",
"bool",
"{",
"if",
"event",
".",
"typ",
"!=",
"yaml_STREAM_START_EVENT",
"{",
"return",
"yaml_emitter_set_emitter_error",
"(",
"emitter",
",",
"\... | // Expect STREAM-START. | [
"Expect",
"STREAM",
"-",
"START",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L272-L308 |
165,297 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_emit_document_content | func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {
emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)
return yaml_emitter_emit_node(emitter, event, true, false, false, false)
} | go | func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool {
emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE)
return yaml_emitter_emit_node(emitter, event, true, false, false, false)
} | [
"func",
"yaml_emitter_emit_document_content",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"event",
"*",
"yaml_event_t",
")",
"bool",
"{",
"emitter",
".",
"states",
"=",
"append",
"(",
"emitter",
".",
"states",
",",
"yaml_EMIT_DOCUMENT_END_STATE",
")",
"\n",
"retur... | // Expect the root node. | [
"Expect",
"the",
"root",
"node",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L425-L428 |
165,298 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_emit_document_end | func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if event.typ != yaml_DOCUMENT_END_EVENT {
return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END")
}
if !yaml_emitter_write_indent(emitter) {
return false
}
if !event.implicit {
// [Go] Allocate the slice elsewhere.
if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
return false
}
if !yaml_emitter_write_indent(emitter) {
return false
}
}
if !yaml_emitter_flush(emitter) {
return false
}
emitter.state = yaml_EMIT_DOCUMENT_START_STATE
emitter.tag_directives = emitter.tag_directives[:0]
return true
} | go | func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool {
if event.typ != yaml_DOCUMENT_END_EVENT {
return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END")
}
if !yaml_emitter_write_indent(emitter) {
return false
}
if !event.implicit {
// [Go] Allocate the slice elsewhere.
if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) {
return false
}
if !yaml_emitter_write_indent(emitter) {
return false
}
}
if !yaml_emitter_flush(emitter) {
return false
}
emitter.state = yaml_EMIT_DOCUMENT_START_STATE
emitter.tag_directives = emitter.tag_directives[:0]
return true
} | [
"func",
"yaml_emitter_emit_document_end",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"event",
"*",
"yaml_event_t",
")",
"bool",
"{",
"if",
"event",
".",
"typ",
"!=",
"yaml_DOCUMENT_END_EVENT",
"{",
"return",
"yaml_emitter_set_emitter_error",
"(",
"emitter",
",",
"\... | // Expect DOCUMENT-END. | [
"Expect",
"DOCUMENT",
"-",
"END",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L431-L453 |
165,299 | kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go | yaml_emitter_emit_flow_sequence_item | func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
if first {
if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) {
return false
}
if !yaml_emitter_increase_indent(emitter, true, false) {
return false
}
emitter.flow_level++
}
if event.typ == yaml_SEQUENCE_END_EVENT {
emitter.flow_level--
emitter.indent = emitter.indents[len(emitter.indents)-1]
emitter.indents = emitter.indents[:len(emitter.indents)-1]
if emitter.canonical && !first {
if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
return false
}
if !yaml_emitter_write_indent(emitter) {
return false
}
}
if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {
return false
}
emitter.state = emitter.states[len(emitter.states)-1]
emitter.states = emitter.states[:len(emitter.states)-1]
return true
}
if !first {
if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
return false
}
}
if emitter.canonical || emitter.column > emitter.best_width {
if !yaml_emitter_write_indent(emitter) {
return false
}
}
emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)
return yaml_emitter_emit_node(emitter, event, false, true, false, false)
} | go | func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
if first {
if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) {
return false
}
if !yaml_emitter_increase_indent(emitter, true, false) {
return false
}
emitter.flow_level++
}
if event.typ == yaml_SEQUENCE_END_EVENT {
emitter.flow_level--
emitter.indent = emitter.indents[len(emitter.indents)-1]
emitter.indents = emitter.indents[:len(emitter.indents)-1]
if emitter.canonical && !first {
if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
return false
}
if !yaml_emitter_write_indent(emitter) {
return false
}
}
if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) {
return false
}
emitter.state = emitter.states[len(emitter.states)-1]
emitter.states = emitter.states[:len(emitter.states)-1]
return true
}
if !first {
if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
return false
}
}
if emitter.canonical || emitter.column > emitter.best_width {
if !yaml_emitter_write_indent(emitter) {
return false
}
}
emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE)
return yaml_emitter_emit_node(emitter, event, false, true, false, false)
} | [
"func",
"yaml_emitter_emit_flow_sequence_item",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"event",
"*",
"yaml_event_t",
",",
"first",
"bool",
")",
"bool",
"{",
"if",
"first",
"{",
"if",
"!",
"yaml_emitter_write_indicator",
"(",
"emitter",
",",
"[",
"]",
"byte"... | // Expect a flow item node. | [
"Expect",
"a",
"flow",
"item",
"node",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/emitterc.go#L456-L501 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.