repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
RemoveAll
func (r *keyring) RemoveAll() error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.keys = nil return nil }
go
func (r *keyring) RemoveAll() error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.keys = nil return nil }
[ "func", "(", "r", "*", "keyring", ")", "RemoveAll", "(", ")", "error", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "errLocked", "\n", "}", "\n\n", "r", ".", "keys", "=", "nil", "\n", "return", "nil", "\n", "}" ]
// RemoveAll removes all identities.
[ "RemoveAll", "removes", "all", "identities", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L40-L49
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Remove
func (r *keyring) Remove(key ssh.PublicKey) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } want := key.Marshal() found := false for i := 0; i < len(r.keys); { if bytes.Equal(r.keys[i].signer.PublicKey().Marshal(), want) { found = true r.keys[i] = r.keys[len(r.keys)-1] r.keys = r.keys[len(r.keys)-1:] continue } else { i++ } } if !found { return errors.New("agent: key not found") } return nil }
go
func (r *keyring) Remove(key ssh.PublicKey) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } want := key.Marshal() found := false for i := 0; i < len(r.keys); { if bytes.Equal(r.keys[i].signer.PublicKey().Marshal(), want) { found = true r.keys[i] = r.keys[len(r.keys)-1] r.keys = r.keys[len(r.keys)-1:] continue } else { i++ } } if !found { return errors.New("agent: key not found") } return nil }
[ "func", "(", "r", "*", "keyring", ")", "Remove", "(", "key", "ssh", ".", "PublicKey", ")", "error", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "errLocked", "\n", "}", "\n\n", "want", ":=", "key", ".", "Marshal", "(", ")", "\n", "found", ":=", "false", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "r", ".", "keys", ")", ";", "{", "if", "bytes", ".", "Equal", "(", "r", ".", "keys", "[", "i", "]", ".", "signer", ".", "PublicKey", "(", ")", ".", "Marshal", "(", ")", ",", "want", ")", "{", "found", "=", "true", "\n", "r", ".", "keys", "[", "i", "]", "=", "r", ".", "keys", "[", "len", "(", "r", ".", "keys", ")", "-", "1", "]", "\n", "r", ".", "keys", "=", "r", ".", "keys", "[", "len", "(", "r", ".", "keys", ")", "-", "1", ":", "]", "\n", "continue", "\n", "}", "else", "{", "i", "++", "\n", "}", "\n", "}", "\n\n", "if", "!", "found", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Remove removes all identities with the given public key.
[ "Remove", "removes", "all", "identities", "with", "the", "given", "public", "key", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L52-L76
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Lock
func (r *keyring) Lock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.locked = true r.passphrase = passphrase return nil }
go
func (r *keyring) Lock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.locked = true r.passphrase = passphrase return nil }
[ "func", "(", "r", "*", "keyring", ")", "Lock", "(", "passphrase", "[", "]", "byte", ")", "error", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "errLocked", "\n", "}", "\n\n", "r", ".", "locked", "=", "true", "\n", "r", ".", "passphrase", "=", "passphrase", "\n", "return", "nil", "\n", "}" ]
// Lock locks the agent. Sign and Remove will fail, and List will empty an empty list.
[ "Lock", "locks", "the", "agent", ".", "Sign", "and", "Remove", "will", "fail", "and", "List", "will", "empty", "an", "empty", "list", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L79-L89
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Unlock
func (r *keyring) Unlock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if !r.locked { return errors.New("agent: not locked") } if len(passphrase) != len(r.passphrase) || 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) { return fmt.Errorf("agent: incorrect passphrase") } r.locked = false r.passphrase = nil return nil }
go
func (r *keyring) Unlock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if !r.locked { return errors.New("agent: not locked") } if len(passphrase) != len(r.passphrase) || 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) { return fmt.Errorf("agent: incorrect passphrase") } r.locked = false r.passphrase = nil return nil }
[ "func", "(", "r", "*", "keyring", ")", "Unlock", "(", "passphrase", "[", "]", "byte", ")", "error", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "!", "r", ".", "locked", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "passphrase", ")", "!=", "len", "(", "r", ".", "passphrase", ")", "||", "1", "!=", "subtle", ".", "ConstantTimeCompare", "(", "passphrase", ",", "r", ".", "passphrase", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "r", ".", "locked", "=", "false", "\n", "r", ".", "passphrase", "=", "nil", "\n", "return", "nil", "\n", "}" ]
// Unlock undoes the effect of Lock
[ "Unlock", "undoes", "the", "effect", "of", "Lock" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L92-L105
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Add
func (r *keyring) Add(priv interface{}, cert *ssh.Certificate, comment string) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } signer, err := ssh.NewSignerFromKey(priv) if err != nil { return err } if cert != nil { signer, err = ssh.NewCertSigner(cert, signer) if err != nil { return err } } r.keys = append(r.keys, privKey{signer, comment}) return nil }
go
func (r *keyring) Add(priv interface{}, cert *ssh.Certificate, comment string) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } signer, err := ssh.NewSignerFromKey(priv) if err != nil { return err } if cert != nil { signer, err = ssh.NewCertSigner(cert, signer) if err != nil { return err } } r.keys = append(r.keys, privKey{signer, comment}) return nil }
[ "func", "(", "r", "*", "keyring", ")", "Add", "(", "priv", "interface", "{", "}", ",", "cert", "*", "ssh", ".", "Certificate", ",", "comment", "string", ")", "error", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "errLocked", "\n", "}", "\n", "signer", ",", "err", ":=", "ssh", ".", "NewSignerFromKey", "(", "priv", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "cert", "!=", "nil", "{", "signer", ",", "err", "=", "ssh", ".", "NewCertSigner", "(", "cert", ",", "signer", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "r", ".", "keys", "=", "append", "(", "r", ".", "keys", ",", "privKey", "{", "signer", ",", "comment", "}", ")", "\n\n", "return", "nil", "\n", "}" ]
// Insert adds a private key to the keyring. If a certificate // is given, that certificate is added as public key.
[ "Insert", "adds", "a", "private", "key", "to", "the", "keyring", ".", "If", "a", "certificate", "is", "given", "that", "certificate", "is", "added", "as", "public", "key", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L129-L151
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Sign
func (r *keyring) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } wanted := key.Marshal() for _, k := range r.keys { if bytes.Equal(k.signer.PublicKey().Marshal(), wanted) { return k.signer.Sign(rand.Reader, data) } } return nil, errors.New("not found") }
go
func (r *keyring) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } wanted := key.Marshal() for _, k := range r.keys { if bytes.Equal(k.signer.PublicKey().Marshal(), wanted) { return k.signer.Sign(rand.Reader, data) } } return nil, errors.New("not found") }
[ "func", "(", "r", "*", "keyring", ")", "Sign", "(", "key", "ssh", ".", "PublicKey", ",", "data", "[", "]", "byte", ")", "(", "*", "ssh", ".", "Signature", ",", "error", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "nil", ",", "errLocked", "\n", "}", "\n\n", "wanted", ":=", "key", ".", "Marshal", "(", ")", "\n", "for", "_", ",", "k", ":=", "range", "r", ".", "keys", "{", "if", "bytes", ".", "Equal", "(", "k", ".", "signer", ".", "PublicKey", "(", ")", ".", "Marshal", "(", ")", ",", "wanted", ")", "{", "return", "k", ".", "signer", ".", "Sign", "(", "rand", ".", "Reader", ",", "data", ")", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// Sign returns a signature for the data.
[ "Sign", "returns", "a", "signature", "for", "the", "data", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L154-L168
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go
Signers
func (r *keyring) Signers() ([]ssh.Signer, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } s := make([]ssh.Signer, 0, len(r.keys)) for _, k := range r.keys { s = append(s, k.signer) } return s, nil }
go
func (r *keyring) Signers() ([]ssh.Signer, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } s := make([]ssh.Signer, 0, len(r.keys)) for _, k := range r.keys { s = append(s, k.signer) } return s, nil }
[ "func", "(", "r", "*", "keyring", ")", "Signers", "(", ")", "(", "[", "]", "ssh", ".", "Signer", ",", "error", ")", "{", "r", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "r", ".", "locked", "{", "return", "nil", ",", "errLocked", "\n", "}", "\n\n", "s", ":=", "make", "(", "[", "]", "ssh", ".", "Signer", ",", "0", ",", "len", "(", "r", ".", "keys", ")", ")", "\n", "for", "_", ",", "k", ":=", "range", "r", ".", "keys", "{", "s", "=", "append", "(", "s", ",", "k", ".", "signer", ")", "\n", "}", "\n", "return", "s", ",", "nil", "\n", "}" ]
// Signers returns signers for all the known keys.
[ "Signers", "returns", "signers", "for", "all", "the", "known", "keys", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/keyring.go#L171-L183
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
Handler
func (h *HumanReadablePrinter) Handler(columns []string, printFunc interface{}) error { printFuncValue := reflect.ValueOf(printFunc) if err := h.validatePrintHandlerFunc(printFuncValue); err != nil { glog.Errorf("Unable to add print handler: %v", err) return err } objType := printFuncValue.Type().In(0) h.handlerMap[objType] = &handlerEntry{ columns: columns, printFunc: printFuncValue, } return nil }
go
func (h *HumanReadablePrinter) Handler(columns []string, printFunc interface{}) error { printFuncValue := reflect.ValueOf(printFunc) if err := h.validatePrintHandlerFunc(printFuncValue); err != nil { glog.Errorf("Unable to add print handler: %v", err) return err } objType := printFuncValue.Type().In(0) h.handlerMap[objType] = &handlerEntry{ columns: columns, printFunc: printFuncValue, } return nil }
[ "func", "(", "h", "*", "HumanReadablePrinter", ")", "Handler", "(", "columns", "[", "]", "string", ",", "printFunc", "interface", "{", "}", ")", "error", "{", "printFuncValue", ":=", "reflect", ".", "ValueOf", "(", "printFunc", ")", "\n", "if", "err", ":=", "h", ".", "validatePrintHandlerFunc", "(", "printFuncValue", ")", ";", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "objType", ":=", "printFuncValue", ".", "Type", "(", ")", ".", "In", "(", "0", ")", "\n", "h", ".", "handlerMap", "[", "objType", "]", "=", "&", "handlerEntry", "{", "columns", ":", "columns", ",", "printFunc", ":", "printFuncValue", ",", "}", "\n", "return", "nil", "\n", "}" ]
// Handler adds a print handler with a given set of columns to HumanReadablePrinter instance. // See validatePrintHandlerFunc for required method signature.
[ "Handler", "adds", "a", "print", "handler", "with", "a", "given", "set", "of", "columns", "to", "HumanReadablePrinter", "instance", ".", "See", "validatePrintHandlerFunc", "for", "required", "method", "signature", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L342-L354
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
addDefaultHandlers
func (h *HumanReadablePrinter) addDefaultHandlers() { h.Handler(podColumns, printPod) h.Handler(podColumns, printPodList) h.Handler(podTemplateColumns, printPodTemplate) h.Handler(podTemplateColumns, printPodTemplateList) h.Handler(replicationControllerColumns, printReplicationController) h.Handler(replicationControllerColumns, printReplicationControllerList) h.Handler(replicaSetColumns, printReplicaSet) h.Handler(replicaSetColumns, printReplicaSetList) h.Handler(daemonSetColumns, printDaemonSet) h.Handler(daemonSetColumns, printDaemonSetList) h.Handler(jobColumns, printJob) h.Handler(jobColumns, printJobList) h.Handler(serviceColumns, printService) h.Handler(serviceColumns, printServiceList) h.Handler(ingressColumns, printIngress) h.Handler(ingressColumns, printIngressList) h.Handler(endpointColumns, printEndpoints) h.Handler(endpointColumns, printEndpointsList) h.Handler(nodeColumns, printNode) h.Handler(nodeColumns, printNodeList) h.Handler(eventColumns, printEvent) h.Handler(eventColumns, printEventList) h.Handler(limitRangeColumns, printLimitRange) h.Handler(limitRangeColumns, printLimitRangeList) h.Handler(resourceQuotaColumns, printResourceQuota) h.Handler(resourceQuotaColumns, printResourceQuotaList) h.Handler(namespaceColumns, printNamespace) h.Handler(namespaceColumns, printNamespaceList) h.Handler(secretColumns, printSecret) h.Handler(secretColumns, printSecretList) h.Handler(serviceAccountColumns, printServiceAccount) h.Handler(serviceAccountColumns, printServiceAccountList) h.Handler(persistentVolumeClaimColumns, printPersistentVolumeClaim) h.Handler(persistentVolumeClaimColumns, printPersistentVolumeClaimList) h.Handler(persistentVolumeColumns, printPersistentVolume) h.Handler(persistentVolumeColumns, printPersistentVolumeList) h.Handler(componentStatusColumns, printComponentStatus) h.Handler(componentStatusColumns, printComponentStatusList) h.Handler(thirdPartyResourceColumns, printThirdPartyResource) h.Handler(thirdPartyResourceColumns, printThirdPartyResourceList) h.Handler(deploymentColumns, printDeployment) h.Handler(deploymentColumns, printDeploymentList) h.Handler(horizontalPodAutoscalerColumns, printHorizontalPodAutoscaler) h.Handler(horizontalPodAutoscalerColumns, printHorizontalPodAutoscalerList) h.Handler(configMapColumns, printConfigMap) h.Handler(configMapColumns, printConfigMapList) h.Handler(podSecurityPolicyColumns, printPodSecurityPolicy) h.Handler(podSecurityPolicyColumns, printPodSecurityPolicyList) }
go
func (h *HumanReadablePrinter) addDefaultHandlers() { h.Handler(podColumns, printPod) h.Handler(podColumns, printPodList) h.Handler(podTemplateColumns, printPodTemplate) h.Handler(podTemplateColumns, printPodTemplateList) h.Handler(replicationControllerColumns, printReplicationController) h.Handler(replicationControllerColumns, printReplicationControllerList) h.Handler(replicaSetColumns, printReplicaSet) h.Handler(replicaSetColumns, printReplicaSetList) h.Handler(daemonSetColumns, printDaemonSet) h.Handler(daemonSetColumns, printDaemonSetList) h.Handler(jobColumns, printJob) h.Handler(jobColumns, printJobList) h.Handler(serviceColumns, printService) h.Handler(serviceColumns, printServiceList) h.Handler(ingressColumns, printIngress) h.Handler(ingressColumns, printIngressList) h.Handler(endpointColumns, printEndpoints) h.Handler(endpointColumns, printEndpointsList) h.Handler(nodeColumns, printNode) h.Handler(nodeColumns, printNodeList) h.Handler(eventColumns, printEvent) h.Handler(eventColumns, printEventList) h.Handler(limitRangeColumns, printLimitRange) h.Handler(limitRangeColumns, printLimitRangeList) h.Handler(resourceQuotaColumns, printResourceQuota) h.Handler(resourceQuotaColumns, printResourceQuotaList) h.Handler(namespaceColumns, printNamespace) h.Handler(namespaceColumns, printNamespaceList) h.Handler(secretColumns, printSecret) h.Handler(secretColumns, printSecretList) h.Handler(serviceAccountColumns, printServiceAccount) h.Handler(serviceAccountColumns, printServiceAccountList) h.Handler(persistentVolumeClaimColumns, printPersistentVolumeClaim) h.Handler(persistentVolumeClaimColumns, printPersistentVolumeClaimList) h.Handler(persistentVolumeColumns, printPersistentVolume) h.Handler(persistentVolumeColumns, printPersistentVolumeList) h.Handler(componentStatusColumns, printComponentStatus) h.Handler(componentStatusColumns, printComponentStatusList) h.Handler(thirdPartyResourceColumns, printThirdPartyResource) h.Handler(thirdPartyResourceColumns, printThirdPartyResourceList) h.Handler(deploymentColumns, printDeployment) h.Handler(deploymentColumns, printDeploymentList) h.Handler(horizontalPodAutoscalerColumns, printHorizontalPodAutoscaler) h.Handler(horizontalPodAutoscalerColumns, printHorizontalPodAutoscalerList) h.Handler(configMapColumns, printConfigMap) h.Handler(configMapColumns, printConfigMapList) h.Handler(podSecurityPolicyColumns, printPodSecurityPolicy) h.Handler(podSecurityPolicyColumns, printPodSecurityPolicyList) }
[ "func", "(", "h", "*", "HumanReadablePrinter", ")", "addDefaultHandlers", "(", ")", "{", "h", ".", "Handler", "(", "podColumns", ",", "printPod", ")", "\n", "h", ".", "Handler", "(", "podColumns", ",", "printPodList", ")", "\n", "h", ".", "Handler", "(", "podTemplateColumns", ",", "printPodTemplate", ")", "\n", "h", ".", "Handler", "(", "podTemplateColumns", ",", "printPodTemplateList", ")", "\n", "h", ".", "Handler", "(", "replicationControllerColumns", ",", "printReplicationController", ")", "\n", "h", ".", "Handler", "(", "replicationControllerColumns", ",", "printReplicationControllerList", ")", "\n", "h", ".", "Handler", "(", "replicaSetColumns", ",", "printReplicaSet", ")", "\n", "h", ".", "Handler", "(", "replicaSetColumns", ",", "printReplicaSetList", ")", "\n", "h", ".", "Handler", "(", "daemonSetColumns", ",", "printDaemonSet", ")", "\n", "h", ".", "Handler", "(", "daemonSetColumns", ",", "printDaemonSetList", ")", "\n", "h", ".", "Handler", "(", "jobColumns", ",", "printJob", ")", "\n", "h", ".", "Handler", "(", "jobColumns", ",", "printJobList", ")", "\n", "h", ".", "Handler", "(", "serviceColumns", ",", "printService", ")", "\n", "h", ".", "Handler", "(", "serviceColumns", ",", "printServiceList", ")", "\n", "h", ".", "Handler", "(", "ingressColumns", ",", "printIngress", ")", "\n", "h", ".", "Handler", "(", "ingressColumns", ",", "printIngressList", ")", "\n", "h", ".", "Handler", "(", "endpointColumns", ",", "printEndpoints", ")", "\n", "h", ".", "Handler", "(", "endpointColumns", ",", "printEndpointsList", ")", "\n", "h", ".", "Handler", "(", "nodeColumns", ",", "printNode", ")", "\n", "h", ".", "Handler", "(", "nodeColumns", ",", "printNodeList", ")", "\n", "h", ".", "Handler", "(", "eventColumns", ",", "printEvent", ")", "\n", "h", ".", "Handler", "(", "eventColumns", ",", "printEventList", ")", "\n", "h", ".", "Handler", "(", "limitRangeColumns", ",", "printLimitRange", ")", "\n", "h", ".", "Handler", "(", "limitRangeColumns", ",", "printLimitRangeList", ")", "\n", "h", ".", "Handler", "(", "resourceQuotaColumns", ",", "printResourceQuota", ")", "\n", "h", ".", "Handler", "(", "resourceQuotaColumns", ",", "printResourceQuotaList", ")", "\n", "h", ".", "Handler", "(", "namespaceColumns", ",", "printNamespace", ")", "\n", "h", ".", "Handler", "(", "namespaceColumns", ",", "printNamespaceList", ")", "\n", "h", ".", "Handler", "(", "secretColumns", ",", "printSecret", ")", "\n", "h", ".", "Handler", "(", "secretColumns", ",", "printSecretList", ")", "\n", "h", ".", "Handler", "(", "serviceAccountColumns", ",", "printServiceAccount", ")", "\n", "h", ".", "Handler", "(", "serviceAccountColumns", ",", "printServiceAccountList", ")", "\n", "h", ".", "Handler", "(", "persistentVolumeClaimColumns", ",", "printPersistentVolumeClaim", ")", "\n", "h", ".", "Handler", "(", "persistentVolumeClaimColumns", ",", "printPersistentVolumeClaimList", ")", "\n", "h", ".", "Handler", "(", "persistentVolumeColumns", ",", "printPersistentVolume", ")", "\n", "h", ".", "Handler", "(", "persistentVolumeColumns", ",", "printPersistentVolumeList", ")", "\n", "h", ".", "Handler", "(", "componentStatusColumns", ",", "printComponentStatus", ")", "\n", "h", ".", "Handler", "(", "componentStatusColumns", ",", "printComponentStatusList", ")", "\n", "h", ".", "Handler", "(", "thirdPartyResourceColumns", ",", "printThirdPartyResource", ")", "\n", "h", ".", "Handler", "(", "thirdPartyResourceColumns", ",", "printThirdPartyResourceList", ")", "\n", "h", ".", "Handler", "(", "deploymentColumns", ",", "printDeployment", ")", "\n", "h", ".", "Handler", "(", "deploymentColumns", ",", "printDeploymentList", ")", "\n", "h", ".", "Handler", "(", "horizontalPodAutoscalerColumns", ",", "printHorizontalPodAutoscaler", ")", "\n", "h", ".", "Handler", "(", "horizontalPodAutoscalerColumns", ",", "printHorizontalPodAutoscalerList", ")", "\n", "h", ".", "Handler", "(", "configMapColumns", ",", "printConfigMap", ")", "\n", "h", ".", "Handler", "(", "configMapColumns", ",", "printConfigMapList", ")", "\n", "h", ".", "Handler", "(", "podSecurityPolicyColumns", ",", "printPodSecurityPolicy", ")", "\n", "h", ".", "Handler", "(", "podSecurityPolicyColumns", ",", "printPodSecurityPolicyList", ")", "\n", "}" ]
// addDefaultHandlers adds print handlers for default Kubernetes types.
[ "addDefaultHandlers", "adds", "print", "handlers", "for", "default", "Kubernetes", "types", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L424-L473
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
translateTimestamp
func translateTimestamp(timestamp unversioned.Time) string { if timestamp.IsZero() { return "<unknown>" } return shortHumanDuration(time.Now().Sub(timestamp.Time)) }
go
func translateTimestamp(timestamp unversioned.Time) string { if timestamp.IsZero() { return "<unknown>" } return shortHumanDuration(time.Now().Sub(timestamp.Time)) }
[ "func", "translateTimestamp", "(", "timestamp", "unversioned", ".", "Time", ")", "string", "{", "if", "timestamp", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "shortHumanDuration", "(", "time", ".", "Now", "(", ")", ".", "Sub", "(", "timestamp", ".", "Time", ")", ")", "\n", "}" ]
// translateTimestamp returns the elapsed time since timestamp in // human-readable approximation.
[ "translateTimestamp", "returns", "the", "elapsed", "time", "since", "timestamp", "in", "human", "-", "readable", "approximation", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L542-L547
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
loadBalancerStatusStringer
func loadBalancerStatusStringer(s api.LoadBalancerStatus) string { ingress := s.Ingress result := []string{} for i := range ingress { if ingress[i].IP != "" { result = append(result, ingress[i].IP) } } return strings.Join(result, ",") }
go
func loadBalancerStatusStringer(s api.LoadBalancerStatus) string { ingress := s.Ingress result := []string{} for i := range ingress { if ingress[i].IP != "" { result = append(result, ingress[i].IP) } } return strings.Join(result, ",") }
[ "func", "loadBalancerStatusStringer", "(", "s", "api", ".", "LoadBalancerStatus", ")", "string", "{", "ingress", ":=", "s", ".", "Ingress", "\n", "result", ":=", "[", "]", "string", "{", "}", "\n", "for", "i", ":=", "range", "ingress", "{", "if", "ingress", "[", "i", "]", ".", "IP", "!=", "\"", "\"", "{", "result", "=", "append", "(", "result", ",", "ingress", "[", "i", "]", ".", "IP", ")", "\n", "}", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "result", ",", "\"", "\"", ")", "\n", "}" ]
// loadBalancerStatusStringer behaves just like a string interface and converts the given status to a string.
[ "loadBalancerStatusStringer", "behaves", "just", "like", "a", "string", "interface", "and", "converts", "the", "given", "status", "to", "a", "string", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L882-L891
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
backendStringer
func backendStringer(backend *extensions.IngressBackend) string { if backend == nil { return "" } return fmt.Sprintf("%v:%v", backend.ServiceName, backend.ServicePort.String()) }
go
func backendStringer(backend *extensions.IngressBackend) string { if backend == nil { return "" } return fmt.Sprintf("%v:%v", backend.ServiceName, backend.ServicePort.String()) }
[ "func", "backendStringer", "(", "backend", "*", "extensions", ".", "IngressBackend", ")", "string", "{", "if", "backend", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "backend", ".", "ServiceName", ",", "backend", ".", "ServicePort", ".", "String", "(", ")", ")", "\n", "}" ]
// backendStringer behaves just like a string interface and converts the given backend to a string.
[ "backendStringer", "behaves", "just", "like", "a", "string", "interface", "and", "converts", "the", "given", "backend", "to", "a", "string", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L968-L973
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go
appendLabelTabs
func appendLabelTabs(columnLabels []string) string { var buffer bytes.Buffer for i := range columnLabels { // NB: This odd dance is to make the loop both compatible with go 1.3 and // pass `gofmt -s` _ = i buffer.WriteString("\t") } buffer.WriteString("\n") return buffer.String() }
go
func appendLabelTabs(columnLabels []string) string { var buffer bytes.Buffer for i := range columnLabels { // NB: This odd dance is to make the loop both compatible with go 1.3 and // pass `gofmt -s` _ = i buffer.WriteString("\t") } buffer.WriteString("\n") return buffer.String() }
[ "func", "appendLabelTabs", "(", "columnLabels", "[", "]", "string", ")", "string", "{", "var", "buffer", "bytes", ".", "Buffer", "\n\n", "for", "i", ":=", "range", "columnLabels", "{", "// NB: This odd dance is to make the loop both compatible with go 1.3 and", "// pass `gofmt -s`", "_", "=", "i", "\n", "buffer", ".", "WriteString", "(", "\"", "\\t", "\"", ")", "\n", "}", "\n", "buffer", ".", "WriteString", "(", "\"", "\\n", "\"", ")", "\n\n", "return", "buffer", ".", "String", "(", ")", "\n", "}" ]
// Append a set of tabs for each label column. We need this in the case where // we have extra lines so that the tabwriter will still line things up.
[ "Append", "a", "set", "of", "tabs", "for", "each", "label", "column", ".", "We", "need", "this", "in", "the", "case", "where", "we", "have", "extra", "lines", "so", "that", "the", "tabwriter", "will", "still", "line", "things", "up", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L1689-L1701
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetOldReplicaSets
func GetOldReplicaSets(deployment extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { return GetOldReplicaSetsFromLists(deployment, c, func(namespace string, options api.ListOptions) (*api.PodList, error) { return c.Core().Pods(namespace).List(options) }, func(namespace string, options api.ListOptions) ([]extensions.ReplicaSet, error) { rsList, err := c.Extensions().ReplicaSets(namespace).List(options) return rsList.Items, err }) }
go
func GetOldReplicaSets(deployment extensions.Deployment, c clientset.Interface) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { return GetOldReplicaSetsFromLists(deployment, c, func(namespace string, options api.ListOptions) (*api.PodList, error) { return c.Core().Pods(namespace).List(options) }, func(namespace string, options api.ListOptions) ([]extensions.ReplicaSet, error) { rsList, err := c.Extensions().ReplicaSets(namespace).List(options) return rsList.Items, err }) }
[ "func", "GetOldReplicaSets", "(", "deployment", "extensions", ".", "Deployment", ",", "c", "clientset", ".", "Interface", ")", "(", "[", "]", "*", "extensions", ".", "ReplicaSet", ",", "[", "]", "*", "extensions", ".", "ReplicaSet", ",", "error", ")", "{", "return", "GetOldReplicaSetsFromLists", "(", "deployment", ",", "c", ",", "func", "(", "namespace", "string", ",", "options", "api", ".", "ListOptions", ")", "(", "*", "api", ".", "PodList", ",", "error", ")", "{", "return", "c", ".", "Core", "(", ")", ".", "Pods", "(", "namespace", ")", ".", "List", "(", "options", ")", "\n", "}", ",", "func", "(", "namespace", "string", ",", "options", "api", ".", "ListOptions", ")", "(", "[", "]", "extensions", ".", "ReplicaSet", ",", "error", ")", "{", "rsList", ",", "err", ":=", "c", ".", "Extensions", "(", ")", ".", "ReplicaSets", "(", "namespace", ")", ".", "List", "(", "options", ")", "\n", "return", "rsList", ".", "Items", ",", "err", "\n", "}", ")", "\n", "}" ]
// GetOldReplicaSets returns the old replica sets targeted by the given Deployment; get PodList and ReplicaSetList from client interface. // Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.
[ "GetOldReplicaSets", "returns", "the", "old", "replica", "sets", "targeted", "by", "the", "given", "Deployment", ";", "get", "PodList", "and", "ReplicaSetList", "from", "client", "interface", ".", "Note", "that", "the", "first", "set", "of", "old", "replica", "sets", "doesn", "t", "include", "the", "ones", "with", "no", "pods", "and", "the", "second", "set", "of", "old", "replica", "sets", "include", "all", "old", "replica", "sets", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L47-L56
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetOldReplicaSetsFromLists
func GetOldReplicaSetsFromLists(deployment extensions.Deployment, c clientset.Interface, getPodList func(string, api.ListOptions) (*api.PodList, error), getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { return nil, nil, fmt.Errorf("invalid label selector: %v", err) } // 1. Find all pods whose labels match deployment.Spec.Selector options := api.ListOptions{LabelSelector: selector} podList, err := getPodList(namespace, options) if err != nil { return nil, nil, fmt.Errorf("error listing pods: %v", err) } // 2. Find the corresponding replica sets for pods in podList. // TODO: Right now we list all replica sets and then filter. We should add an API for this. oldRSs := map[string]extensions.ReplicaSet{} allOldRSs := map[string]extensions.ReplicaSet{} rsList, err := getRSList(namespace, options) if err != nil { return nil, nil, fmt.Errorf("error listing replica sets: %v", err) } newRSTemplate := GetNewReplicaSetTemplate(deployment) for _, pod := range podList.Items { podLabelsSelector := labels.Set(pod.ObjectMeta.Labels) for _, rs := range rsList { rsLabelsSelector, err := unversioned.LabelSelectorAsSelector(rs.Spec.Selector) if err != nil { return nil, nil, fmt.Errorf("invalid label selector: %v", err) } // Filter out replica set that has the same pod template spec as the deployment - that is the new replica set. if api.Semantic.DeepEqual(rs.Spec.Template, &newRSTemplate) { continue } allOldRSs[rs.ObjectMeta.Name] = rs if rsLabelsSelector.Matches(podLabelsSelector) { oldRSs[rs.ObjectMeta.Name] = rs } } } requiredRSs := []*extensions.ReplicaSet{} for key := range oldRSs { value := oldRSs[key] requiredRSs = append(requiredRSs, &value) } allRSs := []*extensions.ReplicaSet{} for key := range allOldRSs { value := allOldRSs[key] allRSs = append(allRSs, &value) } return requiredRSs, allRSs, nil }
go
func GetOldReplicaSetsFromLists(deployment extensions.Deployment, c clientset.Interface, getPodList func(string, api.ListOptions) (*api.PodList, error), getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) ([]*extensions.ReplicaSet, []*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { return nil, nil, fmt.Errorf("invalid label selector: %v", err) } // 1. Find all pods whose labels match deployment.Spec.Selector options := api.ListOptions{LabelSelector: selector} podList, err := getPodList(namespace, options) if err != nil { return nil, nil, fmt.Errorf("error listing pods: %v", err) } // 2. Find the corresponding replica sets for pods in podList. // TODO: Right now we list all replica sets and then filter. We should add an API for this. oldRSs := map[string]extensions.ReplicaSet{} allOldRSs := map[string]extensions.ReplicaSet{} rsList, err := getRSList(namespace, options) if err != nil { return nil, nil, fmt.Errorf("error listing replica sets: %v", err) } newRSTemplate := GetNewReplicaSetTemplate(deployment) for _, pod := range podList.Items { podLabelsSelector := labels.Set(pod.ObjectMeta.Labels) for _, rs := range rsList { rsLabelsSelector, err := unversioned.LabelSelectorAsSelector(rs.Spec.Selector) if err != nil { return nil, nil, fmt.Errorf("invalid label selector: %v", err) } // Filter out replica set that has the same pod template spec as the deployment - that is the new replica set. if api.Semantic.DeepEqual(rs.Spec.Template, &newRSTemplate) { continue } allOldRSs[rs.ObjectMeta.Name] = rs if rsLabelsSelector.Matches(podLabelsSelector) { oldRSs[rs.ObjectMeta.Name] = rs } } } requiredRSs := []*extensions.ReplicaSet{} for key := range oldRSs { value := oldRSs[key] requiredRSs = append(requiredRSs, &value) } allRSs := []*extensions.ReplicaSet{} for key := range allOldRSs { value := allOldRSs[key] allRSs = append(allRSs, &value) } return requiredRSs, allRSs, nil }
[ "func", "GetOldReplicaSetsFromLists", "(", "deployment", "extensions", ".", "Deployment", ",", "c", "clientset", ".", "Interface", ",", "getPodList", "func", "(", "string", ",", "api", ".", "ListOptions", ")", "(", "*", "api", ".", "PodList", ",", "error", ")", ",", "getRSList", "func", "(", "string", ",", "api", ".", "ListOptions", ")", "(", "[", "]", "extensions", ".", "ReplicaSet", ",", "error", ")", ")", "(", "[", "]", "*", "extensions", ".", "ReplicaSet", ",", "[", "]", "*", "extensions", ".", "ReplicaSet", ",", "error", ")", "{", "namespace", ":=", "deployment", ".", "ObjectMeta", ".", "Namespace", "\n", "selector", ",", "err", ":=", "unversioned", ".", "LabelSelectorAsSelector", "(", "deployment", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "// 1. Find all pods whose labels match deployment.Spec.Selector", "options", ":=", "api", ".", "ListOptions", "{", "LabelSelector", ":", "selector", "}", "\n", "podList", ",", "err", ":=", "getPodList", "(", "namespace", ",", "options", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// 2. Find the corresponding replica sets for pods in podList.", "// TODO: Right now we list all replica sets and then filter. We should add an API for this.", "oldRSs", ":=", "map", "[", "string", "]", "extensions", ".", "ReplicaSet", "{", "}", "\n", "allOldRSs", ":=", "map", "[", "string", "]", "extensions", ".", "ReplicaSet", "{", "}", "\n", "rsList", ",", "err", ":=", "getRSList", "(", "namespace", ",", "options", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "newRSTemplate", ":=", "GetNewReplicaSetTemplate", "(", "deployment", ")", "\n", "for", "_", ",", "pod", ":=", "range", "podList", ".", "Items", "{", "podLabelsSelector", ":=", "labels", ".", "Set", "(", "pod", ".", "ObjectMeta", ".", "Labels", ")", "\n", "for", "_", ",", "rs", ":=", "range", "rsList", "{", "rsLabelsSelector", ",", "err", ":=", "unversioned", ".", "LabelSelectorAsSelector", "(", "rs", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "// Filter out replica set that has the same pod template spec as the deployment - that is the new replica set.", "if", "api", ".", "Semantic", ".", "DeepEqual", "(", "rs", ".", "Spec", ".", "Template", ",", "&", "newRSTemplate", ")", "{", "continue", "\n", "}", "\n", "allOldRSs", "[", "rs", ".", "ObjectMeta", ".", "Name", "]", "=", "rs", "\n", "if", "rsLabelsSelector", ".", "Matches", "(", "podLabelsSelector", ")", "{", "oldRSs", "[", "rs", ".", "ObjectMeta", ".", "Name", "]", "=", "rs", "\n", "}", "\n", "}", "\n", "}", "\n", "requiredRSs", ":=", "[", "]", "*", "extensions", ".", "ReplicaSet", "{", "}", "\n", "for", "key", ":=", "range", "oldRSs", "{", "value", ":=", "oldRSs", "[", "key", "]", "\n", "requiredRSs", "=", "append", "(", "requiredRSs", ",", "&", "value", ")", "\n", "}", "\n", "allRSs", ":=", "[", "]", "*", "extensions", ".", "ReplicaSet", "{", "}", "\n", "for", "key", ":=", "range", "allOldRSs", "{", "value", ":=", "allOldRSs", "[", "key", "]", "\n", "allRSs", "=", "append", "(", "allRSs", ",", "&", "value", ")", "\n", "}", "\n", "return", "requiredRSs", ",", "allRSs", ",", "nil", "\n", "}" ]
// GetOldReplicaSetsFromLists returns two sets of old replica sets targeted by the given Deployment; get PodList and ReplicaSetList with input functions. // Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.
[ "GetOldReplicaSetsFromLists", "returns", "two", "sets", "of", "old", "replica", "sets", "targeted", "by", "the", "given", "Deployment", ";", "get", "PodList", "and", "ReplicaSetList", "with", "input", "functions", ".", "Note", "that", "the", "first", "set", "of", "old", "replica", "sets", "doesn", "t", "include", "the", "ones", "with", "no", "pods", "and", "the", "second", "set", "of", "old", "replica", "sets", "include", "all", "old", "replica", "sets", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L60-L110
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetNewReplicaSetFromList
func GetNewReplicaSetFromList(deployment extensions.Deployment, c clientset.Interface, getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) (*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { return nil, fmt.Errorf("invalid label selector: %v", err) } rsList, err := getRSList(namespace, api.ListOptions{LabelSelector: selector}) if err != nil { return nil, fmt.Errorf("error listing ReplicaSets: %v", err) } newRSTemplate := GetNewReplicaSetTemplate(deployment) for i := range rsList { if api.Semantic.DeepEqual(rsList[i].Spec.Template, &newRSTemplate) { // This is the new ReplicaSet. return &rsList[i], nil } } // new ReplicaSet does not exist. return nil, nil }
go
func GetNewReplicaSetFromList(deployment extensions.Deployment, c clientset.Interface, getRSList func(string, api.ListOptions) ([]extensions.ReplicaSet, error)) (*extensions.ReplicaSet, error) { namespace := deployment.ObjectMeta.Namespace selector, err := unversioned.LabelSelectorAsSelector(deployment.Spec.Selector) if err != nil { return nil, fmt.Errorf("invalid label selector: %v", err) } rsList, err := getRSList(namespace, api.ListOptions{LabelSelector: selector}) if err != nil { return nil, fmt.Errorf("error listing ReplicaSets: %v", err) } newRSTemplate := GetNewReplicaSetTemplate(deployment) for i := range rsList { if api.Semantic.DeepEqual(rsList[i].Spec.Template, &newRSTemplate) { // This is the new ReplicaSet. return &rsList[i], nil } } // new ReplicaSet does not exist. return nil, nil }
[ "func", "GetNewReplicaSetFromList", "(", "deployment", "extensions", ".", "Deployment", ",", "c", "clientset", ".", "Interface", ",", "getRSList", "func", "(", "string", ",", "api", ".", "ListOptions", ")", "(", "[", "]", "extensions", ".", "ReplicaSet", ",", "error", ")", ")", "(", "*", "extensions", ".", "ReplicaSet", ",", "error", ")", "{", "namespace", ":=", "deployment", ".", "ObjectMeta", ".", "Namespace", "\n", "selector", ",", "err", ":=", "unversioned", ".", "LabelSelectorAsSelector", "(", "deployment", ".", "Spec", ".", "Selector", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "rsList", ",", "err", ":=", "getRSList", "(", "namespace", ",", "api", ".", "ListOptions", "{", "LabelSelector", ":", "selector", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "newRSTemplate", ":=", "GetNewReplicaSetTemplate", "(", "deployment", ")", "\n\n", "for", "i", ":=", "range", "rsList", "{", "if", "api", ".", "Semantic", ".", "DeepEqual", "(", "rsList", "[", "i", "]", ".", "Spec", ".", "Template", ",", "&", "newRSTemplate", ")", "{", "// This is the new ReplicaSet.", "return", "&", "rsList", "[", "i", "]", ",", "nil", "\n", "}", "\n", "}", "\n", "// new ReplicaSet does not exist.", "return", "nil", ",", "nil", "\n", "}" ]
// GetNewReplicaSetFromList returns a replica set that matches the intent of the given deployment; get ReplicaSetList with the input function. // Returns nil if the new replica set doesn't exist yet.
[ "GetNewReplicaSetFromList", "returns", "a", "replica", "set", "that", "matches", "the", "intent", "of", "the", "given", "deployment", ";", "get", "ReplicaSetList", "with", "the", "input", "function", ".", "Returns", "nil", "if", "the", "new", "replica", "set", "doesn", "t", "exist", "yet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L124-L145
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetNewReplicaSetTemplate
func GetNewReplicaSetTemplate(deployment extensions.Deployment) api.PodTemplateSpec { // newRS will have the same template as in deployment spec, plus a unique label in some cases. newRSTemplate := api.PodTemplateSpec{ ObjectMeta: deployment.Spec.Template.ObjectMeta, Spec: deployment.Spec.Template.Spec, } newRSTemplate.ObjectMeta.Labels = labelsutil.CloneAndAddLabel( deployment.Spec.Template.ObjectMeta.Labels, extensions.DefaultDeploymentUniqueLabelKey, podutil.GetPodTemplateSpecHash(newRSTemplate)) return newRSTemplate }
go
func GetNewReplicaSetTemplate(deployment extensions.Deployment) api.PodTemplateSpec { // newRS will have the same template as in deployment spec, plus a unique label in some cases. newRSTemplate := api.PodTemplateSpec{ ObjectMeta: deployment.Spec.Template.ObjectMeta, Spec: deployment.Spec.Template.Spec, } newRSTemplate.ObjectMeta.Labels = labelsutil.CloneAndAddLabel( deployment.Spec.Template.ObjectMeta.Labels, extensions.DefaultDeploymentUniqueLabelKey, podutil.GetPodTemplateSpecHash(newRSTemplate)) return newRSTemplate }
[ "func", "GetNewReplicaSetTemplate", "(", "deployment", "extensions", ".", "Deployment", ")", "api", ".", "PodTemplateSpec", "{", "// newRS will have the same template as in deployment spec, plus a unique label in some cases.", "newRSTemplate", ":=", "api", ".", "PodTemplateSpec", "{", "ObjectMeta", ":", "deployment", ".", "Spec", ".", "Template", ".", "ObjectMeta", ",", "Spec", ":", "deployment", ".", "Spec", ".", "Template", ".", "Spec", ",", "}", "\n", "newRSTemplate", ".", "ObjectMeta", ".", "Labels", "=", "labelsutil", ".", "CloneAndAddLabel", "(", "deployment", ".", "Spec", ".", "Template", ".", "ObjectMeta", ".", "Labels", ",", "extensions", ".", "DefaultDeploymentUniqueLabelKey", ",", "podutil", ".", "GetPodTemplateSpecHash", "(", "newRSTemplate", ")", ")", "\n", "return", "newRSTemplate", "\n", "}" ]
// Returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet.
[ "Returns", "the", "desired", "PodTemplateSpec", "for", "the", "new", "ReplicaSet", "corresponding", "to", "the", "given", "ReplicaSet", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L148-L159
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetReplicaCountForReplicaSets
func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int { totalReplicaCount := 0 for _, rs := range replicaSets { totalReplicaCount += rs.Spec.Replicas } return totalReplicaCount }
go
func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int { totalReplicaCount := 0 for _, rs := range replicaSets { totalReplicaCount += rs.Spec.Replicas } return totalReplicaCount }
[ "func", "GetReplicaCountForReplicaSets", "(", "replicaSets", "[", "]", "*", "extensions", ".", "ReplicaSet", ")", "int", "{", "totalReplicaCount", ":=", "0", "\n", "for", "_", ",", "rs", ":=", "range", "replicaSets", "{", "totalReplicaCount", "+=", "rs", ".", "Spec", ".", "Replicas", "\n", "}", "\n", "return", "totalReplicaCount", "\n", "}" ]
// Returns the sum of Replicas of the given replica sets.
[ "Returns", "the", "sum", "of", "Replicas", "of", "the", "given", "replica", "sets", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L172-L178
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
GetAvailablePodsForReplicaSets
func GetAvailablePodsForReplicaSets(c clientset.Interface, rss []*extensions.ReplicaSet, minReadySeconds int) (int, error) { allPods, err := GetPodsForReplicaSets(c, rss) if err != nil { return 0, err } return getReadyPodsCount(allPods, minReadySeconds), nil }
go
func GetAvailablePodsForReplicaSets(c clientset.Interface, rss []*extensions.ReplicaSet, minReadySeconds int) (int, error) { allPods, err := GetPodsForReplicaSets(c, rss) if err != nil { return 0, err } return getReadyPodsCount(allPods, minReadySeconds), nil }
[ "func", "GetAvailablePodsForReplicaSets", "(", "c", "clientset", ".", "Interface", ",", "rss", "[", "]", "*", "extensions", ".", "ReplicaSet", ",", "minReadySeconds", "int", ")", "(", "int", ",", "error", ")", "{", "allPods", ",", "err", ":=", "GetPodsForReplicaSets", "(", "c", ",", "rss", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "return", "getReadyPodsCount", "(", "allPods", ",", "minReadySeconds", ")", ",", "nil", "\n", "}" ]
// Returns the number of available pods corresponding to the given replica sets.
[ "Returns", "the", "number", "of", "available", "pods", "corresponding", "to", "the", "given", "replica", "sets", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L181-L187
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go
Revision
func Revision(rs *extensions.ReplicaSet) (int64, error) { v, ok := rs.Annotations[RevisionAnnotation] if !ok { return 0, nil } return strconv.ParseInt(v, 10, 64) }
go
func Revision(rs *extensions.ReplicaSet) (int64, error) { v, ok := rs.Annotations[RevisionAnnotation] if !ok { return 0, nil } return strconv.ParseInt(v, 10, 64) }
[ "func", "Revision", "(", "rs", "*", "extensions", ".", "ReplicaSet", ")", "(", "int64", ",", "error", ")", "{", "v", ",", "ok", ":=", "rs", ".", "Annotations", "[", "RevisionAnnotation", "]", "\n", "if", "!", "ok", "{", "return", "0", ",", "nil", "\n", "}", "\n", "return", "strconv", ".", "ParseInt", "(", "v", ",", "10", ",", "64", ")", "\n", "}" ]
// Revision returns the revision number of the input replica set
[ "Revision", "returns", "the", "revision", "number", "of", "the", "input", "replica", "set" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/deployment/deployment.go#L235-L241
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go
Memory
func (self *ResourceList) Memory() *resource.Quantity { if val, ok := (*self)[ResourceMemory]; ok { return &val } return &resource.Quantity{} }
go
func (self *ResourceList) Memory() *resource.Quantity { if val, ok := (*self)[ResourceMemory]; ok { return &val } return &resource.Quantity{} }
[ "func", "(", "self", "*", "ResourceList", ")", "Memory", "(", ")", "*", "resource", ".", "Quantity", "{", "if", "val", ",", "ok", ":=", "(", "*", "self", ")", "[", "ResourceMemory", "]", ";", "ok", "{", "return", "&", "val", "\n", "}", "\n", "return", "&", "resource", ".", "Quantity", "{", "}", "\n", "}" ]
// Returns the Memory limit if specified.
[ "Returns", "the", "Memory", "limit", "if", "specified", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go#L37-L42
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go
GetPodReadyCondition
func GetPodReadyCondition(status PodStatus) *PodCondition { for i, c := range status.Conditions { if c.Type == PodReady { return &status.Conditions[i] } } return nil }
go
func GetPodReadyCondition(status PodStatus) *PodCondition { for i, c := range status.Conditions { if c.Type == PodReady { return &status.Conditions[i] } } return nil }
[ "func", "GetPodReadyCondition", "(", "status", "PodStatus", ")", "*", "PodCondition", "{", "for", "i", ",", "c", ":=", "range", "status", ".", "Conditions", "{", "if", "c", ".", "Type", "==", "PodReady", "{", "return", "&", "status", ".", "Conditions", "[", "i", "]", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Extracts the pod ready condition from the given status and returns that. // Returns nil if the condition is not present.
[ "Extracts", "the", "pod", "ready", "condition", "from", "the", "given", "status", "and", "returns", "that", ".", "Returns", "nil", "if", "the", "condition", "is", "not", "present", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go#L82-L89
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go
IsNodeReady
func IsNodeReady(node *Node) bool { for _, c := range node.Status.Conditions { if c.Type == NodeReady { return c.Status == ConditionTrue } } return false }
go
func IsNodeReady(node *Node) bool { for _, c := range node.Status.Conditions { if c.Type == NodeReady { return c.Status == ConditionTrue } } return false }
[ "func", "IsNodeReady", "(", "node", "*", "Node", ")", "bool", "{", "for", "_", ",", "c", ":=", "range", "node", ".", "Status", ".", "Conditions", "{", "if", "c", ".", "Type", "==", "NodeReady", "{", "return", "c", ".", "Status", "==", "ConditionTrue", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsNodeReady returns true if a node is ready; false otherwise.
[ "IsNodeReady", "returns", "true", "if", "a", "node", "is", "ready", ";", "false", "otherwise", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource_helpers.go#L92-L99
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/handshake.go
sendKexInit
func (t *handshakeTransport) sendKexInit() (*kexInitMsg, []byte, error) { t.mu.Lock() defer t.mu.Unlock() return t.sendKexInitLocked() }
go
func (t *handshakeTransport) sendKexInit() (*kexInitMsg, []byte, error) { t.mu.Lock() defer t.mu.Unlock() return t.sendKexInitLocked() }
[ "func", "(", "t", "*", "handshakeTransport", ")", "sendKexInit", "(", ")", "(", "*", "kexInitMsg", ",", "[", "]", "byte", ",", "error", ")", "{", "t", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "t", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "t", ".", "sendKexInitLocked", "(", ")", "\n", "}" ]
// sendKexInit sends a key change message, and returns the message // that was sent. After initiating the key change, all writes will be // blocked until the change is done, and a failed key change will // close the underlying transport. This function is safe for // concurrent use by multiple goroutines.
[ "sendKexInit", "sends", "a", "key", "change", "message", "and", "returns", "the", "message", "that", "was", "sent", ".", "After", "initiating", "the", "key", "change", "all", "writes", "will", "be", "blocked", "until", "the", "change", "is", "done", "and", "a", "failed", "key", "change", "will", "close", "the", "underlying", "transport", ".", "This", "function", "is", "safe", "for", "concurrent", "use", "by", "multiple", "goroutines", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/handshake.go#L199-L203
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
NewDec
func NewDec(unscaled int64, scale Scale) *Dec { return new(Dec).SetUnscaled(unscaled).SetScale(scale) }
go
func NewDec(unscaled int64, scale Scale) *Dec { return new(Dec).SetUnscaled(unscaled).SetScale(scale) }
[ "func", "NewDec", "(", "unscaled", "int64", ",", "scale", "Scale", ")", "*", "Dec", "{", "return", "new", "(", "Dec", ")", ".", "SetUnscaled", "(", "unscaled", ")", ".", "SetScale", "(", "scale", ")", "\n", "}" ]
// NewDec allocates and returns a new Dec set to the given int64 unscaled value // and scale.
[ "NewDec", "allocates", "and", "returns", "a", "new", "Dec", "set", "to", "the", "given", "int64", "unscaled", "value", "and", "scale", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L116-L118
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
SetUnscaled
func (z *Dec) SetUnscaled(unscaled int64) *Dec { z.unscaled.SetInt64(unscaled) return z }
go
func (z *Dec) SetUnscaled(unscaled int64) *Dec { z.unscaled.SetInt64(unscaled) return z }
[ "func", "(", "z", "*", "Dec", ")", "SetUnscaled", "(", "unscaled", "int64", ")", "*", "Dec", "{", "z", ".", "unscaled", ".", "SetInt64", "(", "unscaled", ")", "\n", "return", "z", "\n", "}" ]
// SetUnscaled sets the unscaled value of z, with the scale unchanged, and // returns z.
[ "SetUnscaled", "sets", "the", "unscaled", "value", "of", "z", "with", "the", "scale", "unchanged", "and", "returns", "z", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L158-L161
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
SetUnscaledBig
func (z *Dec) SetUnscaledBig(unscaled *big.Int) *Dec { z.unscaled.Set(unscaled) return z }
go
func (z *Dec) SetUnscaledBig(unscaled *big.Int) *Dec { z.unscaled.Set(unscaled) return z }
[ "func", "(", "z", "*", "Dec", ")", "SetUnscaledBig", "(", "unscaled", "*", "big", ".", "Int", ")", "*", "Dec", "{", "z", ".", "unscaled", ".", "Set", "(", "unscaled", ")", "\n", "return", "z", "\n", "}" ]
// SetUnscaledBig sets the unscaled value of z, with the scale unchanged, and // returns z.
[ "SetUnscaledBig", "sets", "the", "unscaled", "value", "of", "z", "with", "the", "scale", "unchanged", "and", "returns", "z", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L165-L168
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
Set
func (z *Dec) Set(x *Dec) *Dec { if z != x { z.SetUnscaledBig(x.UnscaledBig()) z.SetScale(x.Scale()) } return z }
go
func (z *Dec) Set(x *Dec) *Dec { if z != x { z.SetUnscaledBig(x.UnscaledBig()) z.SetScale(x.Scale()) } return z }
[ "func", "(", "z", "*", "Dec", ")", "Set", "(", "x", "*", "Dec", ")", "*", "Dec", "{", "if", "z", "!=", "x", "{", "z", ".", "SetUnscaledBig", "(", "x", ".", "UnscaledBig", "(", ")", ")", "\n", "z", ".", "SetScale", "(", "x", ".", "Scale", "(", ")", ")", "\n", "}", "\n", "return", "z", "\n", "}" ]
// Set sets z to the value of x and returns z. // It does nothing if z == x.
[ "Set", "sets", "z", "to", "the", "value", "of", "x", "and", "returns", "z", ".", "It", "does", "nothing", "if", "z", "==", "x", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L172-L178
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
Neg
func (z *Dec) Neg(x *Dec) *Dec { z.SetScale(x.Scale()) z.UnscaledBig().Neg(x.UnscaledBig()) return z }
go
func (z *Dec) Neg(x *Dec) *Dec { z.SetScale(x.Scale()) z.UnscaledBig().Neg(x.UnscaledBig()) return z }
[ "func", "(", "z", "*", "Dec", ")", "Neg", "(", "x", "*", "Dec", ")", "*", "Dec", "{", "z", ".", "SetScale", "(", "x", ".", "Scale", "(", ")", ")", "\n", "z", ".", "UnscaledBig", "(", ")", ".", "Neg", "(", "x", ".", "UnscaledBig", "(", ")", ")", "\n", "return", "z", "\n", "}" ]
// Neg sets z to -x and returns z.
[ "Neg", "sets", "z", "to", "-", "x", "and", "returns", "z", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L191-L195
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
Add
func (z *Dec) Add(x, y *Dec) *Dec { xx, yy := upscale(x, y) z.SetScale(xx.Scale()) z.UnscaledBig().Add(xx.UnscaledBig(), yy.UnscaledBig()) return z }
go
func (z *Dec) Add(x, y *Dec) *Dec { xx, yy := upscale(x, y) z.SetScale(xx.Scale()) z.UnscaledBig().Add(xx.UnscaledBig(), yy.UnscaledBig()) return z }
[ "func", "(", "z", "*", "Dec", ")", "Add", "(", "x", ",", "y", "*", "Dec", ")", "*", "Dec", "{", "xx", ",", "yy", ":=", "upscale", "(", "x", ",", "y", ")", "\n", "z", ".", "SetScale", "(", "xx", ".", "Scale", "(", ")", ")", "\n", "z", ".", "UnscaledBig", "(", ")", ".", "Add", "(", "xx", ".", "UnscaledBig", "(", ")", ",", "yy", ".", "UnscaledBig", "(", ")", ")", "\n", "return", "z", "\n", "}" ]
// Add sets z to the sum x+y and returns z. // The scale of z is the greater of the scales of x and y.
[ "Add", "sets", "z", "to", "the", "sum", "x", "+", "y", "and", "returns", "z", ".", "The", "scale", "of", "z", "is", "the", "greater", "of", "the", "scales", "of", "x", "and", "y", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L217-L222
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
Round
func (z *Dec) Round(x *Dec, s Scale, r Rounder) *Dec { return z.QuoRound(x, NewDec(1, 0), s, r) }
go
func (z *Dec) Round(x *Dec, s Scale, r Rounder) *Dec { return z.QuoRound(x, NewDec(1, 0), s, r) }
[ "func", "(", "z", "*", "Dec", ")", "Round", "(", "x", "*", "Dec", ",", "s", "Scale", ",", "r", "Rounder", ")", "*", "Dec", "{", "return", "z", ".", "QuoRound", "(", "x", ",", "NewDec", "(", "1", ",", "0", ")", ",", "s", ",", "r", ")", "\n", "}" ]
// Round sets z to the value of x rounded to Scale s using Rounder r, and // returns z.
[ "Round", "sets", "z", "to", "the", "value", "of", "x", "rounded", "to", "Scale", "s", "using", "Rounder", "r", "and", "returns", "z", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L243-L245
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
Format
func (x *Dec) Format(s fmt.State, ch rune) { if ch != 'd' && ch != 'f' && ch != 'v' && ch != 's' { fmt.Fprintf(s, "%%!%c(dec.Dec=%s)", ch, x.String()) return } fmt.Fprintf(s, x.String()) }
go
func (x *Dec) Format(s fmt.State, ch rune) { if ch != 'd' && ch != 'f' && ch != 'v' && ch != 's' { fmt.Fprintf(s, "%%!%c(dec.Dec=%s)", ch, x.String()) return } fmt.Fprintf(s, x.String()) }
[ "func", "(", "x", "*", "Dec", ")", "Format", "(", "s", "fmt", ".", "State", ",", "ch", "rune", ")", "{", "if", "ch", "!=", "'d'", "&&", "ch", "!=", "'f'", "&&", "ch", "!=", "'v'", "&&", "ch", "!=", "'s'", "{", "fmt", ".", "Fprintf", "(", "s", ",", "\"", "\"", ",", "ch", ",", "x", ".", "String", "(", ")", ")", "\n", "return", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "s", ",", "x", ".", "String", "(", ")", ")", "\n", "}" ]
// Format is a support routine for fmt.Formatter. It accepts the decimal // formats 'd' and 'f', and handles both equivalently. // Width, precision, flags and bases 2, 8, 16 are not supported.
[ "Format", "is", "a", "support", "routine", "for", "fmt", ".", "Formatter", ".", "It", "accepts", "the", "decimal", "formats", "d", "and", "f", "and", "handles", "both", "equivalently", ".", "Width", "precision", "flags", "and", "bases", "2", "8", "16", "are", "not", "supported", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L462-L468
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
GobEncode
func (x *Dec) GobEncode() ([]byte, error) { buf, err := x.UnscaledBig().GobEncode() if err != nil { return nil, err } buf = append(append(buf, scaleBytes(x.Scale())...), decGobVersion) return buf, nil }
go
func (x *Dec) GobEncode() ([]byte, error) { buf, err := x.UnscaledBig().GobEncode() if err != nil { return nil, err } buf = append(append(buf, scaleBytes(x.Scale())...), decGobVersion) return buf, nil }
[ "func", "(", "x", "*", "Dec", ")", "GobEncode", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "buf", ",", "err", ":=", "x", ".", "UnscaledBig", "(", ")", ".", "GobEncode", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "buf", "=", "append", "(", "append", "(", "buf", ",", "scaleBytes", "(", "x", ".", "Scale", "(", ")", ")", "...", ")", ",", "decGobVersion", ")", "\n", "return", "buf", ",", "nil", "\n", "}" ]
// GobEncode implements the gob.GobEncoder interface.
[ "GobEncode", "implements", "the", "gob", ".", "GobEncoder", "interface", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L576-L583
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go
GobDecode
func (z *Dec) GobDecode(buf []byte) error { if len(buf) == 0 { return fmt.Errorf("Dec.GobDecode: no data") } b := buf[len(buf)-1] if b != decGobVersion { return fmt.Errorf("Dec.GobDecode: encoding version %d not supported", b) } l := len(buf) - scaleSize - 1 err := z.UnscaledBig().GobDecode(buf[:l]) if err != nil { return err } z.SetScale(scale(buf[l : l+scaleSize])) return nil }
go
func (z *Dec) GobDecode(buf []byte) error { if len(buf) == 0 { return fmt.Errorf("Dec.GobDecode: no data") } b := buf[len(buf)-1] if b != decGobVersion { return fmt.Errorf("Dec.GobDecode: encoding version %d not supported", b) } l := len(buf) - scaleSize - 1 err := z.UnscaledBig().GobDecode(buf[:l]) if err != nil { return err } z.SetScale(scale(buf[l : l+scaleSize])) return nil }
[ "func", "(", "z", "*", "Dec", ")", "GobDecode", "(", "buf", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "buf", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "b", ":=", "buf", "[", "len", "(", "buf", ")", "-", "1", "]", "\n", "if", "b", "!=", "decGobVersion", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "b", ")", "\n", "}", "\n", "l", ":=", "len", "(", "buf", ")", "-", "scaleSize", "-", "1", "\n", "err", ":=", "z", ".", "UnscaledBig", "(", ")", ".", "GobDecode", "(", "buf", "[", ":", "l", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "z", ".", "SetScale", "(", "scale", "(", "buf", "[", "l", ":", "l", "+", "scaleSize", "]", ")", ")", "\n", "return", "nil", "\n", "}" ]
// GobDecode implements the gob.GobDecoder interface.
[ "GobDecode", "implements", "the", "gob", ".", "GobDecoder", "interface", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go#L586-L601
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go
newEvents
func newEvents(c *Client, ns string) *events { return &events{ client: c, namespace: ns, } }
go
func newEvents(c *Client, ns string) *events { return &events{ client: c, namespace: ns, } }
[ "func", "newEvents", "(", "c", "*", "Client", ",", "ns", "string", ")", "*", "events", "{", "return", "&", "events", "{", "client", ":", "c", ",", "namespace", ":", "ns", ",", "}", "\n", "}" ]
// newEvents returns a new events object.
[ "newEvents", "returns", "a", "new", "events", "object", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L58-L63
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go
Update
func (e *events) Update(event *api.Event) (*api.Event, error) { if len(event.ResourceVersion) == 0 { return nil, fmt.Errorf("invalid event update object, missing resource version: %#v", event) } 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) Update(event *api.Event) (*api.Event, error) { if len(event.ResourceVersion) == 0 { return nil, fmt.Errorf("invalid event update object, missing resource version: %#v", event) } 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", ")", "Update", "(", "event", "*", "api", ".", "Event", ")", "(", "*", "api", ".", "Event", ",", "error", ")", "{", "if", "len", "(", "event", ".", "ResourceVersion", ")", "==", "0", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "event", ")", "\n", "}", "\n", "result", ":=", "&", "api", ".", "Event", "{", "}", "\n", "err", ":=", "e", ".", "client", ".", "Put", "(", ")", ".", "NamespaceIfScoped", "(", "event", ".", "Namespace", ",", "len", "(", "event", ".", "Namespace", ")", ">", "0", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "event", ".", "Name", ")", ".", "Body", "(", "event", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "result", ",", "err", "\n", "}" ]
// Update 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.
[ "Update", "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", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L88-L101
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go
List
func (e *events) List(opts api.ListOptions) (*api.EventList, error) { result := &api.EventList{} err := e.client.Get(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). VersionedParams(&opts, api.Scheme). Do(). Into(result) return result, err }
go
func (e *events) List(opts api.ListOptions) (*api.EventList, error) { result := &api.EventList{} err := e.client.Get(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). VersionedParams(&opts, api.Scheme). Do(). Into(result) return result, err }
[ "func", "(", "e", "*", "events", ")", "List", "(", "opts", "api", ".", "ListOptions", ")", "(", "*", "api", ".", "EventList", ",", "error", ")", "{", "result", ":=", "&", "api", ".", "EventList", "{", "}", "\n", "err", ":=", "e", ".", "client", ".", "Get", "(", ")", ".", "NamespaceIfScoped", "(", "e", ".", "namespace", ",", "len", "(", "e", ".", "namespace", ")", ">", "0", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "VersionedParams", "(", "&", "opts", ",", "api", ".", "Scheme", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "result", ",", "err", "\n", "}" ]
// List returns a list of events matching the selectors.
[ "List", "returns", "a", "list", "of", "events", "matching", "the", "selectors", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L120-L129
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go
Get
func (e *events) Get(name string) (*api.Event, error) { result := &api.Event{} err := e.client.Get(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). Name(name). Do(). Into(result) return result, err }
go
func (e *events) Get(name string) (*api.Event, error) { result := &api.Event{} err := e.client.Get(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). Name(name). Do(). Into(result) return result, err }
[ "func", "(", "e", "*", "events", ")", "Get", "(", "name", "string", ")", "(", "*", "api", ".", "Event", ",", "error", ")", "{", "result", ":=", "&", "api", ".", "Event", "{", "}", "\n", "err", ":=", "e", ".", "client", ".", "Get", "(", ")", ".", "NamespaceIfScoped", "(", "e", ".", "namespace", ",", "len", "(", "e", ".", "namespace", ")", ">", "0", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "result", ",", "err", "\n", "}" ]
// Get returns the given event, or an error.
[ "Get", "returns", "the", "given", "event", "or", "an", "error", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L132-L141
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go
Delete
func (e *events) Delete(name string) error { return e.client.Delete(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). Name(name). Do(). Error() }
go
func (e *events) Delete(name string) error { return e.client.Delete(). NamespaceIfScoped(e.namespace, len(e.namespace) > 0). Resource("events"). Name(name). Do(). Error() }
[ "func", "(", "e", "*", "events", ")", "Delete", "(", "name", "string", ")", "error", "{", "return", "e", ".", "client", ".", "Delete", "(", ")", ".", "NamespaceIfScoped", "(", "e", ".", "namespace", ",", "len", "(", "e", ".", "namespace", ")", ">", "0", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Error", "(", ")", "\n", "}" ]
// Delete deletes an existing event.
[ "Delete", "deletes", "an", "existing", "event", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/events.go#L179-L186
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/meta.go
extractFromObjectMeta
func extractFromObjectMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "Namespace", &a.namespace); err != nil { return err } if err := runtime.FieldPtr(v, "Name", &a.name); err != nil { return err } if err := runtime.FieldPtr(v, "GenerateName", &a.generateName); err != nil { return err } if err := runtime.FieldPtr(v, "UID", &a.uid); err != nil { return err } if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } if err := runtime.FieldPtr(v, "Labels", &a.labels); err != nil { return err } if err := runtime.FieldPtr(v, "Annotations", &a.annotations); err != nil { return err } return nil }
go
func extractFromObjectMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "Namespace", &a.namespace); err != nil { return err } if err := runtime.FieldPtr(v, "Name", &a.name); err != nil { return err } if err := runtime.FieldPtr(v, "GenerateName", &a.generateName); err != nil { return err } if err := runtime.FieldPtr(v, "UID", &a.uid); err != nil { return err } if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } if err := runtime.FieldPtr(v, "Labels", &a.labels); err != nil { return err } if err := runtime.FieldPtr(v, "Annotations", &a.annotations); err != nil { return err } return nil }
[ "func", "extractFromObjectMeta", "(", "v", "reflect", ".", "Value", ",", "a", "*", "genericAccessor", ")", "error", "{", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "namespace", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "name", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "generateName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "uid", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "resourceVersion", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "selfLink", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "labels", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "annotations", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// extractFromObjectMeta extracts pointers to metadata fields from an object
[ "extractFromObjectMeta", "extracts", "pointers", "to", "metadata", "fields", "from", "an", "object" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/meta.go#L462-L488
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/meta.go
extractFromListMeta
func extractFromListMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } return nil }
go
func extractFromListMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } return nil }
[ "func", "extractFromListMeta", "(", "v", "reflect", ".", "Value", ",", "a", "*", "genericAccessor", ")", "error", "{", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "resourceVersion", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "runtime", ".", "FieldPtr", "(", "v", ",", "\"", "\"", ",", "&", "a", ".", "selfLink", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// extractFromObjectMeta extracts pointers to metadata fields from a list object
[ "extractFromObjectMeta", "extracts", "pointers", "to", "metadata", "fields", "from", "a", "list", "object" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/meta.go#L491-L499
train
kubernetes-retired/contrib
rescheduler/utils.go
Add
func (s *podSet) Add(pod *v1.Pod) { s.mutex.Lock() defer s.mutex.Unlock() s.set[podId(pod)] = struct{}{} }
go
func (s *podSet) Add(pod *v1.Pod) { s.mutex.Lock() defer s.mutex.Unlock() s.set[podId(pod)] = struct{}{} }
[ "func", "(", "s", "*", "podSet", ")", "Add", "(", "pod", "*", "v1", ".", "Pod", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "s", ".", "set", "[", "podId", "(", "pod", ")", "]", "=", "struct", "{", "}", "{", "}", "\n", "}" ]
// Add the pod to the set.
[ "Add", "the", "pod", "to", "the", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/utils.go#L45-L49
train
kubernetes-retired/contrib
rescheduler/utils.go
Remove
func (s *podSet) Remove(pod *v1.Pod) { s.mutex.Lock() defer s.mutex.Unlock() delete(s.set, podId(pod)) }
go
func (s *podSet) Remove(pod *v1.Pod) { s.mutex.Lock() defer s.mutex.Unlock() delete(s.set, podId(pod)) }
[ "func", "(", "s", "*", "podSet", ")", "Remove", "(", "pod", "*", "v1", ".", "Pod", ")", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "delete", "(", "s", ".", "set", ",", "podId", "(", "pod", ")", ")", "\n", "}" ]
// Remove the pod from set.
[ "Remove", "the", "pod", "from", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/utils.go#L52-L56
train
kubernetes-retired/contrib
rescheduler/utils.go
Has
func (s *podSet) Has(pod *v1.Pod) bool { return s.HasId(podId(pod)) }
go
func (s *podSet) Has(pod *v1.Pod) bool { return s.HasId(podId(pod)) }
[ "func", "(", "s", "*", "podSet", ")", "Has", "(", "pod", "*", "v1", ".", "Pod", ")", "bool", "{", "return", "s", ".", "HasId", "(", "podId", "(", "pod", ")", ")", "\n", "}" ]
// Has checks whether the pod is in the set.
[ "Has", "checks", "whether", "the", "pod", "is", "in", "the", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/utils.go#L59-L61
train
kubernetes-retired/contrib
rescheduler/utils.go
HasId
func (s *podSet) HasId(pod string) bool { s.mutex.Lock() defer s.mutex.Unlock() _, found := s.set[pod] return found }
go
func (s *podSet) HasId(pod string) bool { s.mutex.Lock() defer s.mutex.Unlock() _, found := s.set[pod] return found }
[ "func", "(", "s", "*", "podSet", ")", "HasId", "(", "pod", "string", ")", "bool", "{", "s", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mutex", ".", "Unlock", "(", ")", "\n", "_", ",", "found", ":=", "s", ".", "set", "[", "pod", "]", "\n", "return", "found", "\n", "}" ]
// HasId checks whether the pod is in the set.
[ "HasId", "checks", "whether", "the", "pod", "is", "in", "the", "set", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/rescheduler/utils.go#L64-L69
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_alpha
func is_alpha(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' }
go
func is_alpha(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' }
[ "func", "is_alpha", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "return", "b", "[", "i", "]", ">=", "'0'", "&&", "b", "[", "i", "]", "<=", "'9'", "||", "b", "[", "i", "]", ">=", "'A'", "&&", "b", "[", "i", "]", "<=", "'Z'", "||", "b", "[", "i", "]", ">=", "'a'", "&&", "b", "[", "i", "]", "<=", "'z'", "||", "b", "[", "i", "]", "==", "'_'", "||", "b", "[", "i", "]", "==", "'-'", "\n", "}" ]
// Check if the character at the specified position is an alphabetical // character, a digit, '_', or '-'.
[ "Check", "if", "the", "character", "at", "the", "specified", "position", "is", "an", "alphabetical", "character", "a", "digit", "_", "or", "-", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L26-L28
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_digit
func is_digit(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' }
go
func is_digit(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' }
[ "func", "is_digit", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "return", "b", "[", "i", "]", ">=", "'0'", "&&", "b", "[", "i", "]", "<=", "'9'", "\n", "}" ]
// Check if the character at the specified position is a digit.
[ "Check", "if", "the", "character", "at", "the", "specified", "position", "is", "a", "digit", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L31-L33
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_hex
func is_hex(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' }
go
func is_hex(b []byte, i int) bool { return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' }
[ "func", "is_hex", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "return", "b", "[", "i", "]", ">=", "'0'", "&&", "b", "[", "i", "]", "<=", "'9'", "||", "b", "[", "i", "]", ">=", "'A'", "&&", "b", "[", "i", "]", "<=", "'F'", "||", "b", "[", "i", "]", ">=", "'a'", "&&", "b", "[", "i", "]", "<=", "'f'", "\n", "}" ]
// Check if the character at the specified position is a hex-digit.
[ "Check", "if", "the", "character", "at", "the", "specified", "position", "is", "a", "hex", "-", "digit", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L41-L43
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
as_hex
func as_hex(b []byte, i int) int { bi := b[i] if bi >= 'A' && bi <= 'F' { return int(bi) - 'A' + 10 } if bi >= 'a' && bi <= 'f' { return int(bi) - 'a' + 10 } return int(bi) - '0' }
go
func as_hex(b []byte, i int) int { bi := b[i] if bi >= 'A' && bi <= 'F' { return int(bi) - 'A' + 10 } if bi >= 'a' && bi <= 'f' { return int(bi) - 'a' + 10 } return int(bi) - '0' }
[ "func", "as_hex", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "int", "{", "bi", ":=", "b", "[", "i", "]", "\n", "if", "bi", ">=", "'A'", "&&", "bi", "<=", "'F'", "{", "return", "int", "(", "bi", ")", "-", "'A'", "+", "10", "\n", "}", "\n", "if", "bi", ">=", "'a'", "&&", "bi", "<=", "'f'", "{", "return", "int", "(", "bi", ")", "-", "'a'", "+", "10", "\n", "}", "\n", "return", "int", "(", "bi", ")", "-", "'0'", "\n", "}" ]
// Get the value of a hex-digit.
[ "Get", "the", "value", "of", "a", "hex", "-", "digit", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L46-L55
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_printable
func is_printable(b []byte, i int) bool { return ((b[i] == 0x0A) || // . == #x0A (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF (b[i] > 0xC2 && b[i] < 0xED) || (b[i] == 0xED && b[i+1] < 0xA0) || (b[i] == 0xEE) || (b[i] == 0xEF && // #xE000 <= . <= #xFFFD !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) }
go
func is_printable(b []byte, i int) bool { return ((b[i] == 0x0A) || // . == #x0A (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF (b[i] > 0xC2 && b[i] < 0xED) || (b[i] == 0xED && b[i+1] < 0xA0) || (b[i] == 0xEE) || (b[i] == 0xEF && // #xE000 <= . <= #xFFFD !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) }
[ "func", "is_printable", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "return", "(", "(", "b", "[", "i", "]", "==", "0x0A", ")", "||", "// . == #x0A", "(", "b", "[", "i", "]", ">=", "0x20", "&&", "b", "[", "i", "]", "<=", "0x7E", ")", "||", "// #x20 <= . <= #x7E", "(", "b", "[", "i", "]", "==", "0xC2", "&&", "b", "[", "i", "+", "1", "]", ">=", "0xA0", ")", "||", "// #0xA0 <= . <= #xD7FF", "(", "b", "[", "i", "]", ">", "0xC2", "&&", "b", "[", "i", "]", "<", "0xED", ")", "||", "(", "b", "[", "i", "]", "==", "0xED", "&&", "b", "[", "i", "+", "1", "]", "<", "0xA0", ")", "||", "(", "b", "[", "i", "]", "==", "0xEE", ")", "||", "(", "b", "[", "i", "]", "==", "0xEF", "&&", "// #xE000 <= . <= #xFFFD", "!", "(", "b", "[", "i", "+", "1", "]", "==", "0xBB", "&&", "b", "[", "i", "+", "2", "]", "==", "0xBF", ")", "&&", "// && . != #xFEFF", "!", "(", "b", "[", "i", "+", "1", "]", "==", "0xBF", "&&", "(", "b", "[", "i", "+", "2", "]", "==", "0xBE", "||", "b", "[", "i", "+", "2", "]", "==", "0xBF", ")", ")", ")", ")", "\n", "}" ]
// Check if the character at the start of the buffer can be printed unescaped.
[ "Check", "if", "the", "character", "at", "the", "start", "of", "the", "buffer", "can", "be", "printed", "unescaped", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L63-L73
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_break
func is_break(b []byte, i int) bool { return (b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) }
go
func is_break(b []byte, i int) bool { return (b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) }
[ "func", "is_break", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "return", "(", "b", "[", "i", "]", "==", "'\\r'", "||", "// CR (#xD)", "b", "[", "i", "]", "==", "'\\n'", "||", "// LF (#xA)", "b", "[", "i", "]", "==", "0xC2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x85", "||", "// NEL (#x85)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA8", "||", "// LS (#x2028)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA9", ")", "// PS (#x2029)", "\n", "}" ]
// Check if the character at the specified position is a line break.
[ "Check", "if", "the", "character", "at", "the", "specified", "position", "is", "a", "line", "break", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L102-L108
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_breakz
func is_breakz(b []byte, i int) bool { //return is_break(b, i) || is_z(b, i) return ( // is_break: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) // is_z: b[i] == 0) }
go
func is_breakz(b []byte, i int) bool { //return is_break(b, i) || is_z(b, i) return ( // is_break: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) // is_z: b[i] == 0) }
[ "func", "is_breakz", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "//return is_break(b, i) || is_z(b, i)", "return", "(", "// is_break:", "b", "[", "i", "]", "==", "'\\r'", "||", "// CR (#xD)", "b", "[", "i", "]", "==", "'\\n'", "||", "// LF (#xA)", "b", "[", "i", "]", "==", "0xC2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x85", "||", "// NEL (#x85)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA8", "||", "// LS (#x2028)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA9", "||", "// PS (#x2029)", "// is_z:", "b", "[", "i", "]", "==", "0", ")", "\n", "}" ]
// Check if the character is a line break or NUL.
[ "Check", "if", "the", "character", "is", "a", "line", "break", "or", "NUL", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L115-L125
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_spacez
func is_spacez(b []byte, i int) bool { //return is_space(b, i) || is_breakz(b, i) return ( // is_space: b[i] == ' ' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) }
go
func is_spacez(b []byte, i int) bool { //return is_space(b, i) || is_breakz(b, i) return ( // is_space: b[i] == ' ' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) }
[ "func", "is_spacez", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "//return is_space(b, i) || is_breakz(b, i)", "return", "(", "// is_space:", "b", "[", "i", "]", "==", "' '", "||", "// is_breakz:", "b", "[", "i", "]", "==", "'\\r'", "||", "// CR (#xD)", "b", "[", "i", "]", "==", "'\\n'", "||", "// LF (#xA)", "b", "[", "i", "]", "==", "0xC2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x85", "||", "// NEL (#x85)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA8", "||", "// LS (#x2028)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA9", "||", "// PS (#x2029)", "b", "[", "i", "]", "==", "0", ")", "\n", "}" ]
// Check if the character is a line break, space, or NUL.
[ "Check", "if", "the", "character", "is", "a", "line", "break", "space", "or", "NUL", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L128-L139
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go
is_blankz
func is_blankz(b []byte, i int) bool { //return is_blank(b, i) || is_breakz(b, i) return ( // is_blank: b[i] == ' ' || b[i] == '\t' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) }
go
func is_blankz(b []byte, i int) bool { //return is_blank(b, i) || is_breakz(b, i) return ( // is_blank: b[i] == ' ' || b[i] == '\t' || // is_breakz: b[i] == '\r' || // CR (#xD) b[i] == '\n' || // LF (#xA) b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) b[i] == 0) }
[ "func", "is_blankz", "(", "b", "[", "]", "byte", ",", "i", "int", ")", "bool", "{", "//return is_blank(b, i) || is_breakz(b, i)", "return", "(", "// is_blank:", "b", "[", "i", "]", "==", "' '", "||", "b", "[", "i", "]", "==", "'\\t'", "||", "// is_breakz:", "b", "[", "i", "]", "==", "'\\r'", "||", "// CR (#xD)", "b", "[", "i", "]", "==", "'\\n'", "||", "// LF (#xA)", "b", "[", "i", "]", "==", "0xC2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x85", "||", "// NEL (#x85)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA8", "||", "// LS (#x2028)", "b", "[", "i", "]", "==", "0xE2", "&&", "b", "[", "i", "+", "1", "]", "==", "0x80", "&&", "b", "[", "i", "+", "2", "]", "==", "0xA9", "||", "// PS (#x2029)", "b", "[", "i", "]", "==", "0", ")", "\n", "}" ]
// Check if the character is a line break, space, tab, or NUL.
[ "Check", "if", "the", "character", "is", "a", "line", "break", "space", "tab", "or", "NUL", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlprivateh.go#L142-L153
train
kubernetes-retired/contrib
keepalived-vip/controller.go
sync
func (ipvsc *ipvsControllerController) sync(key string) error { ipvsc.reloadRateLimiter.Accept() if !ipvsc.epController.HasSynced() || !ipvsc.svcController.HasSynced() { time.Sleep(100 * time.Millisecond) return fmt.Errorf("deferring sync till endpoints controller has synced") } ns, name, err := parseNsName(ipvsc.configMapName) if err != nil { glog.Warningf("%v", err) return err } cfgMap, err := ipvsc.getConfigMap(ns, name) if err != nil { return fmt.Errorf("unexpected error searching configmap %v: %v", ipvsc.configMapName, err) } svc := ipvsc.getServices(cfgMap) ipvsc.ruCfg = svc err = ipvsc.keepalived.WriteCfg(svc) if err != nil { return err } glog.V(2).Infof("services: %v", svc) md5, err := checksum(keepalivedCfg) if err == nil && md5 == ipvsc.ruMD5 { return nil } ipvsc.ruMD5 = md5 err = ipvsc.keepalived.Reload() if err != nil { glog.Errorf("error reloading keepalived: %v", err) } return nil }
go
func (ipvsc *ipvsControllerController) sync(key string) error { ipvsc.reloadRateLimiter.Accept() if !ipvsc.epController.HasSynced() || !ipvsc.svcController.HasSynced() { time.Sleep(100 * time.Millisecond) return fmt.Errorf("deferring sync till endpoints controller has synced") } ns, name, err := parseNsName(ipvsc.configMapName) if err != nil { glog.Warningf("%v", err) return err } cfgMap, err := ipvsc.getConfigMap(ns, name) if err != nil { return fmt.Errorf("unexpected error searching configmap %v: %v", ipvsc.configMapName, err) } svc := ipvsc.getServices(cfgMap) ipvsc.ruCfg = svc err = ipvsc.keepalived.WriteCfg(svc) if err != nil { return err } glog.V(2).Infof("services: %v", svc) md5, err := checksum(keepalivedCfg) if err == nil && md5 == ipvsc.ruMD5 { return nil } ipvsc.ruMD5 = md5 err = ipvsc.keepalived.Reload() if err != nil { glog.Errorf("error reloading keepalived: %v", err) } return nil }
[ "func", "(", "ipvsc", "*", "ipvsControllerController", ")", "sync", "(", "key", "string", ")", "error", "{", "ipvsc", ".", "reloadRateLimiter", ".", "Accept", "(", ")", "\n\n", "if", "!", "ipvsc", ".", "epController", ".", "HasSynced", "(", ")", "||", "!", "ipvsc", ".", "svcController", ".", "HasSynced", "(", ")", "{", "time", ".", "Sleep", "(", "100", "*", "time", ".", "Millisecond", ")", "\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "ns", ",", "name", ",", "err", ":=", "parseNsName", "(", "ipvsc", ".", "configMapName", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "cfgMap", ",", "err", ":=", "ipvsc", ".", "getConfigMap", "(", "ns", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "ipvsc", ".", "configMapName", ",", "err", ")", "\n", "}", "\n\n", "svc", ":=", "ipvsc", ".", "getServices", "(", "cfgMap", ")", "\n", "ipvsc", ".", "ruCfg", "=", "svc", "\n\n", "err", "=", "ipvsc", ".", "keepalived", ".", "WriteCfg", "(", "svc", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "svc", ")", "\n\n", "md5", ",", "err", ":=", "checksum", "(", "keepalivedCfg", ")", "\n", "if", "err", "==", "nil", "&&", "md5", "==", "ipvsc", ".", "ruMD5", "{", "return", "nil", "\n", "}", "\n\n", "ipvsc", ".", "ruMD5", "=", "md5", "\n", "err", "=", "ipvsc", ".", "keepalived", ".", "Reload", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// sync all services with the
[ "sync", "all", "services", "with", "the" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/controller.go#L240-L279
train
kubernetes-retired/contrib
keepalived-vip/controller.go
Stop
func (ipvsc *ipvsControllerController) Stop() error { ipvsc.stopLock.Lock() defer ipvsc.stopLock.Unlock() // Only try draining the workqueue if we haven't already. if !ipvsc.shutdown { ipvsc.shutdown = true close(ipvsc.stopCh) glog.Infof("Shutting down controller queue") ipvsc.syncQueue.shutdown() ipvsc.keepalived.Stop() return nil } return fmt.Errorf("shutdown already in progress") }
go
func (ipvsc *ipvsControllerController) Stop() error { ipvsc.stopLock.Lock() defer ipvsc.stopLock.Unlock() // Only try draining the workqueue if we haven't already. if !ipvsc.shutdown { ipvsc.shutdown = true close(ipvsc.stopCh) glog.Infof("Shutting down controller queue") ipvsc.syncQueue.shutdown() ipvsc.keepalived.Stop() return nil } return fmt.Errorf("shutdown already in progress") }
[ "func", "(", "ipvsc", "*", "ipvsControllerController", ")", "Stop", "(", ")", "error", "{", "ipvsc", ".", "stopLock", ".", "Lock", "(", ")", "\n", "defer", "ipvsc", ".", "stopLock", ".", "Unlock", "(", ")", "\n\n", "// Only try draining the workqueue if we haven't already.", "if", "!", "ipvsc", ".", "shutdown", "{", "ipvsc", ".", "shutdown", "=", "true", "\n", "close", "(", "ipvsc", ".", "stopCh", ")", "\n\n", "glog", ".", "Infof", "(", "\"", "\"", ")", "\n", "ipvsc", ".", "syncQueue", ".", "shutdown", "(", ")", "\n\n", "ipvsc", ".", "keepalived", ".", "Stop", "(", ")", "\n\n", "return", "nil", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// Stop stops the loadbalancer controller.
[ "Stop", "stops", "the", "loadbalancer", "controller", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/keepalived-vip/controller.go#L282-L300
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/jobs.go
Get
func (c *jobsV1) Get(name string) (result *extensions.Job, err error) { result = &extensions.Job{} err = c.r.Get().Namespace(c.ns).Resource("jobs").Name(name).Do().Into(result) return }
go
func (c *jobsV1) Get(name string) (result *extensions.Job, err error) { result = &extensions.Job{} err = c.r.Get().Namespace(c.ns).Resource("jobs").Name(name).Do().Into(result) return }
[ "func", "(", "c", "*", "jobsV1", ")", "Get", "(", "name", "string", ")", "(", "result", "*", "extensions", ".", "Job", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "Job", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Get", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Name", "(", "name", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Get returns information about a particular job.
[ "Get", "returns", "information", "about", "a", "particular", "job", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/jobs.go#L127-L131
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/jobs.go
Create
func (c *jobsV1) Create(job *extensions.Job) (result *extensions.Job, err error) { result = &extensions.Job{} err = c.r.Post().Namespace(c.ns).Resource("jobs").Body(job).Do().Into(result) return }
go
func (c *jobsV1) Create(job *extensions.Job) (result *extensions.Job, err error) { result = &extensions.Job{} err = c.r.Post().Namespace(c.ns).Resource("jobs").Body(job).Do().Into(result) return }
[ "func", "(", "c", "*", "jobsV1", ")", "Create", "(", "job", "*", "extensions", ".", "Job", ")", "(", "result", "*", "extensions", ".", "Job", ",", "err", "error", ")", "{", "result", "=", "&", "extensions", ".", "Job", "{", "}", "\n", "err", "=", "c", ".", "r", ".", "Post", "(", ")", ".", "Namespace", "(", "c", ".", "ns", ")", ".", "Resource", "(", "\"", "\"", ")", ".", "Body", "(", "job", ")", ".", "Do", "(", ")", ".", "Into", "(", "result", ")", "\n", "return", "\n", "}" ]
// Create creates a new job.
[ "Create", "creates", "a", "new", "job", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/jobs.go#L134-L138
train
kubernetes-retired/contrib
kubeform/pkg/provider/provider.go
Provider
func Provider() terraform.ResourceProvider { return &schema.Provider{ ResourcesMap: map[string]*schema.Resource{ "kubernetes_kubeconfig": resourceKubeconfig(), "kubernetes_cluster": resourceCluster(), }, ConfigureFunc: providerConfig, } }
go
func Provider() terraform.ResourceProvider { return &schema.Provider{ ResourcesMap: map[string]*schema.Resource{ "kubernetes_kubeconfig": resourceKubeconfig(), "kubernetes_cluster": resourceCluster(), }, ConfigureFunc: providerConfig, } }
[ "func", "Provider", "(", ")", "terraform", ".", "ResourceProvider", "{", "return", "&", "schema", ".", "Provider", "{", "ResourcesMap", ":", "map", "[", "string", "]", "*", "schema", ".", "Resource", "{", "\"", "\"", ":", "resourceKubeconfig", "(", ")", ",", "\"", "\"", ":", "resourceCluster", "(", ")", ",", "}", ",", "ConfigureFunc", ":", "providerConfig", ",", "}", "\n", "}" ]
// Provider returns an implementation of the Kubernetes provider.
[ "Provider", "returns", "an", "implementation", "of", "the", "Kubernetes", "provider", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/kubeform/pkg/provider/provider.go#L47-L56
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go
AddResourceAlias
func (m *DefaultRESTMapper) AddResourceAlias(alias string, resources ...string) { if len(resources) == 0 { return } aliasToResource[alias] = resources }
go
func (m *DefaultRESTMapper) AddResourceAlias(alias string, resources ...string) { if len(resources) == 0 { return } aliasToResource[alias] = resources }
[ "func", "(", "m", "*", "DefaultRESTMapper", ")", "AddResourceAlias", "(", "alias", "string", ",", "resources", "...", "string", ")", "{", "if", "len", "(", "resources", ")", "==", "0", "{", "return", "\n", "}", "\n", "aliasToResource", "[", "alias", "]", "=", "resources", "\n", "}" ]
// AddResourceAlias maps aliases to resources
[ "AddResourceAlias", "maps", "aliases", "to", "resources" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go#L487-L492
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go
AliasesForResource
func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool) { if res, ok := aliasToResource[alias]; ok { return res, true } return nil, false }
go
func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool) { if res, ok := aliasToResource[alias]; ok { return res, true } return nil, false }
[ "func", "(", "m", "*", "DefaultRESTMapper", ")", "AliasesForResource", "(", "alias", "string", ")", "(", "[", "]", "string", ",", "bool", ")", "{", "if", "res", ",", "ok", ":=", "aliasToResource", "[", "alias", "]", ";", "ok", "{", "return", "res", ",", "true", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
// AliasesForResource returns whether a resource has an alias or not
[ "AliasesForResource", "returns", "whether", "a", "resource", "has", "an", "alias", "or", "not" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go#L495-L500
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go
ResourceIsValid
func (m *DefaultRESTMapper) ResourceIsValid(resource unversioned.GroupVersionResource) bool { _, err := m.KindFor(resource) return err == nil }
go
func (m *DefaultRESTMapper) ResourceIsValid(resource unversioned.GroupVersionResource) bool { _, err := m.KindFor(resource) return err == nil }
[ "func", "(", "m", "*", "DefaultRESTMapper", ")", "ResourceIsValid", "(", "resource", "unversioned", ".", "GroupVersionResource", ")", "bool", "{", "_", ",", "err", ":=", "m", ".", "KindFor", "(", "resource", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// ResourceIsValid takes a partial resource and checks if it's valid
[ "ResourceIsValid", "takes", "a", "partial", "resource", "and", "checks", "if", "it", "s", "valid" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go#L503-L506
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go
AliasesForResource
func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok bool) { for _, t := range m { if aliases, ok = t.AliasesForResource(alias); ok { return } } return nil, false }
go
func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok bool) { for _, t := range m { if aliases, ok = t.AliasesForResource(alias); ok { return } } return nil, false }
[ "func", "(", "m", "MultiRESTMapper", ")", "AliasesForResource", "(", "alias", "string", ")", "(", "aliases", "[", "]", "string", ",", "ok", "bool", ")", "{", "for", "_", ",", "t", ":=", "range", "m", "{", "if", "aliases", ",", "ok", "=", "t", ".", "AliasesForResource", "(", "alias", ")", ";", "ok", "{", "return", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "false", "\n", "}" ]
// AliasesForResource finds the first alias response for the provided mappers.
[ "AliasesForResource", "finds", "the", "first", "alias", "response", "for", "the", "provided", "mappers", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/meta/restmapper.go#L581-L588
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go
PollInfinite
func PollInfinite(interval time.Duration, condition ConditionFunc) error { done := make(chan struct{}) defer close(done) return WaitFor(poller(interval, 0), condition, done) }
go
func PollInfinite(interval time.Duration, condition ConditionFunc) error { done := make(chan struct{}) defer close(done) return WaitFor(poller(interval, 0), condition, done) }
[ "func", "PollInfinite", "(", "interval", "time", ".", "Duration", ",", "condition", "ConditionFunc", ")", "error", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "defer", "close", "(", "done", ")", "\n", "return", "WaitFor", "(", "poller", "(", "interval", ",", "0", ")", ",", "condition", ",", "done", ")", "\n", "}" ]
// PollInfinite polls forever.
[ "PollInfinite", "polls", "forever", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go#L162-L166
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/backoff.go
IsInBackOffSince
func (p *Backoff) IsInBackOffSince(id string, eventTime time.Time) bool { p.Lock() defer p.Unlock() entry, ok := p.perItemBackoff[id] if !ok { return false } if hasExpired(eventTime, entry.lastUpdate, p.maxDuration) { return false } return p.Clock.Now().Sub(eventTime) < entry.backoff }
go
func (p *Backoff) IsInBackOffSince(id string, eventTime time.Time) bool { p.Lock() defer p.Unlock() entry, ok := p.perItemBackoff[id] if !ok { return false } if hasExpired(eventTime, entry.lastUpdate, p.maxDuration) { return false } return p.Clock.Now().Sub(eventTime) < entry.backoff }
[ "func", "(", "p", "*", "Backoff", ")", "IsInBackOffSince", "(", "id", "string", ",", "eventTime", "time", ".", "Time", ")", "bool", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "entry", ",", "ok", ":=", "p", ".", "perItemBackoff", "[", "id", "]", "\n", "if", "!", "ok", "{", "return", "false", "\n", "}", "\n", "if", "hasExpired", "(", "eventTime", ",", "entry", ".", "lastUpdate", ",", "p", ".", "maxDuration", ")", "{", "return", "false", "\n", "}", "\n", "return", "p", ".", "Clock", ".", "Now", "(", ")", ".", "Sub", "(", "eventTime", ")", "<", "entry", ".", "backoff", "\n", "}" ]
// Returns True if the elapsed time since eventTime is smaller than the current backoff window
[ "Returns", "True", "if", "the", "elapsed", "time", "since", "eventTime", "is", "smaller", "than", "the", "current", "backoff", "window" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/backoff.go#L81-L92
train
kubernetes-retired/contrib
release-notes/Godeps/_workspace/src/golang.org/x/oauth2/oauth2.go
TokenSource
func (c *Config) TokenSource(ctx context.Context, t *Token) TokenSource { tkr := &tokenRefresher{ ctx: ctx, conf: c, } if t != nil { tkr.refreshToken = t.RefreshToken } return &reuseTokenSource{ t: t, new: tkr, } }
go
func (c *Config) TokenSource(ctx context.Context, t *Token) TokenSource { tkr := &tokenRefresher{ ctx: ctx, conf: c, } if t != nil { tkr.refreshToken = t.RefreshToken } return &reuseTokenSource{ t: t, new: tkr, } }
[ "func", "(", "c", "*", "Config", ")", "TokenSource", "(", "ctx", "context", ".", "Context", ",", "t", "*", "Token", ")", "TokenSource", "{", "tkr", ":=", "&", "tokenRefresher", "{", "ctx", ":", "ctx", ",", "conf", ":", "c", ",", "}", "\n", "if", "t", "!=", "nil", "{", "tkr", ".", "refreshToken", "=", "t", ".", "RefreshToken", "\n", "}", "\n", "return", "&", "reuseTokenSource", "{", "t", ":", "t", ",", "new", ":", "tkr", ",", "}", "\n", "}" ]
// TokenSource returns a TokenSource that returns t until t expires, // automatically refreshing it as necessary using the provided context. // // Most users will use Config.Client instead.
[ "TokenSource", "returns", "a", "TokenSource", "that", "returns", "t", "until", "t", "expires", "automatically", "refreshing", "it", "as", "necessary", "using", "the", "provided", "context", ".", "Most", "users", "will", "use", "Config", ".", "Client", "instead", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/release-notes/Godeps/_workspace/src/golang.org/x/oauth2/oauth2.go#L183-L195
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go
buildDataSignedForAuth
func buildDataSignedForAuth(sessionId []byte, req userAuthRequestMsg, algo, pubKey []byte) []byte { data := struct { Session []byte Type byte User string Service string Method string Sign bool Algo []byte PubKey []byte }{ sessionId, msgUserAuthRequest, req.User, req.Service, req.Method, true, algo, pubKey, } return Marshal(data) }
go
func buildDataSignedForAuth(sessionId []byte, req userAuthRequestMsg, algo, pubKey []byte) []byte { data := struct { Session []byte Type byte User string Service string Method string Sign bool Algo []byte PubKey []byte }{ sessionId, msgUserAuthRequest, req.User, req.Service, req.Method, true, algo, pubKey, } return Marshal(data) }
[ "func", "buildDataSignedForAuth", "(", "sessionId", "[", "]", "byte", ",", "req", "userAuthRequestMsg", ",", "algo", ",", "pubKey", "[", "]", "byte", ")", "[", "]", "byte", "{", "data", ":=", "struct", "{", "Session", "[", "]", "byte", "\n", "Type", "byte", "\n", "User", "string", "\n", "Service", "string", "\n", "Method", "string", "\n", "Sign", "bool", "\n", "Algo", "[", "]", "byte", "\n", "PubKey", "[", "]", "byte", "\n", "}", "{", "sessionId", ",", "msgUserAuthRequest", ",", "req", ".", "User", ",", "req", ".", "Service", ",", "req", ".", "Method", ",", "true", ",", "algo", ",", "pubKey", ",", "}", "\n", "return", "Marshal", "(", "data", ")", "\n", "}" ]
// buildDataSignedForAuth returns the data that is signed in order to prove // possession of a private key. See RFC 4252, section 7.
[ "buildDataSignedForAuth", "returns", "the", "data", "that", "is", "signed", "in", "order", "to", "prove", "possession", "of", "a", "private", "key", ".", "See", "RFC", "4252", "section", "7", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go#L237-L258
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go
add
func (w *window) add(win uint32) bool { // a zero sized window adjust is a noop. if win == 0 { return true } w.L.Lock() if w.win+win < win { w.L.Unlock() return false } w.win += win // It is unusual that multiple goroutines would be attempting to reserve // window space, but not guaranteed. Use broadcast to notify all waiters // that additional window is available. w.Broadcast() w.L.Unlock() return true }
go
func (w *window) add(win uint32) bool { // a zero sized window adjust is a noop. if win == 0 { return true } w.L.Lock() if w.win+win < win { w.L.Unlock() return false } w.win += win // It is unusual that multiple goroutines would be attempting to reserve // window space, but not guaranteed. Use broadcast to notify all waiters // that additional window is available. w.Broadcast() w.L.Unlock() return true }
[ "func", "(", "w", "*", "window", ")", "add", "(", "win", "uint32", ")", "bool", "{", "// a zero sized window adjust is a noop.", "if", "win", "==", "0", "{", "return", "true", "\n", "}", "\n", "w", ".", "L", ".", "Lock", "(", ")", "\n", "if", "w", ".", "win", "+", "win", "<", "win", "{", "w", ".", "L", ".", "Unlock", "(", ")", "\n", "return", "false", "\n", "}", "\n", "w", ".", "win", "+=", "win", "\n", "// It is unusual that multiple goroutines would be attempting to reserve", "// window space, but not guaranteed. Use broadcast to notify all waiters", "// that additional window is available.", "w", ".", "Broadcast", "(", ")", "\n", "w", ".", "L", ".", "Unlock", "(", ")", "\n", "return", "true", "\n", "}" ]
// add adds win to the amount of window available // for consumers.
[ "add", "adds", "win", "to", "the", "amount", "of", "window", "available", "for", "consumers", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go#L306-L323
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go
close
func (w *window) close() { w.L.Lock() w.closed = true w.Broadcast() w.L.Unlock() }
go
func (w *window) close() { w.L.Lock() w.closed = true w.Broadcast() w.L.Unlock() }
[ "func", "(", "w", "*", "window", ")", "close", "(", ")", "{", "w", ".", "L", ".", "Lock", "(", ")", "\n", "w", ".", "closed", "=", "true", "\n", "w", ".", "Broadcast", "(", ")", "\n", "w", ".", "L", ".", "Unlock", "(", ")", "\n", "}" ]
// close sets the window to closed, so all reservations fail // immediately.
[ "close", "sets", "the", "window", "to", "closed", "so", "all", "reservations", "fail", "immediately", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go#L327-L332
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go
reserve
func (w *window) reserve(win uint32) (uint32, error) { var err error w.L.Lock() w.writeWaiters++ w.Broadcast() for w.win == 0 && !w.closed { w.Wait() } w.writeWaiters-- if w.win < win { win = w.win } w.win -= win if w.closed { err = io.EOF } w.L.Unlock() return win, err }
go
func (w *window) reserve(win uint32) (uint32, error) { var err error w.L.Lock() w.writeWaiters++ w.Broadcast() for w.win == 0 && !w.closed { w.Wait() } w.writeWaiters-- if w.win < win { win = w.win } w.win -= win if w.closed { err = io.EOF } w.L.Unlock() return win, err }
[ "func", "(", "w", "*", "window", ")", "reserve", "(", "win", "uint32", ")", "(", "uint32", ",", "error", ")", "{", "var", "err", "error", "\n", "w", ".", "L", ".", "Lock", "(", ")", "\n", "w", ".", "writeWaiters", "++", "\n", "w", ".", "Broadcast", "(", ")", "\n", "for", "w", ".", "win", "==", "0", "&&", "!", "w", ".", "closed", "{", "w", ".", "Wait", "(", ")", "\n", "}", "\n", "w", ".", "writeWaiters", "--", "\n", "if", "w", ".", "win", "<", "win", "{", "win", "=", "w", ".", "win", "\n", "}", "\n", "w", ".", "win", "-=", "win", "\n", "if", "w", ".", "closed", "{", "err", "=", "io", ".", "EOF", "\n", "}", "\n", "w", ".", "L", ".", "Unlock", "(", ")", "\n", "return", "win", ",", "err", "\n", "}" ]
// reserve reserves win from the available window capacity. // If no capacity remains, reserve will block. reserve may // return less than requested.
[ "reserve", "reserves", "win", "from", "the", "available", "window", "capacity", ".", "If", "no", "capacity", "remains", "reserve", "will", "block", ".", "reserve", "may", "return", "less", "than", "requested", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go#L337-L355
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go
waitWriterBlocked
func (w *window) waitWriterBlocked() { w.Cond.L.Lock() for w.writeWaiters == 0 { w.Cond.Wait() } w.Cond.L.Unlock() }
go
func (w *window) waitWriterBlocked() { w.Cond.L.Lock() for w.writeWaiters == 0 { w.Cond.Wait() } w.Cond.L.Unlock() }
[ "func", "(", "w", "*", "window", ")", "waitWriterBlocked", "(", ")", "{", "w", ".", "Cond", ".", "L", ".", "Lock", "(", ")", "\n", "for", "w", ".", "writeWaiters", "==", "0", "{", "w", ".", "Cond", ".", "Wait", "(", ")", "\n", "}", "\n", "w", ".", "Cond", ".", "L", ".", "Unlock", "(", ")", "\n", "}" ]
// waitWriterBlocked waits until some goroutine is blocked for further // writes. It is used in tests only.
[ "waitWriterBlocked", "waits", "until", "some", "goroutine", "is", "blocked", "for", "further", "writes", ".", "It", "is", "used", "in", "tests", "only", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/golang.org/x/crypto/ssh/common.go#L359-L365
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go
FromObject
func FromObject(obj runtime.Object) error { switch t := obj.(type) { case *unversioned.Status: return &StatusError{*t} } return &UnexpectedObjectError{obj} }
go
func FromObject(obj runtime.Object) error { switch t := obj.(type) { case *unversioned.Status: return &StatusError{*t} } return &UnexpectedObjectError{obj} }
[ "func", "FromObject", "(", "obj", "runtime", ".", "Object", ")", "error", "{", "switch", "t", ":=", "obj", ".", "(", "type", ")", "{", "case", "*", "unversioned", ".", "Status", ":", "return", "&", "StatusError", "{", "*", "t", "}", "\n", "}", "\n", "return", "&", "UnexpectedObjectError", "{", "obj", "}", "\n", "}" ]
// FromObject generates an StatusError from an unversioned.Status, if that is the type of obj; otherwise, // returns an UnexpecteObjectError.
[ "FromObject", "generates", "an", "StatusError", "from", "an", "unversioned", ".", "Status", "if", "that", "is", "the", "type", "of", "obj", ";", "otherwise", "returns", "an", "UnexpecteObjectError", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go#L87-L93
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go
NewUnauthorized
func NewUnauthorized(reason string) error { message := reason if len(message) == 0 { message = "not authorized" } return &StatusError{unversioned.Status{ Status: unversioned.StatusFailure, Code: http.StatusUnauthorized, Reason: unversioned.StatusReasonUnauthorized, Message: message, }} }
go
func NewUnauthorized(reason string) error { message := reason if len(message) == 0 { message = "not authorized" } return &StatusError{unversioned.Status{ Status: unversioned.StatusFailure, Code: http.StatusUnauthorized, Reason: unversioned.StatusReasonUnauthorized, Message: message, }} }
[ "func", "NewUnauthorized", "(", "reason", "string", ")", "error", "{", "message", ":=", "reason", "\n", "if", "len", "(", "message", ")", "==", "0", "{", "message", "=", "\"", "\"", "\n", "}", "\n", "return", "&", "StatusError", "{", "unversioned", ".", "Status", "{", "Status", ":", "unversioned", ".", "StatusFailure", ",", "Code", ":", "http", ".", "StatusUnauthorized", ",", "Reason", ":", "unversioned", ".", "StatusReasonUnauthorized", ",", "Message", ":", "message", ",", "}", "}", "\n", "}" ]
// NewUnauthorized returns an error indicating the client is not authorized to perform the requested // action.
[ "NewUnauthorized", "returns", "an", "error", "indicating", "the", "client", "is", "not", "authorized", "to", "perform", "the", "requested", "action", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go#L127-L138
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go
SuggestsClientDelay
func SuggestsClientDelay(err error) (int, bool) { switch t := err.(type) { case APIStatus: if t.Status().Details != nil { switch t.Status().Reason { case unversioned.StatusReasonServerTimeout, unversioned.StatusReasonTimeout: return int(t.Status().Details.RetryAfterSeconds), true } } } return 0, false }
go
func SuggestsClientDelay(err error) (int, bool) { switch t := err.(type) { case APIStatus: if t.Status().Details != nil { switch t.Status().Reason { case unversioned.StatusReasonServerTimeout, unversioned.StatusReasonTimeout: return int(t.Status().Details.RetryAfterSeconds), true } } } return 0, false }
[ "func", "SuggestsClientDelay", "(", "err", "error", ")", "(", "int", ",", "bool", ")", "{", "switch", "t", ":=", "err", ".", "(", "type", ")", "{", "case", "APIStatus", ":", "if", "t", ".", "Status", "(", ")", ".", "Details", "!=", "nil", "{", "switch", "t", ".", "Status", "(", ")", ".", "Reason", "{", "case", "unversioned", ".", "StatusReasonServerTimeout", ",", "unversioned", ".", "StatusReasonTimeout", ":", "return", "int", "(", "t", ".", "Status", "(", ")", ".", "Details", ".", "RetryAfterSeconds", ")", ",", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "0", ",", "false", "\n", "}" ]
// SuggestsClientDelay returns true if this error suggests a client delay as well as the // suggested seconds to wait, or false if the error does not imply a wait.
[ "SuggestsClientDelay", "returns", "true", "if", "this", "error", "suggests", "a", "client", "delay", "as", "well", "as", "the", "suggested", "seconds", "to", "wait", "or", "false", "if", "the", "error", "does", "not", "imply", "a", "wait", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/errors/errors.go#L437-L448
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go
SubResource
func (r *Request) SubResource(subresources ...string) *Request { if r.err != nil { return r } subresource := path.Join(subresources...) if len(r.subresource) != 0 { r.err = fmt.Errorf("subresource already set to %q, cannot change to %q", r.resource, subresource) return r } for _, s := range subresources { if ok, msg := validation.IsValidPathSegmentName(s); !ok { r.err = fmt.Errorf("invalid subresource %q: %s", s, msg) return r } } r.subresource = subresource return r }
go
func (r *Request) SubResource(subresources ...string) *Request { if r.err != nil { return r } subresource := path.Join(subresources...) if len(r.subresource) != 0 { r.err = fmt.Errorf("subresource already set to %q, cannot change to %q", r.resource, subresource) return r } for _, s := range subresources { if ok, msg := validation.IsValidPathSegmentName(s); !ok { r.err = fmt.Errorf("invalid subresource %q: %s", s, msg) return r } } r.subresource = subresource return r }
[ "func", "(", "r", "*", "Request", ")", "SubResource", "(", "subresources", "...", "string", ")", "*", "Request", "{", "if", "r", ".", "err", "!=", "nil", "{", "return", "r", "\n", "}", "\n", "subresource", ":=", "path", ".", "Join", "(", "subresources", "...", ")", "\n", "if", "len", "(", "r", ".", "subresource", ")", "!=", "0", "{", "r", ".", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "r", ".", "resource", ",", "subresource", ")", "\n", "return", "r", "\n", "}", "\n", "for", "_", ",", "s", ":=", "range", "subresources", "{", "if", "ok", ",", "msg", ":=", "validation", ".", "IsValidPathSegmentName", "(", "s", ")", ";", "!", "ok", "{", "r", ".", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ",", "msg", ")", "\n", "return", "r", "\n", "}", "\n", "}", "\n", "r", ".", "subresource", "=", "subresource", "\n", "return", "r", "\n", "}" ]
// SubResource sets a sub-resource path which can be multiple segments segment after the resource // name but before the suffix.
[ "SubResource", "sets", "a", "sub", "-", "resource", "path", "which", "can", "be", "multiple", "segments", "segment", "after", "the", "resource", "name", "but", "before", "the", "suffix", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go#L189-L206
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go
UintParam
func (r *Request) UintParam(paramName string, u uint64) *Request { if r.err != nil { return r } return r.setParam(paramName, strconv.FormatUint(u, 10)) }
go
func (r *Request) UintParam(paramName string, u uint64) *Request { if r.err != nil { return r } return r.setParam(paramName, strconv.FormatUint(u, 10)) }
[ "func", "(", "r", "*", "Request", ")", "UintParam", "(", "paramName", "string", ",", "u", "uint64", ")", "*", "Request", "{", "if", "r", ".", "err", "!=", "nil", "{", "return", "r", "\n", "}", "\n", "return", "r", ".", "setParam", "(", "paramName", ",", "strconv", ".", "FormatUint", "(", "u", ",", "10", ")", ")", "\n", "}" ]
// UintParam creates a query parameter with the given value.
[ "UintParam", "creates", "a", "query", "parameter", "with", "the", "given", "value", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go#L421-L426
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go
checkWait
func checkWait(resp *http.Response) (int, bool) { switch r := resp.StatusCode; { // any 500 error code and 429 can trigger a wait case r == errors.StatusTooManyRequests, r >= 500: default: return 0, false } i, ok := retryAfterSeconds(resp) return i, ok }
go
func checkWait(resp *http.Response) (int, bool) { switch r := resp.StatusCode; { // any 500 error code and 429 can trigger a wait case r == errors.StatusTooManyRequests, r >= 500: default: return 0, false } i, ok := retryAfterSeconds(resp) return i, ok }
[ "func", "checkWait", "(", "resp", "*", "http", ".", "Response", ")", "(", "int", ",", "bool", ")", "{", "switch", "r", ":=", "resp", ".", "StatusCode", ";", "{", "// any 500 error code and 429 can trigger a wait", "case", "r", "==", "errors", ".", "StatusTooManyRequests", ",", "r", ">=", "500", ":", "default", ":", "return", "0", ",", "false", "\n", "}", "\n", "i", ",", "ok", ":=", "retryAfterSeconds", "(", "resp", ")", "\n", "return", "i", ",", "ok", "\n", "}" ]
// checkWait returns true along with a number of seconds if the server instructed us to wait // before retrying.
[ "checkWait", "returns", "true", "along", "with", "a", "number", "of", "seconds", "if", "the", "server", "instructed", "us", "to", "wait", "before", "retrying", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/request.go#L969-L978
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/keymutex/keymutex.go
UnlockKey
func (km *keyMutex) UnlockKey(id string) error { glog.V(5).Infof("UnlockKey(...) called for id %q\r\n", id) km.RLock() defer km.RUnlock() mutex, exists := km.mutexMap[id] if !exists { return fmt.Errorf("id %q not found", id) } glog.V(5).Infof("UnlockKey(...) for id. Mutex found, trying to unlock it. %q\r\n", id) mutex.Unlock() glog.V(5).Infof("UnlockKey(...) for id %q completed.\r\n", id) return nil }
go
func (km *keyMutex) UnlockKey(id string) error { glog.V(5).Infof("UnlockKey(...) called for id %q\r\n", id) km.RLock() defer km.RUnlock() mutex, exists := km.mutexMap[id] if !exists { return fmt.Errorf("id %q not found", id) } glog.V(5).Infof("UnlockKey(...) for id. Mutex found, trying to unlock it. %q\r\n", id) mutex.Unlock() glog.V(5).Infof("UnlockKey(...) for id %q completed.\r\n", id) return nil }
[ "func", "(", "km", "*", "keyMutex", ")", "UnlockKey", "(", "id", "string", ")", "error", "{", "glog", ".", "V", "(", "5", ")", ".", "Infof", "(", "\"", "\\r", "\\n", "\"", ",", "id", ")", "\n", "km", ".", "RLock", "(", ")", "\n", "defer", "km", ".", "RUnlock", "(", ")", "\n", "mutex", ",", "exists", ":=", "km", ".", "mutexMap", "[", "id", "]", "\n", "if", "!", "exists", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "id", ")", "\n", "}", "\n", "glog", ".", "V", "(", "5", ")", ".", "Infof", "(", "\"", "\\r", "\\n", "\"", ",", "id", ")", "\n\n", "mutex", ".", "Unlock", "(", ")", "\n", "glog", ".", "V", "(", "5", ")", ".", "Infof", "(", "\"", "\\r", "\\n", "\"", ",", "id", ")", "\n", "return", "nil", "\n", "}" ]
// Releases the lock associated with the specified ID. // Returns an error if the specified ID doesn't exist.
[ "Releases", "the", "lock", "associated", "with", "the", "specified", "ID", ".", "Returns", "an", "error", "if", "the", "specified", "ID", "doesn", "t", "exist", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/keymutex/keymutex.go#L57-L70
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/keymutex/keymutex.go
getOrCreateLock
func (km *keyMutex) getOrCreateLock(id string) *sync.Mutex { km.Lock() defer km.Unlock() if _, exists := km.mutexMap[id]; !exists { km.mutexMap[id] = &sync.Mutex{} } return km.mutexMap[id] }
go
func (km *keyMutex) getOrCreateLock(id string) *sync.Mutex { km.Lock() defer km.Unlock() if _, exists := km.mutexMap[id]; !exists { km.mutexMap[id] = &sync.Mutex{} } return km.mutexMap[id] }
[ "func", "(", "km", "*", "keyMutex", ")", "getOrCreateLock", "(", "id", "string", ")", "*", "sync", ".", "Mutex", "{", "km", ".", "Lock", "(", ")", "\n", "defer", "km", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "exists", ":=", "km", ".", "mutexMap", "[", "id", "]", ";", "!", "exists", "{", "km", ".", "mutexMap", "[", "id", "]", "=", "&", "sync", ".", "Mutex", "{", "}", "\n", "}", "\n\n", "return", "km", ".", "mutexMap", "[", "id", "]", "\n", "}" ]
// Returns lock associated with the specified ID, or creates the lock if one doesn't already exist.
[ "Returns", "lock", "associated", "with", "the", "specified", "ID", "or", "creates", "the", "lock", "if", "one", "doesn", "t", "already", "exist", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/keymutex/keymutex.go#L73-L82
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
NewDockerHelper
func NewDockerHelper(client *docker.Client) *DockerHelper { return &DockerHelper{ client: client, errStats: newErrorStats(), } }
go
func NewDockerHelper(client *docker.Client) *DockerHelper { return &DockerHelper{ client: client, errStats: newErrorStats(), } }
[ "func", "NewDockerHelper", "(", "client", "*", "docker", ".", "Client", ")", "*", "DockerHelper", "{", "return", "&", "DockerHelper", "{", "client", ":", "client", ",", "errStats", ":", "newErrorStats", "(", ")", ",", "}", "\n", "}" ]
// NewDockerHelper creates and returns a new DockerHelper
[ "NewDockerHelper", "creates", "and", "returns", "a", "new", "DockerHelper" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L61-L66
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
GetContainerIDs
func (d *DockerHelper) GetContainerIDs() []string { containerIDs := []string{} containers, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: true}) if err != nil { panic(fmt.Sprintf("Error list containers: %v", err)) } for _, container := range containers { containerIDs = append(containerIDs, container.ID) } return containerIDs }
go
func (d *DockerHelper) GetContainerIDs() []string { containerIDs := []string{} containers, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: true}) if err != nil { panic(fmt.Sprintf("Error list containers: %v", err)) } for _, container := range containers { containerIDs = append(containerIDs, container.ID) } return containerIDs }
[ "func", "(", "d", "*", "DockerHelper", ")", "GetContainerIDs", "(", ")", "[", "]", "string", "{", "containerIDs", ":=", "[", "]", "string", "{", "}", "\n", "containers", ",", "err", ":=", "d", ".", "client", ".", "ContainerList", "(", "getContext", "(", ")", ",", "types", ".", "ContainerListOptions", "{", "All", ":", "true", "}", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n", "for", "_", ",", "container", ":=", "range", "containers", "{", "containerIDs", "=", "append", "(", "containerIDs", ",", "container", ".", "ID", ")", "\n", "}", "\n", "return", "containerIDs", "\n", "}" ]
// GetContainerIDs returns all the container ids in the system, panics when error occurs
[ "GetContainerIDs", "returns", "all", "the", "container", "ids", "in", "the", "system", "panics", "when", "error", "occurs" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L94-L104
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
GetContainerNum
func (d *DockerHelper) GetContainerNum(all bool) int { containers, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: all}) if err != nil { panic(fmt.Sprintf("Error list containers: %v", err)) } return len(containers) }
go
func (d *DockerHelper) GetContainerNum(all bool) int { containers, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: all}) if err != nil { panic(fmt.Sprintf("Error list containers: %v", err)) } return len(containers) }
[ "func", "(", "d", "*", "DockerHelper", ")", "GetContainerNum", "(", "all", "bool", ")", "int", "{", "containers", ",", "err", ":=", "d", ".", "client", ".", "ContainerList", "(", "getContext", "(", ")", ",", "types", ".", "ContainerListOptions", "{", "All", ":", "all", "}", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n", "return", "len", "(", "containers", ")", "\n", "}" ]
// GetContainerNum returns container number in the system, panics when error occurs
[ "GetContainerNum", "returns", "container", "number", "in", "the", "system", "panics", "when", "error", "occurs" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L107-L113
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
CreateContainers
func (d *DockerHelper) CreateContainers(num int) []string { ids := []string{} for i := 0; i < num; i++ { name := newContainerName() cfg := &container.Config{ AttachStderr: false, AttachStdin: false, AttachStdout: false, Tty: true, Cmd: strslice.StrSlice([]string{TestCommand}), Image: TestImage, } container, err := d.client.ContainerCreate(getContext(), cfg, &container.HostConfig{}, &network.NetworkingConfig{}, name) ids = append(ids, container.ID) d.errStats.add("create containers", err) } return ids }
go
func (d *DockerHelper) CreateContainers(num int) []string { ids := []string{} for i := 0; i < num; i++ { name := newContainerName() cfg := &container.Config{ AttachStderr: false, AttachStdin: false, AttachStdout: false, Tty: true, Cmd: strslice.StrSlice([]string{TestCommand}), Image: TestImage, } container, err := d.client.ContainerCreate(getContext(), cfg, &container.HostConfig{}, &network.NetworkingConfig{}, name) ids = append(ids, container.ID) d.errStats.add("create containers", err) } return ids }
[ "func", "(", "d", "*", "DockerHelper", ")", "CreateContainers", "(", "num", "int", ")", "[", "]", "string", "{", "ids", ":=", "[", "]", "string", "{", "}", "\n", "for", "i", ":=", "0", ";", "i", "<", "num", ";", "i", "++", "{", "name", ":=", "newContainerName", "(", ")", "\n", "cfg", ":=", "&", "container", ".", "Config", "{", "AttachStderr", ":", "false", ",", "AttachStdin", ":", "false", ",", "AttachStdout", ":", "false", ",", "Tty", ":", "true", ",", "Cmd", ":", "strslice", ".", "StrSlice", "(", "[", "]", "string", "{", "TestCommand", "}", ")", ",", "Image", ":", "TestImage", ",", "}", "\n", "container", ",", "err", ":=", "d", ".", "client", ".", "ContainerCreate", "(", "getContext", "(", ")", ",", "cfg", ",", "&", "container", ".", "HostConfig", "{", "}", ",", "&", "network", ".", "NetworkingConfig", "{", "}", ",", "name", ")", "\n", "ids", "=", "append", "(", "ids", ",", "container", ".", "ID", ")", "\n", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "ids", "\n", "}" ]
// CreateContainers creates num of containers, returns a slice of container ids
[ "CreateContainers", "creates", "num", "of", "containers", "returns", "a", "slice", "of", "container", "ids" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L116-L133
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
StartContainers
func (d *DockerHelper) StartContainers(ids []string) { for _, id := range ids { d.errStats.add("start containers", d.client.ContainerStart(getContext(), id)) } }
go
func (d *DockerHelper) StartContainers(ids []string) { for _, id := range ids { d.errStats.add("start containers", d.client.ContainerStart(getContext(), id)) } }
[ "func", "(", "d", "*", "DockerHelper", ")", "StartContainers", "(", "ids", "[", "]", "string", ")", "{", "for", "_", ",", "id", ":=", "range", "ids", "{", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "d", ".", "client", ".", "ContainerStart", "(", "getContext", "(", ")", ",", "id", ")", ")", "\n", "}", "\n", "}" ]
// StartContainers starts all the containers in ids slice
[ "StartContainers", "starts", "all", "the", "containers", "in", "ids", "slice" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L136-L140
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
StopContainers
func (d *DockerHelper) StopContainers(ids []string) { for _, id := range ids { d.errStats.add("stop containers", d.client.ContainerStop(getContext(), id, 10)) } }
go
func (d *DockerHelper) StopContainers(ids []string) { for _, id := range ids { d.errStats.add("stop containers", d.client.ContainerStop(getContext(), id, 10)) } }
[ "func", "(", "d", "*", "DockerHelper", ")", "StopContainers", "(", "ids", "[", "]", "string", ")", "{", "for", "_", ",", "id", ":=", "range", "ids", "{", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "d", ".", "client", ".", "ContainerStop", "(", "getContext", "(", ")", ",", "id", ",", "10", ")", ")", "\n", "}", "\n", "}" ]
// StopContainers stops all the containers in ids slice
[ "StopContainers", "stops", "all", "the", "containers", "in", "ids", "slice" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L143-L147
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
RemoveContainers
func (d *DockerHelper) RemoveContainers(ids []string) { for _, id := range ids { d.errStats.add("remove containers", d.client.ContainerRemove(getContext(), id, types.ContainerRemoveOptions{})) } }
go
func (d *DockerHelper) RemoveContainers(ids []string) { for _, id := range ids { d.errStats.add("remove containers", d.client.ContainerRemove(getContext(), id, types.ContainerRemoveOptions{})) } }
[ "func", "(", "d", "*", "DockerHelper", ")", "RemoveContainers", "(", "ids", "[", "]", "string", ")", "{", "for", "_", ",", "id", ":=", "range", "ids", "{", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "d", ".", "client", ".", "ContainerRemove", "(", "getContext", "(", ")", ",", "id", ",", "types", ".", "ContainerRemoveOptions", "{", "}", ")", ")", "\n", "}", "\n", "}" ]
// RemoveContainers removes all the containers in ids slice
[ "RemoveContainers", "removes", "all", "the", "containers", "in", "ids", "slice" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L150-L154
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
CreateAliveContainers
func (d *DockerHelper) CreateAliveContainers(num int) []string { ids := d.CreateContainers(num) d.StartContainers(ids) return ids }
go
func (d *DockerHelper) CreateAliveContainers(num int) []string { ids := d.CreateContainers(num) d.StartContainers(ids) return ids }
[ "func", "(", "d", "*", "DockerHelper", ")", "CreateAliveContainers", "(", "num", "int", ")", "[", "]", "string", "{", "ids", ":=", "d", ".", "CreateContainers", "(", "num", ")", "\n", "d", ".", "StartContainers", "(", "ids", ")", "\n", "return", "ids", "\n", "}" ]
// CreateAliveContainers creates num of containers and also starts them, returns a slice of container ids
[ "CreateAliveContainers", "creates", "num", "of", "containers", "and", "also", "starts", "them", "returns", "a", "slice", "of", "container", "ids" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L162-L166
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoListContainerBenchmark
func (d *DockerHelper) DoListContainerBenchmark(interval, testPeriod time.Duration, listAll bool) []int { startTime := time.Now() latencies := []int{} for { start := time.Now() _, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: listAll}) d.errStats.add("list containers", err) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } if interval != 0 { time.Sleep(interval) } } return latencies }
go
func (d *DockerHelper) DoListContainerBenchmark(interval, testPeriod time.Duration, listAll bool) []int { startTime := time.Now() latencies := []int{} for { start := time.Now() _, err := d.client.ContainerList(getContext(), types.ContainerListOptions{All: listAll}) d.errStats.add("list containers", err) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } if interval != 0 { time.Sleep(interval) } } return latencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoListContainerBenchmark", "(", "interval", ",", "testPeriod", "time", ".", "Duration", ",", "listAll", "bool", ")", "[", "]", "int", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "latencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n", "_", ",", "err", ":=", "d", ".", "client", ".", "ContainerList", "(", "getContext", "(", ")", ",", "types", ".", "ContainerListOptions", "{", "All", ":", "listAll", "}", ")", "\n", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "err", ")", "\n", "latencies", "=", "append", "(", "latencies", ",", "int", "(", "time", ".", "Since", "(", "start", ")", ".", "Nanoseconds", "(", ")", ")", ")", "\n", "if", "time", ".", "Now", "(", ")", ".", "Sub", "(", "startTime", ")", ">=", "testPeriod", "{", "break", "\n", "}", "\n", "if", "interval", "!=", "0", "{", "time", ".", "Sleep", "(", "interval", ")", "\n", "}", "\n", "}", "\n", "return", "latencies", "\n", "}" ]
// DoListContainerBenchmark does periodically ListContainers with specific interval, returns latencies of // all the calls in nanoseconds
[ "DoListContainerBenchmark", "does", "periodically", "ListContainers", "with", "specific", "interval", "returns", "latencies", "of", "all", "the", "calls", "in", "nanoseconds" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L170-L186
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoInspectContainerBenchmark
func (d *DockerHelper) DoInspectContainerBenchmark(interval, testPeriod time.Duration, containerIDs []string) []int { startTime := time.Now() latencies := []int{} rand.Seed(time.Now().Unix()) for { containerID := containerIDs[rand.Int()%len(containerIDs)] start := time.Now() _, err := d.client.ContainerInspect(getContext(), containerID) d.errStats.add("inspect container", err) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } if interval != 0 { time.Sleep(interval) } } return latencies }
go
func (d *DockerHelper) DoInspectContainerBenchmark(interval, testPeriod time.Duration, containerIDs []string) []int { startTime := time.Now() latencies := []int{} rand.Seed(time.Now().Unix()) for { containerID := containerIDs[rand.Int()%len(containerIDs)] start := time.Now() _, err := d.client.ContainerInspect(getContext(), containerID) d.errStats.add("inspect container", err) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } if interval != 0 { time.Sleep(interval) } } return latencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoInspectContainerBenchmark", "(", "interval", ",", "testPeriod", "time", ".", "Duration", ",", "containerIDs", "[", "]", "string", ")", "[", "]", "int", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "latencies", ":=", "[", "]", "int", "{", "}", "\n", "rand", ".", "Seed", "(", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", ")", "\n", "for", "{", "containerID", ":=", "containerIDs", "[", "rand", ".", "Int", "(", ")", "%", "len", "(", "containerIDs", ")", "]", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "_", ",", "err", ":=", "d", ".", "client", ".", "ContainerInspect", "(", "getContext", "(", ")", ",", "containerID", ")", "\n", "d", ".", "errStats", ".", "add", "(", "\"", "\"", ",", "err", ")", "\n", "latencies", "=", "append", "(", "latencies", ",", "int", "(", "time", ".", "Since", "(", "start", ")", ".", "Nanoseconds", "(", ")", ")", ")", "\n", "if", "time", ".", "Now", "(", ")", ".", "Sub", "(", "startTime", ")", ">=", "testPeriod", "{", "break", "\n", "}", "\n", "if", "interval", "!=", "0", "{", "time", ".", "Sleep", "(", "interval", ")", "\n", "}", "\n", "}", "\n", "return", "latencies", "\n", "}" ]
// DoInspectContainerBenchmark does periodically InspectContainer with specific interval, returns latencies // of all the calls in nanoseconds
[ "DoInspectContainerBenchmark", "does", "periodically", "InspectContainer", "with", "specific", "interval", "returns", "latencies", "of", "all", "the", "calls", "in", "nanoseconds" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L190-L208
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoParallelListContainerBenchmark
func (d *DockerHelper) DoParallelListContainerBenchmark(interval, testPeriod time.Duration, routineNumber int, all bool) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latenciesTable[index] = d.DoListContainerBenchmark(interval, testPeriod, all) wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
go
func (d *DockerHelper) DoParallelListContainerBenchmark(interval, testPeriod time.Duration, routineNumber int, all bool) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latenciesTable[index] = d.DoListContainerBenchmark(interval, testPeriod, all) wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoParallelListContainerBenchmark", "(", "interval", ",", "testPeriod", "time", ".", "Duration", ",", "routineNumber", "int", ",", "all", "bool", ")", "[", "]", "int", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "routineNumber", ")", "\n", "latenciesTable", ":=", "make", "(", "[", "]", "[", "]", "int", ",", "routineNumber", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "routineNumber", ";", "i", "++", "{", "go", "func", "(", "index", "int", ")", "{", "latenciesTable", "[", "index", "]", "=", "d", ".", "DoListContainerBenchmark", "(", "interval", ",", "testPeriod", ",", "all", ")", "\n", "wg", ".", "Done", "(", ")", "\n", "}", "(", "i", ")", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "allLatencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "latencies", ":=", "range", "latenciesTable", "{", "allLatencies", "=", "append", "(", "allLatencies", ",", "latencies", "...", ")", "\n", "}", "\n", "return", "allLatencies", "\n", "}" ]
// DoParallelListContainerBenchmark starts routineNumber of goroutines and let them do DoListContainerBenchmark, // returns latencies of all the calls in nanoseconds
[ "DoParallelListContainerBenchmark", "starts", "routineNumber", "of", "goroutines", "and", "let", "them", "do", "DoListContainerBenchmark", "returns", "latencies", "of", "all", "the", "calls", "in", "nanoseconds" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L212-L228
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoParallelInspectContainerBenchmark
func (d *DockerHelper) DoParallelInspectContainerBenchmark(interval, testPeriod time.Duration, routineNumber int, containerIDs []string) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latenciesTable[index] = d.DoInspectContainerBenchmark(interval, testPeriod, containerIDs) wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
go
func (d *DockerHelper) DoParallelInspectContainerBenchmark(interval, testPeriod time.Duration, routineNumber int, containerIDs []string) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latenciesTable[index] = d.DoInspectContainerBenchmark(interval, testPeriod, containerIDs) wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoParallelInspectContainerBenchmark", "(", "interval", ",", "testPeriod", "time", ".", "Duration", ",", "routineNumber", "int", ",", "containerIDs", "[", "]", "string", ")", "[", "]", "int", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "routineNumber", ")", "\n", "latenciesTable", ":=", "make", "(", "[", "]", "[", "]", "int", ",", "routineNumber", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "routineNumber", ";", "i", "++", "{", "go", "func", "(", "index", "int", ")", "{", "latenciesTable", "[", "index", "]", "=", "d", ".", "DoInspectContainerBenchmark", "(", "interval", ",", "testPeriod", ",", "containerIDs", ")", "\n", "wg", ".", "Done", "(", ")", "\n", "}", "(", "i", ")", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "allLatencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "latencies", ":=", "range", "latenciesTable", "{", "allLatencies", "=", "append", "(", "allLatencies", ",", "latencies", "...", ")", "\n", "}", "\n", "return", "allLatencies", "\n", "}" ]
// DoParallelInspectContainerBenchmark starts routineNumber of goroutines and let them do DoInspectContainerBenchmark, // returns latencies of all the calls in nanoseconds
[ "DoParallelInspectContainerBenchmark", "starts", "routineNumber", "of", "goroutines", "and", "let", "them", "do", "DoInspectContainerBenchmark", "returns", "latencies", "of", "all", "the", "calls", "in", "nanoseconds" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L232-L248
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoParallelContainerStartBenchmark
func (d *DockerHelper) DoParallelContainerStartBenchmark(qps float64, testPeriod time.Duration, routineNumber int) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) ratelimit := ratelimit.NewBucketWithRate(qps, int64(routineNumber)) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { startTime := time.Now() latencies := []int{} for { ratelimit.Wait(1) start := time.Now() ids := d.CreateContainers(1) d.StartContainers(ids) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } } latenciesTable[index] = latencies wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
go
func (d *DockerHelper) DoParallelContainerStartBenchmark(qps float64, testPeriod time.Duration, routineNumber int) []int { wg := &sync.WaitGroup{} wg.Add(routineNumber) ratelimit := ratelimit.NewBucketWithRate(qps, int64(routineNumber)) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { startTime := time.Now() latencies := []int{} for { ratelimit.Wait(1) start := time.Now() ids := d.CreateContainers(1) d.StartContainers(ids) latencies = append(latencies, int(time.Since(start).Nanoseconds())) if time.Now().Sub(startTime) >= testPeriod { break } } latenciesTable[index] = latencies wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoParallelContainerStartBenchmark", "(", "qps", "float64", ",", "testPeriod", "time", ".", "Duration", ",", "routineNumber", "int", ")", "[", "]", "int", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "wg", ".", "Add", "(", "routineNumber", ")", "\n", "ratelimit", ":=", "ratelimit", ".", "NewBucketWithRate", "(", "qps", ",", "int64", "(", "routineNumber", ")", ")", "\n", "latenciesTable", ":=", "make", "(", "[", "]", "[", "]", "int", ",", "routineNumber", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "routineNumber", ";", "i", "++", "{", "go", "func", "(", "index", "int", ")", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "latencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "{", "ratelimit", ".", "Wait", "(", "1", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "ids", ":=", "d", ".", "CreateContainers", "(", "1", ")", "\n", "d", ".", "StartContainers", "(", "ids", ")", "\n", "latencies", "=", "append", "(", "latencies", ",", "int", "(", "time", ".", "Since", "(", "start", ")", ".", "Nanoseconds", "(", ")", ")", ")", "\n", "if", "time", ".", "Now", "(", ")", ".", "Sub", "(", "startTime", ")", ">=", "testPeriod", "{", "break", "\n", "}", "\n", "}", "\n", "latenciesTable", "[", "index", "]", "=", "latencies", "\n", "wg", ".", "Done", "(", ")", "\n", "}", "(", "i", ")", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "allLatencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "latencies", ":=", "range", "latenciesTable", "{", "allLatencies", "=", "append", "(", "allLatencies", ",", "latencies", "...", ")", "\n", "}", "\n", "return", "allLatencies", "\n", "}" ]
// DoParallelContainerStartBenchmark starts routineNumber of goroutines and let them start containers, returns latencies // of all the starting calls in nanoseconds. There is a global rate limit on starting calls per second.
[ "DoParallelContainerStartBenchmark", "starts", "routineNumber", "of", "goroutines", "and", "let", "them", "start", "containers", "returns", "latencies", "of", "all", "the", "starting", "calls", "in", "nanoseconds", ".", "There", "is", "a", "global", "rate", "limit", "on", "starting", "calls", "per", "second", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L252-L281
train
kubernetes-retired/contrib
docker-micro-benchmark/helpers/docker_helpers.go
DoParallelContainerStopBenchmark
func (d *DockerHelper) DoParallelContainerStopBenchmark(qps float64, routineNumber int) []int { wg := &sync.WaitGroup{} ids := d.GetContainerIDs() idTable := make([][]string, routineNumber) for i := 0; i < len(ids); i++ { idTable[i%routineNumber] = append(idTable[i%routineNumber], ids[i]) } wg.Add(routineNumber) ratelimit := ratelimit.NewBucketWithRate(qps, int64(routineNumber)) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latencies := []int{} for _, id := range idTable[index] { ratelimit.Wait(1) start := time.Now() d.StopContainers([]string{id}) d.RemoveContainers([]string{id}) latencies = append(latencies, int(time.Since(start).Nanoseconds())) } latenciesTable[index] = latencies wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
go
func (d *DockerHelper) DoParallelContainerStopBenchmark(qps float64, routineNumber int) []int { wg := &sync.WaitGroup{} ids := d.GetContainerIDs() idTable := make([][]string, routineNumber) for i := 0; i < len(ids); i++ { idTable[i%routineNumber] = append(idTable[i%routineNumber], ids[i]) } wg.Add(routineNumber) ratelimit := ratelimit.NewBucketWithRate(qps, int64(routineNumber)) latenciesTable := make([][]int, routineNumber) for i := 0; i < routineNumber; i++ { go func(index int) { latencies := []int{} for _, id := range idTable[index] { ratelimit.Wait(1) start := time.Now() d.StopContainers([]string{id}) d.RemoveContainers([]string{id}) latencies = append(latencies, int(time.Since(start).Nanoseconds())) } latenciesTable[index] = latencies wg.Done() }(i) } wg.Wait() allLatencies := []int{} for _, latencies := range latenciesTable { allLatencies = append(allLatencies, latencies...) } return allLatencies }
[ "func", "(", "d", "*", "DockerHelper", ")", "DoParallelContainerStopBenchmark", "(", "qps", "float64", ",", "routineNumber", "int", ")", "[", "]", "int", "{", "wg", ":=", "&", "sync", ".", "WaitGroup", "{", "}", "\n", "ids", ":=", "d", ".", "GetContainerIDs", "(", ")", "\n", "idTable", ":=", "make", "(", "[", "]", "[", "]", "string", ",", "routineNumber", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "ids", ")", ";", "i", "++", "{", "idTable", "[", "i", "%", "routineNumber", "]", "=", "append", "(", "idTable", "[", "i", "%", "routineNumber", "]", ",", "ids", "[", "i", "]", ")", "\n", "}", "\n", "wg", ".", "Add", "(", "routineNumber", ")", "\n", "ratelimit", ":=", "ratelimit", ".", "NewBucketWithRate", "(", "qps", ",", "int64", "(", "routineNumber", ")", ")", "\n", "latenciesTable", ":=", "make", "(", "[", "]", "[", "]", "int", ",", "routineNumber", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "routineNumber", ";", "i", "++", "{", "go", "func", "(", "index", "int", ")", "{", "latencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "id", ":=", "range", "idTable", "[", "index", "]", "{", "ratelimit", ".", "Wait", "(", "1", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "d", ".", "StopContainers", "(", "[", "]", "string", "{", "id", "}", ")", "\n", "d", ".", "RemoveContainers", "(", "[", "]", "string", "{", "id", "}", ")", "\n", "latencies", "=", "append", "(", "latencies", ",", "int", "(", "time", ".", "Since", "(", "start", ")", ".", "Nanoseconds", "(", ")", ")", ")", "\n", "}", "\n", "latenciesTable", "[", "index", "]", "=", "latencies", "\n", "wg", ".", "Done", "(", ")", "\n", "}", "(", "i", ")", "\n", "}", "\n", "wg", ".", "Wait", "(", ")", "\n", "allLatencies", ":=", "[", "]", "int", "{", "}", "\n", "for", "_", ",", "latencies", ":=", "range", "latenciesTable", "{", "allLatencies", "=", "append", "(", "allLatencies", ",", "latencies", "...", ")", "\n", "}", "\n", "return", "allLatencies", "\n", "}" ]
// DoParallelContainerStopBenchmark starts routineNumber of goroutines and let them stop containers, returns latencies // of all the stopping calls in nanoseconds. There is a global rate limit on stopping calls per second.
[ "DoParallelContainerStopBenchmark", "starts", "routineNumber", "of", "goroutines", "and", "let", "them", "stop", "containers", "returns", "latencies", "of", "all", "the", "stopping", "calls", "in", "nanoseconds", ".", "There", "is", "a", "global", "rate", "limit", "on", "stopping", "calls", "per", "second", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/docker-micro-benchmark/helpers/docker_helpers.go#L285-L315
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg.go
Negotiate
func Negotiate(header string, alternatives []string) (content_type string) { asp := make([][]string, 0, len(alternatives)) for _, ctype := range alternatives { asp = append(asp, strings.SplitN(ctype, "/", 2)) } for _, clause := range ParseAccept(header) { for i, ctsp := range asp { if clause.Type == ctsp[0] && clause.SubType == ctsp[1] { content_type = alternatives[i] return } if clause.Type == ctsp[0] && clause.SubType == "*" { content_type = alternatives[i] return } if clause.Type == "*" && clause.SubType == "*" { content_type = alternatives[i] return } } } return }
go
func Negotiate(header string, alternatives []string) (content_type string) { asp := make([][]string, 0, len(alternatives)) for _, ctype := range alternatives { asp = append(asp, strings.SplitN(ctype, "/", 2)) } for _, clause := range ParseAccept(header) { for i, ctsp := range asp { if clause.Type == ctsp[0] && clause.SubType == ctsp[1] { content_type = alternatives[i] return } if clause.Type == ctsp[0] && clause.SubType == "*" { content_type = alternatives[i] return } if clause.Type == "*" && clause.SubType == "*" { content_type = alternatives[i] return } } } return }
[ "func", "Negotiate", "(", "header", "string", ",", "alternatives", "[", "]", "string", ")", "(", "content_type", "string", ")", "{", "asp", ":=", "make", "(", "[", "]", "[", "]", "string", ",", "0", ",", "len", "(", "alternatives", ")", ")", "\n", "for", "_", ",", "ctype", ":=", "range", "alternatives", "{", "asp", "=", "append", "(", "asp", ",", "strings", ".", "SplitN", "(", "ctype", ",", "\"", "\"", ",", "2", ")", ")", "\n", "}", "\n", "for", "_", ",", "clause", ":=", "range", "ParseAccept", "(", "header", ")", "{", "for", "i", ",", "ctsp", ":=", "range", "asp", "{", "if", "clause", ".", "Type", "==", "ctsp", "[", "0", "]", "&&", "clause", ".", "SubType", "==", "ctsp", "[", "1", "]", "{", "content_type", "=", "alternatives", "[", "i", "]", "\n", "return", "\n", "}", "\n", "if", "clause", ".", "Type", "==", "ctsp", "[", "0", "]", "&&", "clause", ".", "SubType", "==", "\"", "\"", "{", "content_type", "=", "alternatives", "[", "i", "]", "\n", "return", "\n", "}", "\n", "if", "clause", ".", "Type", "==", "\"", "\"", "&&", "clause", ".", "SubType", "==", "\"", "\"", "{", "content_type", "=", "alternatives", "[", "i", "]", "\n", "return", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "\n", "}" ]
// Negotiate the most appropriate content_type given the accept header // and a list of alternatives.
[ "Negotiate", "the", "most", "appropriate", "content_type", "given", "the", "accept", "header", "and", "a", "list", "of", "alternatives", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg.go#L140-L162
train
kubernetes-retired/contrib
scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/port_range.go
Set
func (pr *PortRange) Set(value string) error { value = strings.TrimSpace(value) // TODO: Accept "80" syntax // TODO: Accept "80+8" syntax if value == "" { pr.Base = 0 pr.Size = 0 return nil } hyphenIndex := strings.Index(value, "-") if hyphenIndex == -1 { return fmt.Errorf("expected hyphen in port range") } var err error var low int var high int low, err = strconv.Atoi(value[:hyphenIndex]) if err == nil { high, err = strconv.Atoi(value[hyphenIndex+1:]) } if err != nil { return fmt.Errorf("unable to parse port range: %s", value) } if high < low { return fmt.Errorf("end port cannot be less than start port: %s", value) } pr.Base = low pr.Size = 1 + high - low return nil }
go
func (pr *PortRange) Set(value string) error { value = strings.TrimSpace(value) // TODO: Accept "80" syntax // TODO: Accept "80+8" syntax if value == "" { pr.Base = 0 pr.Size = 0 return nil } hyphenIndex := strings.Index(value, "-") if hyphenIndex == -1 { return fmt.Errorf("expected hyphen in port range") } var err error var low int var high int low, err = strconv.Atoi(value[:hyphenIndex]) if err == nil { high, err = strconv.Atoi(value[hyphenIndex+1:]) } if err != nil { return fmt.Errorf("unable to parse port range: %s", value) } if high < low { return fmt.Errorf("end port cannot be less than start port: %s", value) } pr.Base = low pr.Size = 1 + high - low return nil }
[ "func", "(", "pr", "*", "PortRange", ")", "Set", "(", "value", "string", ")", "error", "{", "value", "=", "strings", ".", "TrimSpace", "(", "value", ")", "\n\n", "// TODO: Accept \"80\" syntax", "// TODO: Accept \"80+8\" syntax", "if", "value", "==", "\"", "\"", "{", "pr", ".", "Base", "=", "0", "\n", "pr", ".", "Size", "=", "0", "\n", "return", "nil", "\n", "}", "\n\n", "hyphenIndex", ":=", "strings", ".", "Index", "(", "value", ",", "\"", "\"", ")", "\n", "if", "hyphenIndex", "==", "-", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "err", "error", "\n", "var", "low", "int", "\n", "var", "high", "int", "\n", "low", ",", "err", "=", "strconv", ".", "Atoi", "(", "value", "[", ":", "hyphenIndex", "]", ")", "\n", "if", "err", "==", "nil", "{", "high", ",", "err", "=", "strconv", ".", "Atoi", "(", "value", "[", "hyphenIndex", "+", "1", ":", "]", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n\n", "if", "high", "<", "low", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n", "pr", ".", "Base", "=", "low", "\n", "pr", ".", "Size", "=", "1", "+", "high", "-", "low", "\n", "return", "nil", "\n", "}" ]
// Set parses a string of the form "min-max", inclusive at both ends, and // sets the PortRange from it. This is part of the flag.Value and pflag.Value // interfaces.
[ "Set", "parses", "a", "string", "of", "the", "form", "min", "-", "max", "inclusive", "at", "both", "ends", "and", "sets", "the", "PortRange", "from", "it", ".", "This", "is", "part", "of", "the", "flag", ".", "Value", "and", "pflag", ".", "Value", "interfaces", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/port_range.go#L49-L83
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go
ValidateReplicationController
func (precondition *ScalePrecondition) ValidateReplicationController(controller *api.ReplicationController) error { if precondition.Size != -1 && controller.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(controller.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && controller.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, controller.ResourceVersion} } return nil }
go
func (precondition *ScalePrecondition) ValidateReplicationController(controller *api.ReplicationController) error { if precondition.Size != -1 && controller.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(controller.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && controller.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, controller.ResourceVersion} } return nil }
[ "func", "(", "precondition", "*", "ScalePrecondition", ")", "ValidateReplicationController", "(", "controller", "*", "api", ".", "ReplicationController", ")", "error", "{", "if", "precondition", ".", "Size", "!=", "-", "1", "&&", "controller", ".", "Spec", ".", "Replicas", "!=", "precondition", ".", "Size", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "precondition", ".", "Size", ")", ",", "strconv", ".", "Itoa", "(", "controller", ".", "Spec", ".", "Replicas", ")", "}", "\n", "}", "\n", "if", "len", "(", "precondition", ".", "ResourceVersion", ")", "!=", "0", "&&", "controller", ".", "ResourceVersion", "!=", "precondition", ".", "ResourceVersion", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "precondition", ".", "ResourceVersion", ",", "controller", ".", "ResourceVersion", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateReplicationController ensures that the preconditions match. Returns nil if they are valid, an error otherwise
[ "ValidateReplicationController", "ensures", "that", "the", "preconditions", "match", ".", "Returns", "nil", "if", "they", "are", "valid", "an", "error", "otherwise" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L131-L139
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go
ValidateReplicaSet
func (precondition *ScalePrecondition) ValidateReplicaSet(replicaSet *extensions.ReplicaSet) error { if precondition.Size != -1 && replicaSet.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(replicaSet.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && replicaSet.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, replicaSet.ResourceVersion} } return nil }
go
func (precondition *ScalePrecondition) ValidateReplicaSet(replicaSet *extensions.ReplicaSet) error { if precondition.Size != -1 && replicaSet.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(replicaSet.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && replicaSet.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, replicaSet.ResourceVersion} } return nil }
[ "func", "(", "precondition", "*", "ScalePrecondition", ")", "ValidateReplicaSet", "(", "replicaSet", "*", "extensions", ".", "ReplicaSet", ")", "error", "{", "if", "precondition", ".", "Size", "!=", "-", "1", "&&", "replicaSet", ".", "Spec", ".", "Replicas", "!=", "precondition", ".", "Size", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "precondition", ".", "Size", ")", ",", "strconv", ".", "Itoa", "(", "replicaSet", ".", "Spec", ".", "Replicas", ")", "}", "\n", "}", "\n", "if", "len", "(", "precondition", ".", "ResourceVersion", ")", "!=", "0", "&&", "replicaSet", ".", "ResourceVersion", "!=", "precondition", ".", "ResourceVersion", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "precondition", ".", "ResourceVersion", ",", "replicaSet", ".", "ResourceVersion", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateReplicaSet ensures that the preconditions match. Returns nil if they are valid, an error otherwise
[ "ValidateReplicaSet", "ensures", "that", "the", "preconditions", "match", ".", "Returns", "nil", "if", "they", "are", "valid", "an", "error", "otherwise" ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L193-L201
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go
ValidateJob
func (precondition *ScalePrecondition) ValidateJob(job *extensions.Job) error { if precondition.Size != -1 && job.Spec.Parallelism == nil { return PreconditionError{"parallelism", strconv.Itoa(precondition.Size), "nil"} } if precondition.Size != -1 && *job.Spec.Parallelism != precondition.Size { return PreconditionError{"parallelism", strconv.Itoa(precondition.Size), strconv.Itoa(*job.Spec.Parallelism)} } if len(precondition.ResourceVersion) != 0 && job.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, job.ResourceVersion} } return nil }
go
func (precondition *ScalePrecondition) ValidateJob(job *extensions.Job) error { if precondition.Size != -1 && job.Spec.Parallelism == nil { return PreconditionError{"parallelism", strconv.Itoa(precondition.Size), "nil"} } if precondition.Size != -1 && *job.Spec.Parallelism != precondition.Size { return PreconditionError{"parallelism", strconv.Itoa(precondition.Size), strconv.Itoa(*job.Spec.Parallelism)} } if len(precondition.ResourceVersion) != 0 && job.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, job.ResourceVersion} } return nil }
[ "func", "(", "precondition", "*", "ScalePrecondition", ")", "ValidateJob", "(", "job", "*", "extensions", ".", "Job", ")", "error", "{", "if", "precondition", ".", "Size", "!=", "-", "1", "&&", "job", ".", "Spec", ".", "Parallelism", "==", "nil", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "precondition", ".", "Size", ")", ",", "\"", "\"", "}", "\n", "}", "\n", "if", "precondition", ".", "Size", "!=", "-", "1", "&&", "*", "job", ".", "Spec", ".", "Parallelism", "!=", "precondition", ".", "Size", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "precondition", ".", "Size", ")", ",", "strconv", ".", "Itoa", "(", "*", "job", ".", "Spec", ".", "Parallelism", ")", "}", "\n", "}", "\n", "if", "len", "(", "precondition", ".", "ResourceVersion", ")", "!=", "0", "&&", "job", ".", "ResourceVersion", "!=", "precondition", ".", "ResourceVersion", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "precondition", ".", "ResourceVersion", ",", "job", ".", "ResourceVersion", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateJob ensures that the preconditions match. Returns nil if they are valid, an error otherwise.
[ "ValidateJob", "ensures", "that", "the", "preconditions", "match", ".", "Returns", "nil", "if", "they", "are", "valid", "an", "error", "otherwise", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L255-L266
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go
ScaleSimple
func (scaler *JobScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error { job, err := scaler.c.Jobs(namespace).Get(name) if err != nil { return ScaleError{ScaleGetFailure, "Unknown", err} } if preconditions != nil { if err := preconditions.ValidateJob(job); err != nil { return err } } parallelism := int(newSize) job.Spec.Parallelism = &parallelism if _, err := scaler.c.Jobs(namespace).Update(job); err != nil { if errors.IsInvalid(err) { return ScaleError{ScaleUpdateInvalidFailure, job.ResourceVersion, err} } return ScaleError{ScaleUpdateFailure, job.ResourceVersion, err} } return nil }
go
func (scaler *JobScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) error { job, err := scaler.c.Jobs(namespace).Get(name) if err != nil { return ScaleError{ScaleGetFailure, "Unknown", err} } if preconditions != nil { if err := preconditions.ValidateJob(job); err != nil { return err } } parallelism := int(newSize) job.Spec.Parallelism = &parallelism if _, err := scaler.c.Jobs(namespace).Update(job); err != nil { if errors.IsInvalid(err) { return ScaleError{ScaleUpdateInvalidFailure, job.ResourceVersion, err} } return ScaleError{ScaleUpdateFailure, job.ResourceVersion, err} } return nil }
[ "func", "(", "scaler", "*", "JobScaler", ")", "ScaleSimple", "(", "namespace", ",", "name", "string", ",", "preconditions", "*", "ScalePrecondition", ",", "newSize", "uint", ")", "error", "{", "job", ",", "err", ":=", "scaler", ".", "c", ".", "Jobs", "(", "namespace", ")", ".", "Get", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ScaleError", "{", "ScaleGetFailure", ",", "\"", "\"", ",", "err", "}", "\n", "}", "\n", "if", "preconditions", "!=", "nil", "{", "if", "err", ":=", "preconditions", ".", "ValidateJob", "(", "job", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "parallelism", ":=", "int", "(", "newSize", ")", "\n", "job", ".", "Spec", ".", "Parallelism", "=", "&", "parallelism", "\n", "if", "_", ",", "err", ":=", "scaler", ".", "c", ".", "Jobs", "(", "namespace", ")", ".", "Update", "(", "job", ")", ";", "err", "!=", "nil", "{", "if", "errors", ".", "IsInvalid", "(", "err", ")", "{", "return", "ScaleError", "{", "ScaleUpdateInvalidFailure", ",", "job", ".", "ResourceVersion", ",", "err", "}", "\n", "}", "\n", "return", "ScaleError", "{", "ScaleUpdateFailure", ",", "job", ".", "ResourceVersion", ",", "err", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ScaleSimple is responsible for updating job's parallelism.
[ "ScaleSimple", "is", "responsible", "for", "updating", "job", "s", "parallelism", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L273-L292
train
kubernetes-retired/contrib
service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go
ValidateDeployment
func (precondition *ScalePrecondition) ValidateDeployment(deployment *extensions.Deployment) error { if precondition.Size != -1 && deployment.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(deployment.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && deployment.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, deployment.ResourceVersion} } return nil }
go
func (precondition *ScalePrecondition) ValidateDeployment(deployment *extensions.Deployment) error { if precondition.Size != -1 && deployment.Spec.Replicas != precondition.Size { return PreconditionError{"replicas", strconv.Itoa(precondition.Size), strconv.Itoa(deployment.Spec.Replicas)} } if len(precondition.ResourceVersion) != 0 && deployment.ResourceVersion != precondition.ResourceVersion { return PreconditionError{"resource version", precondition.ResourceVersion, deployment.ResourceVersion} } return nil }
[ "func", "(", "precondition", "*", "ScalePrecondition", ")", "ValidateDeployment", "(", "deployment", "*", "extensions", ".", "Deployment", ")", "error", "{", "if", "precondition", ".", "Size", "!=", "-", "1", "&&", "deployment", ".", "Spec", ".", "Replicas", "!=", "precondition", ".", "Size", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "strconv", ".", "Itoa", "(", "precondition", ".", "Size", ")", ",", "strconv", ".", "Itoa", "(", "deployment", ".", "Spec", ".", "Replicas", ")", "}", "\n", "}", "\n", "if", "len", "(", "precondition", ".", "ResourceVersion", ")", "!=", "0", "&&", "deployment", ".", "ResourceVersion", "!=", "precondition", ".", "ResourceVersion", "{", "return", "PreconditionError", "{", "\"", "\"", ",", "precondition", ".", "ResourceVersion", ",", "deployment", ".", "ResourceVersion", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ValidateDeployment ensures that the preconditions match. Returns nil if they are valid, an error otherwise.
[ "ValidateDeployment", "ensures", "that", "the", "preconditions", "match", ".", "Returns", "nil", "if", "they", "are", "valid", "an", "error", "otherwise", "." ]
89f6948e24578fed2a90a87871b2263729f90ac3
https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/scale.go#L321-L329
train