repo stringclasses 1 value | path stringlengths 18 145 | func_name stringlengths 2 108 | original_string stringlengths 68 22.9k | language stringclasses 1 value | code stringlengths 68 22.9k | code_tokens listlengths 23 4.91k | docstring stringlengths 13 1.73k | docstring_tokens listlengths 1 335 | sha stringclasses 1 value | url stringlengths 113 242 | partition stringclasses 1 value | summary stringlengths 15 310 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
kubernetes/kubernetes | staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service.go | NewGRPCService | func NewGRPCService(endpoint string, callTimeout time.Duration) (Service, error) {
klog.V(4).Infof("Configure KMS provider with endpoint: %s", endpoint)
addr, err := parseEndpoint(endpoint)
if err != nil {
return nil, err
}
connection, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.FailFast(false)), grpc.WithDialer(
func(string, time.Duration) (net.Conn, error) {
// Ignoring addr and timeout arguments:
// addr - comes from the closure
// timeout - is ignored since we are connecting in a non-blocking configuration
c, err := net.DialTimeout(unixProtocol, addr, 0)
if err != nil {
klog.Errorf("failed to create connection to unix socket: %s, error: %v", addr, err)
}
return c, err
}))
if err != nil {
return nil, fmt.Errorf("failed to create connection to %s, error: %v", endpoint, err)
}
kmsClient := kmsapi.NewKeyManagementServiceClient(connection)
return &gRPCService{
kmsClient: kmsClient,
connection: connection,
callTimeout: callTimeout,
}, nil
} | go | func NewGRPCService(endpoint string, callTimeout time.Duration) (Service, error) {
klog.V(4).Infof("Configure KMS provider with endpoint: %s", endpoint)
addr, err := parseEndpoint(endpoint)
if err != nil {
return nil, err
}
connection, err := grpc.Dial(addr, grpc.WithInsecure(), grpc.WithDefaultCallOptions(grpc.FailFast(false)), grpc.WithDialer(
func(string, time.Duration) (net.Conn, error) {
// Ignoring addr and timeout arguments:
// addr - comes from the closure
// timeout - is ignored since we are connecting in a non-blocking configuration
c, err := net.DialTimeout(unixProtocol, addr, 0)
if err != nil {
klog.Errorf("failed to create connection to unix socket: %s, error: %v", addr, err)
}
return c, err
}))
if err != nil {
return nil, fmt.Errorf("failed to create connection to %s, error: %v", endpoint, err)
}
kmsClient := kmsapi.NewKeyManagementServiceClient(connection)
return &gRPCService{
kmsClient: kmsClient,
connection: connection,
callTimeout: callTimeout,
}, nil
} | [
"func",
"NewGRPCService",
"(",
"endpoint",
"string",
",",
"callTimeout",
"time",
".",
"Duration",
")",
"(",
"Service",
",",
"error",
")",
"{",
"klog",
".",
"V",
"(",
"4",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"endpoint",
")",
"\n\n",
"addr",
",",
... | // NewGRPCService returns an envelope.Service which use gRPC to communicate the remote KMS provider. | [
"NewGRPCService",
"returns",
"an",
"envelope",
".",
"Service",
"which",
"use",
"gRPC",
"to",
"communicate",
"the",
"remote",
"KMS",
"provider",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service.go#L56-L86 | train | NewGRPCService creates a new service with the given endpoint and callTimeout. | [
30522,
4569,
2278,
2047,
16523,
15042,
8043,
7903,
2063,
1006,
2203,
8400,
5164,
1010,
2655,
7292,
5833,
2051,
1012,
9367,
1007,
1006,
2326,
1010,
7561,
1007,
1063,
1047,
21197,
1012,
1058,
1006,
1018,
1007,
1012,
18558,
2546,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/api/v1/persistentvolume/util.go | VisitPVSecretNames | func VisitPVSecretNames(pv *corev1.PersistentVolume, visitor Visitor) bool {
source := &pv.Spec.PersistentVolumeSource
switch {
case source.AzureFile != nil:
if source.AzureFile.SecretNamespace != nil && len(*source.AzureFile.SecretNamespace) > 0 {
if len(source.AzureFile.SecretName) > 0 && !visitor(*source.AzureFile.SecretNamespace, source.AzureFile.SecretName, true /* kubeletVisible */) {
return false
}
} else {
if len(source.AzureFile.SecretName) > 0 && !visitor(getClaimRefNamespace(pv), source.AzureFile.SecretName, true /* kubeletVisible */) {
return false
}
}
return true
case source.CephFS != nil:
if source.CephFS.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.CephFS.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.CephFS.SecretRef.Namespace
}
if !visitor(ns, source.CephFS.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.Cinder != nil:
if source.Cinder.SecretRef != nil && !visitor(source.Cinder.SecretRef.Namespace, source.Cinder.SecretRef.Name, true /* kubeletVisible */) {
return false
}
case source.FlexVolume != nil:
if source.FlexVolume.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.FlexVolume.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.FlexVolume.SecretRef.Namespace
}
if !visitor(ns, source.FlexVolume.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.RBD != nil:
if source.RBD.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.RBD.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.RBD.SecretRef.Namespace
}
if !visitor(ns, source.RBD.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.ScaleIO != nil:
if source.ScaleIO.SecretRef != nil {
ns := getClaimRefNamespace(pv)
if source.ScaleIO.SecretRef != nil && len(source.ScaleIO.SecretRef.Namespace) > 0 {
ns = source.ScaleIO.SecretRef.Namespace
}
if !visitor(ns, source.ScaleIO.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.ISCSI != nil:
if source.ISCSI.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.ISCSI.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.ISCSI.SecretRef.Namespace
}
if !visitor(ns, source.ISCSI.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.StorageOS != nil:
if source.StorageOS.SecretRef != nil && !visitor(source.StorageOS.SecretRef.Namespace, source.StorageOS.SecretRef.Name, true /* kubeletVisible */) {
return false
}
case source.CSI != nil:
if source.CSI.ControllerPublishSecretRef != nil {
if !visitor(source.CSI.ControllerPublishSecretRef.Namespace, source.CSI.ControllerPublishSecretRef.Name, false /* kubeletVisible */) {
return false
}
}
if source.CSI.NodePublishSecretRef != nil {
if !visitor(source.CSI.NodePublishSecretRef.Namespace, source.CSI.NodePublishSecretRef.Name, true /* kubeletVisible */) {
return false
}
}
if source.CSI.NodeStageSecretRef != nil {
if !visitor(source.CSI.NodeStageSecretRef.Namespace, source.CSI.NodeStageSecretRef.Name, true /* kubeletVisible */) {
return false
}
}
}
return true
} | go | func VisitPVSecretNames(pv *corev1.PersistentVolume, visitor Visitor) bool {
source := &pv.Spec.PersistentVolumeSource
switch {
case source.AzureFile != nil:
if source.AzureFile.SecretNamespace != nil && len(*source.AzureFile.SecretNamespace) > 0 {
if len(source.AzureFile.SecretName) > 0 && !visitor(*source.AzureFile.SecretNamespace, source.AzureFile.SecretName, true /* kubeletVisible */) {
return false
}
} else {
if len(source.AzureFile.SecretName) > 0 && !visitor(getClaimRefNamespace(pv), source.AzureFile.SecretName, true /* kubeletVisible */) {
return false
}
}
return true
case source.CephFS != nil:
if source.CephFS.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.CephFS.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.CephFS.SecretRef.Namespace
}
if !visitor(ns, source.CephFS.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.Cinder != nil:
if source.Cinder.SecretRef != nil && !visitor(source.Cinder.SecretRef.Namespace, source.Cinder.SecretRef.Name, true /* kubeletVisible */) {
return false
}
case source.FlexVolume != nil:
if source.FlexVolume.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.FlexVolume.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.FlexVolume.SecretRef.Namespace
}
if !visitor(ns, source.FlexVolume.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.RBD != nil:
if source.RBD.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.RBD.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.RBD.SecretRef.Namespace
}
if !visitor(ns, source.RBD.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.ScaleIO != nil:
if source.ScaleIO.SecretRef != nil {
ns := getClaimRefNamespace(pv)
if source.ScaleIO.SecretRef != nil && len(source.ScaleIO.SecretRef.Namespace) > 0 {
ns = source.ScaleIO.SecretRef.Namespace
}
if !visitor(ns, source.ScaleIO.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.ISCSI != nil:
if source.ISCSI.SecretRef != nil {
// previously persisted PV objects use claimRef namespace
ns := getClaimRefNamespace(pv)
if len(source.ISCSI.SecretRef.Namespace) > 0 {
// use the secret namespace if namespace is set
ns = source.ISCSI.SecretRef.Namespace
}
if !visitor(ns, source.ISCSI.SecretRef.Name, true /* kubeletVisible */) {
return false
}
}
case source.StorageOS != nil:
if source.StorageOS.SecretRef != nil && !visitor(source.StorageOS.SecretRef.Namespace, source.StorageOS.SecretRef.Name, true /* kubeletVisible */) {
return false
}
case source.CSI != nil:
if source.CSI.ControllerPublishSecretRef != nil {
if !visitor(source.CSI.ControllerPublishSecretRef.Namespace, source.CSI.ControllerPublishSecretRef.Name, false /* kubeletVisible */) {
return false
}
}
if source.CSI.NodePublishSecretRef != nil {
if !visitor(source.CSI.NodePublishSecretRef.Namespace, source.CSI.NodePublishSecretRef.Name, true /* kubeletVisible */) {
return false
}
}
if source.CSI.NodeStageSecretRef != nil {
if !visitor(source.CSI.NodeStageSecretRef.Namespace, source.CSI.NodeStageSecretRef.Name, true /* kubeletVisible */) {
return false
}
}
}
return true
} | [
"func",
"VisitPVSecretNames",
"(",
"pv",
"*",
"corev1",
".",
"PersistentVolume",
",",
"visitor",
"Visitor",
")",
"bool",
"{",
"source",
":=",
"&",
"pv",
".",
"Spec",
".",
"PersistentVolumeSource",
"\n",
"switch",
"{",
"case",
"source",
".",
"AzureFile",
"!="... | // VisitPVSecretNames invokes the visitor function with the name of every secret
// referenced by the PV spec. If visitor returns false, visiting is short-circuited.
// Returns true if visiting completed, false if visiting was short-circuited. | [
"VisitPVSecretNames",
"invokes",
"the",
"visitor",
"function",
"with",
"the",
"name",
"of",
"every",
"secret",
"referenced",
"by",
"the",
"PV",
"spec",
".",
"If",
"visitor",
"returns",
"false",
"visiting",
"is",
"short",
"-",
"circuited",
".",
"Returns",
"true... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/api/v1/persistentvolume/util.go#L36-L134 | train | VisitPVSecretNames visits PV secrets | [
30522,
4569,
2278,
3942,
2361,
15088,
8586,
13465,
18442,
2015,
1006,
26189,
1008,
4563,
2615,
2487,
1012,
14516,
6767,
12942,
2063,
1010,
10367,
10367,
1007,
22017,
2140,
1063,
3120,
1024,
1027,
1004,
26189,
1012,
28699,
1012,
14516,
6767,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/metrics/pkg/apis/external_metrics/zz_generated.deepcopy.go | DeepCopyObject | func (in *ExternalMetricValue) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
} | go | func (in *ExternalMetricValue) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
} | [
"func",
"(",
"in",
"*",
"ExternalMetricValue",
")",
"DeepCopyObject",
"(",
")",
"runtime",
".",
"Object",
"{",
"if",
"c",
":=",
"in",
".",
"DeepCopy",
"(",
")",
";",
"c",
"!=",
"nil",
"{",
"return",
"c",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
... | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. | [
"DeepCopyObject",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"runtime",
".",
"Object",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/metrics/pkg/apis/external_metrics/zz_generated.deepcopy.go#L59-L64 | train | DeepCopyObject is an autogenerated deepcopy function copying the receiver creating a new runtime. Object. | [
30522,
4569,
2278,
1006,
1999,
1008,
6327,
12589,
10175,
5657,
1007,
2784,
3597,
7685,
16429,
20614,
1006,
1007,
2448,
7292,
1012,
4874,
1063,
2065,
1039,
1024,
1027,
1999,
1012,
2784,
3597,
7685,
1006,
1007,
1025,
1039,
999,
1027,
9152,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/kubeadm/app/images/images.go | GetEtcdImage | func GetEtcdImage(cfg *kubeadmapi.ClusterConfiguration) string {
// Etcd uses default image repository by default
etcdImageRepository := cfg.ImageRepository
// unless an override is specified
if cfg.Etcd.Local != nil && cfg.Etcd.Local.ImageRepository != "" {
etcdImageRepository = cfg.Etcd.Local.ImageRepository
}
// Etcd uses an imageTag that corresponds to the etcd version matching the Kubernetes version
etcdImageTag := constants.DefaultEtcdVersion
etcdVersion, err := constants.EtcdSupportedVersion(cfg.KubernetesVersion)
if err == nil {
etcdImageTag = etcdVersion.String()
}
// unless an override is specified
if cfg.Etcd.Local != nil && cfg.Etcd.Local.ImageTag != "" {
etcdImageTag = cfg.Etcd.Local.ImageTag
}
return GetGenericImage(etcdImageRepository, constants.Etcd, etcdImageTag)
} | go | func GetEtcdImage(cfg *kubeadmapi.ClusterConfiguration) string {
// Etcd uses default image repository by default
etcdImageRepository := cfg.ImageRepository
// unless an override is specified
if cfg.Etcd.Local != nil && cfg.Etcd.Local.ImageRepository != "" {
etcdImageRepository = cfg.Etcd.Local.ImageRepository
}
// Etcd uses an imageTag that corresponds to the etcd version matching the Kubernetes version
etcdImageTag := constants.DefaultEtcdVersion
etcdVersion, err := constants.EtcdSupportedVersion(cfg.KubernetesVersion)
if err == nil {
etcdImageTag = etcdVersion.String()
}
// unless an override is specified
if cfg.Etcd.Local != nil && cfg.Etcd.Local.ImageTag != "" {
etcdImageTag = cfg.Etcd.Local.ImageTag
}
return GetGenericImage(etcdImageRepository, constants.Etcd, etcdImageTag)
} | [
"func",
"GetEtcdImage",
"(",
"cfg",
"*",
"kubeadmapi",
".",
"ClusterConfiguration",
")",
"string",
"{",
"// Etcd uses default image repository by default",
"etcdImageRepository",
":=",
"cfg",
".",
"ImageRepository",
"\n",
"// unless an override is specified",
"if",
"cfg",
"... | // GetEtcdImage generates and returns the image for etcd | [
"GetEtcdImage",
"generates",
"and",
"returns",
"the",
"image",
"for",
"etcd"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/kubeadm/app/images/images.go#L63-L81 | train | GetEtcdImage returns the image for the etcd image | [
30522,
4569,
2278,
2131,
3388,
19797,
9581,
3351,
1006,
12935,
2290,
1008,
13970,
4783,
4215,
2863,
8197,
1012,
9324,
8663,
8873,
27390,
3370,
1007,
5164,
1063,
1013,
1013,
4385,
2094,
3594,
12398,
3746,
22409,
2011,
12398,
4385,
22172,
173... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | plugin/pkg/admission/podtolerationrestriction/admission.go | extractNSTolerations | func extractNSTolerations(ns *corev1.Namespace, key string) ([]api.Toleration, error) {
// if a namespace does not have any annotations
if len(ns.Annotations) == 0 {
return nil, nil
}
// if NSWLTolerations or NSDefaultTolerations does not exist
if _, ok := ns.Annotations[key]; !ok {
return nil, nil
}
// if value is set to empty
if len(ns.Annotations[key]) == 0 {
return []api.Toleration{}, nil
}
var v1Tolerations []v1.Toleration
err := json.Unmarshal([]byte(ns.Annotations[key]), &v1Tolerations)
if err != nil {
return nil, err
}
ts := make([]api.Toleration, len(v1Tolerations))
for i := range v1Tolerations {
if err := k8s_api_v1.Convert_v1_Toleration_To_core_Toleration(&v1Tolerations[i], &ts[i], nil); err != nil {
return nil, err
}
}
return ts, nil
} | go | func extractNSTolerations(ns *corev1.Namespace, key string) ([]api.Toleration, error) {
// if a namespace does not have any annotations
if len(ns.Annotations) == 0 {
return nil, nil
}
// if NSWLTolerations or NSDefaultTolerations does not exist
if _, ok := ns.Annotations[key]; !ok {
return nil, nil
}
// if value is set to empty
if len(ns.Annotations[key]) == 0 {
return []api.Toleration{}, nil
}
var v1Tolerations []v1.Toleration
err := json.Unmarshal([]byte(ns.Annotations[key]), &v1Tolerations)
if err != nil {
return nil, err
}
ts := make([]api.Toleration, len(v1Tolerations))
for i := range v1Tolerations {
if err := k8s_api_v1.Convert_v1_Toleration_To_core_Toleration(&v1Tolerations[i], &ts[i], nil); err != nil {
return nil, err
}
}
return ts, nil
} | [
"func",
"extractNSTolerations",
"(",
"ns",
"*",
"corev1",
".",
"Namespace",
",",
"key",
"string",
")",
"(",
"[",
"]",
"api",
".",
"Toleration",
",",
"error",
")",
"{",
"// if a namespace does not have any annotations",
"if",
"len",
"(",
"ns",
".",
"Annotations... | // extractNSTolerations extracts default or whitelist of tolerations from
// following namespace annotations keys: "scheduler.alpha.kubernetes.io/defaultTolerations"
// and "scheduler.alpha.kubernetes.io/tolerationsWhitelist". If these keys are
// unset (nil), extractNSTolerations returns nil. If the value to these
// keys are set to empty, an empty toleration is returned, otherwise
// configured tolerations are returned. | [
"extractNSTolerations",
"extracts",
"default",
"or",
"whitelist",
"of",
"tolerations",
"from",
"following",
"namespace",
"annotations",
"keys",
":",
"scheduler",
".",
"alpha",
".",
"kubernetes",
".",
"io",
"/",
"defaultTolerations",
"and",
"scheduler",
".",
"alpha",... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/plugin/pkg/admission/podtolerationrestriction/admission.go#L263-L293 | train | extractNSTolerations extracts the NSTolerations from a namespace and the given key. | [
30522,
4569,
2278,
14817,
23808,
9890,
28893,
1006,
24978,
1008,
4563,
2615,
2487,
1012,
3415,
15327,
1010,
3145,
5164,
1007,
1006,
1031,
1033,
17928,
1012,
2000,
3917,
3370,
1010,
7561,
1007,
1063,
1013,
1013,
2065,
1037,
3415,
15327,
2515... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/kubeadm/app/cmd/token.go | RunDeleteTokens | func RunDeleteTokens(out io.Writer, client clientset.Interface, tokenIDsOrTokens []string) error {
for _, tokenIDOrToken := range tokenIDsOrTokens {
// Assume this is a token id and try to parse it
tokenID := tokenIDOrToken
klog.V(1).Infof("[token] parsing token %q", tokenIDOrToken)
if !bootstraputil.IsValidBootstrapTokenID(tokenIDOrToken) {
// Okay, the full token with both id and secret was probably passed. Parse it and extract the ID only
bts, err := kubeadmapiv1beta2.NewBootstrapTokenString(tokenIDOrToken)
if err != nil {
return errors.Errorf("given token %q didn't match pattern %q or %q",
tokenIDOrToken, bootstrapapi.BootstrapTokenIDPattern, bootstrapapi.BootstrapTokenIDPattern)
}
tokenID = bts.ID
}
tokenSecretName := bootstraputil.BootstrapTokenSecretName(tokenID)
klog.V(1).Infof("[token] deleting token %q", tokenID)
if err := client.CoreV1().Secrets(metav1.NamespaceSystem).Delete(tokenSecretName, nil); err != nil {
return errors.Wrapf(err, "failed to delete bootstrap token %q", tokenID)
}
fmt.Fprintf(out, "bootstrap token %q deleted\n", tokenID)
}
return nil
} | go | func RunDeleteTokens(out io.Writer, client clientset.Interface, tokenIDsOrTokens []string) error {
for _, tokenIDOrToken := range tokenIDsOrTokens {
// Assume this is a token id and try to parse it
tokenID := tokenIDOrToken
klog.V(1).Infof("[token] parsing token %q", tokenIDOrToken)
if !bootstraputil.IsValidBootstrapTokenID(tokenIDOrToken) {
// Okay, the full token with both id and secret was probably passed. Parse it and extract the ID only
bts, err := kubeadmapiv1beta2.NewBootstrapTokenString(tokenIDOrToken)
if err != nil {
return errors.Errorf("given token %q didn't match pattern %q or %q",
tokenIDOrToken, bootstrapapi.BootstrapTokenIDPattern, bootstrapapi.BootstrapTokenIDPattern)
}
tokenID = bts.ID
}
tokenSecretName := bootstraputil.BootstrapTokenSecretName(tokenID)
klog.V(1).Infof("[token] deleting token %q", tokenID)
if err := client.CoreV1().Secrets(metav1.NamespaceSystem).Delete(tokenSecretName, nil); err != nil {
return errors.Wrapf(err, "failed to delete bootstrap token %q", tokenID)
}
fmt.Fprintf(out, "bootstrap token %q deleted\n", tokenID)
}
return nil
} | [
"func",
"RunDeleteTokens",
"(",
"out",
"io",
".",
"Writer",
",",
"client",
"clientset",
".",
"Interface",
",",
"tokenIDsOrTokens",
"[",
"]",
"string",
")",
"error",
"{",
"for",
"_",
",",
"tokenIDOrToken",
":=",
"range",
"tokenIDsOrTokens",
"{",
"// Assume this... | // RunDeleteTokens removes a bootstrap tokens from the server. | [
"RunDeleteTokens",
"removes",
"a",
"bootstrap",
"tokens",
"from",
"the",
"server",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/kubeadm/app/cmd/token.go#L300-L323 | train | RunDeleteTokens deletes the given tokens from the given list of tokens | [
30522,
4569,
2278,
2448,
9247,
12870,
18715,
6132,
1006,
2041,
22834,
1012,
3213,
1010,
7396,
7846,
3388,
1012,
8278,
1010,
19204,
9821,
11589,
11045,
3619,
1031,
1033,
5164,
1007,
7561,
1063,
2005,
1035,
1010,
19204,
13820,
5339,
11045,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/kubeadm/app/util/certs/util.go | CreateCACert | func CreateCACert(t *testing.T) (*x509.Certificate, crypto.Signer) {
certCfg := &certutil.Config{CommonName: "kubernetes"}
cert, key, err := pkiutil.NewCertificateAuthority(certCfg)
if err != nil {
t.Fatalf("couldn't create CA: %v", err)
}
return cert, key
} | go | func CreateCACert(t *testing.T) (*x509.Certificate, crypto.Signer) {
certCfg := &certutil.Config{CommonName: "kubernetes"}
cert, key, err := pkiutil.NewCertificateAuthority(certCfg)
if err != nil {
t.Fatalf("couldn't create CA: %v", err)
}
return cert, key
} | [
"func",
"CreateCACert",
"(",
"t",
"*",
"testing",
".",
"T",
")",
"(",
"*",
"x509",
".",
"Certificate",
",",
"crypto",
".",
"Signer",
")",
"{",
"certCfg",
":=",
"&",
"certutil",
".",
"Config",
"{",
"CommonName",
":",
"\"",
"\"",
"}",
"\n",
"cert",
"... | // CreateCACert creates a generic CA cert. | [
"CreateCACert",
"creates",
"a",
"generic",
"CA",
"cert",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/kubeadm/app/util/certs/util.go#L134-L141 | train | CreateCACert creates a certificate and key pair for the Kubernetes CA | [
30522,
4569,
2278,
3443,
3540,
17119,
2102,
1006,
1056,
1008,
5604,
1012,
1056,
1007,
1006,
1008,
1060,
12376,
2683,
1012,
8196,
1010,
19888,
2080,
1012,
3696,
2121,
1007,
1063,
8292,
5339,
2278,
2546,
2290,
1024,
1027,
1004,
8292,
5339,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/scheduler/internal/cache/fake/fake_cache.go | GetPod | func (c *Cache) GetPod(pod *v1.Pod) (*v1.Pod, error) {
return c.GetPodFunc(pod), nil
} | go | func (c *Cache) GetPod(pod *v1.Pod) (*v1.Pod, error) {
return c.GetPodFunc(pod), nil
} | [
"func",
"(",
"c",
"*",
"Cache",
")",
"GetPod",
"(",
"pod",
"*",
"v1",
".",
"Pod",
")",
"(",
"*",
"v1",
".",
"Pod",
",",
"error",
")",
"{",
"return",
"c",
".",
"GetPodFunc",
"(",
"pod",
")",
",",
"nil",
"\n",
"}"
] | // GetPod is a fake method for testing. | [
"GetPod",
"is",
"a",
"fake",
"method",
"for",
"testing",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/scheduler/internal/cache/fake/fake_cache.go#L64-L66 | train | GetPod returns the last query result set for a pod. | [
30522,
4569,
2278,
1006,
1039,
1008,
17053,
1007,
2131,
27633,
1006,
17491,
1008,
1058,
2487,
1012,
17491,
1007,
1006,
1008,
1058,
2487,
1012,
17491,
1010,
7561,
1007,
1063,
2709,
1039,
1012,
2131,
27633,
11263,
12273,
1006,
17491,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/generate/versioned/secret_for_docker_registry.go | ParamNames | func (s SecretForDockerRegistryGeneratorV1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "name", Required: true},
{Name: "from-file", Required: false},
{Name: "docker-username", Required: true},
{Name: "docker-email", Required: false},
{Name: "docker-password", Required: true},
{Name: "docker-server", Required: true},
{Name: "append-hash", Required: false},
}
} | go | func (s SecretForDockerRegistryGeneratorV1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "name", Required: true},
{Name: "from-file", Required: false},
{Name: "docker-username", Required: true},
{Name: "docker-email", Required: false},
{Name: "docker-password", Required: true},
{Name: "docker-server", Required: true},
{Name: "append-hash", Required: false},
}
} | [
"func",
"(",
"s",
"SecretForDockerRegistryGeneratorV1",
")",
"ParamNames",
"(",
")",
"[",
"]",
"generate",
".",
"GeneratorParam",
"{",
"return",
"[",
"]",
"generate",
".",
"GeneratorParam",
"{",
"{",
"Name",
":",
"\"",
"\"",
",",
"Required",
":",
"true",
"... | // ParamNames returns the set of supported input parameters when using the parameter injection generator pattern | [
"ParamNames",
"returns",
"the",
"set",
"of",
"supported",
"input",
"parameters",
"when",
"using",
"the",
"parameter",
"injection",
"generator",
"pattern"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/generate/versioned/secret_for_docker_registry.go#L118-L128 | train | ParamNames returns a list of parameters that are required to generate a secret for a docker registry | [
30522,
4569,
2278,
1006,
1055,
3595,
3877,
7432,
28849,
24063,
2854,
6914,
6906,
4263,
2615,
2487,
1007,
11498,
2213,
18442,
2015,
1006,
1007,
1031,
1033,
9699,
1012,
13103,
28689,
2213,
1063,
2709,
1031,
1033,
9699,
1012,
13103,
28689,
221... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/zz_generated.deepcopy.go | DeepCopy | func (in *Event) DeepCopy() *Event {
if in == nil {
return nil
}
out := new(Event)
in.DeepCopyInto(out)
return out
} | go | func (in *Event) DeepCopy() *Event {
if in == nil {
return nil
}
out := new(Event)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"Event",
")",
"DeepCopy",
"(",
")",
"*",
"Event",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Event",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"retur... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Event. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Event",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/zz_generated.deepcopy.go#L1300-L1307 | train | DeepCopy is an autogenerated deepcopy function copying the receiver creating a new Event. | [
30522,
4569,
2278,
1006,
1999,
1008,
2724,
1007,
2784,
3597,
7685,
1006,
1007,
1008,
2724,
1063,
2065,
1999,
1027,
1027,
9152,
2140,
1063,
2709,
9152,
2140,
1065,
2041,
1024,
1027,
2047,
1006,
2724,
1007,
1999,
1012,
2784,
3597,
7685,
184... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/registry/core/persistentvolumeclaim/strategy.go | GetAttrs | func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
persistentvolumeclaimObj, ok := obj.(*api.PersistentVolumeClaim)
if !ok {
return nil, nil, fmt.Errorf("not a persistentvolumeclaim")
}
return labels.Set(persistentvolumeclaimObj.Labels), PersistentVolumeClaimToSelectableFields(persistentvolumeclaimObj), nil
} | go | func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
persistentvolumeclaimObj, ok := obj.(*api.PersistentVolumeClaim)
if !ok {
return nil, nil, fmt.Errorf("not a persistentvolumeclaim")
}
return labels.Set(persistentvolumeclaimObj.Labels), PersistentVolumeClaimToSelectableFields(persistentvolumeclaimObj), nil
} | [
"func",
"GetAttrs",
"(",
"obj",
"runtime",
".",
"Object",
")",
"(",
"labels",
".",
"Set",
",",
"fields",
".",
"Set",
",",
"error",
")",
"{",
"persistentvolumeclaimObj",
",",
"ok",
":=",
"obj",
".",
"(",
"*",
"api",
".",
"PersistentVolumeClaim",
")",
"\... | // GetAttrs returns labels and fields of a given object for filtering purposes. | [
"GetAttrs",
"returns",
"labels",
"and",
"fields",
"of",
"a",
"given",
"object",
"for",
"filtering",
"purposes",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/registry/core/persistentvolumeclaim/strategy.go#L112-L118 | train | GetAttrs returns a set of labels and fields for a persistent volume claim | [
30522,
4569,
2278,
2131,
19321,
2869,
1006,
27885,
3501,
2448,
7292,
1012,
4874,
1007,
1006,
10873,
1012,
2275,
1010,
4249,
1012,
2275,
1010,
7561,
1007,
1063,
14516,
6767,
12942,
8586,
19771,
5302,
2497,
3501,
1010,
7929,
1024,
1027,
27885... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go | DeepCopyInto | func (in *APIGroupList) DeepCopyInto(out *APIGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.Groups != nil {
in, out := &in.Groups, &out.Groups
*out = make([]APIGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
} | go | func (in *APIGroupList) DeepCopyInto(out *APIGroupList) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.Groups != nil {
in, out := &in.Groups, &out.Groups
*out = make([]APIGroup, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
} | [
"func",
"(",
"in",
"*",
"APIGroupList",
")",
"DeepCopyInto",
"(",
"out",
"*",
"APIGroupList",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"out",
".",
"TypeMeta",
"=",
"in",
".",
"TypeMeta",
"\n",
"if",
"in",
".",
"Groups",
"!=",
"nil",
"{",
"in",
... | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go#L65-L76 | train | DeepCopyInto is an autogenerated deepcopy function copying the receiver creating a new APIGroupList. | [
30522,
4569,
2278,
1006,
1999,
1008,
17928,
17058,
9863,
1007,
2784,
3597,
7685,
18447,
2080,
1006,
2041,
1008,
17928,
17058,
9863,
1007,
1063,
1008,
2041,
1027,
1008,
1999,
2041,
1012,
2828,
11368,
2050,
1027,
1999,
1012,
2828,
11368,
2050... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/remote/remote_runtime.go | StopPodSandbox | func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
_, err := r.runtimeClient.StopPodSandbox(ctx, &runtimeapi.StopPodSandboxRequest{
PodSandboxId: podSandBoxID,
})
if err != nil {
klog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
return err
}
return nil
} | go | func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
_, err := r.runtimeClient.StopPodSandbox(ctx, &runtimeapi.StopPodSandboxRequest{
PodSandboxId: podSandBoxID,
})
if err != nil {
klog.Errorf("StopPodSandbox %q from runtime service failed: %v", podSandBoxID, err)
return err
}
return nil
} | [
"func",
"(",
"r",
"*",
"RemoteRuntimeService",
")",
"StopPodSandbox",
"(",
"podSandBoxID",
"string",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"getContextWithTimeout",
"(",
"r",
".",
"timeout",
")",
"\n",
"defer",
"cancel",
"(",
")",
"\n\n",
"_",
",",... | // StopPodSandbox stops the sandbox. If there are any running containers in the
// sandbox, they should be forced to termination. | [
"StopPodSandbox",
"stops",
"the",
"sandbox",
".",
"If",
"there",
"are",
"any",
"running",
"containers",
"in",
"the",
"sandbox",
"they",
"should",
"be",
"forced",
"to",
"termination",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/remote/remote_runtime.go#L120-L133 | train | StopPodSandbox stops a podSandbox from the runtime service | [
30522,
4569,
2278,
1006,
1054,
1008,
6556,
15532,
7292,
8043,
7903,
2063,
1007,
2644,
22925,
5685,
8758,
1006,
26723,
5685,
8758,
3593,
5164,
1007,
7561,
1063,
14931,
2595,
1010,
17542,
1024,
1027,
2131,
8663,
18209,
24415,
7292,
5833,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/util/nsenter/nsenter_mount_unsupported.go | GetFileType | func (*Mounter) GetFileType(_ string) (mount.FileType, error) {
return mount.FileType("fake"), errors.New("not implemented")
} | go | func (*Mounter) GetFileType(_ string) (mount.FileType, error) {
return mount.FileType("fake"), errors.New("not implemented")
} | [
"func",
"(",
"*",
"Mounter",
")",
"GetFileType",
"(",
"_",
"string",
")",
"(",
"mount",
".",
"FileType",
",",
"error",
")",
"{",
"return",
"mount",
".",
"FileType",
"(",
"\"",
"\"",
")",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
... | // GetFileType checks for file/directory/socket/block/character devices.
// Always returns an error and "fake" filetype on unsupported platforms | [
"GetFileType",
"checks",
"for",
"file",
"/",
"directory",
"/",
"socket",
"/",
"block",
"/",
"character",
"devices",
".",
"Always",
"returns",
"an",
"error",
"and",
"fake",
"filetype",
"on",
"unsupported",
"platforms"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/util/nsenter/nsenter_mount_unsupported.go#L93-L95 | train | GetFileType returns the file type of the file system. | [
30522,
4569,
2278,
1006,
1008,
4057,
2121,
1007,
2131,
8873,
7485,
18863,
1006,
1035,
5164,
1007,
1006,
4057,
1012,
5371,
13874,
1010,
7561,
1007,
1063,
2709,
4057,
1012,
5371,
13874,
1006,
1000,
8275,
1000,
1007,
1010,
10697,
1012,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/generate/versioned/secret_for_docker_registry.go | Generate | func (s SecretForDockerRegistryGeneratorV1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
err := generate.ValidateParams(s.ParamNames(), genericParams)
if err != nil {
return nil, err
}
delegate := &SecretForDockerRegistryGeneratorV1{}
hashParam, found := genericParams["append-hash"]
if found {
hashBool, isBool := hashParam.(bool)
if !isBool {
return nil, fmt.Errorf("expected bool, found :%v", hashParam)
}
delegate.AppendHash = hashBool
delete(genericParams, "append-hash")
}
params := map[string]string{}
for key, value := range genericParams {
strVal, isString := value.(string)
if !isString {
return nil, fmt.Errorf("expected string, saw %v for '%s'", value, key)
}
params[key] = strVal
}
delegate.Name = params["name"]
delegate.Username = params["docker-username"]
delegate.Email = params["docker-email"]
delegate.Password = params["docker-password"]
delegate.Server = params["docker-server"]
return delegate.StructuredGenerate()
} | go | func (s SecretForDockerRegistryGeneratorV1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
err := generate.ValidateParams(s.ParamNames(), genericParams)
if err != nil {
return nil, err
}
delegate := &SecretForDockerRegistryGeneratorV1{}
hashParam, found := genericParams["append-hash"]
if found {
hashBool, isBool := hashParam.(bool)
if !isBool {
return nil, fmt.Errorf("expected bool, found :%v", hashParam)
}
delegate.AppendHash = hashBool
delete(genericParams, "append-hash")
}
params := map[string]string{}
for key, value := range genericParams {
strVal, isString := value.(string)
if !isString {
return nil, fmt.Errorf("expected string, saw %v for '%s'", value, key)
}
params[key] = strVal
}
delegate.Name = params["name"]
delegate.Username = params["docker-username"]
delegate.Email = params["docker-email"]
delegate.Password = params["docker-password"]
delegate.Server = params["docker-server"]
return delegate.StructuredGenerate()
} | [
"func",
"(",
"s",
"SecretForDockerRegistryGeneratorV1",
")",
"Generate",
"(",
"genericParams",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"runtime",
".",
"Object",
",",
"error",
")",
"{",
"err",
":=",
"generate",
".",
"ValidateParams",
"(",
... | // Generate returns a secret using the specified parameters | [
"Generate",
"returns",
"a",
"secret",
"using",
"the",
"specified",
"parameters"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/generate/versioned/secret_for_docker_registry.go#L55-L84 | train | Generate generates a secret for docker registry | [
30522,
4569,
2278,
1006,
1055,
3595,
3877,
7432,
28849,
24063,
2854,
6914,
6906,
4263,
2615,
2487,
1007,
9699,
1006,
12391,
28689,
5244,
4949,
1031,
5164,
1033,
8278,
1063,
1065,
1007,
1006,
2448,
7292,
1012,
4874,
1010,
7561,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/util/volumepathhandler/volume_path_handler_linux.go | AttachFileDevice | func (v VolumePathHandler) AttachFileDevice(path string) (string, error) {
blockDevicePath, err := v.GetLoopDevice(path)
if err != nil && err.Error() != ErrDeviceNotFound {
return "", err
}
// If no existing loop device for the path, create one
if blockDevicePath == "" {
klog.V(4).Infof("Creating device for path: %s", path)
blockDevicePath, err = makeLoopDevice(path)
if err != nil {
return "", err
}
}
return blockDevicePath, nil
} | go | func (v VolumePathHandler) AttachFileDevice(path string) (string, error) {
blockDevicePath, err := v.GetLoopDevice(path)
if err != nil && err.Error() != ErrDeviceNotFound {
return "", err
}
// If no existing loop device for the path, create one
if blockDevicePath == "" {
klog.V(4).Infof("Creating device for path: %s", path)
blockDevicePath, err = makeLoopDevice(path)
if err != nil {
return "", err
}
}
return blockDevicePath, nil
} | [
"func",
"(",
"v",
"VolumePathHandler",
")",
"AttachFileDevice",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"blockDevicePath",
",",
"err",
":=",
"v",
".",
"GetLoopDevice",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"... | // AttachFileDevice takes a path to a regular file and makes it available as an
// attached block device. | [
"AttachFileDevice",
"takes",
"a",
"path",
"to",
"a",
"regular",
"file",
"and",
"makes",
"it",
"available",
"as",
"an",
"attached",
"block",
"device",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/util/volumepathhandler/volume_path_handler_linux.go#L33-L48 | train | AttachFileDevice attachs a file device to a loop device | [
30522,
4569,
2278,
1006,
1058,
3872,
15069,
11774,
3917,
1007,
22476,
8873,
3709,
17726,
2063,
1006,
4130,
5164,
1007,
1006,
5164,
1010,
7561,
1007,
1063,
3796,
24844,
6610,
15069,
1010,
9413,
2099,
1024,
1027,
1058,
1012,
2131,
4135,
7361,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/container/sync_result.go | NewSyncResult | func NewSyncResult(action SyncAction, target interface{}) *SyncResult {
return &SyncResult{Action: action, Target: target}
} | go | func NewSyncResult(action SyncAction, target interface{}) *SyncResult {
return &SyncResult{Action: action, Target: target}
} | [
"func",
"NewSyncResult",
"(",
"action",
"SyncAction",
",",
"target",
"interface",
"{",
"}",
")",
"*",
"SyncResult",
"{",
"return",
"&",
"SyncResult",
"{",
"Action",
":",
"action",
",",
"Target",
":",
"target",
"}",
"\n",
"}"
] | // NewSyncResult generates new SyncResult with specific Action and Target | [
"NewSyncResult",
"generates",
"new",
"SyncResult",
"with",
"specific",
"Action",
"and",
"Target"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/container/sync_result.go#L82-L84 | train | NewSyncResult returns a new SyncResult. | [
30522,
4569,
2278,
2739,
6038,
16748,
23722,
2102,
1006,
2895,
26351,
18908,
3258,
1010,
4539,
8278,
1063,
1065,
1007,
1008,
26351,
6072,
11314,
1063,
2709,
1004,
26351,
6072,
11314,
1063,
2895,
1024,
2895,
1010,
4539,
1024,
4539,
1065,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/batch/zz_generated.deepcopy.go | DeepCopyInto | func (in *Job) DeepCopyInto(out *Job) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
} | go | func (in *Job) DeepCopyInto(out *Job) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
} | [
"func",
"(",
"in",
"*",
"Job",
")",
"DeepCopyInto",
"(",
"out",
"*",
"Job",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"out",
".",
"TypeMeta",
"=",
"in",
".",
"TypeMeta",
"\n",
"in",
".",
"ObjectMeta",
".",
"DeepCopyInto",
"(",
"&",
"out",
".",
... | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/batch/zz_generated.deepcopy.go#L153-L160 | train | DeepCopyInto is a deep copy of the receiver | [
30522,
4569,
2278,
1006,
1999,
1008,
3105,
1007,
2784,
3597,
7685,
18447,
2080,
1006,
2041,
1008,
3105,
1007,
1063,
1008,
2041,
1027,
1008,
1999,
2041,
1012,
2828,
11368,
2050,
1027,
1999,
1012,
2828,
11368,
2050,
1999,
1012,
4874,
11368,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/iscsi/iscsi_util.go | AttachDisk | func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
var devicePath string
devicePaths := map[string]string{}
var iscsiTransport string
var lastErr error
out, err := b.exec.Run("iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "show")
if err != nil {
klog.Errorf("iscsi: could not read iface %s error: %s", b.Iface, string(out))
return "", err
}
iscsiTransport = extractTransportname(string(out))
bkpPortal := b.Portals
// create new iface and copy parameters from pre-configured iface to the created iface
if b.InitiatorName != "" {
// new iface name is <target portal>:<volume name>
newIface := bkpPortal[0] + ":" + b.VolName
err = cloneIface(b, newIface)
if err != nil {
klog.Errorf("iscsi: failed to clone iface: %s error: %v", b.Iface, err)
return "", err
}
// update iface name
b.Iface = newIface
}
// Lock the target while we login to avoid races between 2 volumes that share the same
// target both logging in or one logging out while another logs in.
b.plugin.targetLocks.LockKey(b.Iqn)
defer b.plugin.targetLocks.UnlockKey(b.Iqn)
// Build a map of SCSI hosts for each target portal. We will need this to
// issue the bus rescans.
portalHostMap, err := b.deviceUtil.GetISCSIPortalHostMapForTarget(b.Iqn)
if err != nil {
return "", err
}
klog.V(4).Infof("AttachDisk portal->host map for %s is %v", b.Iqn, portalHostMap)
for i := 1; i <= maxAttachAttempts; i++ {
for _, tp := range bkpPortal {
if _, found := devicePaths[tp]; found {
klog.V(4).Infof("Device for portal %q already known", tp)
continue
}
hostNumber, loggedIn := portalHostMap[tp]
if !loggedIn {
klog.V(4).Infof("Could not get SCSI host number for portal %s, will attempt login", tp)
// build discoverydb and discover iscsi target
b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "new")
// update discoverydb with CHAP secret
err = updateISCSIDiscoverydb(b, tp)
if err != nil {
lastErr = fmt.Errorf("iscsi: failed to update discoverydb to portal %s error: %v", tp, err)
continue
}
out, err = b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "--discover")
if err != nil {
// delete discoverydb record
b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "delete")
lastErr = fmt.Errorf("iscsi: failed to sendtargets to portal %s output: %s, err %v", tp, string(out), err)
continue
}
err = updateISCSINode(b, tp)
if err != nil {
// failure to update node db is rare. But deleting record will likely impact those who already start using it.
lastErr = fmt.Errorf("iscsi: failed to update iscsi node to portal %s error: %v", tp, err)
continue
}
// login to iscsi target
out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "--login")
if err != nil {
// delete the node record from database
b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-I", b.Iface, "-T", b.Iqn, "-o", "delete")
lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", string(out), err)
continue
}
// in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot
out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "-n", "node.startup", "-v", "manual")
if err != nil {
// don't fail if we can't set startup mode, but log warning so there is a clue
klog.Warningf("Warning: Failed to set iSCSI login mode to manual. Error: %v", err)
}
// Rebuild the host map after logging in
portalHostMap, err := b.deviceUtil.GetISCSIPortalHostMapForTarget(b.Iqn)
if err != nil {
return "", err
}
klog.V(6).Infof("AttachDisk portal->host map for %s is %v", b.Iqn, portalHostMap)
hostNumber, loggedIn = portalHostMap[tp]
if !loggedIn {
klog.Warningf("Could not get SCSI host number for portal %s after logging in", tp)
continue
}
}
klog.V(5).Infof("AttachDisk: scanning SCSI host %d LUN %s", hostNumber, b.Lun)
lunNumber, err := strconv.Atoi(b.Lun)
if err != nil {
return "", fmt.Errorf("AttachDisk: lun is not a number: %s\nError: %v", b.Lun, err)
}
// Scan the iSCSI bus for the LUN
err = scanOneLun(hostNumber, lunNumber)
if err != nil {
return "", err
}
if iscsiTransport == "" {
klog.Errorf("iscsi: could not find transport name in iface %s", b.Iface)
return "", fmt.Errorf("Could not parse iface file for %s", b.Iface)
}
if iscsiTransport == "tcp" {
devicePath = strings.Join([]string{"/dev/disk/by-path/ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-")
} else {
devicePath = strings.Join([]string{"/dev/disk/by-path/pci", "*", "ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-")
}
if exist := waitForPathToExist(&devicePath, multipathDeviceTimeout, iscsiTransport); !exist {
klog.Errorf("Could not attach disk: Timeout after 10s")
// update last error
lastErr = fmt.Errorf("Could not attach disk: Timeout after 10s")
continue
} else {
devicePaths[tp] = devicePath
}
}
klog.V(4).Infof("iscsi: tried all devices for %q %d times, %d paths found", b.Iqn, i, len(devicePaths))
if len(devicePaths) == 0 {
// No path attached, report error and stop trying. kubelet will try again in a short while
// delete cloned iface
b.exec.Run("iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "delete")
klog.Errorf("iscsi: failed to get any path for iscsi disk, last err seen:\n%v", lastErr)
return "", fmt.Errorf("failed to get any path for iscsi disk, last err seen:\n%v", lastErr)
}
if len(devicePaths) == len(bkpPortal) {
// We have all paths
klog.V(4).Infof("iscsi: all devices for %q found", b.Iqn)
break
}
if len(devicePaths) >= minMultipathCount && i >= minAttachAttempts {
// We have at least two paths for multipath and we tried the other paths long enough
klog.V(4).Infof("%d devices found for %q", len(devicePaths), b.Iqn)
break
}
}
if lastErr != nil {
klog.Errorf("iscsi: last error occurred during iscsi init:\n%v", lastErr)
}
devicePathList := []string{}
for _, path := range devicePaths {
devicePathList = append(devicePathList, path)
}
// Try to find a multipath device for the volume
if len(bkpPortal) > 1 {
// Multipath volume was requested. Wait up to 10 seconds for the multipath device to appear.
devicePath = waitForMultiPathToExist(devicePathList, 10, b.deviceUtil)
} else {
// For PVs with 1 portal, just try one time to find the multipath device. This
// avoids a long pause when the multipath device will never get created, and
// matches legacy behavior.
devicePath = waitForMultiPathToExist(devicePathList, 1, b.deviceUtil)
}
// When no multipath device is found, just use the first (and presumably only) device
if devicePath == "" {
devicePath = devicePathList[0]
}
klog.V(5).Infof("iscsi: AttachDisk devicePath: %s", devicePath)
// run global mount path related operations based on volumeMode
return globalPDPathOperation(b)(b, devicePath, util)
} | go | func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
var devicePath string
devicePaths := map[string]string{}
var iscsiTransport string
var lastErr error
out, err := b.exec.Run("iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "show")
if err != nil {
klog.Errorf("iscsi: could not read iface %s error: %s", b.Iface, string(out))
return "", err
}
iscsiTransport = extractTransportname(string(out))
bkpPortal := b.Portals
// create new iface and copy parameters from pre-configured iface to the created iface
if b.InitiatorName != "" {
// new iface name is <target portal>:<volume name>
newIface := bkpPortal[0] + ":" + b.VolName
err = cloneIface(b, newIface)
if err != nil {
klog.Errorf("iscsi: failed to clone iface: %s error: %v", b.Iface, err)
return "", err
}
// update iface name
b.Iface = newIface
}
// Lock the target while we login to avoid races between 2 volumes that share the same
// target both logging in or one logging out while another logs in.
b.plugin.targetLocks.LockKey(b.Iqn)
defer b.plugin.targetLocks.UnlockKey(b.Iqn)
// Build a map of SCSI hosts for each target portal. We will need this to
// issue the bus rescans.
portalHostMap, err := b.deviceUtil.GetISCSIPortalHostMapForTarget(b.Iqn)
if err != nil {
return "", err
}
klog.V(4).Infof("AttachDisk portal->host map for %s is %v", b.Iqn, portalHostMap)
for i := 1; i <= maxAttachAttempts; i++ {
for _, tp := range bkpPortal {
if _, found := devicePaths[tp]; found {
klog.V(4).Infof("Device for portal %q already known", tp)
continue
}
hostNumber, loggedIn := portalHostMap[tp]
if !loggedIn {
klog.V(4).Infof("Could not get SCSI host number for portal %s, will attempt login", tp)
// build discoverydb and discover iscsi target
b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "new")
// update discoverydb with CHAP secret
err = updateISCSIDiscoverydb(b, tp)
if err != nil {
lastErr = fmt.Errorf("iscsi: failed to update discoverydb to portal %s error: %v", tp, err)
continue
}
out, err = b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "--discover")
if err != nil {
// delete discoverydb record
b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "delete")
lastErr = fmt.Errorf("iscsi: failed to sendtargets to portal %s output: %s, err %v", tp, string(out), err)
continue
}
err = updateISCSINode(b, tp)
if err != nil {
// failure to update node db is rare. But deleting record will likely impact those who already start using it.
lastErr = fmt.Errorf("iscsi: failed to update iscsi node to portal %s error: %v", tp, err)
continue
}
// login to iscsi target
out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "--login")
if err != nil {
// delete the node record from database
b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-I", b.Iface, "-T", b.Iqn, "-o", "delete")
lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", string(out), err)
continue
}
// in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot
out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "-n", "node.startup", "-v", "manual")
if err != nil {
// don't fail if we can't set startup mode, but log warning so there is a clue
klog.Warningf("Warning: Failed to set iSCSI login mode to manual. Error: %v", err)
}
// Rebuild the host map after logging in
portalHostMap, err := b.deviceUtil.GetISCSIPortalHostMapForTarget(b.Iqn)
if err != nil {
return "", err
}
klog.V(6).Infof("AttachDisk portal->host map for %s is %v", b.Iqn, portalHostMap)
hostNumber, loggedIn = portalHostMap[tp]
if !loggedIn {
klog.Warningf("Could not get SCSI host number for portal %s after logging in", tp)
continue
}
}
klog.V(5).Infof("AttachDisk: scanning SCSI host %d LUN %s", hostNumber, b.Lun)
lunNumber, err := strconv.Atoi(b.Lun)
if err != nil {
return "", fmt.Errorf("AttachDisk: lun is not a number: %s\nError: %v", b.Lun, err)
}
// Scan the iSCSI bus for the LUN
err = scanOneLun(hostNumber, lunNumber)
if err != nil {
return "", err
}
if iscsiTransport == "" {
klog.Errorf("iscsi: could not find transport name in iface %s", b.Iface)
return "", fmt.Errorf("Could not parse iface file for %s", b.Iface)
}
if iscsiTransport == "tcp" {
devicePath = strings.Join([]string{"/dev/disk/by-path/ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-")
} else {
devicePath = strings.Join([]string{"/dev/disk/by-path/pci", "*", "ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-")
}
if exist := waitForPathToExist(&devicePath, multipathDeviceTimeout, iscsiTransport); !exist {
klog.Errorf("Could not attach disk: Timeout after 10s")
// update last error
lastErr = fmt.Errorf("Could not attach disk: Timeout after 10s")
continue
} else {
devicePaths[tp] = devicePath
}
}
klog.V(4).Infof("iscsi: tried all devices for %q %d times, %d paths found", b.Iqn, i, len(devicePaths))
if len(devicePaths) == 0 {
// No path attached, report error and stop trying. kubelet will try again in a short while
// delete cloned iface
b.exec.Run("iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "delete")
klog.Errorf("iscsi: failed to get any path for iscsi disk, last err seen:\n%v", lastErr)
return "", fmt.Errorf("failed to get any path for iscsi disk, last err seen:\n%v", lastErr)
}
if len(devicePaths) == len(bkpPortal) {
// We have all paths
klog.V(4).Infof("iscsi: all devices for %q found", b.Iqn)
break
}
if len(devicePaths) >= minMultipathCount && i >= minAttachAttempts {
// We have at least two paths for multipath and we tried the other paths long enough
klog.V(4).Infof("%d devices found for %q", len(devicePaths), b.Iqn)
break
}
}
if lastErr != nil {
klog.Errorf("iscsi: last error occurred during iscsi init:\n%v", lastErr)
}
devicePathList := []string{}
for _, path := range devicePaths {
devicePathList = append(devicePathList, path)
}
// Try to find a multipath device for the volume
if len(bkpPortal) > 1 {
// Multipath volume was requested. Wait up to 10 seconds for the multipath device to appear.
devicePath = waitForMultiPathToExist(devicePathList, 10, b.deviceUtil)
} else {
// For PVs with 1 portal, just try one time to find the multipath device. This
// avoids a long pause when the multipath device will never get created, and
// matches legacy behavior.
devicePath = waitForMultiPathToExist(devicePathList, 1, b.deviceUtil)
}
// When no multipath device is found, just use the first (and presumably only) device
if devicePath == "" {
devicePath = devicePathList[0]
}
klog.V(5).Infof("iscsi: AttachDisk devicePath: %s", devicePath)
// run global mount path related operations based on volumeMode
return globalPDPathOperation(b)(b, devicePath, util)
} | [
"func",
"(",
"util",
"*",
"ISCSIUtil",
")",
"AttachDisk",
"(",
"b",
"iscsiDiskMounter",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"devicePath",
"string",
"\n",
"devicePaths",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"var",
"i... | // AttachDisk returns devicePath of volume if attach succeeded otherwise returns error | [
"AttachDisk",
"returns",
"devicePath",
"of",
"volume",
"if",
"attach",
"succeeded",
"otherwise",
"returns",
"error"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/iscsi/iscsi_util.go#L290-L476 | train | AttachDisk attaches a volume to the specified device. | [
30522,
4569,
2278,
1006,
21183,
4014,
1008,
2003,
6169,
17922,
3775,
2140,
1007,
22476,
10521,
2243,
1006,
1038,
2003,
6169,
28173,
6711,
20048,
2121,
1007,
1006,
5164,
1010,
7561,
1007,
1063,
13075,
5080,
15069,
5164,
5080,
15069,
2015,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/resourcequota/resource_quota_controller.go | Run | func (rq *ResourceQuotaController) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
defer rq.queue.ShutDown()
klog.Infof("Starting resource quota controller")
defer klog.Infof("Shutting down resource quota controller")
if rq.quotaMonitor != nil {
go rq.quotaMonitor.Run(stopCh)
}
if !controller.WaitForCacheSync("resource quota", stopCh, rq.informerSyncedFuncs...) {
return
}
// the workers that chug through the quota calculation backlog
for i := 0; i < workers; i++ {
go wait.Until(rq.worker(rq.queue), time.Second, stopCh)
go wait.Until(rq.worker(rq.missingUsageQueue), time.Second, stopCh)
}
// the timer for how often we do a full recalculation across all quotas
go wait.Until(func() { rq.enqueueAll() }, rq.resyncPeriod(), stopCh)
<-stopCh
} | go | func (rq *ResourceQuotaController) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
defer rq.queue.ShutDown()
klog.Infof("Starting resource quota controller")
defer klog.Infof("Shutting down resource quota controller")
if rq.quotaMonitor != nil {
go rq.quotaMonitor.Run(stopCh)
}
if !controller.WaitForCacheSync("resource quota", stopCh, rq.informerSyncedFuncs...) {
return
}
// the workers that chug through the quota calculation backlog
for i := 0; i < workers; i++ {
go wait.Until(rq.worker(rq.queue), time.Second, stopCh)
go wait.Until(rq.worker(rq.missingUsageQueue), time.Second, stopCh)
}
// the timer for how often we do a full recalculation across all quotas
go wait.Until(func() { rq.enqueueAll() }, rq.resyncPeriod(), stopCh)
<-stopCh
} | [
"func",
"(",
"rq",
"*",
"ResourceQuotaController",
")",
"Run",
"(",
"workers",
"int",
",",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"defer",
"utilruntime",
".",
"HandleCrash",
"(",
")",
"\n",
"defer",
"rq",
".",
"queue",
".",
"ShutDown",
"... | // Run begins quota controller using the specified number of workers | [
"Run",
"begins",
"quota",
"controller",
"using",
"the",
"specified",
"number",
"of",
"workers"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/resourcequota/resource_quota_controller.go#L267-L290 | train | Run starts the quota controller | [
30522,
4569,
2278,
1006,
28134,
1008,
7692,
28940,
17287,
8663,
13181,
10820,
1007,
2448,
1006,
3667,
20014,
1010,
2644,
2818,
1026,
1011,
9212,
2358,
6820,
6593,
1063,
1065,
1007,
1063,
13366,
2121,
21183,
4014,
15532,
7292,
1012,
5047,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/tools/cache/controller.go | OnDelete | func (r ResourceEventHandlerFuncs) OnDelete(obj interface{}) {
if r.DeleteFunc != nil {
r.DeleteFunc(obj)
}
} | go | func (r ResourceEventHandlerFuncs) OnDelete(obj interface{}) {
if r.DeleteFunc != nil {
r.DeleteFunc(obj)
}
} | [
"func",
"(",
"r",
"ResourceEventHandlerFuncs",
")",
"OnDelete",
"(",
"obj",
"interface",
"{",
"}",
")",
"{",
"if",
"r",
".",
"DeleteFunc",
"!=",
"nil",
"{",
"r",
".",
"DeleteFunc",
"(",
"obj",
")",
"\n",
"}",
"\n",
"}"
] | // OnDelete calls DeleteFunc if it's not nil. | [
"OnDelete",
"calls",
"DeleteFunc",
"if",
"it",
"s",
"not",
"nil",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/cache/controller.go#L207-L211 | train | OnDelete calls the DeleteFunc if it is not nil | [
30522,
4569,
2278,
1006,
1054,
7692,
18697,
3372,
11774,
3917,
11263,
12273,
2015,
1007,
2006,
9247,
12870,
1006,
27885,
3501,
8278,
1063,
1065,
1007,
1063,
2065,
1054,
1012,
3972,
12870,
11263,
12273,
999,
1027,
9152,
2140,
1063,
1054,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/validation/validation.go | validateContainerResourceName | func validateContainerResourceName(value string, fldPath *field.Path) field.ErrorList {
allErrs := validateResourceName(value, fldPath)
if len(strings.Split(value, "/")) == 1 {
if !helper.IsStandardContainerResourceName(value) {
return append(allErrs, field.Invalid(fldPath, value, "must be a standard resource for containers"))
}
} else if !helper.IsNativeResource(core.ResourceName(value)) {
if !helper.IsExtendedResourceName(core.ResourceName(value)) {
return append(allErrs, field.Invalid(fldPath, value, "doesn't follow extended resource name standard"))
}
}
return allErrs
} | go | func validateContainerResourceName(value string, fldPath *field.Path) field.ErrorList {
allErrs := validateResourceName(value, fldPath)
if len(strings.Split(value, "/")) == 1 {
if !helper.IsStandardContainerResourceName(value) {
return append(allErrs, field.Invalid(fldPath, value, "must be a standard resource for containers"))
}
} else if !helper.IsNativeResource(core.ResourceName(value)) {
if !helper.IsExtendedResourceName(core.ResourceName(value)) {
return append(allErrs, field.Invalid(fldPath, value, "doesn't follow extended resource name standard"))
}
}
return allErrs
} | [
"func",
"validateContainerResourceName",
"(",
"value",
"string",
",",
"fldPath",
"*",
"field",
".",
"Path",
")",
"field",
".",
"ErrorList",
"{",
"allErrs",
":=",
"validateResourceName",
"(",
"value",
",",
"fldPath",
")",
"\n\n",
"if",
"len",
"(",
"strings",
... | // Validate container resource name
// Refer to docs/design/resources.md for more details. | [
"Validate",
"container",
"resource",
"name",
"Refer",
"to",
"docs",
"/",
"design",
"/",
"resources",
".",
"md",
"for",
"more",
"details",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/validation/validation.go#L4362-L4375 | train | validateContainerResourceName validates the resource name of a container | [
30522,
4569,
2278,
9398,
3686,
8663,
18249,
28849,
6499,
3126,
27524,
14074,
1006,
3643,
5164,
1010,
13109,
18927,
8988,
1008,
2492,
1012,
4130,
1007,
2492,
1012,
7561,
9863,
1063,
2035,
2121,
2869,
1024,
1027,
9398,
24932,
2229,
8162,
2752... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go | DeepCopyInto | func (in *DeleteOptions) DeepCopyInto(out *DeleteOptions) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.GracePeriodSeconds != nil {
in, out := &in.GracePeriodSeconds, &out.GracePeriodSeconds
*out = new(int64)
**out = **in
}
if in.Preconditions != nil {
in, out := &in.Preconditions, &out.Preconditions
*out = new(Preconditions)
(*in).DeepCopyInto(*out)
}
if in.OrphanDependents != nil {
in, out := &in.OrphanDependents, &out.OrphanDependents
*out = new(bool)
**out = **in
}
if in.PropagationPolicy != nil {
in, out := &in.PropagationPolicy, &out.PropagationPolicy
*out = new(DeletionPropagation)
**out = **in
}
if in.DryRun != nil {
in, out := &in.DryRun, &out.DryRun
*out = make([]string, len(*in))
copy(*out, *in)
}
return
} | go | func (in *DeleteOptions) DeepCopyInto(out *DeleteOptions) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.GracePeriodSeconds != nil {
in, out := &in.GracePeriodSeconds, &out.GracePeriodSeconds
*out = new(int64)
**out = **in
}
if in.Preconditions != nil {
in, out := &in.Preconditions, &out.Preconditions
*out = new(Preconditions)
(*in).DeepCopyInto(*out)
}
if in.OrphanDependents != nil {
in, out := &in.OrphanDependents, &out.OrphanDependents
*out = new(bool)
**out = **in
}
if in.PropagationPolicy != nil {
in, out := &in.PropagationPolicy, &out.PropagationPolicy
*out = new(DeletionPropagation)
**out = **in
}
if in.DryRun != nil {
in, out := &in.DryRun, &out.DryRun
*out = make([]string, len(*in))
copy(*out, *in)
}
return
} | [
"func",
"(",
"in",
"*",
"DeleteOptions",
")",
"DeepCopyInto",
"(",
"out",
"*",
"DeleteOptions",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"out",
".",
"TypeMeta",
"=",
"in",
".",
"TypeMeta",
"\n",
"if",
"in",
".",
"GracePeriodSeconds",
"!=",
"nil",
... | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go#L225-L254 | train | DeepCopyInto is an autogenerated deepcopy function copying the receiver creating a new DeleteOptions. | [
30522,
4569,
2278,
1006,
1999,
1008,
3972,
12870,
7361,
9285,
1007,
2784,
3597,
7685,
18447,
2080,
1006,
2041,
1008,
3972,
12870,
7361,
9285,
1007,
1063,
1008,
2041,
1027,
1008,
1999,
2041,
1012,
2828,
11368,
2050,
1027,
1999,
1012,
2828,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go | Install | func Install(scheme *runtime.Scheme) {
utilruntime.Must(custom_metrics.AddToScheme(scheme))
utilruntime.Must(v1beta2.AddToScheme(scheme))
utilruntime.Must(v1beta1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1beta2.SchemeGroupVersion))
} | go | func Install(scheme *runtime.Scheme) {
utilruntime.Must(custom_metrics.AddToScheme(scheme))
utilruntime.Must(v1beta2.AddToScheme(scheme))
utilruntime.Must(v1beta1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion, v1beta2.SchemeGroupVersion))
} | [
"func",
"Install",
"(",
"scheme",
"*",
"runtime",
".",
"Scheme",
")",
"{",
"utilruntime",
".",
"Must",
"(",
"custom_metrics",
".",
"AddToScheme",
"(",
"scheme",
")",
")",
"\n",
"utilruntime",
".",
"Must",
"(",
"v1beta2",
".",
"AddToScheme",
"(",
"scheme",
... | // Install registers the API group and adds types to a scheme | [
"Install",
"registers",
"the",
"API",
"group",
"and",
"adds",
"types",
"to",
"a",
"scheme"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/metrics/pkg/apis/custom_metrics/install/install.go#L30-L35 | train | Install installs a new scheme. | [
30522,
4569,
2278,
16500,
1006,
5679,
1008,
2448,
7292,
1012,
5679,
1007,
1063,
21183,
4014,
15532,
7292,
1012,
2442,
1006,
7661,
1035,
12046,
2015,
1012,
5587,
13122,
5403,
4168,
1006,
5679,
1007,
1007,
21183,
4014,
15532,
7292,
1012,
2442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go | extractScaleSetNameByProviderID | func extractScaleSetNameByProviderID(providerID string) (string, error) {
matches := scaleSetNameRE.FindStringSubmatch(providerID)
if len(matches) != 2 {
return "", ErrorNotVmssInstance
}
return matches[1], nil
} | go | func extractScaleSetNameByProviderID(providerID string) (string, error) {
matches := scaleSetNameRE.FindStringSubmatch(providerID)
if len(matches) != 2 {
return "", ErrorNotVmssInstance
}
return matches[1], nil
} | [
"func",
"extractScaleSetNameByProviderID",
"(",
"providerID",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"matches",
":=",
"scaleSetNameRE",
".",
"FindStringSubmatch",
"(",
"providerID",
")",
"\n",
"if",
"len",
"(",
"matches",
")",
"!=",
"2",
"{",
... | // extractScaleSetNameByProviderID extracts the scaleset name by vmss node's ProviderID. | [
"extractScaleSetNameByProviderID",
"extracts",
"the",
"scaleset",
"name",
"by",
"vmss",
"node",
"s",
"ProviderID",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go#L381-L388 | train | extractScaleSetNameByProviderID returns the scaleSetName that matches the given providerID. | [
30522,
4569,
2278,
27059,
9289,
6810,
2102,
18442,
3762,
21572,
17258,
11124,
2094,
1006,
10802,
3593,
5164,
1007,
1006,
5164,
1010,
7561,
1007,
1063,
3503,
1024,
1027,
9539,
3388,
18442,
2890,
1012,
4858,
18886,
3070,
6342,
25526,
4017,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/storageos/storageos.go | getVolumeInfo | func getVolumeInfo(pvName string, podUID types.UID, host volume.VolumeHost) (string, string, error) {
if volNamespace, volName, err := getVolumeFromRef(pvName); err == nil {
return volNamespace, volName, nil
}
volumeDir := filepath.Dir(host.GetPodVolumeDir(podUID, utilstrings.EscapeQualifiedName(storageosPluginName), pvName))
files, err := ioutil.ReadDir(volumeDir)
if err != nil {
return "", "", fmt.Errorf("Could not read mounts from pod volume dir: %s", err)
}
for _, f := range files {
if f.Mode().IsDir() && strings.HasPrefix(f.Name(), pvName+".") {
if volNamespace, volName, err := getVolumeFromRef(f.Name()); err == nil {
return volNamespace, volName, nil
}
}
}
return "", "", fmt.Errorf("Could not get info from unmounted pv %q at %q", pvName, volumeDir)
} | go | func getVolumeInfo(pvName string, podUID types.UID, host volume.VolumeHost) (string, string, error) {
if volNamespace, volName, err := getVolumeFromRef(pvName); err == nil {
return volNamespace, volName, nil
}
volumeDir := filepath.Dir(host.GetPodVolumeDir(podUID, utilstrings.EscapeQualifiedName(storageosPluginName), pvName))
files, err := ioutil.ReadDir(volumeDir)
if err != nil {
return "", "", fmt.Errorf("Could not read mounts from pod volume dir: %s", err)
}
for _, f := range files {
if f.Mode().IsDir() && strings.HasPrefix(f.Name(), pvName+".") {
if volNamespace, volName, err := getVolumeFromRef(f.Name()); err == nil {
return volNamespace, volName, nil
}
}
}
return "", "", fmt.Errorf("Could not get info from unmounted pv %q at %q", pvName, volumeDir)
} | [
"func",
"getVolumeInfo",
"(",
"pvName",
"string",
",",
"podUID",
"types",
".",
"UID",
",",
"host",
"volume",
".",
"VolumeHost",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"if",
"volNamespace",
",",
"volName",
",",
"err",
":=",
"getVolumeF... | // Given the pod id and PV name, finds the volume's namespace and name from the
// name or volume mount. We mount as volNamespace.pvName, but k8s will specify
// only the pvName to unmount.
// Will return empty volNamespace/pvName if the volume is not mounted. | [
"Given",
"the",
"pod",
"id",
"and",
"PV",
"name",
"finds",
"the",
"volume",
"s",
"namespace",
"and",
"name",
"from",
"the",
"name",
"or",
"volume",
"mount",
".",
"We",
"mount",
"as",
"volNamespace",
".",
"pvName",
"but",
"k8s",
"will",
"specify",
"only",... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/storageos/storageos.go#L450-L468 | train | getVolumeInfo returns the namespace and name of the volume | [
30522,
4569,
2278,
2131,
6767,
12942,
12377,
14876,
1006,
26189,
18442,
5164,
1010,
17491,
21272,
4127,
1012,
21318,
2094,
1010,
3677,
3872,
1012,
3872,
15006,
2102,
1007,
1006,
5164,
1010,
5164,
1010,
7561,
1007,
1063,
2065,
5285,
18442,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/cmd/cmd.go | NewDefaultKubectlCommandWithArgs | func NewDefaultKubectlCommandWithArgs(pluginHandler PluginHandler, args []string, in io.Reader, out, errout io.Writer) *cobra.Command {
cmd := NewKubectlCommand(in, out, errout)
if pluginHandler == nil {
return cmd
}
if len(args) > 1 {
cmdPathPieces := args[1:]
// only look for suitable extension executables if
// the specified command does not already exist
if _, _, err := cmd.Find(cmdPathPieces); err != nil {
if err := HandlePluginCommand(pluginHandler, cmdPathPieces); err != nil {
fmt.Fprintf(errout, "%v\n", err)
os.Exit(1)
}
}
}
return cmd
} | go | func NewDefaultKubectlCommandWithArgs(pluginHandler PluginHandler, args []string, in io.Reader, out, errout io.Writer) *cobra.Command {
cmd := NewKubectlCommand(in, out, errout)
if pluginHandler == nil {
return cmd
}
if len(args) > 1 {
cmdPathPieces := args[1:]
// only look for suitable extension executables if
// the specified command does not already exist
if _, _, err := cmd.Find(cmdPathPieces); err != nil {
if err := HandlePluginCommand(pluginHandler, cmdPathPieces); err != nil {
fmt.Fprintf(errout, "%v\n", err)
os.Exit(1)
}
}
}
return cmd
} | [
"func",
"NewDefaultKubectlCommandWithArgs",
"(",
"pluginHandler",
"PluginHandler",
",",
"args",
"[",
"]",
"string",
",",
"in",
"io",
".",
"Reader",
",",
"out",
",",
"errout",
"io",
".",
"Writer",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"NewKub... | // NewDefaultKubectlCommandWithArgs creates the `kubectl` command with arguments | [
"NewDefaultKubectlCommandWithArgs",
"creates",
"the",
"kubectl",
"command",
"with",
"arguments"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/cmd.go#L301-L322 | train | NewDefaultKubectlCommandWithArgs creates a new command with the specified arguments. | [
30522,
4569,
2278,
2047,
3207,
7011,
11314,
5283,
4783,
6593,
22499,
14760,
4859,
24415,
2906,
5620,
1006,
13354,
2378,
11774,
3917,
13354,
2378,
11774,
3917,
1010,
12098,
5620,
1031,
1033,
5164,
1010,
1999,
22834,
1012,
8068,
1010,
2041,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/flexvolume/mounter-defaults.go | SetUpAt | func (f *mounterDefaults) SetUpAt(dir string, fsGroup *int64) error {
klog.Warning(logPrefix(f.plugin), "using default SetUpAt to ", dir)
src, err := f.plugin.getDeviceMountPath(f.spec)
if err != nil {
return err
}
if err := doMount(f.mounter, src, dir, "auto", []string{"bind"}); err != nil {
return err
}
return nil
} | go | func (f *mounterDefaults) SetUpAt(dir string, fsGroup *int64) error {
klog.Warning(logPrefix(f.plugin), "using default SetUpAt to ", dir)
src, err := f.plugin.getDeviceMountPath(f.spec)
if err != nil {
return err
}
if err := doMount(f.mounter, src, dir, "auto", []string{"bind"}); err != nil {
return err
}
return nil
} | [
"func",
"(",
"f",
"*",
"mounterDefaults",
")",
"SetUpAt",
"(",
"dir",
"string",
",",
"fsGroup",
"*",
"int64",
")",
"error",
"{",
"klog",
".",
"Warning",
"(",
"logPrefix",
"(",
"f",
".",
"plugin",
")",
",",
"\"",
"\"",
",",
"dir",
")",
"\n\n",
"src"... | // SetUpAt is part of the volume.Mounter interface.
// This implementation relies on the attacher's device mount path and does a bind mount to dir. | [
"SetUpAt",
"is",
"part",
"of",
"the",
"volume",
".",
"Mounter",
"interface",
".",
"This",
"implementation",
"relies",
"on",
"the",
"attacher",
"s",
"device",
"mount",
"path",
"and",
"does",
"a",
"bind",
"mount",
"to",
"dir",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/flexvolume/mounter-defaults.go#L29-L42 | train | SetUpAt sets up the filesystem at the specified path. | [
30522,
4569,
2278,
1006,
1042,
1008,
4057,
2121,
3207,
7011,
11314,
2015,
1007,
16437,
4017,
1006,
16101,
5164,
1010,
1042,
28745,
22107,
1008,
20014,
21084,
1007,
7561,
1063,
1047,
21197,
1012,
5432,
1006,
8833,
28139,
8873,
2595,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/cloudprovider/providers/photon/photon.go | GetZoneByNodeName | func (pc *PCCloud) GetZoneByNodeName(ctx context.Context, nodeName k8stypes.NodeName) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not imeplemented")
} | go | func (pc *PCCloud) GetZoneByNodeName(ctx context.Context, nodeName k8stypes.NodeName) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not imeplemented")
} | [
"func",
"(",
"pc",
"*",
"PCCloud",
")",
"GetZoneByNodeName",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeName",
"k8stypes",
".",
"NodeName",
")",
"(",
"cloudprovider",
".",
"Zone",
",",
"error",
")",
"{",
"return",
"cloudprovider",
".",
"Zone",
"{",
... | // GetZoneByNodeName implements Zones.GetZoneByNodeName
// This is particularly useful in external cloud providers where the kubelet
// does not initialize node data. | [
"GetZoneByNodeName",
"implements",
"Zones",
".",
"GetZoneByNodeName",
"This",
"is",
"particularly",
"useful",
"in",
"external",
"cloud",
"providers",
"where",
"the",
"kubelet",
"does",
"not",
"initialize",
"node",
"data",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/photon/photon.go#L531-L533 | train | GetZoneByNodeName returns zone by node name | [
30522,
4569,
2278,
1006,
7473,
1008,
7473,
20464,
19224,
1007,
2131,
15975,
3762,
3630,
4181,
14074,
1006,
14931,
2595,
6123,
1012,
6123,
1010,
13045,
18442,
1047,
2620,
21756,
10374,
1012,
13045,
18442,
1007,
1006,
6112,
21572,
17258,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/cloudprovider/providers/openstack/openstack_routes.go | NewRoutes | func NewRoutes(compute *gophercloud.ServiceClient, network *gophercloud.ServiceClient, opts RouterOpts) (cloudprovider.Routes, error) {
if opts.RouterID == "" {
return nil, errNoRouterID
}
return &Routes{
compute: compute,
network: network,
opts: opts,
}, nil
} | go | func NewRoutes(compute *gophercloud.ServiceClient, network *gophercloud.ServiceClient, opts RouterOpts) (cloudprovider.Routes, error) {
if opts.RouterID == "" {
return nil, errNoRouterID
}
return &Routes{
compute: compute,
network: network,
opts: opts,
}, nil
} | [
"func",
"NewRoutes",
"(",
"compute",
"*",
"gophercloud",
".",
"ServiceClient",
",",
"network",
"*",
"gophercloud",
".",
"ServiceClient",
",",
"opts",
"RouterOpts",
")",
"(",
"cloudprovider",
".",
"Routes",
",",
"error",
")",
"{",
"if",
"opts",
".",
"RouterID... | // NewRoutes creates a new instance of Routes | [
"NewRoutes",
"creates",
"a",
"new",
"instance",
"of",
"Routes"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/openstack/openstack_routes.go#L46-L56 | train | NewRoutes returns a new routes object | [
30522,
4569,
2278,
2047,
22494,
4570,
1006,
24134,
1008,
2175,
27921,
20464,
19224,
1012,
2326,
20464,
11638,
1010,
2897,
1008,
2175,
27921,
20464,
19224,
1012,
2326,
20464,
11638,
1010,
23569,
2015,
2799,
18981,
3215,
1007,
1006,
6112,
21572... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/util/ipset/ipset.go | DestroySet | func (runner *runner) DestroySet(set string) error {
if out, err := runner.exec.Command(IPSetCmd, "destroy", set).CombinedOutput(); err != nil {
return fmt.Errorf("error destroying set %s, error: %v(%s)", set, err, out)
}
return nil
} | go | func (runner *runner) DestroySet(set string) error {
if out, err := runner.exec.Command(IPSetCmd, "destroy", set).CombinedOutput(); err != nil {
return fmt.Errorf("error destroying set %s, error: %v(%s)", set, err, out)
}
return nil
} | [
"func",
"(",
"runner",
"*",
"runner",
")",
"DestroySet",
"(",
"set",
"string",
")",
"error",
"{",
"if",
"out",
",",
"err",
":=",
"runner",
".",
"exec",
".",
"Command",
"(",
"IPSetCmd",
",",
"\"",
"\"",
",",
"set",
")",
".",
"CombinedOutput",
"(",
"... | // DestroySet is used to destroy a named set. | [
"DestroySet",
"is",
"used",
"to",
"destroy",
"a",
"named",
"set",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/util/ipset/ipset.go#L355-L360 | train | DestroySet destroys a set | [
30522,
4569,
2278,
1006,
5479,
1008,
5479,
1007,
20735,
3388,
1006,
2275,
5164,
1007,
7561,
1063,
2065,
2041,
1010,
9413,
2099,
1024,
1027,
5479,
1012,
4654,
8586,
1012,
3094,
1006,
12997,
13462,
27487,
2094,
1010,
1000,
6033,
1000,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/daemon/daemon_controller.go | requeueSuspendedDaemonPods | func (dsc *DaemonSetsController) requeueSuspendedDaemonPods(node string) {
dss := dsc.listSuspendedDaemonPods(node)
for _, dsKey := range dss {
if ns, name, err := cache.SplitMetaNamespaceKey(dsKey); err != nil {
klog.Errorf("Failed to get DaemonSet's namespace and name from %s: %v", dsKey, err)
continue
} else if ds, err := dsc.dsLister.DaemonSets(ns).Get(name); err != nil {
klog.Errorf("Failed to get DaemonSet %s/%s: %v", ns, name, err)
continue
} else {
dsc.enqueueDaemonSetRateLimited(ds)
}
}
} | go | func (dsc *DaemonSetsController) requeueSuspendedDaemonPods(node string) {
dss := dsc.listSuspendedDaemonPods(node)
for _, dsKey := range dss {
if ns, name, err := cache.SplitMetaNamespaceKey(dsKey); err != nil {
klog.Errorf("Failed to get DaemonSet's namespace and name from %s: %v", dsKey, err)
continue
} else if ds, err := dsc.dsLister.DaemonSets(ns).Get(name); err != nil {
klog.Errorf("Failed to get DaemonSet %s/%s: %v", ns, name, err)
continue
} else {
dsc.enqueueDaemonSetRateLimited(ds)
}
}
} | [
"func",
"(",
"dsc",
"*",
"DaemonSetsController",
")",
"requeueSuspendedDaemonPods",
"(",
"node",
"string",
")",
"{",
"dss",
":=",
"dsc",
".",
"listSuspendedDaemonPods",
"(",
"node",
")",
"\n",
"for",
"_",
",",
"dsKey",
":=",
"range",
"dss",
"{",
"if",
"ns"... | // requeueSuspendedDaemonPods enqueues all DaemonSets which has pods that 'want to run,
// but should not schedule' for the node; so DaemonSetController will sync up them again. | [
"requeueSuspendedDaemonPods",
"enqueues",
"all",
"DaemonSets",
"which",
"has",
"pods",
"that",
"want",
"to",
"run",
"but",
"should",
"not",
"schedule",
"for",
"the",
"node",
";",
"so",
"DaemonSetController",
"will",
"sync",
"up",
"them",
"again",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/daemon/daemon_controller.go#L599-L612 | train | requeueSuspendedDaemonPods requeue all suspended daemon pods | [
30522,
4569,
2278,
1006,
16233,
2278,
1008,
12828,
13462,
9363,
3372,
26611,
1007,
2128,
4226,
15808,
2271,
11837,
5732,
6858,
8202,
22925,
1006,
13045,
5164,
1007,
1063,
16233,
2015,
1024,
1027,
16233,
2278,
1012,
7201,
2271,
11837,
5732,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/remote/remote_runtime.go | PodSandboxStatus | func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodSandboxStatus, error) {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
resp, err := r.runtimeClient.PodSandboxStatus(ctx, &runtimeapi.PodSandboxStatusRequest{
PodSandboxId: podSandBoxID,
})
if err != nil {
return nil, err
}
if resp.Status != nil {
if err := verifySandboxStatus(resp.Status); err != nil {
return nil, err
}
}
return resp.Status, nil
} | go | func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeapi.PodSandboxStatus, error) {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
resp, err := r.runtimeClient.PodSandboxStatus(ctx, &runtimeapi.PodSandboxStatusRequest{
PodSandboxId: podSandBoxID,
})
if err != nil {
return nil, err
}
if resp.Status != nil {
if err := verifySandboxStatus(resp.Status); err != nil {
return nil, err
}
}
return resp.Status, nil
} | [
"func",
"(",
"r",
"*",
"RemoteRuntimeService",
")",
"PodSandboxStatus",
"(",
"podSandBoxID",
"string",
")",
"(",
"*",
"runtimeapi",
".",
"PodSandboxStatus",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"getContextWithTimeout",
"(",
"r",
".",
"timeout",
... | // PodSandboxStatus returns the status of the PodSandbox. | [
"PodSandboxStatus",
"returns",
"the",
"status",
"of",
"the",
"PodSandbox",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/remote/remote_runtime.go#L153-L171 | train | PodSandboxStatus returns the status of a pod sandbox. | [
30522,
4569,
2278,
1006,
1054,
1008,
6556,
15532,
7292,
8043,
7903,
2063,
1007,
26723,
5685,
8758,
9153,
5809,
1006,
26723,
5685,
8758,
3593,
5164,
1007,
1006,
1008,
2448,
7292,
9331,
2072,
1012,
26723,
5685,
8758,
9153,
5809,
1010,
7561,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/rbac/v1beta1/zz_generated.conversion.go | Convert_v1beta1_Subject_To_rbac_Subject | func Convert_v1beta1_Subject_To_rbac_Subject(in *v1beta1.Subject, out *rbac.Subject, s conversion.Scope) error {
return autoConvert_v1beta1_Subject_To_rbac_Subject(in, out, s)
} | go | func Convert_v1beta1_Subject_To_rbac_Subject(in *v1beta1.Subject, out *rbac.Subject, s conversion.Scope) error {
return autoConvert_v1beta1_Subject_To_rbac_Subject(in, out, s)
} | [
"func",
"Convert_v1beta1_Subject_To_rbac_Subject",
"(",
"in",
"*",
"v1beta1",
".",
"Subject",
",",
"out",
"*",
"rbac",
".",
"Subject",
",",
"s",
"conversion",
".",
"Scope",
")",
"error",
"{",
"return",
"autoConvert_v1beta1_Subject_To_rbac_Subject",
"(",
"in",
",",... | // Convert_v1beta1_Subject_To_rbac_Subject is an autogenerated conversion function. | [
"Convert_v1beta1_Subject_To_rbac_Subject",
"is",
"an",
"autogenerated",
"conversion",
"function",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/rbac/v1beta1/zz_generated.conversion.go#L434-L436 | train | Convert_v1beta1_Subject_To_rbac_Subject is an autogenerated conversion function. | [
30522,
4569,
2278,
10463,
1035,
1058,
2487,
20915,
27717,
1035,
3395,
1035,
2000,
1035,
21144,
6305,
1035,
3395,
1006,
1999,
1008,
1058,
2487,
20915,
27717,
1012,
3395,
1010,
2041,
1008,
21144,
6305,
1012,
3395,
1010,
1055,
7584,
1012,
9531... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificates_client.go | RESTClient | func (c *CertificatesV1beta1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
} | go | func (c *CertificatesV1beta1Client) RESTClient() rest.Interface {
if c == nil {
return nil
}
return c.restClient
} | [
"func",
"(",
"c",
"*",
"CertificatesV1beta1Client",
")",
"RESTClient",
"(",
")",
"rest",
".",
"Interface",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
".",
"restClient",
"\n",
"}"
] | // RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation. | [
"RESTClient",
"returns",
"a",
"RESTClient",
"that",
"is",
"used",
"to",
"communicate",
"with",
"API",
"server",
"by",
"this",
"client",
"implementation",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificates_client.go#L84-L89 | train | RESTClient returns a RESTClient that is used to get the RESTClient function. | [
30522,
4569,
2278,
1006,
1039,
1008,
17987,
2615,
2487,
20915,
27717,
20464,
11638,
1007,
2717,
20464,
11638,
1006,
1007,
2717,
1012,
8278,
1063,
2065,
1039,
1027,
1027,
9152,
2140,
1063,
2709,
9152,
2140,
1065,
2709,
1039,
1012,
2717,
2046... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/dockershim/docker_sandbox.go | ipcNamespaceMode | func ipcNamespaceMode(container *dockertypes.ContainerJSON) runtimeapi.NamespaceMode {
if container != nil && container.HostConfig != nil && string(container.HostConfig.IpcMode) == namespaceModeHost {
return runtimeapi.NamespaceMode_NODE
}
return runtimeapi.NamespaceMode_POD
} | go | func ipcNamespaceMode(container *dockertypes.ContainerJSON) runtimeapi.NamespaceMode {
if container != nil && container.HostConfig != nil && string(container.HostConfig.IpcMode) == namespaceModeHost {
return runtimeapi.NamespaceMode_NODE
}
return runtimeapi.NamespaceMode_POD
} | [
"func",
"ipcNamespaceMode",
"(",
"container",
"*",
"dockertypes",
".",
"ContainerJSON",
")",
"runtimeapi",
".",
"NamespaceMode",
"{",
"if",
"container",
"!=",
"nil",
"&&",
"container",
".",
"HostConfig",
"!=",
"nil",
"&&",
"string",
"(",
"container",
".",
"Hos... | // ipcNamespaceMode returns the IPC runtimeapi.NamespaceMode for this container.
// Supports: POD, NODE | [
"ipcNamespaceMode",
"returns",
"the",
"IPC",
"runtimeapi",
".",
"NamespaceMode",
"for",
"this",
"container",
".",
"Supports",
":",
"POD",
"NODE"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/dockershim/docker_sandbox.go#L660-L665 | train | ipcNamespaceMode returns the namespace mode of the container | [
30522,
4569,
2278,
12997,
2278,
18442,
23058,
5302,
3207,
1006,
11661,
1008,
8946,
15010,
10374,
1012,
11661,
22578,
2239,
1007,
2448,
7292,
9331,
2072,
1012,
3415,
15327,
5302,
3207,
1063,
2065,
11661,
999,
1027,
9152,
2140,
1004,
1004,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/node/v1alpha1/zz_generated.conversion.go | Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList | func Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.RuntimeClassList, out *v1alpha1.RuntimeClassList, s conversion.Scope) error {
return autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in, out, s)
} | go | func Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.RuntimeClassList, out *v1alpha1.RuntimeClassList, s conversion.Scope) error {
return autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in, out, s)
} | [
"func",
"Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList",
"(",
"in",
"*",
"node",
".",
"RuntimeClassList",
",",
"out",
"*",
"v1alpha1",
".",
"RuntimeClassList",
",",
"s",
"conversion",
".",
"Scope",
")",
"error",
"{",
"return",
"autoConvert_node_RuntimeClass... | // Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList is an autogenerated conversion function. | [
"Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList",
"is",
"an",
"autogenerated",
"conversion",
"function",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/node/v1alpha1/zz_generated.conversion.go#L120-L122 | train | Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList is an autogenerated conversion function. | [
30522,
4569,
2278,
10463,
1035,
13045,
1035,
2448,
7292,
26266,
9863,
1035,
2000,
1035,
1058,
2487,
2389,
21890,
2487,
1035,
2448,
7292,
26266,
9863,
1006,
1999,
1008,
13045,
1012,
2448,
7292,
26266,
9863,
1010,
2041,
1008,
1058,
2487,
2389... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/apply/parse/util.go | getFieldMeta | func getFieldMeta(s proto.Schema, name string) (apply.FieldMetaImpl, error) {
m := apply.FieldMetaImpl{}
if s != nil {
ext := s.GetExtensions()
if e, found := ext["x-kubernetes-patch-strategy"]; found {
strategy, ok := e.(string)
if !ok {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected string for x-kubernetes-patch-strategy by got %T", e)
}
// Take the first strategy if there are substrategies.
// Sub strategies are copied to sub types in openapi.go
strategies := strings.Split(strategy, ",")
if len(strategies) > 2 {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected between 0 and 2 elements for x-kubernetes-patch-merge-strategy by got %v", strategies)
}
// For lists, choose the strategy for this type, not the subtype
m.MergeType = strategies[0]
}
if k, found := ext["x-kubernetes-patch-merge-key"]; found {
key, ok := k.(string)
if !ok {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected string for x-kubernetes-patch-merge-key by got %T", k)
}
m.MergeKeys = apply.MergeKeys(strings.Split(key, ","))
}
}
m.Name = name
return m, nil
} | go | func getFieldMeta(s proto.Schema, name string) (apply.FieldMetaImpl, error) {
m := apply.FieldMetaImpl{}
if s != nil {
ext := s.GetExtensions()
if e, found := ext["x-kubernetes-patch-strategy"]; found {
strategy, ok := e.(string)
if !ok {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected string for x-kubernetes-patch-strategy by got %T", e)
}
// Take the first strategy if there are substrategies.
// Sub strategies are copied to sub types in openapi.go
strategies := strings.Split(strategy, ",")
if len(strategies) > 2 {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected between 0 and 2 elements for x-kubernetes-patch-merge-strategy by got %v", strategies)
}
// For lists, choose the strategy for this type, not the subtype
m.MergeType = strategies[0]
}
if k, found := ext["x-kubernetes-patch-merge-key"]; found {
key, ok := k.(string)
if !ok {
return apply.FieldMetaImpl{}, fmt.Errorf("Expected string for x-kubernetes-patch-merge-key by got %T", k)
}
m.MergeKeys = apply.MergeKeys(strings.Split(key, ","))
}
}
m.Name = name
return m, nil
} | [
"func",
"getFieldMeta",
"(",
"s",
"proto",
".",
"Schema",
",",
"name",
"string",
")",
"(",
"apply",
".",
"FieldMetaImpl",
",",
"error",
")",
"{",
"m",
":=",
"apply",
".",
"FieldMetaImpl",
"{",
"}",
"\n",
"if",
"s",
"!=",
"nil",
"{",
"ext",
":=",
"s... | // getFieldMeta parses the metadata about the field from the openapi spec | [
"getFieldMeta",
"parses",
"the",
"metadata",
"about",
"the",
"field",
"from",
"the",
"openapi",
"spec"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/apply/parse/util.go#L100-L129 | train | getFieldMeta returns a FieldMetaImpl for the given schema and name. | [
30522,
4569,
2278,
2131,
3790,
11368,
2050,
1006,
1055,
15053,
1012,
8040,
28433,
1010,
2171,
5164,
1007,
1006,
6611,
1012,
2492,
11368,
4886,
8737,
2140,
1010,
7561,
1007,
1063,
1049,
1024,
1027,
6611,
1012,
2492,
11368,
4886,
8737,
2140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/flexvolume/detacher.go | UnmountDevice | func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error {
pathExists, pathErr := mount.PathExists(deviceMountPath)
if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
return nil
}
if pathErr != nil && !mount.IsCorruptedMnt(pathErr) {
return fmt.Errorf("Error checking path: %v", pathErr)
}
notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath)
if err != nil {
if mount.IsCorruptedMnt(err) {
notmnt = false // Corrupted error is assumed to be mounted.
} else {
return err
}
}
if notmnt {
klog.Warningf("Warning: Path: %v already unmounted", deviceMountPath)
} else {
call := d.plugin.NewDriverCall(unmountDeviceCmd)
call.Append(deviceMountPath)
_, err := call.Run()
if isCmdNotSupportedErr(err) {
err = (*detacherDefaults)(d).UnmountDevice(deviceMountPath)
}
if err != nil {
return err
}
}
// Flexvolume driver may remove the directory. Ignore if it does.
if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr)
} else if !pathExists {
return nil
}
return os.Remove(deviceMountPath)
} | go | func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error {
pathExists, pathErr := mount.PathExists(deviceMountPath)
if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
return nil
}
if pathErr != nil && !mount.IsCorruptedMnt(pathErr) {
return fmt.Errorf("Error checking path: %v", pathErr)
}
notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath)
if err != nil {
if mount.IsCorruptedMnt(err) {
notmnt = false // Corrupted error is assumed to be mounted.
} else {
return err
}
}
if notmnt {
klog.Warningf("Warning: Path: %v already unmounted", deviceMountPath)
} else {
call := d.plugin.NewDriverCall(unmountDeviceCmd)
call.Append(deviceMountPath)
_, err := call.Run()
if isCmdNotSupportedErr(err) {
err = (*detacherDefaults)(d).UnmountDevice(deviceMountPath)
}
if err != nil {
return err
}
}
// Flexvolume driver may remove the directory. Ignore if it does.
if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr)
} else if !pathExists {
return nil
}
return os.Remove(deviceMountPath)
} | [
"func",
"(",
"d",
"*",
"flexVolumeDetacher",
")",
"UnmountDevice",
"(",
"deviceMountPath",
"string",
")",
"error",
"{",
"pathExists",
",",
"pathErr",
":=",
"mount",
".",
"PathExists",
"(",
"deviceMountPath",
")",
"\n",
"if",
"!",
"pathExists",
"{",
"klog",
"... | // UnmountDevice is part of the volume.Detacher interface. | [
"UnmountDevice",
"is",
"part",
"of",
"the",
"volume",
".",
"Detacher",
"interface",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/flexvolume/detacher.go#L52-L94 | train | UnmountDevice unmounts the device specified by deviceMountPath. | [
30522,
4569,
2278,
1006,
1040,
1008,
23951,
6767,
12942,
14728,
2696,
7474,
1007,
4895,
20048,
24844,
6610,
1006,
5080,
20048,
15069,
5164,
1007,
7561,
1063,
4130,
10288,
5130,
1010,
4130,
2121,
2099,
1024,
1027,
4057,
1012,
4130,
10288,
51... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/cm/cgroup_manager_linux.go | Name | func (m *cgroupManagerImpl) Name(name CgroupName) string {
if m.adapter.cgroupManagerType == libcontainerSystemd {
return name.ToSystemd()
}
return name.ToCgroupfs()
} | go | func (m *cgroupManagerImpl) Name(name CgroupName) string {
if m.adapter.cgroupManagerType == libcontainerSystemd {
return name.ToSystemd()
}
return name.ToCgroupfs()
} | [
"func",
"(",
"m",
"*",
"cgroupManagerImpl",
")",
"Name",
"(",
"name",
"CgroupName",
")",
"string",
"{",
"if",
"m",
".",
"adapter",
".",
"cgroupManagerType",
"==",
"libcontainerSystemd",
"{",
"return",
"name",
".",
"ToSystemd",
"(",
")",
"\n",
"}",
"\n",
... | // Name converts the cgroup to the driver specific value in cgroupfs form.
// This always returns a valid cgroupfs path even when systemd driver is in use! | [
"Name",
"converts",
"the",
"cgroup",
"to",
"the",
"driver",
"specific",
"value",
"in",
"cgroupfs",
"form",
".",
"This",
"always",
"returns",
"a",
"valid",
"cgroupfs",
"path",
"even",
"when",
"systemd",
"driver",
"is",
"in",
"use!"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/cm/cgroup_manager_linux.go#L207-L212 | train | Name returns the name of the cgroup | [
30522,
4569,
2278,
1006,
1049,
1008,
1039,
17058,
24805,
4590,
5714,
24759,
1007,
2171,
1006,
2171,
1039,
17058,
18442,
1007,
5164,
1063,
2065,
1049,
1012,
15581,
2121,
1012,
1039,
17058,
24805,
4590,
13874,
1027,
1027,
5622,
9818,
12162,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apimachinery/pkg/util/sets/int.go | List | func (s Int) List() []int {
res := make(sortableSliceOfInt, 0, len(s))
for key := range s {
res = append(res, key)
}
sort.Sort(res)
return []int(res)
} | go | func (s Int) List() []int {
res := make(sortableSliceOfInt, 0, len(s))
for key := range s {
res = append(res, key)
}
sort.Sort(res)
return []int(res)
} | [
"func",
"(",
"s",
"Int",
")",
"List",
"(",
")",
"[",
"]",
"int",
"{",
"res",
":=",
"make",
"(",
"sortableSliceOfInt",
",",
"0",
",",
"len",
"(",
"s",
")",
")",
"\n",
"for",
"key",
":=",
"range",
"s",
"{",
"res",
"=",
"append",
"(",
"res",
","... | // List returns the contents as a sorted int slice. | [
"List",
"returns",
"the",
"contents",
"as",
"a",
"sorted",
"int",
"slice",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/util/sets/int.go#L168-L175 | train | List returns a slice of int | [
30522,
4569,
2278,
1006,
1055,
20014,
1007,
2862,
1006,
1007,
1031,
1033,
20014,
1063,
24501,
1024,
1027,
2191,
1006,
4066,
3085,
14540,
6610,
11253,
18447,
1010,
1014,
1010,
18798,
1006,
1055,
1007,
1007,
2005,
3145,
1024,
1027,
2846,
1055... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/cronjob/utils.go | groupJobsByParent | func groupJobsByParent(js []batchv1.Job) map[types.UID][]batchv1.Job {
jobsBySj := make(map[types.UID][]batchv1.Job)
for _, job := range js {
parentUID, found := getParentUIDFromJob(job)
if !found {
klog.V(4).Infof("Unable to get parent uid from job %s in namespace %s", job.Name, job.Namespace)
continue
}
jobsBySj[parentUID] = append(jobsBySj[parentUID], job)
}
return jobsBySj
} | go | func groupJobsByParent(js []batchv1.Job) map[types.UID][]batchv1.Job {
jobsBySj := make(map[types.UID][]batchv1.Job)
for _, job := range js {
parentUID, found := getParentUIDFromJob(job)
if !found {
klog.V(4).Infof("Unable to get parent uid from job %s in namespace %s", job.Name, job.Namespace)
continue
}
jobsBySj[parentUID] = append(jobsBySj[parentUID], job)
}
return jobsBySj
} | [
"func",
"groupJobsByParent",
"(",
"js",
"[",
"]",
"batchv1",
".",
"Job",
")",
"map",
"[",
"types",
".",
"UID",
"]",
"[",
"]",
"batchv1",
".",
"Job",
"{",
"jobsBySj",
":=",
"make",
"(",
"map",
"[",
"types",
".",
"UID",
"]",
"[",
"]",
"batchv1",
".... | // groupJobsByParent groups jobs into a map keyed by the job parent UID (e.g. scheduledJob).
// It has no receiver, to facilitate testing. | [
"groupJobsByParent",
"groups",
"jobs",
"into",
"a",
"map",
"keyed",
"by",
"the",
"job",
"parent",
"UID",
"(",
"e",
".",
"g",
".",
"scheduledJob",
")",
".",
"It",
"has",
"no",
"receiver",
"to",
"facilitate",
"testing",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/cronjob/utils.go#L76-L87 | train | groupJobsByParent returns a map of job UID to batch v1. Job | [
30522,
4569,
2278,
2177,
5558,
5910,
3762,
19362,
4765,
1006,
1046,
2015,
1031,
1033,
14108,
2615,
2487,
1012,
3105,
1007,
4949,
1031,
4127,
1012,
21318,
2094,
1033,
1031,
1033,
14108,
2615,
2487,
1012,
3105,
1063,
5841,
3762,
2015,
3501,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/zz_generated.deepcopy.go | DeepCopy | func (in *PodDNSConfigOption) DeepCopy() *PodDNSConfigOption {
if in == nil {
return nil
}
out := new(PodDNSConfigOption)
in.DeepCopyInto(out)
return out
} | go | func (in *PodDNSConfigOption) DeepCopy() *PodDNSConfigOption {
if in == nil {
return nil
}
out := new(PodDNSConfigOption)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"PodDNSConfigOption",
")",
"DeepCopy",
"(",
")",
"*",
"PodDNSConfigOption",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"PodDNSConfigOption",
")",
"\n",
"in",
".",
"DeepCopyInto",
... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodDNSConfigOption. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"PodDNSConfigOption",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/zz_generated.deepcopy.go#L3259-L3266 | train | DeepCopy is an autogenerated deepcopy function copying the receiver creating a new PodDNSConfigOption. | [
30522,
4569,
2278,
1006,
1999,
1008,
17491,
2094,
3619,
8663,
8873,
3995,
16790,
1007,
2784,
3597,
7685,
1006,
1007,
1008,
17491,
2094,
3619,
8663,
8873,
3995,
16790,
1063,
2065,
1999,
1027,
1027,
9152,
2140,
1063,
2709,
9152,
2140,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go | Create | func (c *volumeAttachments) Create(volumeAttachment *v1alpha1.VolumeAttachment) (result *v1alpha1.VolumeAttachment, err error) {
result = &v1alpha1.VolumeAttachment{}
err = c.client.Post().
Resource("volumeattachments").
Body(volumeAttachment).
Do().
Into(result)
return
} | go | func (c *volumeAttachments) Create(volumeAttachment *v1alpha1.VolumeAttachment) (result *v1alpha1.VolumeAttachment, err error) {
result = &v1alpha1.VolumeAttachment{}
err = c.client.Post().
Resource("volumeattachments").
Body(volumeAttachment).
Do().
Into(result)
return
} | [
"func",
"(",
"c",
"*",
"volumeAttachments",
")",
"Create",
"(",
"volumeAttachment",
"*",
"v1alpha1",
".",
"VolumeAttachment",
")",
"(",
"result",
"*",
"v1alpha1",
".",
"VolumeAttachment",
",",
"err",
"error",
")",
"{",
"result",
"=",
"&",
"v1alpha1",
".",
... | // Create takes the representation of a volumeAttachment and creates it. Returns the server's representation of the volumeAttachment, and an error, if there is any. | [
"Create",
"takes",
"the",
"representation",
"of",
"a",
"volumeAttachment",
"and",
"creates",
"it",
".",
"Returns",
"the",
"server",
"s",
"representation",
"of",
"the",
"volumeAttachment",
"and",
"an",
"error",
"if",
"there",
"is",
"any",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go#L107-L115 | train | Create a new volume attachment. | [
30522,
4569,
2278,
1006,
1039,
1008,
3872,
19321,
6776,
8163,
1007,
3443,
1006,
3872,
19321,
6776,
3672,
1008,
1058,
2487,
2389,
21890,
2487,
1012,
3872,
19321,
6776,
3672,
1007,
1006,
2765,
1008,
1058,
2487,
2389,
21890,
2487,
1012,
3872,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/util/connrotation/connrotation.go | NewDialer | func NewDialer(dial DialFunc) *Dialer {
return &Dialer{
dial: dial,
conns: make(map[*closableConn]struct{}),
}
} | go | func NewDialer(dial DialFunc) *Dialer {
return &Dialer{
dial: dial,
conns: make(map[*closableConn]struct{}),
}
} | [
"func",
"NewDialer",
"(",
"dial",
"DialFunc",
")",
"*",
"Dialer",
"{",
"return",
"&",
"Dialer",
"{",
"dial",
":",
"dial",
",",
"conns",
":",
"make",
"(",
"map",
"[",
"*",
"closableConn",
"]",
"struct",
"{",
"}",
")",
",",
"}",
"\n",
"}"
] | // NewDialer creates a new Dialer instance.
//
// If dial is not nil, it will be used to create new underlying connections.
// Otherwise net.DialContext is used. | [
"NewDialer",
"creates",
"a",
"new",
"Dialer",
"instance",
".",
"If",
"dial",
"is",
"not",
"nil",
"it",
"will",
"be",
"used",
"to",
"create",
"new",
"underlying",
"connections",
".",
"Otherwise",
"net",
".",
"DialContext",
"is",
"used",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/util/connrotation/connrotation.go#L45-L50 | train | NewDialer returns a new dialer that uses the given DialFunc to connect to the database. | [
30522,
4569,
2278,
2047,
27184,
2121,
1006,
13764,
13764,
11263,
12273,
1007,
1008,
13764,
2121,
1063,
2709,
1004,
13764,
2121,
1063,
13764,
1024,
13764,
1010,
9530,
3619,
1024,
2191,
1006,
4949,
1031,
1008,
18856,
8820,
3468,
8663,
2078,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/remote/remote_runtime.go | Version | func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error) {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
typedVersion, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{
Version: apiVersion,
})
if err != nil {
klog.Errorf("Version from runtime service failed: %v", err)
return nil, err
}
if typedVersion.Version == "" || typedVersion.RuntimeName == "" || typedVersion.RuntimeApiVersion == "" || typedVersion.RuntimeVersion == "" {
return nil, fmt.Errorf("not all fields are set in VersionResponse (%q)", *typedVersion)
}
return typedVersion, err
} | go | func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionResponse, error) {
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()
typedVersion, err := r.runtimeClient.Version(ctx, &runtimeapi.VersionRequest{
Version: apiVersion,
})
if err != nil {
klog.Errorf("Version from runtime service failed: %v", err)
return nil, err
}
if typedVersion.Version == "" || typedVersion.RuntimeName == "" || typedVersion.RuntimeApiVersion == "" || typedVersion.RuntimeVersion == "" {
return nil, fmt.Errorf("not all fields are set in VersionResponse (%q)", *typedVersion)
}
return typedVersion, err
} | [
"func",
"(",
"r",
"*",
"RemoteRuntimeService",
")",
"Version",
"(",
"apiVersion",
"string",
")",
"(",
"*",
"runtimeapi",
".",
"VersionResponse",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"getContextWithTimeout",
"(",
"r",
".",
"timeout",
")",
"\n... | // Version returns the runtime name, runtime version and runtime API version. | [
"Version",
"returns",
"the",
"runtime",
"name",
"runtime",
"version",
"and",
"runtime",
"API",
"version",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/remote/remote_runtime.go#L73-L90 | train | Version returns the version of the runtime service. | [
30522,
4569,
2278,
1006,
1054,
1008,
6556,
15532,
7292,
8043,
7903,
2063,
1007,
2544,
1006,
17928,
27774,
5164,
1007,
1006,
1008,
2448,
7292,
9331,
2072,
1012,
2544,
6072,
26029,
3366,
1010,
7561,
1007,
1063,
14931,
2595,
1010,
17542,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/cmd/util/helpers.go | DefaultSubCommandRun | func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string) {
return func(c *cobra.Command, args []string) {
c.SetOutput(out)
RequireNoArguments(c, args)
c.Help()
CheckErr(ErrExit)
}
} | go | func DefaultSubCommandRun(out io.Writer) func(c *cobra.Command, args []string) {
return func(c *cobra.Command, args []string) {
c.SetOutput(out)
RequireNoArguments(c, args)
c.Help()
CheckErr(ErrExit)
}
} | [
"func",
"DefaultSubCommandRun",
"(",
"out",
"io",
".",
"Writer",
")",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"return",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"strin... | // DefaultSubCommandRun prints a command's help string to the specified output if no
// arguments (sub-commands) are provided, or a usage error otherwise. | [
"DefaultSubCommandRun",
"prints",
"a",
"command",
"s",
"help",
"string",
"to",
"the",
"specified",
"output",
"if",
"no",
"arguments",
"(",
"sub",
"-",
"commands",
")",
"are",
"provided",
"or",
"a",
"usage",
"error",
"otherwise",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/util/helpers.go#L579-L586 | train | DefaultSubCommandRun returns a function that can be used to run a command. | [
30522,
4569,
2278,
12398,
6342,
9818,
5358,
2386,
13626,
4609,
1006,
2041,
22834,
1012,
3213,
1007,
4569,
2278,
1006,
1039,
1008,
16604,
1012,
3094,
1010,
12098,
5620,
1031,
1033,
5164,
1007,
1063,
2709,
4569,
2278,
1006,
1039,
1008,
16604,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go | DeepCopy | func (in *Requirement) DeepCopy() *Requirement {
if in == nil {
return nil
}
out := new(Requirement)
in.DeepCopyInto(out)
return out
} | go | func (in *Requirement) DeepCopy() *Requirement {
if in == nil {
return nil
}
out := new(Requirement)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"Requirement",
")",
"DeepCopy",
"(",
")",
"*",
"Requirement",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Requirement",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")"... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Requirement. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Requirement",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/labels/zz_generated.deepcopy.go#L35-L42 | train | DeepCopy is an autogenerated deepcopy function copying the receiver creating a new Requirement. | [
30522,
4569,
2278,
1006,
1999,
1008,
9095,
1007,
2784,
3597,
7685,
1006,
1007,
1008,
9095,
1063,
2065,
1999,
1027,
1027,
9152,
2140,
1063,
2709,
9152,
2140,
1065,
2041,
1024,
1027,
2047,
1006,
9095,
1007,
1999,
1012,
2784,
3597,
7685,
184... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/zz_generated.deepcopy.go | DeepCopyInto | func (in *PodTemplate) DeepCopyInto(out *PodTemplate) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Template.DeepCopyInto(&out.Template)
return
} | go | func (in *PodTemplate) DeepCopyInto(out *PodTemplate) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Template.DeepCopyInto(&out.Template)
return
} | [
"func",
"(",
"in",
"*",
"PodTemplate",
")",
"DeepCopyInto",
"(",
"out",
"*",
"PodTemplate",
")",
"{",
"*",
"out",
"=",
"*",
"in",
"\n",
"out",
".",
"TypeMeta",
"=",
"in",
".",
"TypeMeta",
"\n",
"in",
".",
"ObjectMeta",
".",
"DeepCopyInto",
"(",
"&",
... | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | [
"DeepCopyInto",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"writing",
"into",
"out",
".",
"in",
"must",
"be",
"non",
"-",
"nil",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/zz_generated.deepcopy.go#L3710-L3716 | train | DeepCopyInto is an autogenerated deepcopy function copying the receiver | [
30522,
4569,
2278,
1006,
1999,
1008,
17491,
18532,
15725,
1007,
2784,
3597,
7685,
18447,
2080,
1006,
2041,
1008,
17491,
18532,
15725,
1007,
1063,
1008,
2041,
1027,
1008,
1999,
2041,
1012,
2828,
11368,
2050,
1027,
1999,
1012,
2828,
11368,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/volumemanager/volume_manager.go | filterUnmountedVolumes | func filterUnmountedVolumes(mountedVolumes sets.String, expectedVolumes []string) []string {
unmountedVolumes := []string{}
for _, expectedVolume := range expectedVolumes {
if !mountedVolumes.Has(expectedVolume) {
unmountedVolumes = append(unmountedVolumes, expectedVolume)
}
}
return unmountedVolumes
} | go | func filterUnmountedVolumes(mountedVolumes sets.String, expectedVolumes []string) []string {
unmountedVolumes := []string{}
for _, expectedVolume := range expectedVolumes {
if !mountedVolumes.Has(expectedVolume) {
unmountedVolumes = append(unmountedVolumes, expectedVolume)
}
}
return unmountedVolumes
} | [
"func",
"filterUnmountedVolumes",
"(",
"mountedVolumes",
"sets",
".",
"String",
",",
"expectedVolumes",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"unmountedVolumes",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"_",
",",
"expectedVolume",
":=",
... | // filterUnmountedVolumes adds each element of expectedVolumes that is not in
// mountedVolumes to a list of unmountedVolumes and returns it. | [
"filterUnmountedVolumes",
"adds",
"each",
"element",
"of",
"expectedVolumes",
"that",
"is",
"not",
"in",
"mountedVolumes",
"to",
"a",
"list",
"of",
"unmountedVolumes",
"and",
"returns",
"it",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/volumemanager/volume_manager.go#L420-L428 | train | filterUnmountedVolumes returns a list of volumes that are not mounted | [
30522,
4569,
2278,
11307,
4609,
27632,
6767,
12942,
2229,
1006,
5614,
6767,
12942,
2229,
4520,
1012,
5164,
1010,
3517,
6767,
12942,
2229,
1031,
1033,
5164,
1007,
1031,
1033,
5164,
1063,
4895,
27632,
6767,
12942,
2229,
1024,
1027,
1031,
1033... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go | processNextWorkItem | func (ec *EstablishingController) processNextWorkItem() bool {
key, quit := ec.queue.Get()
if quit {
return false
}
defer ec.queue.Done(key)
err := ec.syncFn(key.(string))
if err == nil {
ec.queue.Forget(key)
return true
}
utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err))
ec.queue.AddRateLimited(key)
return true
} | go | func (ec *EstablishingController) processNextWorkItem() bool {
key, quit := ec.queue.Get()
if quit {
return false
}
defer ec.queue.Done(key)
err := ec.syncFn(key.(string))
if err == nil {
ec.queue.Forget(key)
return true
}
utilruntime.HandleError(fmt.Errorf("%v failed with: %v", key, err))
ec.queue.AddRateLimited(key)
return true
} | [
"func",
"(",
"ec",
"*",
"EstablishingController",
")",
"processNextWorkItem",
"(",
")",
"bool",
"{",
"key",
",",
"quit",
":=",
"ec",
".",
"queue",
".",
"Get",
"(",
")",
"\n",
"if",
"quit",
"{",
"return",
"false",
"\n",
"}",
"\n",
"defer",
"ec",
".",
... | // processNextWorkItem deals with one key off the queue.
// It returns false when it's time to quit. | [
"processNextWorkItem",
"deals",
"with",
"one",
"key",
"off",
"the",
"queue",
".",
"It",
"returns",
"false",
"when",
"it",
"s",
"time",
"to",
"quit",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/establish/establishing_controller.go#L93-L110 | train | processNextWorkItem is called when a new work item is processed. | [
30522,
4569,
2278,
1006,
14925,
1008,
7411,
8663,
13181,
10820,
1007,
2832,
2638,
18413,
6198,
4221,
2213,
1006,
1007,
22017,
2140,
1063,
3145,
1010,
8046,
1024,
1027,
14925,
1012,
24240,
1012,
2131,
1006,
1007,
2065,
8046,
1063,
2709,
6270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go | newHorizontalPodAutoscalers | func newHorizontalPodAutoscalers(c *AutoscalingV2beta1Client, namespace string) *horizontalPodAutoscalers {
return &horizontalPodAutoscalers{
client: c.RESTClient(),
ns: namespace,
}
} | go | func newHorizontalPodAutoscalers(c *AutoscalingV2beta1Client, namespace string) *horizontalPodAutoscalers {
return &horizontalPodAutoscalers{
client: c.RESTClient(),
ns: namespace,
}
} | [
"func",
"newHorizontalPodAutoscalers",
"(",
"c",
"*",
"AutoscalingV2beta1Client",
",",
"namespace",
"string",
")",
"*",
"horizontalPodAutoscalers",
"{",
"return",
"&",
"horizontalPodAutoscalers",
"{",
"client",
":",
"c",
".",
"RESTClient",
"(",
")",
",",
"ns",
":"... | // newHorizontalPodAutoscalers returns a HorizontalPodAutoscalers | [
"newHorizontalPodAutoscalers",
"returns",
"a",
"HorizontalPodAutoscalers"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go#L59-L64 | train | newHorizontalPodAutoscalers returns a HorizontalPodAutoscalers | [
30522,
4569,
2278,
2047,
16368,
10993,
12162,
2389,
27633,
4887,
13122,
9289,
2545,
1006,
1039,
1008,
8285,
15782,
2989,
2615,
2475,
20915,
27717,
20464,
11638,
1010,
3415,
15327,
5164,
1007,
1008,
9876,
27633,
4887,
13122,
9289,
2545,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/hyperkube/main.go | NewHyperKubeCommand | func NewHyperKubeCommand(stopCh <-chan struct{}) (*cobra.Command, []func() *cobra.Command) {
// these have to be functions since the command is polymorphic. Cobra wants you to be top level
// command to get executed
apiserver := func() *cobra.Command {
ret := kubeapiserver.NewAPIServerCommand(stopCh)
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"apiserver"}
return ret
}
controller := func() *cobra.Command {
ret := kubecontrollermanager.NewControllerManagerCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"controller-manager"}
return ret
}
proxy := func() *cobra.Command {
ret := kubeproxy.NewProxyCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"proxy"}
return ret
}
scheduler := func() *cobra.Command {
ret := kubescheduler.NewSchedulerCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"scheduler"}
return ret
}
kubectlCmd := func() *cobra.Command { return kubectl.NewDefaultKubectlCommand() }
kubelet := func() *cobra.Command { return kubelet.NewKubeletCommand(stopCh) }
cloudController := func() *cobra.Command { return cloudcontrollermanager.NewCloudControllerManagerCommand() }
commandFns := []func() *cobra.Command{
apiserver,
controller,
proxy,
scheduler,
kubectlCmd,
kubelet,
cloudController,
}
makeSymlinksFlag := false
cmd := &cobra.Command{
Use: "hyperkube",
Short: "Request a new project",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 || !makeSymlinksFlag {
cmd.Help()
os.Exit(1)
}
if err := makeSymlinks(os.Args[0], commandFns); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err.Error())
}
},
}
cmd.Flags().BoolVar(&makeSymlinksFlag, "make-symlinks", makeSymlinksFlag, "create a symlink for each server in current directory")
cmd.Flags().MarkHidden("make-symlinks") // hide this flag from appearing in servers' usage output
cmd.Flags().MarkDeprecated("make-symlinks", "This feature will be removed in a later release.")
for i := range commandFns {
cmd.AddCommand(commandFns[i]())
}
return cmd, commandFns
} | go | func NewHyperKubeCommand(stopCh <-chan struct{}) (*cobra.Command, []func() *cobra.Command) {
// these have to be functions since the command is polymorphic. Cobra wants you to be top level
// command to get executed
apiserver := func() *cobra.Command {
ret := kubeapiserver.NewAPIServerCommand(stopCh)
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"apiserver"}
return ret
}
controller := func() *cobra.Command {
ret := kubecontrollermanager.NewControllerManagerCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"controller-manager"}
return ret
}
proxy := func() *cobra.Command {
ret := kubeproxy.NewProxyCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"proxy"}
return ret
}
scheduler := func() *cobra.Command {
ret := kubescheduler.NewSchedulerCommand()
// add back some unfortunate aliases that should be removed
ret.Aliases = []string{"scheduler"}
return ret
}
kubectlCmd := func() *cobra.Command { return kubectl.NewDefaultKubectlCommand() }
kubelet := func() *cobra.Command { return kubelet.NewKubeletCommand(stopCh) }
cloudController := func() *cobra.Command { return cloudcontrollermanager.NewCloudControllerManagerCommand() }
commandFns := []func() *cobra.Command{
apiserver,
controller,
proxy,
scheduler,
kubectlCmd,
kubelet,
cloudController,
}
makeSymlinksFlag := false
cmd := &cobra.Command{
Use: "hyperkube",
Short: "Request a new project",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 || !makeSymlinksFlag {
cmd.Help()
os.Exit(1)
}
if err := makeSymlinks(os.Args[0], commandFns); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err.Error())
}
},
}
cmd.Flags().BoolVar(&makeSymlinksFlag, "make-symlinks", makeSymlinksFlag, "create a symlink for each server in current directory")
cmd.Flags().MarkHidden("make-symlinks") // hide this flag from appearing in servers' usage output
cmd.Flags().MarkDeprecated("make-symlinks", "This feature will be removed in a later release.")
for i := range commandFns {
cmd.AddCommand(commandFns[i]())
}
return cmd, commandFns
} | [
"func",
"NewHyperKubeCommand",
"(",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"(",
"*",
"cobra",
".",
"Command",
",",
"[",
"]",
"func",
"(",
")",
"*",
"cobra",
".",
"Command",
")",
"{",
"// these have to be functions since the command is polymorphic. Cobr... | // NewHyperKubeCommand is the entry point for hyperkube | [
"NewHyperKubeCommand",
"is",
"the",
"entry",
"point",
"for",
"hyperkube"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/hyperkube/main.go#L87-L152 | train | NewHyperKubeCommand creates a new HyperKube command | [
30522,
4569,
2278,
2047,
10536,
4842,
5283,
4783,
9006,
2386,
2094,
1006,
2644,
2818,
1026,
1011,
9212,
2358,
6820,
6593,
1063,
1065,
1007,
1006,
1008,
16604,
1012,
3094,
1010,
1031,
1033,
4569,
2278,
1006,
1007,
1008,
16604,
1012,
3094,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/awsebs/aws_util.go | getCloudProvider | func getCloudProvider(cloudProvider cloudprovider.Interface) (*aws.Cloud, error) {
awsCloudProvider, ok := cloudProvider.(*aws.Cloud)
if !ok || awsCloudProvider == nil {
return nil, fmt.Errorf("Failed to get AWS Cloud Provider. GetCloudProvider returned %v instead", cloudProvider)
}
return awsCloudProvider, nil
} | go | func getCloudProvider(cloudProvider cloudprovider.Interface) (*aws.Cloud, error) {
awsCloudProvider, ok := cloudProvider.(*aws.Cloud)
if !ok || awsCloudProvider == nil {
return nil, fmt.Errorf("Failed to get AWS Cloud Provider. GetCloudProvider returned %v instead", cloudProvider)
}
return awsCloudProvider, nil
} | [
"func",
"getCloudProvider",
"(",
"cloudProvider",
"cloudprovider",
".",
"Interface",
")",
"(",
"*",
"aws",
".",
"Cloud",
",",
"error",
")",
"{",
"awsCloudProvider",
",",
"ok",
":=",
"cloudProvider",
".",
"(",
"*",
"aws",
".",
"Cloud",
")",
"\n",
"if",
"!... | // Return cloud provider | [
"Return",
"cloud",
"provider"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/awsebs/aws_util.go#L234-L241 | train | getCloudProvider returns the cloud provider | [
30522,
4569,
2278,
2131,
20464,
19224,
21572,
17258,
2121,
1006,
6112,
21572,
17258,
2121,
6112,
21572,
17258,
2121,
1012,
8278,
1007,
1006,
1008,
22091,
2015,
1012,
6112,
1010,
7561,
1007,
1063,
22091,
11020,
23743,
18927,
12298,
18688,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/sample-apiserver/pkg/generated/informers/externalversions/wardle/interface.go | V1alpha1 | func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
} | go | func (g *group) V1alpha1() v1alpha1.Interface {
return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions)
} | [
"func",
"(",
"g",
"*",
"group",
")",
"V1alpha1",
"(",
")",
"v1alpha1",
".",
"Interface",
"{",
"return",
"v1alpha1",
".",
"New",
"(",
"g",
".",
"factory",
",",
"g",
".",
"namespace",
",",
"g",
".",
"tweakListOptions",
")",
"\n",
"}"
] | // V1alpha1 returns a new v1alpha1.Interface. | [
"V1alpha1",
"returns",
"a",
"new",
"v1alpha1",
".",
"Interface",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/sample-apiserver/pkg/generated/informers/externalversions/wardle/interface.go#L47-L49 | train | V1alpha1 returns a new v1alpha1. Interface. | [
30522,
4569,
2278,
1006,
1043,
1008,
2177,
1007,
1058,
2487,
2389,
21890,
2487,
1006,
1007,
1058,
2487,
2389,
21890,
2487,
1012,
8278,
1063,
2709,
1058,
2487,
2389,
21890,
2487,
1012,
2047,
1006,
1043,
1012,
4713,
1010,
1043,
1012,
3415,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/util/atomic_writer.go | shouldWritePayload | func shouldWritePayload(payload map[string]FileProjection, oldTsDir string) (bool, error) {
for userVisiblePath, fileProjection := range payload {
shouldWrite, err := shouldWriteFile(filepath.Join(oldTsDir, userVisiblePath), fileProjection.Data)
if err != nil {
return false, err
}
if shouldWrite {
return true, nil
}
}
return false, nil
} | go | func shouldWritePayload(payload map[string]FileProjection, oldTsDir string) (bool, error) {
for userVisiblePath, fileProjection := range payload {
shouldWrite, err := shouldWriteFile(filepath.Join(oldTsDir, userVisiblePath), fileProjection.Data)
if err != nil {
return false, err
}
if shouldWrite {
return true, nil
}
}
return false, nil
} | [
"func",
"shouldWritePayload",
"(",
"payload",
"map",
"[",
"string",
"]",
"FileProjection",
",",
"oldTsDir",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"for",
"userVisiblePath",
",",
"fileProjection",
":=",
"range",
"payload",
"{",
"shouldWrite",
",",
... | // shouldWritePayload returns whether the payload should be written to disk. | [
"shouldWritePayload",
"returns",
"whether",
"the",
"payload",
"should",
"be",
"written",
"to",
"disk",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/util/atomic_writer.go#L280-L293 | train | shouldWritePayload returns true if the payload should be written to the oldTsDir | [
30522,
4569,
2278,
2323,
26373,
4502,
8516,
10441,
2094,
1006,
18093,
4949,
1031,
5164,
1033,
5371,
21572,
20614,
30524,
2323,
26373,
8873,
2571,
1006,
5371,
15069,
1012,
3693,
1006,
2214,
3215,
4305,
2099,
1010,
5310,
11365,
7028,
15069,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/cloud-provider/volume/helpers/zones.go | ZonesToSet | func ZonesToSet(zonesString string) (sets.String, error) {
zones, err := stringToSet(zonesString, ",")
if err != nil {
return nil, fmt.Errorf("error parsing zones %s, must be strings separated by commas: %v", zonesString, err)
}
return zones, nil
} | go | func ZonesToSet(zonesString string) (sets.String, error) {
zones, err := stringToSet(zonesString, ",")
if err != nil {
return nil, fmt.Errorf("error parsing zones %s, must be strings separated by commas: %v", zonesString, err)
}
return zones, nil
} | [
"func",
"ZonesToSet",
"(",
"zonesString",
"string",
")",
"(",
"sets",
".",
"String",
",",
"error",
")",
"{",
"zones",
",",
"err",
":=",
"stringToSet",
"(",
"zonesString",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
","... | // ZonesToSet converts a string containing a comma separated list of zones to set | [
"ZonesToSet",
"converts",
"a",
"string",
"containing",
"a",
"comma",
"separated",
"list",
"of",
"zones",
"to",
"set"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/cloud-provider/volume/helpers/zones.go#L43-L49 | train | ZonesToSet returns a set of zones from a string | [
30522,
4569,
2278,
10019,
22282,
2102,
1006,
10019,
3367,
4892,
5164,
1007,
1006,
4520,
1012,
5164,
1010,
7561,
1007,
1063,
10019,
1010,
9413,
2099,
1024,
1027,
5164,
22282,
2102,
1006,
10019,
3367,
4892,
1010,
1000,
1010,
1000,
1007,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/cloudprovider/providers/openstack/openstack_instances.go | InstanceExistsByProviderID | func (i *Instances) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) {
instanceID, err := instanceIDFromProviderID(providerID)
if err != nil {
return false, err
}
_, err = servers.Get(i.compute, instanceID).Extract()
if err != nil {
if isNotFound(err) {
return false, nil
}
return false, err
}
return true, nil
} | go | func (i *Instances) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) {
instanceID, err := instanceIDFromProviderID(providerID)
if err != nil {
return false, err
}
_, err = servers.Get(i.compute, instanceID).Extract()
if err != nil {
if isNotFound(err) {
return false, nil
}
return false, err
}
return true, nil
} | [
"func",
"(",
"i",
"*",
"Instances",
")",
"InstanceExistsByProviderID",
"(",
"ctx",
"context",
".",
"Context",
",",
"providerID",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"instanceID",
",",
"err",
":=",
"instanceIDFromProviderID",
"(",
"providerID",
... | // InstanceExistsByProviderID returns true if the instance with the given provider id still exist.
// If false is returned with no error, the instance will be immediately deleted by the cloud controller manager. | [
"InstanceExistsByProviderID",
"returns",
"true",
"if",
"the",
"instance",
"with",
"the",
"given",
"provider",
"id",
"still",
"exist",
".",
"If",
"false",
"is",
"returned",
"with",
"no",
"error",
"the",
"instance",
"will",
"be",
"immediately",
"deleted",
"by",
... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/openstack/openstack_instances.go#L117-L132 | train | InstanceExistsByProviderID returns true if instance exists by providerID | [
30522,
4569,
2278,
1006,
1045,
1008,
12107,
1007,
6013,
10288,
5130,
3762,
21572,
17258,
11124,
2094,
1006,
14931,
2595,
6123,
1012,
6123,
1010,
10802,
3593,
5164,
1007,
1006,
22017,
2140,
1010,
7561,
1007,
1063,
6013,
3593,
1010,
9413,
209... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go | getAgentPoolScaleSets | func (ss *scaleSet) getAgentPoolScaleSets(nodes []*v1.Node) (*[]string, error) {
agentPoolScaleSets := &[]string{}
for nx := range nodes {
if isMasterNode(nodes[nx]) {
continue
}
if ss.ShouldNodeExcludedFromLoadBalancer(nodes[nx]) {
continue
}
nodeName := nodes[nx].Name
ssName, err := ss.getScaleSetNameByNodeName(nodeName)
if err != nil {
return nil, err
}
if ssName == "" {
klog.V(3).Infof("Node %q is not belonging to any known scale sets", nodeName)
continue
}
*agentPoolScaleSets = append(*agentPoolScaleSets, ssName)
}
return agentPoolScaleSets, nil
} | go | func (ss *scaleSet) getAgentPoolScaleSets(nodes []*v1.Node) (*[]string, error) {
agentPoolScaleSets := &[]string{}
for nx := range nodes {
if isMasterNode(nodes[nx]) {
continue
}
if ss.ShouldNodeExcludedFromLoadBalancer(nodes[nx]) {
continue
}
nodeName := nodes[nx].Name
ssName, err := ss.getScaleSetNameByNodeName(nodeName)
if err != nil {
return nil, err
}
if ssName == "" {
klog.V(3).Infof("Node %q is not belonging to any known scale sets", nodeName)
continue
}
*agentPoolScaleSets = append(*agentPoolScaleSets, ssName)
}
return agentPoolScaleSets, nil
} | [
"func",
"(",
"ss",
"*",
"scaleSet",
")",
"getAgentPoolScaleSets",
"(",
"nodes",
"[",
"]",
"*",
"v1",
".",
"Node",
")",
"(",
"*",
"[",
"]",
"string",
",",
"error",
")",
"{",
"agentPoolScaleSets",
":=",
"&",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",... | // getAgentPoolScaleSets lists the virtual machines for the resource group and then builds
// a list of scale sets that match the nodes available to k8s. | [
"getAgentPoolScaleSets",
"lists",
"the",
"virtual",
"machines",
"for",
"the",
"resource",
"group",
"and",
"then",
"builds",
"a",
"list",
"of",
"scale",
"sets",
"that",
"match",
"the",
"nodes",
"available",
"to",
"k8s",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go#L437-L463 | train | getAgentPoolScaleSets returns a slice of agentPoolScaleSets that are associated with the given nodes. | [
30522,
4569,
2278,
1006,
7020,
1008,
9539,
3388,
1007,
2131,
4270,
3372,
16869,
15782,
24527,
30524,
1063,
2065,
2003,
8706,
3630,
3207,
1006,
14164,
1031,
1050,
2595,
1033,
1007,
1063,
3613,
1065,
2065,
7020,
1012,
5807,
10244,
10288,
2046... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go | Admit | func (l *Lifecycle) Admit(a admission.Attributes, o admission.ObjectInterfaces) error {
// prevent deletion of immortal namespaces
if a.GetOperation() == admission.Delete && a.GetKind().GroupKind() == v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() && l.immortalNamespaces.Has(a.GetName()) {
return errors.NewForbidden(a.GetResource().GroupResource(), a.GetName(), fmt.Errorf("this namespace may not be deleted"))
}
// always allow non-namespaced resources
if len(a.GetNamespace()) == 0 && a.GetKind().GroupKind() != v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() {
return nil
}
if a.GetKind().GroupKind() == v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() {
// if a namespace is deleted, we want to prevent all further creates into it
// while it is undergoing termination. to reduce incidences where the cache
// is slow to update, we add the namespace into a force live lookup list to ensure
// we are not looking at stale state.
if a.GetOperation() == admission.Delete {
l.forceLiveLookupCache.Add(a.GetName(), true, forceLiveLookupTTL)
}
// allow all operations to namespaces
return nil
}
// always allow deletion of other resources
if a.GetOperation() == admission.Delete {
return nil
}
// always allow access review checks. Returning status about the namespace would be leaking information
if isAccessReview(a) {
return nil
}
// we need to wait for our caches to warm
if !l.WaitForReady() {
return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request"))
}
var (
exists bool
err error
)
namespace, err := l.namespaceLister.Get(a.GetNamespace())
if err != nil {
if !errors.IsNotFound(err) {
return errors.NewInternalError(err)
}
} else {
exists = true
}
if !exists && a.GetOperation() == admission.Create {
// give the cache time to observe the namespace before rejecting a create.
// this helps when creating a namespace and immediately creating objects within it.
time.Sleep(missingNamespaceWait)
namespace, err = l.namespaceLister.Get(a.GetNamespace())
switch {
case errors.IsNotFound(err):
// no-op
case err != nil:
return errors.NewInternalError(err)
default:
exists = true
}
if exists {
klog.V(4).Infof("found %s in cache after waiting", a.GetNamespace())
}
}
// forceLiveLookup if true will skip looking at local cache state and instead always make a live call to server.
forceLiveLookup := false
if _, ok := l.forceLiveLookupCache.Get(a.GetNamespace()); ok {
// we think the namespace was marked for deletion, but our current local cache says otherwise, we will force a live lookup.
forceLiveLookup = exists && namespace.Status.Phase == v1.NamespaceActive
}
// refuse to operate on non-existent namespaces
if !exists || forceLiveLookup {
// as a last resort, make a call directly to storage
namespace, err = l.client.CoreV1().Namespaces().Get(a.GetNamespace(), metav1.GetOptions{})
switch {
case errors.IsNotFound(err):
return err
case err != nil:
return errors.NewInternalError(err)
}
klog.V(4).Infof("found %s via storage lookup", a.GetNamespace())
}
// ensure that we're not trying to create objects in terminating namespaces
if a.GetOperation() == admission.Create {
if namespace.Status.Phase != v1.NamespaceTerminating {
return nil
}
// TODO: This should probably not be a 403
return admission.NewForbidden(a, fmt.Errorf("unable to create new content in namespace %s because it is being terminated", a.GetNamespace()))
}
return nil
} | go | func (l *Lifecycle) Admit(a admission.Attributes, o admission.ObjectInterfaces) error {
// prevent deletion of immortal namespaces
if a.GetOperation() == admission.Delete && a.GetKind().GroupKind() == v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() && l.immortalNamespaces.Has(a.GetName()) {
return errors.NewForbidden(a.GetResource().GroupResource(), a.GetName(), fmt.Errorf("this namespace may not be deleted"))
}
// always allow non-namespaced resources
if len(a.GetNamespace()) == 0 && a.GetKind().GroupKind() != v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() {
return nil
}
if a.GetKind().GroupKind() == v1.SchemeGroupVersion.WithKind("Namespace").GroupKind() {
// if a namespace is deleted, we want to prevent all further creates into it
// while it is undergoing termination. to reduce incidences where the cache
// is slow to update, we add the namespace into a force live lookup list to ensure
// we are not looking at stale state.
if a.GetOperation() == admission.Delete {
l.forceLiveLookupCache.Add(a.GetName(), true, forceLiveLookupTTL)
}
// allow all operations to namespaces
return nil
}
// always allow deletion of other resources
if a.GetOperation() == admission.Delete {
return nil
}
// always allow access review checks. Returning status about the namespace would be leaking information
if isAccessReview(a) {
return nil
}
// we need to wait for our caches to warm
if !l.WaitForReady() {
return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request"))
}
var (
exists bool
err error
)
namespace, err := l.namespaceLister.Get(a.GetNamespace())
if err != nil {
if !errors.IsNotFound(err) {
return errors.NewInternalError(err)
}
} else {
exists = true
}
if !exists && a.GetOperation() == admission.Create {
// give the cache time to observe the namespace before rejecting a create.
// this helps when creating a namespace and immediately creating objects within it.
time.Sleep(missingNamespaceWait)
namespace, err = l.namespaceLister.Get(a.GetNamespace())
switch {
case errors.IsNotFound(err):
// no-op
case err != nil:
return errors.NewInternalError(err)
default:
exists = true
}
if exists {
klog.V(4).Infof("found %s in cache after waiting", a.GetNamespace())
}
}
// forceLiveLookup if true will skip looking at local cache state and instead always make a live call to server.
forceLiveLookup := false
if _, ok := l.forceLiveLookupCache.Get(a.GetNamespace()); ok {
// we think the namespace was marked for deletion, but our current local cache says otherwise, we will force a live lookup.
forceLiveLookup = exists && namespace.Status.Phase == v1.NamespaceActive
}
// refuse to operate on non-existent namespaces
if !exists || forceLiveLookup {
// as a last resort, make a call directly to storage
namespace, err = l.client.CoreV1().Namespaces().Get(a.GetNamespace(), metav1.GetOptions{})
switch {
case errors.IsNotFound(err):
return err
case err != nil:
return errors.NewInternalError(err)
}
klog.V(4).Infof("found %s via storage lookup", a.GetNamespace())
}
// ensure that we're not trying to create objects in terminating namespaces
if a.GetOperation() == admission.Create {
if namespace.Status.Phase != v1.NamespaceTerminating {
return nil
}
// TODO: This should probably not be a 403
return admission.NewForbidden(a, fmt.Errorf("unable to create new content in namespace %s because it is being terminated", a.GetNamespace()))
}
return nil
} | [
"func",
"(",
"l",
"*",
"Lifecycle",
")",
"Admit",
"(",
"a",
"admission",
".",
"Attributes",
",",
"o",
"admission",
".",
"ObjectInterfaces",
")",
"error",
"{",
"// prevent deletion of immortal namespaces",
"if",
"a",
".",
"GetOperation",
"(",
")",
"==",
"admiss... | // Admit makes an admission decision based on the request attributes | [
"Admit",
"makes",
"an",
"admission",
"decision",
"based",
"on",
"the",
"request",
"attributes"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go#L76-L177 | train | Admit is a helper function to admit a request to the namespace | [
30522,
4569,
2278,
1006,
1048,
1008,
2166,
23490,
1007,
6449,
1006,
1037,
9634,
1012,
12332,
1010,
1051,
9634,
1012,
4874,
18447,
2121,
12172,
2015,
1007,
7561,
1063,
1013,
1013,
4652,
3972,
20624,
2239,
1997,
12147,
3415,
15327,
2015,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/runtimeclass/runtimeclass_manager.go | LookupRuntimeHandler | func (m *Manager) LookupRuntimeHandler(runtimeClassName *string) (string, error) {
if runtimeClassName == nil || *runtimeClassName == "" {
// The default RuntimeClass always resolves to the empty runtime handler.
return "", nil
}
name := *runtimeClassName
rc, err := m.lister.Get(name)
if err != nil {
if errors.IsNotFound(err) {
return "", err
}
return "", fmt.Errorf("Failed to lookup RuntimeClass %s: %v", name, err)
}
return rc.Handler, nil
} | go | func (m *Manager) LookupRuntimeHandler(runtimeClassName *string) (string, error) {
if runtimeClassName == nil || *runtimeClassName == "" {
// The default RuntimeClass always resolves to the empty runtime handler.
return "", nil
}
name := *runtimeClassName
rc, err := m.lister.Get(name)
if err != nil {
if errors.IsNotFound(err) {
return "", err
}
return "", fmt.Errorf("Failed to lookup RuntimeClass %s: %v", name, err)
}
return rc.Handler, nil
} | [
"func",
"(",
"m",
"*",
"Manager",
")",
"LookupRuntimeHandler",
"(",
"runtimeClassName",
"*",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"runtimeClassName",
"==",
"nil",
"||",
"*",
"runtimeClassName",
"==",
"\"",
"\"",
"{",
"// The default Ru... | // LookupRuntimeHandler returns the RuntimeHandler string associated with the given RuntimeClass
// name (or the default of "" for nil). If the RuntimeClass is not found, it returns an
// errors.NotFound error. | [
"LookupRuntimeHandler",
"returns",
"the",
"RuntimeHandler",
"string",
"associated",
"with",
"the",
"given",
"RuntimeClass",
"name",
"(",
"or",
"the",
"default",
"of",
"for",
"nil",
")",
".",
"If",
"the",
"RuntimeClass",
"is",
"not",
"found",
"it",
"returns",
"... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/runtimeclass/runtimeclass_manager.go#L61-L78 | train | LookupRuntimeHandler returns the handler for the given runtimeClassName. | [
30522,
4569,
2278,
1006,
1049,
1008,
3208,
1007,
2298,
6279,
15532,
7292,
11774,
3917,
1006,
2448,
7292,
26266,
18442,
1008,
5164,
1007,
1006,
5164,
1010,
7561,
1007,
1063,
2065,
2448,
7292,
26266,
18442,
1027,
1027,
9152,
2140,
1064,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/explain/field_lookup.go | VisitMap | func (f *fieldLookup) VisitMap(m *proto.Map) {
if f.SaveLeafSchema(m) {
return
}
// Passthrough maps.
m.SubType.Accept(f)
} | go | func (f *fieldLookup) VisitMap(m *proto.Map) {
if f.SaveLeafSchema(m) {
return
}
// Passthrough maps.
m.SubType.Accept(f)
} | [
"func",
"(",
"f",
"*",
"fieldLookup",
")",
"VisitMap",
"(",
"m",
"*",
"proto",
".",
"Map",
")",
"{",
"if",
"f",
".",
"SaveLeafSchema",
"(",
"m",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"// Passthrough maps.",
"m",
".",
"SubType",
".",
"Accept",
"(",
... | // VisitMap is mostly a passthrough. | [
"VisitMap",
"is",
"mostly",
"a",
"passthrough",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/explain/field_lookup.go#L59-L66 | train | VisitMap visits a map. | [
30522,
4569,
2278,
1006,
1042,
1008,
2492,
4135,
21940,
2361,
1007,
3942,
2863,
2361,
1006,
1049,
1008,
15053,
1012,
4949,
1007,
1063,
2065,
1042,
1012,
3828,
19213,
22842,
2863,
1006,
1049,
1007,
1063,
2709,
1065,
1013,
1013,
3413,
2705,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/autoscaling/zz_generated.deepcopy.go | DeepCopy | func (in *MetricTarget) DeepCopy() *MetricTarget {
if in == nil {
return nil
}
out := new(MetricTarget)
in.DeepCopyInto(out)
return out
} | go | func (in *MetricTarget) DeepCopy() *MetricTarget {
if in == nil {
return nil
}
out := new(MetricTarget)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"MetricTarget",
")",
"DeepCopy",
"(",
")",
"*",
"MetricTarget",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"MetricTarget",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
... | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTarget. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"MetricTarget",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/autoscaling/zz_generated.deepcopy.go#L341-L348 | train | DeepCopy is an autogenerated deepcopy function copying the receiver creating a new MetricTarget. | [
30522,
4569,
2278,
1006,
1999,
1008,
12046,
7559,
18150,
1007,
2784,
3597,
7685,
1006,
1007,
1008,
12046,
7559,
18150,
1063,
2065,
1999,
1027,
1027,
9152,
2140,
1063,
2709,
9152,
2140,
1065,
2041,
1024,
1027,
2047,
1006,
12046,
7559,
18150,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go | hasPerVersionSubresources | func hasPerVersionSubresources(versions []apiextensions.CustomResourceDefinitionVersion) bool {
for _, v := range versions {
if v.Subresources != nil {
return true
}
}
return false
} | go | func hasPerVersionSubresources(versions []apiextensions.CustomResourceDefinitionVersion) bool {
for _, v := range versions {
if v.Subresources != nil {
return true
}
}
return false
} | [
"func",
"hasPerVersionSubresources",
"(",
"versions",
"[",
"]",
"apiextensions",
".",
"CustomResourceDefinitionVersion",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"versions",
"{",
"if",
"v",
".",
"Subresources",
"!=",
"nil",
"{",
"return",
"true",... | // hasPerVersionSubresources returns true if a CRD uses per-version subresources. | [
"hasPerVersionSubresources",
"returns",
"true",
"if",
"a",
"CRD",
"uses",
"per",
"-",
"version",
"subresources",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go#L395-L402 | train | hasPerVersionSubresources returns true if there are any subresources in the given list of custom resource versions. | [
30522,
4569,
2278,
2038,
4842,
27774,
6342,
13578,
6499,
3126,
9623,
1006,
4617,
1031,
1033,
17928,
10288,
29048,
2015,
1012,
7661,
6072,
8162,
22119,
16294,
22753,
27774,
1007,
22017,
2140,
1063,
2005,
1035,
1010,
1058,
1024,
1027,
2846,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/configmaplock.go | Update | func (cml *ConfigMapLock) Update(ler LeaderElectionRecord) error {
if cml.cm == nil {
return errors.New("configmap not initialized, call get or create first")
}
recordBytes, err := json.Marshal(ler)
if err != nil {
return err
}
cml.cm.Annotations[LeaderElectionRecordAnnotationKey] = string(recordBytes)
cml.cm, err = cml.Client.ConfigMaps(cml.ConfigMapMeta.Namespace).Update(cml.cm)
return err
} | go | func (cml *ConfigMapLock) Update(ler LeaderElectionRecord) error {
if cml.cm == nil {
return errors.New("configmap not initialized, call get or create first")
}
recordBytes, err := json.Marshal(ler)
if err != nil {
return err
}
cml.cm.Annotations[LeaderElectionRecordAnnotationKey] = string(recordBytes)
cml.cm, err = cml.Client.ConfigMaps(cml.ConfigMapMeta.Namespace).Update(cml.cm)
return err
} | [
"func",
"(",
"cml",
"*",
"ConfigMapLock",
")",
"Update",
"(",
"ler",
"LeaderElectionRecord",
")",
"error",
"{",
"if",
"cml",
".",
"cm",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"recordBytes",
",",
"err"... | // Update will update an existing annotation on a given resource. | [
"Update",
"will",
"update",
"an",
"existing",
"annotation",
"on",
"a",
"given",
"resource",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/configmaplock.go#L81-L92 | train | Update updates the leader election record | [
30522,
4569,
2278,
1006,
4642,
2140,
1008,
9530,
8873,
21693,
9331,
7878,
1007,
10651,
1006,
3393,
2099,
3003,
12260,
7542,
2890,
27108,
2094,
1007,
7561,
1063,
2065,
4642,
2140,
1012,
4642,
1027,
1027,
9152,
2140,
1063,
2709,
10697,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/cli-runtime/pkg/resource/visitor.go | FilterNamespace | func FilterNamespace(info *Info, err error) error {
if err != nil {
return err
}
if !info.Namespaced() {
info.Namespace = ""
UpdateObjectNamespace(info, nil)
}
return nil
} | go | func FilterNamespace(info *Info, err error) error {
if err != nil {
return err
}
if !info.Namespaced() {
info.Namespace = ""
UpdateObjectNamespace(info, nil)
}
return nil
} | [
"func",
"FilterNamespace",
"(",
"info",
"*",
"Info",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"info",
".",
"Namespaced",
"(",
")",
"{",
"info",
".",
"Namespace",
"=",
"\"",
... | // FilterNamespace omits the namespace if the object is not namespace scoped | [
"FilterNamespace",
"omits",
"the",
"namespace",
"if",
"the",
"object",
"is",
"not",
"namespace",
"scoped"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/cli-runtime/pkg/resource/visitor.go#L613-L622 | train | FilterNamespace filters the namespace of the object | [
30522,
4569,
2278,
11307,
18442,
23058,
1006,
18558,
1008,
18558,
1010,
9413,
2099,
7561,
1007,
7561,
1063,
2065,
9413,
2099,
999,
1027,
9152,
2140,
1063,
2709,
9413,
2099,
1065,
2065,
999,
18558,
1012,
3415,
15327,
2094,
1006,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/cmd/rollout/rollout_status.go | NewCmdRolloutStatus | func NewCmdRolloutStatus(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
o := NewRolloutStatusOptions(streams)
validArgs := []string{"deployment", "daemonset", "statefulset"}
cmd := &cobra.Command{
Use: "status (TYPE NAME | TYPE/NAME) [flags]",
DisableFlagsInUseLine: true,
Short: i18n.T("Show the status of the rollout"),
Long: statusLong,
Example: statusExample,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(o.Complete(f, args))
cmdutil.CheckErr(o.Validate())
cmdutil.CheckErr(o.Run())
},
ValidArgs: validArgs,
}
usage := "identifying the resource to get from a server."
cmdutil.AddFilenameOptionFlags(cmd, o.FilenameOptions, usage)
cmd.Flags().BoolVarP(&o.Watch, "watch", "w", o.Watch, "Watch the status of the rollout until it's done.")
cmd.Flags().Int64Var(&o.Revision, "revision", o.Revision, "Pin to a specific revision for showing its status. Defaults to 0 (last revision).")
cmd.Flags().DurationVar(&o.Timeout, "timeout", o.Timeout, "The length of time to wait before ending watch, zero means never. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).")
return cmd
} | go | func NewCmdRolloutStatus(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
o := NewRolloutStatusOptions(streams)
validArgs := []string{"deployment", "daemonset", "statefulset"}
cmd := &cobra.Command{
Use: "status (TYPE NAME | TYPE/NAME) [flags]",
DisableFlagsInUseLine: true,
Short: i18n.T("Show the status of the rollout"),
Long: statusLong,
Example: statusExample,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(o.Complete(f, args))
cmdutil.CheckErr(o.Validate())
cmdutil.CheckErr(o.Run())
},
ValidArgs: validArgs,
}
usage := "identifying the resource to get from a server."
cmdutil.AddFilenameOptionFlags(cmd, o.FilenameOptions, usage)
cmd.Flags().BoolVarP(&o.Watch, "watch", "w", o.Watch, "Watch the status of the rollout until it's done.")
cmd.Flags().Int64Var(&o.Revision, "revision", o.Revision, "Pin to a specific revision for showing its status. Defaults to 0 (last revision).")
cmd.Flags().DurationVar(&o.Timeout, "timeout", o.Timeout, "The length of time to wait before ending watch, zero means never. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).")
return cmd
} | [
"func",
"NewCmdRolloutStatus",
"(",
"f",
"cmdutil",
".",
"Factory",
",",
"streams",
"genericclioptions",
".",
"IOStreams",
")",
"*",
"cobra",
".",
"Command",
"{",
"o",
":=",
"NewRolloutStatusOptions",
"(",
"streams",
")",
"\n\n",
"validArgs",
":=",
"[",
"]",
... | // NewCmdRolloutStatus returns a Command instance for the 'rollout status' sub command | [
"NewCmdRolloutStatus",
"returns",
"a",
"Command",
"instance",
"for",
"the",
"rollout",
"status",
"sub",
"command"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/rollout/rollout_status.go#L95-L121 | train | NewCmdRolloutStatus returns a command to show the status of a rollout. | [
30522,
4569,
2278,
2047,
27487,
22196,
7174,
16446,
29336,
2271,
1006,
1042,
4642,
8566,
3775,
2140,
1012,
4713,
1010,
9199,
12391,
20464,
3695,
16790,
2015,
1012,
16380,
25379,
2015,
1007,
1008,
16604,
1012,
3094,
1063,
1051,
1024,
1027,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/stats/stats_provider.go | RootFsStats | func (p *StatsProvider) RootFsStats() (*statsapi.FsStats, error) {
rootFsInfo, err := p.cadvisor.RootFsInfo()
if err != nil {
return nil, fmt.Errorf("failed to get rootFs info: %v", err)
}
var nodeFsInodesUsed *uint64
if rootFsInfo.Inodes != nil && rootFsInfo.InodesFree != nil {
nodeFsIU := *rootFsInfo.Inodes - *rootFsInfo.InodesFree
nodeFsInodesUsed = &nodeFsIU
}
// Get the root container stats's timestamp, which will be used as the
// imageFs stats timestamp. Dont force a stats update, as we only want the timestamp.
rootStats, err := getCgroupStats(p.cadvisor, "/", false)
if err != nil {
return nil, fmt.Errorf("failed to get root container stats: %v", err)
}
return &statsapi.FsStats{
Time: metav1.NewTime(rootStats.Timestamp),
AvailableBytes: &rootFsInfo.Available,
CapacityBytes: &rootFsInfo.Capacity,
UsedBytes: &rootFsInfo.Usage,
InodesFree: rootFsInfo.InodesFree,
Inodes: rootFsInfo.Inodes,
InodesUsed: nodeFsInodesUsed,
}, nil
} | go | func (p *StatsProvider) RootFsStats() (*statsapi.FsStats, error) {
rootFsInfo, err := p.cadvisor.RootFsInfo()
if err != nil {
return nil, fmt.Errorf("failed to get rootFs info: %v", err)
}
var nodeFsInodesUsed *uint64
if rootFsInfo.Inodes != nil && rootFsInfo.InodesFree != nil {
nodeFsIU := *rootFsInfo.Inodes - *rootFsInfo.InodesFree
nodeFsInodesUsed = &nodeFsIU
}
// Get the root container stats's timestamp, which will be used as the
// imageFs stats timestamp. Dont force a stats update, as we only want the timestamp.
rootStats, err := getCgroupStats(p.cadvisor, "/", false)
if err != nil {
return nil, fmt.Errorf("failed to get root container stats: %v", err)
}
return &statsapi.FsStats{
Time: metav1.NewTime(rootStats.Timestamp),
AvailableBytes: &rootFsInfo.Available,
CapacityBytes: &rootFsInfo.Capacity,
UsedBytes: &rootFsInfo.Usage,
InodesFree: rootFsInfo.InodesFree,
Inodes: rootFsInfo.Inodes,
InodesUsed: nodeFsInodesUsed,
}, nil
} | [
"func",
"(",
"p",
"*",
"StatsProvider",
")",
"RootFsStats",
"(",
")",
"(",
"*",
"statsapi",
".",
"FsStats",
",",
"error",
")",
"{",
"rootFsInfo",
",",
"err",
":=",
"p",
".",
"cadvisor",
".",
"RootFsInfo",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // RootFsStats returns the stats of the node root filesystem. | [
"RootFsStats",
"returns",
"the",
"stats",
"of",
"the",
"node",
"root",
"filesystem",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/stats/stats_provider.go#L134-L162 | train | RootFsStats returns the stats for the root filesystem. | [
30522,
4569,
2278,
1006,
1052,
1008,
26319,
21572,
17258,
2121,
1007,
7117,
10343,
9153,
3215,
1006,
1007,
1006,
1008,
26319,
9331,
2072,
1012,
1042,
4757,
29336,
2015,
1010,
7561,
1007,
1063,
7117,
10343,
2378,
14876,
1010,
9413,
2099,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/rbac/v1alpha1/zz_generated.defaults.go | RegisterDefaults | func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&v1alpha1.ClusterRoleBinding{}, func(obj interface{}) { SetObjectDefaults_ClusterRoleBinding(obj.(*v1alpha1.ClusterRoleBinding)) })
scheme.AddTypeDefaultingFunc(&v1alpha1.ClusterRoleBindingList{}, func(obj interface{}) {
SetObjectDefaults_ClusterRoleBindingList(obj.(*v1alpha1.ClusterRoleBindingList))
})
scheme.AddTypeDefaultingFunc(&v1alpha1.RoleBinding{}, func(obj interface{}) { SetObjectDefaults_RoleBinding(obj.(*v1alpha1.RoleBinding)) })
scheme.AddTypeDefaultingFunc(&v1alpha1.RoleBindingList{}, func(obj interface{}) { SetObjectDefaults_RoleBindingList(obj.(*v1alpha1.RoleBindingList)) })
return nil
} | go | func RegisterDefaults(scheme *runtime.Scheme) error {
scheme.AddTypeDefaultingFunc(&v1alpha1.ClusterRoleBinding{}, func(obj interface{}) { SetObjectDefaults_ClusterRoleBinding(obj.(*v1alpha1.ClusterRoleBinding)) })
scheme.AddTypeDefaultingFunc(&v1alpha1.ClusterRoleBindingList{}, func(obj interface{}) {
SetObjectDefaults_ClusterRoleBindingList(obj.(*v1alpha1.ClusterRoleBindingList))
})
scheme.AddTypeDefaultingFunc(&v1alpha1.RoleBinding{}, func(obj interface{}) { SetObjectDefaults_RoleBinding(obj.(*v1alpha1.RoleBinding)) })
scheme.AddTypeDefaultingFunc(&v1alpha1.RoleBindingList{}, func(obj interface{}) { SetObjectDefaults_RoleBindingList(obj.(*v1alpha1.RoleBindingList)) })
return nil
} | [
"func",
"RegisterDefaults",
"(",
"scheme",
"*",
"runtime",
".",
"Scheme",
")",
"error",
"{",
"scheme",
".",
"AddTypeDefaultingFunc",
"(",
"&",
"v1alpha1",
".",
"ClusterRoleBinding",
"{",
"}",
",",
"func",
"(",
"obj",
"interface",
"{",
"}",
")",
"{",
"SetOb... | // RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters. | [
"RegisterDefaults",
"adds",
"defaulters",
"functions",
"to",
"the",
"given",
"scheme",
".",
"Public",
"to",
"allow",
"building",
"arbitrary",
"schemes",
".",
"All",
"generated",
"defaulters",
"are",
"covering",
"-",
"they",
"call",
"all",
"nested",
"defaulters",
... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/rbac/v1alpha1/zz_generated.defaults.go#L31-L39 | train | RegisterDefaults registers default values for the scheme | [
30522,
4569,
2278,
4236,
3207,
7011,
11314,
2015,
1006,
5679,
1008,
2448,
7292,
1012,
5679,
1007,
7561,
1063,
5679,
1012,
5587,
13874,
3207,
7011,
11314,
2075,
11263,
12273,
1006,
1004,
1058,
2487,
2389,
21890,
2487,
1012,
9324,
13153,
1587... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/util/util.go | CheckVolumeModeFilesystem | func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) {
if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) {
volumeMode, err := GetVolumeMode(volumeSpec)
if err != nil {
return true, err
}
if volumeMode == v1.PersistentVolumeBlock {
return false, nil
}
}
return true, nil
} | go | func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) {
if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) {
volumeMode, err := GetVolumeMode(volumeSpec)
if err != nil {
return true, err
}
if volumeMode == v1.PersistentVolumeBlock {
return false, nil
}
}
return true, nil
} | [
"func",
"CheckVolumeModeFilesystem",
"(",
"volumeSpec",
"*",
"volume",
".",
"Spec",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"utilfeature",
".",
"DefaultFeatureGate",
".",
"Enabled",
"(",
"features",
".",
"BlockVolume",
")",
"{",
"volumeMode",
",",
"e... | // CheckVolumeModeFilesystem checks VolumeMode.
// If the mode is Filesystem, return true otherwise return false. | [
"CheckVolumeModeFilesystem",
"checks",
"VolumeMode",
".",
"If",
"the",
"mode",
"is",
"Filesystem",
"return",
"true",
"otherwise",
"return",
"false",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/util/util.go#L441-L452 | train | CheckVolumeModeFilesystem checks if volume is filesystem | [
30522,
4569,
2278,
4638,
6767,
12942,
6633,
10244,
8873,
4244,
27268,
6633,
1006,
6702,
5051,
2278,
1008,
3872,
1012,
28699,
1007,
1006,
22017,
2140,
1010,
7561,
1007,
1063,
2065,
21183,
4014,
7959,
4017,
5397,
1012,
12398,
7959,
4017,
5397... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cluster/images/etcd/migrate/rollback_v2.go | RollbackV3ToV2 | func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
dbpath := path.Join(migrateDatadir, "member", "snap", "db")
klog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
// etcd3 store backend. We will use it to parse v3 data files and extract information.
be := backend.NewDefaultBackend(dbpath)
tx := be.BatchTx()
// etcd2 store backend. We will use v3 data to update this and then save snapshot to disk.
st := store.New(etcdserver.StoreClusterPrefix, etcdserver.StoreKeysPrefix)
expireTime := time.Now().Add(ttl)
tx.Lock()
err := tx.UnsafeForEach([]byte("key"), func(k, v []byte) error {
kv := &mvccpb.KeyValue{}
kv.Unmarshal(v)
// This is compact key.
if !strings.HasPrefix(string(kv.Key), "/") {
return nil
}
ttlOpt := store.TTLOptionSet{}
if kv.Lease != 0 {
ttlOpt = store.TTLOptionSet{ExpireTime: expireTime}
}
if !isTombstone(k) {
sk := path.Join(strings.Trim(etcdserver.StoreKeysPrefix, "/"), string(kv.Key))
_, err := st.Set(sk, false, string(kv.Value), ttlOpt)
if err != nil {
return err
}
} else {
st.Delete(string(kv.Key), false, false)
}
return nil
})
if err != nil {
return err
}
tx.Unlock()
if err := traverseAndDeleteEmptyDir(st, "/"); err != nil {
return err
}
// rebuild cluster state.
metadata, hardstate, oldSt, err := rebuild(migrateDatadir)
if err != nil {
return err
}
// In the following, it's low level logic that saves metadata and data into v2 snapshot.
backupPath := migrateDatadir + ".rollback.backup"
if err := os.Rename(migrateDatadir, backupPath); err != nil {
return err
}
if err := os.MkdirAll(path.Join(migrateDatadir, "member", "snap"), 0777); err != nil {
return err
}
walDir := path.Join(migrateDatadir, "member", "wal")
w, err := oldwal.Create(walDir, metadata)
if err != nil {
return err
}
err = w.SaveSnapshot(walpb.Snapshot{Index: hardstate.Commit, Term: hardstate.Term})
w.Close()
if err != nil {
return err
}
event, err := oldSt.Get(etcdserver.StoreClusterPrefix, true, false)
if err != nil {
return err
}
// nodes (members info) for ConfState
nodes := []uint64{}
traverseMetadata(event.Node, func(n *store.NodeExtern) {
if n.Key != etcdserver.StoreClusterPrefix {
// update store metadata
v := ""
if !n.Dir {
v = *n.Value
}
if n.Key == path.Join(etcdserver.StoreClusterPrefix, "version") {
v = rollbackVersion
}
if _, err := st.Set(n.Key, n.Dir, v, store.TTLOptionSet{}); err != nil {
klog.Error(err)
}
// update nodes
fields := strings.Split(n.Key, "/")
if len(fields) == 4 && fields[2] == "members" {
nodeID, err := strconv.ParseUint(fields[3], 16, 64)
if err != nil {
klog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
}
nodes = append(nodes, nodeID)
}
}
})
data, err := st.Save()
if err != nil {
return err
}
raftSnap := raftpb.Snapshot{
Data: data,
Metadata: raftpb.SnapshotMetadata{
Index: hardstate.Commit,
Term: hardstate.Term,
ConfState: raftpb.ConfState{
Nodes: nodes,
},
},
}
snapshotter := snap.New(path.Join(migrateDatadir, "member", "snap"))
if err := snapshotter.SaveSnap(raftSnap); err != nil {
return err
}
klog.Infof("Finished successfully")
return nil
} | go | func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
dbpath := path.Join(migrateDatadir, "member", "snap", "db")
klog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
// etcd3 store backend. We will use it to parse v3 data files and extract information.
be := backend.NewDefaultBackend(dbpath)
tx := be.BatchTx()
// etcd2 store backend. We will use v3 data to update this and then save snapshot to disk.
st := store.New(etcdserver.StoreClusterPrefix, etcdserver.StoreKeysPrefix)
expireTime := time.Now().Add(ttl)
tx.Lock()
err := tx.UnsafeForEach([]byte("key"), func(k, v []byte) error {
kv := &mvccpb.KeyValue{}
kv.Unmarshal(v)
// This is compact key.
if !strings.HasPrefix(string(kv.Key), "/") {
return nil
}
ttlOpt := store.TTLOptionSet{}
if kv.Lease != 0 {
ttlOpt = store.TTLOptionSet{ExpireTime: expireTime}
}
if !isTombstone(k) {
sk := path.Join(strings.Trim(etcdserver.StoreKeysPrefix, "/"), string(kv.Key))
_, err := st.Set(sk, false, string(kv.Value), ttlOpt)
if err != nil {
return err
}
} else {
st.Delete(string(kv.Key), false, false)
}
return nil
})
if err != nil {
return err
}
tx.Unlock()
if err := traverseAndDeleteEmptyDir(st, "/"); err != nil {
return err
}
// rebuild cluster state.
metadata, hardstate, oldSt, err := rebuild(migrateDatadir)
if err != nil {
return err
}
// In the following, it's low level logic that saves metadata and data into v2 snapshot.
backupPath := migrateDatadir + ".rollback.backup"
if err := os.Rename(migrateDatadir, backupPath); err != nil {
return err
}
if err := os.MkdirAll(path.Join(migrateDatadir, "member", "snap"), 0777); err != nil {
return err
}
walDir := path.Join(migrateDatadir, "member", "wal")
w, err := oldwal.Create(walDir, metadata)
if err != nil {
return err
}
err = w.SaveSnapshot(walpb.Snapshot{Index: hardstate.Commit, Term: hardstate.Term})
w.Close()
if err != nil {
return err
}
event, err := oldSt.Get(etcdserver.StoreClusterPrefix, true, false)
if err != nil {
return err
}
// nodes (members info) for ConfState
nodes := []uint64{}
traverseMetadata(event.Node, func(n *store.NodeExtern) {
if n.Key != etcdserver.StoreClusterPrefix {
// update store metadata
v := ""
if !n.Dir {
v = *n.Value
}
if n.Key == path.Join(etcdserver.StoreClusterPrefix, "version") {
v = rollbackVersion
}
if _, err := st.Set(n.Key, n.Dir, v, store.TTLOptionSet{}); err != nil {
klog.Error(err)
}
// update nodes
fields := strings.Split(n.Key, "/")
if len(fields) == 4 && fields[2] == "members" {
nodeID, err := strconv.ParseUint(fields[3], 16, 64)
if err != nil {
klog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
}
nodes = append(nodes, nodeID)
}
}
})
data, err := st.Save()
if err != nil {
return err
}
raftSnap := raftpb.Snapshot{
Data: data,
Metadata: raftpb.SnapshotMetadata{
Index: hardstate.Commit,
Term: hardstate.Term,
ConfState: raftpb.ConfState{
Nodes: nodes,
},
},
}
snapshotter := snap.New(path.Join(migrateDatadir, "member", "snap"))
if err := snapshotter.SaveSnap(raftSnap); err != nil {
return err
}
klog.Infof("Finished successfully")
return nil
} | [
"func",
"RollbackV3ToV2",
"(",
"migrateDatadir",
"string",
",",
"ttl",
"time",
".",
"Duration",
")",
"error",
"{",
"dbpath",
":=",
"path",
".",
"Join",
"(",
"migrateDatadir",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"klog",
".",
... | // RollbackV3ToV2 rolls back an etcd 3.0.x data directory to the 2.x.x version specified by rollbackVersion. | [
"RollbackV3ToV2",
"rolls",
"back",
"an",
"etcd",
"3",
".",
"0",
".",
"x",
"data",
"directory",
"to",
"the",
"2",
".",
"x",
".",
"x",
"version",
"specified",
"by",
"rollbackVersion",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cluster/images/etcd/migrate/rollback_v2.go#L51-L177 | train | RollbackV3ToV2 rolls back the v3 snapshot to etcd 2. x | [
30522,
4569,
2278,
4897,
5963,
2615,
2509,
26525,
2475,
1006,
13447,
6790,
4305,
2099,
5164,
1010,
23746,
2140,
2051,
1012,
9367,
1007,
7561,
1063,
16962,
15069,
1024,
1027,
4130,
1012,
3693,
1006,
13447,
6790,
4305,
2099,
1010,
1000,
2266,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/security/podsecuritypolicy/factory.go | createSeccompStrategy | func createSeccompStrategy(psp *policy.PodSecurityPolicy) (seccomp.Strategy, error) {
return seccomp.NewStrategy(psp.Annotations), nil
} | go | func createSeccompStrategy(psp *policy.PodSecurityPolicy) (seccomp.Strategy, error) {
return seccomp.NewStrategy(psp.Annotations), nil
} | [
"func",
"createSeccompStrategy",
"(",
"psp",
"*",
"policy",
".",
"PodSecurityPolicy",
")",
"(",
"seccomp",
".",
"Strategy",
",",
"error",
")",
"{",
"return",
"seccomp",
".",
"NewStrategy",
"(",
"psp",
".",
"Annotations",
")",
",",
"nil",
"\n",
"}"
] | // createSeccompStrategy creates a new seccomp strategy. | [
"createSeccompStrategy",
"creates",
"a",
"new",
"seccomp",
"strategy",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/security/podsecuritypolicy/factory.go#L161-L163 | train | createSeccompStrategy creates a seccomp strategy for a pod security policy. | [
30522,
4569,
2278,
9005,
8586,
9006,
4523,
6494,
2618,
6292,
1006,
8827,
2361,
1008,
3343,
1012,
26723,
8586,
25137,
18155,
2594,
2100,
1007,
1006,
10819,
9006,
2361,
1012,
5656,
1010,
7561,
1007,
1063,
2709,
10819,
9006,
2361,
1012,
2739,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/history/controller_history.go | NewFakeHistory | func NewFakeHistory(informer appsinformers.ControllerRevisionInformer) Interface {
return &fakeHistory{informer.Informer().GetIndexer(), informer.Lister()}
} | go | func NewFakeHistory(informer appsinformers.ControllerRevisionInformer) Interface {
return &fakeHistory{informer.Informer().GetIndexer(), informer.Lister()}
} | [
"func",
"NewFakeHistory",
"(",
"informer",
"appsinformers",
".",
"ControllerRevisionInformer",
")",
"Interface",
"{",
"return",
"&",
"fakeHistory",
"{",
"informer",
".",
"Informer",
"(",
")",
".",
"GetIndexer",
"(",
")",
",",
"informer",
".",
"Lister",
"(",
")... | // NewFakeHistory returns an instance of Interface that uses informer to create, update, list, and delete
// ControllerRevisions. This method should be used to create an Interface for testing purposes. | [
"NewFakeHistory",
"returns",
"an",
"instance",
"of",
"Interface",
"that",
"uses",
"informer",
"to",
"create",
"update",
"list",
"and",
"delete",
"ControllerRevisions",
".",
"This",
"method",
"should",
"be",
"used",
"to",
"create",
"an",
"Interface",
"for",
"test... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/history/controller_history.go#L210-L212 | train | NewFakeHistory returns a new Interface that can be used to get a ControllerRevision. | [
30522,
4569,
2278,
2047,
7011,
3489,
24158,
7062,
1006,
12367,
2121,
18726,
2378,
14192,
2545,
1012,
11486,
2890,
17084,
2378,
14192,
2121,
1007,
8278,
1063,
2709,
1004,
8275,
24158,
7062,
1063,
12367,
2121,
1012,
12367,
2121,
1006,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/kubeadm/app/cmd/phases/init/certs.go | NewCertsPhase | func NewCertsPhase() workflow.Phase {
return workflow.Phase{
Name: "certs",
Short: "Certificate generation",
Phases: newCertSubPhases(),
Run: runCerts,
Long: cmdutil.MacroCommandLongDescription,
}
} | go | func NewCertsPhase() workflow.Phase {
return workflow.Phase{
Name: "certs",
Short: "Certificate generation",
Phases: newCertSubPhases(),
Run: runCerts,
Long: cmdutil.MacroCommandLongDescription,
}
} | [
"func",
"NewCertsPhase",
"(",
")",
"workflow",
".",
"Phase",
"{",
"return",
"workflow",
".",
"Phase",
"{",
"Name",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Phases",
":",
"newCertSubPhases",
"(",
")",
",",
"Run",
":",
"runCerts",
",",
"Lo... | // NewCertsPhase returns the phase for the certs | [
"NewCertsPhase",
"returns",
"the",
"phase",
"for",
"the",
"certs"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/kubeadm/app/cmd/phases/init/certs.go#L58-L66 | train | NewCertsPhase returns a new certs phase | [
30522,
4569,
2278,
2047,
17119,
3215,
21890,
3366,
1006,
1007,
2147,
12314,
1012,
4403,
1063,
2709,
2147,
12314,
1012,
4403,
1063,
2171,
1024,
1000,
8292,
21217,
1000,
1010,
2460,
1024,
1000,
8196,
4245,
1000,
1010,
12335,
1024,
2047,
17119... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | cmd/kubeadm/app/cmd/config.go | NewCmdConfigImagesList | func NewCmdConfigImagesList(out io.Writer, mockK8sVersion *string) *cobra.Command {
externalcfg := &kubeadmapiv1beta2.InitConfiguration{}
kubeadmscheme.Scheme.Default(externalcfg)
var cfgPath, featureGatesString string
var err error
// This just sets the Kubernetes version for unit testing so kubeadm won't try to
// lookup the latest release from the internet.
if mockK8sVersion != nil {
externalcfg.KubernetesVersion = *mockK8sVersion
}
cmd := &cobra.Command{
Use: "list",
Short: "Print a list of images kubeadm will use. The configuration file is used in case any images or image repositories are customized",
Run: func(_ *cobra.Command, _ []string) {
externalcfg.ClusterConfiguration.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString)
kubeadmutil.CheckErr(err)
imagesList, err := NewImagesList(cfgPath, externalcfg)
kubeadmutil.CheckErr(err)
kubeadmutil.CheckErr(imagesList.Run(out))
},
}
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
return cmd
} | go | func NewCmdConfigImagesList(out io.Writer, mockK8sVersion *string) *cobra.Command {
externalcfg := &kubeadmapiv1beta2.InitConfiguration{}
kubeadmscheme.Scheme.Default(externalcfg)
var cfgPath, featureGatesString string
var err error
// This just sets the Kubernetes version for unit testing so kubeadm won't try to
// lookup the latest release from the internet.
if mockK8sVersion != nil {
externalcfg.KubernetesVersion = *mockK8sVersion
}
cmd := &cobra.Command{
Use: "list",
Short: "Print a list of images kubeadm will use. The configuration file is used in case any images or image repositories are customized",
Run: func(_ *cobra.Command, _ []string) {
externalcfg.ClusterConfiguration.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString)
kubeadmutil.CheckErr(err)
imagesList, err := NewImagesList(cfgPath, externalcfg)
kubeadmutil.CheckErr(err)
kubeadmutil.CheckErr(imagesList.Run(out))
},
}
AddImagesCommonConfigFlags(cmd.PersistentFlags(), externalcfg, &cfgPath, &featureGatesString)
return cmd
} | [
"func",
"NewCmdConfigImagesList",
"(",
"out",
"io",
".",
"Writer",
",",
"mockK8sVersion",
"*",
"string",
")",
"*",
"cobra",
".",
"Command",
"{",
"externalcfg",
":=",
"&",
"kubeadmapiv1beta2",
".",
"InitConfiguration",
"{",
"}",
"\n",
"kubeadmscheme",
".",
"Sch... | // NewCmdConfigImagesList returns the "kubeadm config images list" command | [
"NewCmdConfigImagesList",
"returns",
"the",
"kubeadm",
"config",
"images",
"list",
"command"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/cmd/kubeadm/app/cmd/config.go#L461-L486 | train | NewCmdConfigImagesList returns a command to list images | [
30522,
4569,
2278,
2047,
27487,
16409,
2239,
8873,
5856,
26860,
14540,
2923,
1006,
2041,
22834,
1012,
3213,
1010,
12934,
2243,
2620,
2015,
27774,
1008,
5164,
1007,
1008,
16604,
1012,
3094,
1063,
6327,
2278,
2546,
2290,
1024,
1027,
1004,
139... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/cloudprovider/providers/cloudstack/metadata.go | GetZoneByNodeName | func (m *metadata) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not implemented")
} | go | func (m *metadata) GetZoneByNodeName(ctx context.Context, nodeName types.NodeName) (cloudprovider.Zone, error) {
return cloudprovider.Zone{}, errors.New("GetZoneByNodeName not implemented")
} | [
"func",
"(",
"m",
"*",
"metadata",
")",
"GetZoneByNodeName",
"(",
"ctx",
"context",
".",
"Context",
",",
"nodeName",
"types",
".",
"NodeName",
")",
"(",
"cloudprovider",
".",
"Zone",
",",
"error",
")",
"{",
"return",
"cloudprovider",
".",
"Zone",
"{",
"}... | // GetZoneByNodeName returns the Zone, found by using the node name. | [
"GetZoneByNodeName",
"returns",
"the",
"Zone",
"found",
"by",
"using",
"the",
"node",
"name",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/cloudstack/metadata.go#L162-L164 | train | GetZoneByNodeName returns zone by node name | [
30522,
4569,
2278,
1006,
1049,
1008,
27425,
1007,
2131,
15975,
3762,
3630,
4181,
14074,
1006,
14931,
2595,
6123,
1012,
6123,
1010,
13045,
18442,
4127,
1012,
13045,
18442,
1007,
1006,
6112,
21572,
17258,
2121,
1012,
4224,
1010,
7561,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go | Validate | func (mutatingWebhookConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ic := obj.(*admissionregistration.MutatingWebhookConfiguration)
return validation.ValidateMutatingWebhookConfiguration(ic)
} | go | func (mutatingWebhookConfigurationStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
ic := obj.(*admissionregistration.MutatingWebhookConfiguration)
return validation.ValidateMutatingWebhookConfiguration(ic)
} | [
"func",
"(",
"mutatingWebhookConfigurationStrategy",
")",
"Validate",
"(",
"ctx",
"context",
".",
"Context",
",",
"obj",
"runtime",
".",
"Object",
")",
"field",
".",
"ErrorList",
"{",
"ic",
":=",
"obj",
".",
"(",
"*",
"admissionregistration",
".",
"MutatingWeb... | // Validate validates a new mutatingWebhookConfiguration. | [
"Validate",
"validates",
"a",
"new",
"mutatingWebhookConfiguration",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/registry/admissionregistration/mutatingwebhookconfiguration/strategy.go#L65-L68 | train | Validate validates a new mutatingWebhookConfiguration. | [
30522,
4569,
2278,
1006,
14163,
29336,
2075,
8545,
23706,
14659,
8663,
8873,
27390,
10708,
6494,
2618,
6292,
1007,
9398,
3686,
1006,
14931,
2595,
6123,
1012,
6123,
1010,
27885,
3501,
2448,
7292,
1012,
4874,
1007,
2492,
1012,
7561,
9863,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/winstats/winstats.go | newClient | func newClient(statsNodeClient winNodeStatsClient) (Client, error) {
statsClient := new(StatsClient)
statsClient.client = statsNodeClient
err := statsClient.client.startMonitoring()
if err != nil {
return nil, err
}
return statsClient, nil
} | go | func newClient(statsNodeClient winNodeStatsClient) (Client, error) {
statsClient := new(StatsClient)
statsClient.client = statsNodeClient
err := statsClient.client.startMonitoring()
if err != nil {
return nil, err
}
return statsClient, nil
} | [
"func",
"newClient",
"(",
"statsNodeClient",
"winNodeStatsClient",
")",
"(",
"Client",
",",
"error",
")",
"{",
"statsClient",
":=",
"new",
"(",
"StatsClient",
")",
"\n",
"statsClient",
".",
"client",
"=",
"statsNodeClient",
"\n\n",
"err",
":=",
"statsClient",
... | // newClient constructs a Client. | [
"newClient",
"constructs",
"a",
"Client",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/winstats/winstats.go#L73-L83 | train | newClient returns a new StatsClient | [
30522,
4569,
2278,
2047,
20464,
11638,
1006,
26319,
3630,
3207,
20464,
11638,
2663,
3630,
6155,
29336,
11020,
8751,
3372,
1007,
1006,
7396,
1010,
7561,
1007,
1063,
26319,
20464,
11638,
1024,
1027,
2047,
1006,
26319,
20464,
11638,
1007,
26319,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/v1/zz_generated.conversion.go | Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint | func Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint(in *v1.DaemonEndpoint, out *core.DaemonEndpoint, s conversion.Scope) error {
return autoConvert_v1_DaemonEndpoint_To_core_DaemonEndpoint(in, out, s)
} | go | func Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint(in *v1.DaemonEndpoint, out *core.DaemonEndpoint, s conversion.Scope) error {
return autoConvert_v1_DaemonEndpoint_To_core_DaemonEndpoint(in, out, s)
} | [
"func",
"Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint",
"(",
"in",
"*",
"v1",
".",
"DaemonEndpoint",
",",
"out",
"*",
"core",
".",
"DaemonEndpoint",
",",
"s",
"conversion",
".",
"Scope",
")",
"error",
"{",
"return",
"autoConvert_v1_DaemonEndpoint_To_core_DaemonEndpo... | // Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint is an autogenerated conversion function. | [
"Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint",
"is",
"an",
"autogenerated",
"conversion",
"function",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/v1/zz_generated.conversion.go#L3036-L3038 | train | Convert_v1_DaemonEndpoint_To_core_DaemonEndpoint is an autogenerated conversion function. | [
30522,
4569,
2278,
10463,
1035,
1058,
2487,
1035,
12828,
10497,
8400,
1035,
2000,
1035,
4563,
1035,
12828,
10497,
8400,
1006,
1999,
1008,
1058,
2487,
1012,
12828,
10497,
8400,
1010,
2041,
1008,
4563,
1012,
12828,
10497,
8400,
1010,
1055,
75... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/rolling_updater.go | updatePodWithRetries | func updatePodWithRetries(podClient corev1client.PodsGetter, namespace string, pod *corev1.Pod, applyUpdate updatePodFunc) (*corev1.Pod, error) {
// Deep copy the pod in case we failed on Get during retry loop
oldPod := pod.DeepCopy()
err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) {
// Apply the update, then attempt to push it to the apiserver.
applyUpdate(pod)
if pod, e = podClient.Pods(namespace).Update(pod); e == nil {
return
}
updateErr := e
if pod, e = podClient.Pods(namespace).Get(oldPod.Name, metav1.GetOptions{}); e != nil {
pod = oldPod
}
// Only return the error from update
return updateErr
})
// If the error is non-nil the returned pod cannot be trusted, if it is nil, the returned
// controller contains the applied update.
return pod, err
} | go | func updatePodWithRetries(podClient corev1client.PodsGetter, namespace string, pod *corev1.Pod, applyUpdate updatePodFunc) (*corev1.Pod, error) {
// Deep copy the pod in case we failed on Get during retry loop
oldPod := pod.DeepCopy()
err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) {
// Apply the update, then attempt to push it to the apiserver.
applyUpdate(pod)
if pod, e = podClient.Pods(namespace).Update(pod); e == nil {
return
}
updateErr := e
if pod, e = podClient.Pods(namespace).Get(oldPod.Name, metav1.GetOptions{}); e != nil {
pod = oldPod
}
// Only return the error from update
return updateErr
})
// If the error is non-nil the returned pod cannot be trusted, if it is nil, the returned
// controller contains the applied update.
return pod, err
} | [
"func",
"updatePodWithRetries",
"(",
"podClient",
"corev1client",
".",
"PodsGetter",
",",
"namespace",
"string",
",",
"pod",
"*",
"corev1",
".",
"Pod",
",",
"applyUpdate",
"updatePodFunc",
")",
"(",
"*",
"corev1",
".",
"Pod",
",",
"error",
")",
"{",
"// Deep... | // updatePodWithRetries retries updating the given pod on conflict with the following steps:
// 1. Get latest resource
// 2. applyUpdate
// 3. Update the resource | [
"updatePodWithRetries",
"retries",
"updating",
"the",
"given",
"pod",
"on",
"conflict",
"with",
"the",
"following",
"steps",
":",
"1",
".",
"Get",
"latest",
"resource",
"2",
".",
"applyUpdate",
"3",
".",
"Update",
"the",
"resource"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/rolling_updater.go#L812-L831 | train | updatePodWithRetries updates a pod with retries. | [
30522,
4569,
2278,
10651,
27633,
24415,
13465,
5134,
1006,
17491,
20464,
11638,
4563,
2615,
2487,
20464,
11638,
1012,
26723,
18150,
3334,
1010,
3415,
15327,
5164,
1010,
17491,
1008,
4563,
2615,
2487,
1012,
17491,
1010,
6611,
6279,
13701,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/storage/v1/zz_generated.conversion.go | Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList | func Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList(in *v1.VolumeAttachmentList, out *storage.VolumeAttachmentList, s conversion.Scope) error {
return autoConvert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList(in, out, s)
} | go | func Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList(in *v1.VolumeAttachmentList, out *storage.VolumeAttachmentList, s conversion.Scope) error {
return autoConvert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList(in, out, s)
} | [
"func",
"Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList",
"(",
"in",
"*",
"v1",
".",
"VolumeAttachmentList",
",",
"out",
"*",
"storage",
".",
"VolumeAttachmentList",
",",
"s",
"conversion",
".",
"Scope",
")",
"error",
"{",
"return",
"autoConvert_v1_Volu... | // Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList is an autogenerated conversion function. | [
"Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList",
"is",
"an",
"autogenerated",
"conversion",
"function",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/storage/v1/zz_generated.conversion.go#L219-L221 | train | Convert_v1_VolumeAttachmentList_To_storage_VolumeAttachmentList is an autogenerated conversion function. | [
30522,
4569,
2278,
10463,
1035,
1058,
2487,
1035,
3872,
19321,
6776,
3672,
9863,
1035,
2000,
1035,
5527,
1035,
3872,
19321,
6776,
3672,
9863,
1006,
1999,
1008,
1058,
2487,
1012,
3872,
19321,
6776,
3672,
9863,
1010,
2041,
1008,
5527,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/discovery/fake/discovery.go | ServerResourcesForGroupVersion | func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
action := testing.ActionImpl{
Verb: "get",
Resource: schema.GroupVersionResource{Resource: "resource"},
}
c.Invokes(action, nil)
for _, resourceList := range c.Resources {
if resourceList.GroupVersion == groupVersion {
return resourceList, nil
}
}
return nil, fmt.Errorf("GroupVersion %q not found", groupVersion)
} | go | func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
action := testing.ActionImpl{
Verb: "get",
Resource: schema.GroupVersionResource{Resource: "resource"},
}
c.Invokes(action, nil)
for _, resourceList := range c.Resources {
if resourceList.GroupVersion == groupVersion {
return resourceList, nil
}
}
return nil, fmt.Errorf("GroupVersion %q not found", groupVersion)
} | [
"func",
"(",
"c",
"*",
"FakeDiscovery",
")",
"ServerResourcesForGroupVersion",
"(",
"groupVersion",
"string",
")",
"(",
"*",
"metav1",
".",
"APIResourceList",
",",
"error",
")",
"{",
"action",
":=",
"testing",
".",
"ActionImpl",
"{",
"Verb",
":",
"\"",
"\"",... | // ServerResourcesForGroupVersion returns the supported resources for a group
// and version. | [
"ServerResourcesForGroupVersion",
"returns",
"the",
"supported",
"resources",
"for",
"a",
"group",
"and",
"version",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/discovery/fake/discovery.go#L41-L53 | train | ServerResourcesForGroupVersion returns a list of APIResourceLists for the given groupVersion. | [
30522,
4569,
2278,
1006,
1039,
1008,
8275,
10521,
3597,
27900,
1007,
8241,
6072,
8162,
9623,
29278,
17058,
27774,
1006,
2177,
27774,
5164,
1007,
1006,
1008,
18804,
2615,
2487,
1012,
17928,
6072,
8162,
29109,
2923,
1010,
7561,
1007,
1063,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/daemon/daemon_controller.go | nodeShouldRunDaemonPod | func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (wantToRun, shouldSchedule, shouldContinueRunning bool, err error) {
newPod := NewPod(ds, node.Name)
// Because these bools require an && of all their required conditions, we start
// with all bools set to true and set a bool to false if a condition is not met.
// A bool should probably not be set to true after this line.
wantToRun, shouldSchedule, shouldContinueRunning = true, true, true
// If the daemon set specifies a node name, check that it matches with node.Name.
if !(ds.Spec.Template.Spec.NodeName == "" || ds.Spec.Template.Spec.NodeName == node.Name) {
return false, false, false, nil
}
reasons, nodeInfo, err := dsc.simulate(newPod, node, ds)
if err != nil {
klog.Warningf("DaemonSet Predicates failed on node %s for ds '%s/%s' due to unexpected error: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, err)
return false, false, false, err
}
// TODO(k82cn): When 'ScheduleDaemonSetPods' upgrade to beta or GA, remove unnecessary check on failure reason,
// e.g. InsufficientResourceError; and simplify "wantToRun, shouldSchedule, shouldContinueRunning"
// into one result, e.g. selectedNode.
var insufficientResourceErr error
for _, r := range reasons {
klog.V(4).Infof("DaemonSet Predicates failed on node %s for ds '%s/%s' for reason: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, r.GetReason())
switch reason := r.(type) {
case *predicates.InsufficientResourceError:
insufficientResourceErr = reason
case *predicates.PredicateFailureError:
var emitEvent bool
// we try to partition predicates into two partitions here: intentional on the part of the operator and not.
switch reason {
// intentional
case
predicates.ErrNodeSelectorNotMatch,
predicates.ErrPodNotMatchHostName,
predicates.ErrNodeLabelPresenceViolated,
// this one is probably intentional since it's a workaround for not having
// pod hard anti affinity.
predicates.ErrPodNotFitsHostPorts:
return false, false, false, nil
case predicates.ErrTaintsTolerationsNotMatch:
// DaemonSet is expected to respect taints and tolerations
fitsNoExecute, _, err := predicates.PodToleratesNodeNoExecuteTaints(newPod, nil, nodeInfo)
if err != nil {
return false, false, false, err
}
if !fitsNoExecute {
return false, false, false, nil
}
wantToRun, shouldSchedule = false, false
// unintentional
case
predicates.ErrDiskConflict,
predicates.ErrVolumeZoneConflict,
predicates.ErrMaxVolumeCountExceeded,
predicates.ErrNodeUnderMemoryPressure,
predicates.ErrNodeUnderDiskPressure:
// wantToRun and shouldContinueRunning are likely true here. They are
// absolutely true at the time of writing the comment. See first comment
// of this method.
shouldSchedule = false
emitEvent = true
// unexpected
case
predicates.ErrPodAffinityNotMatch,
predicates.ErrServiceAffinityViolated:
klog.Warningf("unexpected predicate failure reason: %s", reason.GetReason())
return false, false, false, fmt.Errorf("unexpected reason: DaemonSet Predicates should not return reason %s", reason.GetReason())
default:
klog.V(4).Infof("unknown predicate failure reason: %s", reason.GetReason())
wantToRun, shouldSchedule, shouldContinueRunning = false, false, false
emitEvent = true
}
if emitEvent {
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, reason.GetReason())
}
}
}
// only emit this event if insufficient resource is the only thing
// preventing the daemon pod from scheduling
if shouldSchedule && insufficientResourceErr != nil {
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, insufficientResourceErr.Error())
shouldSchedule = false
}
return
} | go | func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (wantToRun, shouldSchedule, shouldContinueRunning bool, err error) {
newPod := NewPod(ds, node.Name)
// Because these bools require an && of all their required conditions, we start
// with all bools set to true and set a bool to false if a condition is not met.
// A bool should probably not be set to true after this line.
wantToRun, shouldSchedule, shouldContinueRunning = true, true, true
// If the daemon set specifies a node name, check that it matches with node.Name.
if !(ds.Spec.Template.Spec.NodeName == "" || ds.Spec.Template.Spec.NodeName == node.Name) {
return false, false, false, nil
}
reasons, nodeInfo, err := dsc.simulate(newPod, node, ds)
if err != nil {
klog.Warningf("DaemonSet Predicates failed on node %s for ds '%s/%s' due to unexpected error: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, err)
return false, false, false, err
}
// TODO(k82cn): When 'ScheduleDaemonSetPods' upgrade to beta or GA, remove unnecessary check on failure reason,
// e.g. InsufficientResourceError; and simplify "wantToRun, shouldSchedule, shouldContinueRunning"
// into one result, e.g. selectedNode.
var insufficientResourceErr error
for _, r := range reasons {
klog.V(4).Infof("DaemonSet Predicates failed on node %s for ds '%s/%s' for reason: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, r.GetReason())
switch reason := r.(type) {
case *predicates.InsufficientResourceError:
insufficientResourceErr = reason
case *predicates.PredicateFailureError:
var emitEvent bool
// we try to partition predicates into two partitions here: intentional on the part of the operator and not.
switch reason {
// intentional
case
predicates.ErrNodeSelectorNotMatch,
predicates.ErrPodNotMatchHostName,
predicates.ErrNodeLabelPresenceViolated,
// this one is probably intentional since it's a workaround for not having
// pod hard anti affinity.
predicates.ErrPodNotFitsHostPorts:
return false, false, false, nil
case predicates.ErrTaintsTolerationsNotMatch:
// DaemonSet is expected to respect taints and tolerations
fitsNoExecute, _, err := predicates.PodToleratesNodeNoExecuteTaints(newPod, nil, nodeInfo)
if err != nil {
return false, false, false, err
}
if !fitsNoExecute {
return false, false, false, nil
}
wantToRun, shouldSchedule = false, false
// unintentional
case
predicates.ErrDiskConflict,
predicates.ErrVolumeZoneConflict,
predicates.ErrMaxVolumeCountExceeded,
predicates.ErrNodeUnderMemoryPressure,
predicates.ErrNodeUnderDiskPressure:
// wantToRun and shouldContinueRunning are likely true here. They are
// absolutely true at the time of writing the comment. See first comment
// of this method.
shouldSchedule = false
emitEvent = true
// unexpected
case
predicates.ErrPodAffinityNotMatch,
predicates.ErrServiceAffinityViolated:
klog.Warningf("unexpected predicate failure reason: %s", reason.GetReason())
return false, false, false, fmt.Errorf("unexpected reason: DaemonSet Predicates should not return reason %s", reason.GetReason())
default:
klog.V(4).Infof("unknown predicate failure reason: %s", reason.GetReason())
wantToRun, shouldSchedule, shouldContinueRunning = false, false, false
emitEvent = true
}
if emitEvent {
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, reason.GetReason())
}
}
}
// only emit this event if insufficient resource is the only thing
// preventing the daemon pod from scheduling
if shouldSchedule && insufficientResourceErr != nil {
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, insufficientResourceErr.Error())
shouldSchedule = false
}
return
} | [
"func",
"(",
"dsc",
"*",
"DaemonSetsController",
")",
"nodeShouldRunDaemonPod",
"(",
"node",
"*",
"v1",
".",
"Node",
",",
"ds",
"*",
"apps",
".",
"DaemonSet",
")",
"(",
"wantToRun",
",",
"shouldSchedule",
",",
"shouldContinueRunning",
"bool",
",",
"err",
"er... | // nodeShouldRunDaemonPod checks a set of preconditions against a (node,daemonset) and returns a
// summary. Returned booleans are:
// * wantToRun:
// Returns true when a user would expect a pod to run on this node and ignores conditions
// such as DiskPressure or insufficient resource that would cause a daemonset pod not to schedule.
// This is primarily used to populate daemonset status.
// * shouldSchedule:
// Returns true when a daemonset should be scheduled to a node if a daemonset pod is not already
// running on that node.
// * shouldContinueRunning:
// Returns true when a daemonset should continue running on a node if a daemonset pod is already
// running on that node. | [
"nodeShouldRunDaemonPod",
"checks",
"a",
"set",
"of",
"preconditions",
"against",
"a",
"(",
"node",
"daemonset",
")",
"and",
"returns",
"a",
"summary",
".",
"Returned",
"booleans",
"are",
":",
"*",
"wantToRun",
":",
"Returns",
"true",
"when",
"a",
"user",
"w... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/daemon/daemon_controller.go#L1329-L1414 | train | nodeShouldRunDaemonPod checks if the node should run a daemon set pod. | [
30522,
4569,
2278,
1006,
16233,
2278,
1008,
12828,
13462,
9363,
3372,
26611,
1007,
14164,
6806,
21285,
15532,
6858,
8202,
27633,
1006,
13045,
1008,
1058,
2487,
1012,
13045,
1010,
16233,
1008,
18726,
1012,
12828,
13462,
1007,
1006,
2215,
4263,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/cmd/set/set_subject.go | Run | func (o *SubjectOptions) Run(fn updateSubjects) error {
patches := CalculatePatches(o.Infos, scheme.DefaultJSONEncoder(), func(obj runtime.Object) ([]byte, error) {
subjects := []rbacv1.Subject{}
for _, user := range sets.NewString(o.Users...).List() {
subject := rbacv1.Subject{
Kind: rbacv1.UserKind,
APIGroup: rbacv1.GroupName,
Name: user,
}
subjects = append(subjects, subject)
}
for _, group := range sets.NewString(o.Groups...).List() {
subject := rbacv1.Subject{
Kind: rbacv1.GroupKind,
APIGroup: rbacv1.GroupName,
Name: group,
}
subjects = append(subjects, subject)
}
for _, sa := range sets.NewString(o.ServiceAccounts...).List() {
tokens := strings.Split(sa, ":")
namespace := tokens[0]
name := tokens[1]
if len(namespace) == 0 {
namespace = o.namespace
}
subject := rbacv1.Subject{
Kind: rbacv1.ServiceAccountKind,
Namespace: namespace,
Name: name,
}
subjects = append(subjects, subject)
}
transformed, err := updateSubjectForObject(obj, subjects, fn)
if transformed && err == nil {
// TODO: switch UpdatePodSpecForObject to work on v1.PodSpec
return runtime.Encode(scheme.DefaultJSONEncoder(), obj)
}
return nil, err
})
allErrs := []error{}
for _, patch := range patches {
info := patch.Info
name := info.ObjectName()
if patch.Err != nil {
allErrs = append(allErrs, fmt.Errorf("error: %s %v\n", name, patch.Err))
continue
}
//no changes
if string(patch.Patch) == "{}" || len(patch.Patch) == 0 {
allErrs = append(allErrs, fmt.Errorf("info: %s was not changed\n", name))
continue
}
if o.Local || o.DryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
allErrs = append(allErrs, err)
}
continue
}
actual, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, types.StrategicMergePatchType, patch.Patch, nil)
if err != nil {
allErrs = append(allErrs, fmt.Errorf("failed to patch subjects to rolebinding: %v", err))
continue
}
if err := o.PrintObj(actual, o.Out); err != nil {
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)
} | go | func (o *SubjectOptions) Run(fn updateSubjects) error {
patches := CalculatePatches(o.Infos, scheme.DefaultJSONEncoder(), func(obj runtime.Object) ([]byte, error) {
subjects := []rbacv1.Subject{}
for _, user := range sets.NewString(o.Users...).List() {
subject := rbacv1.Subject{
Kind: rbacv1.UserKind,
APIGroup: rbacv1.GroupName,
Name: user,
}
subjects = append(subjects, subject)
}
for _, group := range sets.NewString(o.Groups...).List() {
subject := rbacv1.Subject{
Kind: rbacv1.GroupKind,
APIGroup: rbacv1.GroupName,
Name: group,
}
subjects = append(subjects, subject)
}
for _, sa := range sets.NewString(o.ServiceAccounts...).List() {
tokens := strings.Split(sa, ":")
namespace := tokens[0]
name := tokens[1]
if len(namespace) == 0 {
namespace = o.namespace
}
subject := rbacv1.Subject{
Kind: rbacv1.ServiceAccountKind,
Namespace: namespace,
Name: name,
}
subjects = append(subjects, subject)
}
transformed, err := updateSubjectForObject(obj, subjects, fn)
if transformed && err == nil {
// TODO: switch UpdatePodSpecForObject to work on v1.PodSpec
return runtime.Encode(scheme.DefaultJSONEncoder(), obj)
}
return nil, err
})
allErrs := []error{}
for _, patch := range patches {
info := patch.Info
name := info.ObjectName()
if patch.Err != nil {
allErrs = append(allErrs, fmt.Errorf("error: %s %v\n", name, patch.Err))
continue
}
//no changes
if string(patch.Patch) == "{}" || len(patch.Patch) == 0 {
allErrs = append(allErrs, fmt.Errorf("info: %s was not changed\n", name))
continue
}
if o.Local || o.DryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
allErrs = append(allErrs, err)
}
continue
}
actual, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, types.StrategicMergePatchType, patch.Patch, nil)
if err != nil {
allErrs = append(allErrs, fmt.Errorf("failed to patch subjects to rolebinding: %v", err))
continue
}
if err := o.PrintObj(actual, o.Out); err != nil {
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)
} | [
"func",
"(",
"o",
"*",
"SubjectOptions",
")",
"Run",
"(",
"fn",
"updateSubjects",
")",
"error",
"{",
"patches",
":=",
"CalculatePatches",
"(",
"o",
".",
"Infos",
",",
"scheme",
".",
"DefaultJSONEncoder",
"(",
")",
",",
"func",
"(",
"obj",
"runtime",
".",... | // Run performs the execution of "set subject" sub command | [
"Run",
"performs",
"the",
"execution",
"of",
"set",
"subject",
"sub",
"command"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/set/set_subject.go#L198-L273 | train | Run runs the updateSubjects function. | [
30522,
4569,
2278,
1006,
1051,
1008,
3395,
7361,
9285,
1007,
2448,
1006,
1042,
2078,
14409,
12083,
20614,
2015,
1007,
7561,
1063,
13864,
1024,
1027,
18422,
4502,
10649,
2229,
1006,
1051,
1012,
18558,
2015,
1010,
5679,
1012,
12398,
22578,
56... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | plugin/pkg/admission/resourcequota/controller.go | prettyPrint | func prettyPrint(item corev1.ResourceList) string {
parts := []string{}
keys := []string{}
for key := range item {
keys = append(keys, string(key))
}
sort.Strings(keys)
for _, key := range keys {
value := item[corev1.ResourceName(key)]
constraint := key + "=" + value.String()
parts = append(parts, constraint)
}
return strings.Join(parts, ",")
} | go | func prettyPrint(item corev1.ResourceList) string {
parts := []string{}
keys := []string{}
for key := range item {
keys = append(keys, string(key))
}
sort.Strings(keys)
for _, key := range keys {
value := item[corev1.ResourceName(key)]
constraint := key + "=" + value.String()
parts = append(parts, constraint)
}
return strings.Join(parts, ",")
} | [
"func",
"prettyPrint",
"(",
"item",
"corev1",
".",
"ResourceList",
")",
"string",
"{",
"parts",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"keys",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"key",
":=",
"range",
"item",
"{",
"keys",
"=",
"appe... | // prettyPrint formats a resource list for usage in errors
// it outputs resources sorted in increasing order | [
"prettyPrint",
"formats",
"a",
"resource",
"list",
"for",
"usage",
"in",
"errors",
"it",
"outputs",
"resources",
"sorted",
"in",
"increasing",
"order"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/plugin/pkg/admission/resourcequota/controller.go#L681-L694 | train | prettyPrint returns a string representation of a resource list | [
30522,
4569,
2278,
3492,
16550,
1006,
8875,
4563,
2615,
2487,
1012,
7692,
9863,
1007,
5164,
1063,
3033,
1024,
1027,
1031,
1033,
5164,
1063,
1065,
6309,
1024,
1027,
1031,
1033,
5164,
1063,
1065,
2005,
3145,
1024,
1027,
2846,
8875,
1063,
63... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/proxy/ipvs/proxier.go | CleanupLeftovers | func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
if cleanupIPVS {
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
if ipvs == nil {
return true
}
encounteredError = false
err := ipvs.Flush()
if err != nil {
klog.Errorf("Error flushing IPVS rules: %v", err)
encounteredError = true
}
}
// Delete dummy interface created by ipvs Proxier.
nl := NewNetLinkHandle(false)
err := nl.DeleteDummyDevice(DefaultDummyDevice)
if err != nil {
klog.Errorf("Error deleting dummy device %s created by IPVS proxier: %v", DefaultDummyDevice, err)
encounteredError = true
}
// Clear iptables created by ipvs Proxier.
encounteredError = cleanupIptablesLeftovers(ipt) || encounteredError
// Destroy ip sets created by ipvs Proxier. We should call it after cleaning up
// iptables since we can NOT delete ip set which is still referenced by iptables.
for _, set := range ipsetInfo {
err = ipset.DestroySet(set.name)
if err != nil {
if !utilipset.IsNotFoundError(err) {
klog.Errorf("Error removing ipset %s, error: %v", set.name, err)
encounteredError = true
}
}
}
return encounteredError
} | go | func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
if cleanupIPVS {
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
if ipvs == nil {
return true
}
encounteredError = false
err := ipvs.Flush()
if err != nil {
klog.Errorf("Error flushing IPVS rules: %v", err)
encounteredError = true
}
}
// Delete dummy interface created by ipvs Proxier.
nl := NewNetLinkHandle(false)
err := nl.DeleteDummyDevice(DefaultDummyDevice)
if err != nil {
klog.Errorf("Error deleting dummy device %s created by IPVS proxier: %v", DefaultDummyDevice, err)
encounteredError = true
}
// Clear iptables created by ipvs Proxier.
encounteredError = cleanupIptablesLeftovers(ipt) || encounteredError
// Destroy ip sets created by ipvs Proxier. We should call it after cleaning up
// iptables since we can NOT delete ip set which is still referenced by iptables.
for _, set := range ipsetInfo {
err = ipset.DestroySet(set.name)
if err != nil {
if !utilipset.IsNotFoundError(err) {
klog.Errorf("Error removing ipset %s, error: %v", set.name, err)
encounteredError = true
}
}
}
return encounteredError
} | [
"func",
"CleanupLeftovers",
"(",
"ipvs",
"utilipvs",
".",
"Interface",
",",
"ipt",
"utiliptables",
".",
"Interface",
",",
"ipset",
"utilipset",
".",
"Interface",
",",
"cleanupIPVS",
"bool",
")",
"(",
"encounteredError",
"bool",
")",
"{",
"if",
"cleanupIPVS",
"... | // CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier. | [
"CleanupLeftovers",
"clean",
"up",
"all",
"ipvs",
"and",
"iptables",
"rules",
"created",
"by",
"ipvs",
"Proxier",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/proxy/ipvs/proxier.go#L613-L647 | train | CleanupLeftovers cleans up the iptables and ipvs rules | [
30522,
4569,
2278,
27686,
2571,
6199,
24302,
1006,
12997,
15088,
21183,
18622,
2361,
15088,
1012,
8278,
1010,
12997,
2102,
21183,
18622,
22799,
13510,
1012,
8278,
1010,
12997,
13462,
21183,
18622,
29251,
2102,
1012,
8278,
1010,
27686,
11514,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/autoscaling/v1/zz_generated.conversion.go | Convert_autoscaling_MetricSpec_To_v1_MetricSpec | func Convert_autoscaling_MetricSpec_To_v1_MetricSpec(in *autoscaling.MetricSpec, out *v1.MetricSpec, s conversion.Scope) error {
return autoConvert_autoscaling_MetricSpec_To_v1_MetricSpec(in, out, s)
} | go | func Convert_autoscaling_MetricSpec_To_v1_MetricSpec(in *autoscaling.MetricSpec, out *v1.MetricSpec, s conversion.Scope) error {
return autoConvert_autoscaling_MetricSpec_To_v1_MetricSpec(in, out, s)
} | [
"func",
"Convert_autoscaling_MetricSpec_To_v1_MetricSpec",
"(",
"in",
"*",
"autoscaling",
".",
"MetricSpec",
",",
"out",
"*",
"v1",
".",
"MetricSpec",
",",
"s",
"conversion",
".",
"Scope",
")",
"error",
"{",
"return",
"autoConvert_autoscaling_MetricSpec_To_v1_MetricSpec... | // Convert_autoscaling_MetricSpec_To_v1_MetricSpec is an autogenerated conversion function. | [
"Convert_autoscaling_MetricSpec_To_v1_MetricSpec",
"is",
"an",
"autogenerated",
"conversion",
"function",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/autoscaling/v1/zz_generated.conversion.go#L626-L628 | train | Convert_autoscaling_MetricSpec_To_v1_MetricSpec is an autogenerated conversion function. | [
30522,
4569,
2278,
10463,
1035,
8285,
15782,
2989,
1035,
12046,
13102,
8586,
1035,
2000,
1035,
1058,
2487,
1035,
12046,
13102,
8586,
1006,
1999,
1008,
8285,
15782,
2989,
1012,
12046,
13102,
8586,
1010,
2041,
1008,
1058,
2487,
1012,
12046,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/controller/volume/pvprotection/pv_protection_controller.go | Run | func (c *Controller) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()
klog.Infof("Starting PV protection controller")
defer klog.Infof("Shutting down PV protection controller")
if !controller.WaitForCacheSync("PV protection", stopCh, c.pvListerSynced) {
return
}
for i := 0; i < workers; i++ {
go wait.Until(c.runWorker, time.Second, stopCh)
}
<-stopCh
} | go | func (c *Controller) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()
klog.Infof("Starting PV protection controller")
defer klog.Infof("Shutting down PV protection controller")
if !controller.WaitForCacheSync("PV protection", stopCh, c.pvListerSynced) {
return
}
for i := 0; i < workers; i++ {
go wait.Until(c.runWorker, time.Second, stopCh)
}
<-stopCh
} | [
"func",
"(",
"c",
"*",
"Controller",
")",
"Run",
"(",
"workers",
"int",
",",
"stopCh",
"<-",
"chan",
"struct",
"{",
"}",
")",
"{",
"defer",
"utilruntime",
".",
"HandleCrash",
"(",
")",
"\n",
"defer",
"c",
".",
"queue",
".",
"ShutDown",
"(",
")",
"\... | // Run runs the controller goroutines. | [
"Run",
"runs",
"the",
"controller",
"goroutines",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/controller/volume/pvprotection/pv_protection_controller.go#L78-L94 | train | Run starts a controller. | [
30522,
4569,
2278,
1006,
1039,
1008,
11486,
1007,
2448,
1006,
3667,
20014,
1010,
2644,
2818,
1026,
1011,
9212,
2358,
6820,
6593,
1063,
1065,
1007,
1063,
13366,
2121,
21183,
4014,
15532,
7292,
1012,
5047,
26775,
11823,
1006,
1007,
13366,
212... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubelet/apis/config/validation/validation_windows.go | validateKubeletOSConfiguration | func validateKubeletOSConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
message := "invalid configuration: %v (%v) %v is not supported on Windows"
allErrors := []error{}
if kc.CgroupsPerQOS {
allErrors = append(allErrors, fmt.Errorf(message, "CgroupsPerQOS", "--cgroups-per-qos", kc.CgroupsPerQOS))
}
if len(kc.EnforceNodeAllocatable) > 0 {
allErrors = append(allErrors, fmt.Errorf(message, "EnforceNodeAllocatable", "--enforce-node-allocatable", kc.EnforceNodeAllocatable))
}
return utilerrors.NewAggregate(allErrors)
} | go | func validateKubeletOSConfiguration(kc *kubeletconfig.KubeletConfiguration) error {
message := "invalid configuration: %v (%v) %v is not supported on Windows"
allErrors := []error{}
if kc.CgroupsPerQOS {
allErrors = append(allErrors, fmt.Errorf(message, "CgroupsPerQOS", "--cgroups-per-qos", kc.CgroupsPerQOS))
}
if len(kc.EnforceNodeAllocatable) > 0 {
allErrors = append(allErrors, fmt.Errorf(message, "EnforceNodeAllocatable", "--enforce-node-allocatable", kc.EnforceNodeAllocatable))
}
return utilerrors.NewAggregate(allErrors)
} | [
"func",
"validateKubeletOSConfiguration",
"(",
"kc",
"*",
"kubeletconfig",
".",
"KubeletConfiguration",
")",
"error",
"{",
"message",
":=",
"\"",
"\"",
"\n",
"allErrors",
":=",
"[",
"]",
"error",
"{",
"}",
"\n\n",
"if",
"kc",
".",
"CgroupsPerQOS",
"{",
"allE... | // validateKubeletOSConfiguration validates os specific kubelet configuration and returns an error if it is invalid. | [
"validateKubeletOSConfiguration",
"validates",
"os",
"specific",
"kubelet",
"configuration",
"and",
"returns",
"an",
"error",
"if",
"it",
"is",
"invalid",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubelet/apis/config/validation/validation_windows.go#L29-L42 | train | validateKubeletOSConfiguration validates the kubelet configuration | [
30522,
4569,
2278,
9398,
3686,
5283,
8671,
18903,
9363,
2078,
8873,
27390,
3370,
1006,
21117,
1008,
13970,
8671,
3388,
8663,
8873,
2290,
1012,
13970,
8671,
3388,
8663,
8873,
27390,
3370,
1007,
7561,
1063,
4471,
1024,
1027,
1000,
19528,
9563... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go | UpdateStatus | func (c *FakeReplicationControllers) UpdateStatus(replicationController *corev1.ReplicationController) (*corev1.ReplicationController, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(replicationcontrollersResource, "status", c.ns, replicationController), &corev1.ReplicationController{})
if obj == nil {
return nil, err
}
return obj.(*corev1.ReplicationController), err
} | go | func (c *FakeReplicationControllers) UpdateStatus(replicationController *corev1.ReplicationController) (*corev1.ReplicationController, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(replicationcontrollersResource, "status", c.ns, replicationController), &corev1.ReplicationController{})
if obj == nil {
return nil, err
}
return obj.(*corev1.ReplicationController), err
} | [
"func",
"(",
"c",
"*",
"FakeReplicationControllers",
")",
"UpdateStatus",
"(",
"replicationController",
"*",
"corev1",
".",
"ReplicationController",
")",
"(",
"*",
"corev1",
".",
"ReplicationController",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".... | // UpdateStatus was generated because the type contains a Status member.
// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). | [
"UpdateStatus",
"was",
"generated",
"because",
"the",
"type",
"contains",
"a",
"Status",
"member",
".",
"Add",
"a",
"+",
"genclient",
":",
"noStatus",
"comment",
"above",
"the",
"type",
"to",
"avoid",
"generating",
"UpdateStatus",
"()",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/fake/fake_replicationcontroller.go#L106-L114 | train | UpdateStatus takes the representation of a replicationController and updates it. Returns the server s representation of the replicationController and an error if one occurs. | [
30522,
4569,
2278,
1006,
1039,
1008,
8275,
2890,
21557,
8663,
13181,
10820,
2015,
1007,
14409,
29336,
2271,
1006,
21647,
8663,
13181,
10820,
1008,
4563,
2615,
2487,
1012,
21647,
8663,
13181,
10820,
1007,
1006,
1008,
4563,
2615,
2487,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/apis/core/validation/validation.go | ValidateConfigMapUpdate | func ValidateConfigMapUpdate(newCfg, oldCfg *core.ConfigMap) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))...)
allErrs = append(allErrs, ValidateConfigMap(newCfg)...)
return allErrs
} | go | func ValidateConfigMapUpdate(newCfg, oldCfg *core.ConfigMap) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))...)
allErrs = append(allErrs, ValidateConfigMap(newCfg)...)
return allErrs
} | [
"func",
"ValidateConfigMapUpdate",
"(",
"newCfg",
",",
"oldCfg",
"*",
"core",
".",
"ConfigMap",
")",
"field",
".",
"ErrorList",
"{",
"allErrs",
":=",
"field",
".",
"ErrorList",
"{",
"}",
"\n",
"allErrs",
"=",
"append",
"(",
"allErrs",
",",
"ValidateObjectMet... | // ValidateConfigMapUpdate tests if required fields in the ConfigMap are set. | [
"ValidateConfigMapUpdate",
"tests",
"if",
"required",
"fields",
"in",
"the",
"ConfigMap",
"are",
"set",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/core/validation/validation.go#L4692-L4698 | train | ValidateConfigMapUpdate tests that the newCfg and oldCfg are valid. | [
30522,
4569,
2278,
9398,
3686,
8663,
8873,
21693,
9331,
6279,
13701,
1006,
2047,
2278,
2546,
2290,
1010,
2214,
2278,
2546,
2290,
1008,
4563,
1012,
9530,
8873,
21693,
9331,
1007,
2492,
1012,
7561,
9863,
1063,
2035,
2121,
2869,
1024,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/datacenter.go | GetAllHosts | func (dc *Datacenter) GetAllHosts(ctx context.Context) ([]types.ManagedObjectReference, error) {
finder := getFinder(dc)
hostSystems, err := finder.HostSystemList(ctx, "*")
if err != nil {
klog.Errorf("Failed to get all hostSystems. err: %+v", err)
return nil, err
}
var hostMors []types.ManagedObjectReference
for _, hs := range hostSystems {
hostMors = append(hostMors, hs.Reference())
}
return hostMors, nil
} | go | func (dc *Datacenter) GetAllHosts(ctx context.Context) ([]types.ManagedObjectReference, error) {
finder := getFinder(dc)
hostSystems, err := finder.HostSystemList(ctx, "*")
if err != nil {
klog.Errorf("Failed to get all hostSystems. err: %+v", err)
return nil, err
}
var hostMors []types.ManagedObjectReference
for _, hs := range hostSystems {
hostMors = append(hostMors, hs.Reference())
}
return hostMors, nil
} | [
"func",
"(",
"dc",
"*",
"Datacenter",
")",
"GetAllHosts",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"types",
".",
"ManagedObjectReference",
",",
"error",
")",
"{",
"finder",
":=",
"getFinder",
"(",
"dc",
")",
"\n",
"hostSystems",
",",
... | // GetAllHosts returns all the host objects in this datacenter of VC | [
"GetAllHosts",
"returns",
"all",
"the",
"host",
"objects",
"in",
"this",
"datacenter",
"of",
"VC"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/datacenter.go#L152-L164 | train | GetAllHosts returns all host systems in the datacenter | [
30522,
4569,
2278,
1006,
5887,
1008,
2951,
13013,
2121,
1007,
2131,
8095,
15006,
3215,
1006,
14931,
2595,
6123,
1012,
6123,
1007,
1006,
1031,
1033,
4127,
1012,
3266,
16429,
20614,
2890,
25523,
1010,
7561,
1007,
1063,
2424,
2121,
1024,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/registry/core/service/portallocator/allocator.go | Has | func (r *PortAllocator) Has(port int) bool {
ok, offset := r.contains(port)
if !ok {
return false
}
return r.alloc.Has(offset)
} | go | func (r *PortAllocator) Has(port int) bool {
ok, offset := r.contains(port)
if !ok {
return false
}
return r.alloc.Has(offset)
} | [
"func",
"(",
"r",
"*",
"PortAllocator",
")",
"Has",
"(",
"port",
"int",
")",
"bool",
"{",
"ok",
",",
"offset",
":=",
"r",
".",
"contains",
"(",
"port",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"r",
".",
"... | // Has returns true if the provided port is already allocated and a call
// to Allocate(port) would fail with ErrAllocated. | [
"Has",
"returns",
"true",
"if",
"the",
"provided",
"port",
"is",
"already",
"allocated",
"and",
"a",
"call",
"to",
"Allocate",
"(",
"port",
")",
"would",
"fail",
"with",
"ErrAllocated",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/registry/core/service/portallocator/allocator.go#L164-L171 | train | Has returns true if the port is in the allocation. | [
30522,
4569,
2278,
1006,
1054,
1008,
9445,
4135,
11266,
2953,
1007,
2038,
1006,
3417,
20014,
1007,
22017,
2140,
1063,
7929,
1010,
16396,
1024,
1027,
1054,
1012,
3397,
1006,
3417,
1007,
2065,
999,
7929,
1063,
2709,
6270,
1065,
2709,
1054,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go | NewCRDRESTOptionsGetter | func NewCRDRESTOptionsGetter(etcdOptions genericoptions.EtcdOptions) genericregistry.RESTOptionsGetter {
ret := apiserver.CRDRESTOptionsGetter{
StorageConfig: etcdOptions.StorageConfig,
StoragePrefix: etcdOptions.StorageConfig.Prefix,
EnableWatchCache: etcdOptions.EnableWatchCache,
DefaultWatchCacheSize: etcdOptions.DefaultWatchCacheSize,
EnableGarbageCollection: etcdOptions.EnableGarbageCollection,
DeleteCollectionWorkers: etcdOptions.DeleteCollectionWorkers,
CountMetricPollPeriod: etcdOptions.StorageConfig.CountMetricPollPeriod,
}
ret.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
return ret
} | go | func NewCRDRESTOptionsGetter(etcdOptions genericoptions.EtcdOptions) genericregistry.RESTOptionsGetter {
ret := apiserver.CRDRESTOptionsGetter{
StorageConfig: etcdOptions.StorageConfig,
StoragePrefix: etcdOptions.StorageConfig.Prefix,
EnableWatchCache: etcdOptions.EnableWatchCache,
DefaultWatchCacheSize: etcdOptions.DefaultWatchCacheSize,
EnableGarbageCollection: etcdOptions.EnableGarbageCollection,
DeleteCollectionWorkers: etcdOptions.DeleteCollectionWorkers,
CountMetricPollPeriod: etcdOptions.StorageConfig.CountMetricPollPeriod,
}
ret.StorageConfig.Codec = unstructured.UnstructuredJSONScheme
return ret
} | [
"func",
"NewCRDRESTOptionsGetter",
"(",
"etcdOptions",
"genericoptions",
".",
"EtcdOptions",
")",
"genericregistry",
".",
"RESTOptionsGetter",
"{",
"ret",
":=",
"apiserver",
".",
"CRDRESTOptionsGetter",
"{",
"StorageConfig",
":",
"etcdOptions",
".",
"StorageConfig",
","... | // NewCRDRESTOptionsGetter create a RESTOptionsGetter for CustomResources. | [
"NewCRDRESTOptionsGetter",
"create",
"a",
"RESTOptionsGetter",
"for",
"CustomResources",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiextensions-apiserver/pkg/cmd/server/options/options.go#L113-L126 | train | NewCRDRESTOptionsGetter creates a new RESTOptionsGetter | [
30522,
4569,
2278,
2047,
26775,
16200,
16033,
16790,
28745,
7585,
2099,
1006,
4385,
3527,
16790,
2015,
12391,
7361,
9285,
1012,
4385,
3527,
16790,
2015,
1007,
12391,
2890,
24063,
2854,
1012,
2717,
7361,
9285,
18150,
3334,
1063,
2128,
2102,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go | ConvertJSONSchemaPropsWithPostProcess | func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, out *spec.Schema, postProcess PostProcessFunc) error {
if in == nil {
return nil
}
out.ID = in.ID
out.Schema = spec.SchemaURL(in.Schema)
out.Description = in.Description
if in.Type != "" {
out.Type = spec.StringOrArray([]string{in.Type})
if in.Nullable {
out.Type = append(out.Type, "null")
}
}
out.Format = in.Format
out.Title = in.Title
out.Maximum = in.Maximum
out.ExclusiveMaximum = in.ExclusiveMaximum
out.Minimum = in.Minimum
out.ExclusiveMinimum = in.ExclusiveMinimum
out.MaxLength = in.MaxLength
out.MinLength = in.MinLength
out.Pattern = in.Pattern
out.MaxItems = in.MaxItems
out.MinItems = in.MinItems
out.UniqueItems = in.UniqueItems
out.MultipleOf = in.MultipleOf
out.MaxProperties = in.MaxProperties
out.MinProperties = in.MinProperties
out.Required = in.Required
if in.Default != nil {
out.Default = *(in.Default)
}
if in.Example != nil {
out.Example = *(in.Example)
}
if in.Enum != nil {
out.Enum = make([]interface{}, len(in.Enum))
for k, v := range in.Enum {
out.Enum[k] = v
}
}
if err := convertSliceOfJSONSchemaProps(&in.AllOf, &out.AllOf, postProcess); err != nil {
return err
}
if err := convertSliceOfJSONSchemaProps(&in.OneOf, &out.OneOf, postProcess); err != nil {
return err
}
if err := convertSliceOfJSONSchemaProps(&in.AnyOf, &out.AnyOf, postProcess); err != nil {
return err
}
if in.Not != nil {
in, out := &in.Not, &out.Not
*out = new(spec.Schema)
if err := ConvertJSONSchemaPropsWithPostProcess(*in, *out, postProcess); err != nil {
return err
}
}
var err error
out.Properties, err = convertMapOfJSONSchemaProps(in.Properties, postProcess)
if err != nil {
return err
}
out.PatternProperties, err = convertMapOfJSONSchemaProps(in.PatternProperties, postProcess)
if err != nil {
return err
}
out.Definitions, err = convertMapOfJSONSchemaProps(in.Definitions, postProcess)
if err != nil {
return err
}
if in.Ref != nil {
out.Ref, err = spec.NewRef(*in.Ref)
if err != nil {
return err
}
}
if in.AdditionalProperties != nil {
in, out := &in.AdditionalProperties, &out.AdditionalProperties
*out = new(spec.SchemaOrBool)
if err := convertJSONSchemaPropsorBool(*in, *out, postProcess); err != nil {
return err
}
}
if in.AdditionalItems != nil {
in, out := &in.AdditionalItems, &out.AdditionalItems
*out = new(spec.SchemaOrBool)
if err := convertJSONSchemaPropsorBool(*in, *out, postProcess); err != nil {
return err
}
}
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = new(spec.SchemaOrArray)
if err := convertJSONSchemaPropsOrArray(*in, *out, postProcess); err != nil {
return err
}
}
if in.Dependencies != nil {
in, out := &in.Dependencies, &out.Dependencies
*out = make(spec.Dependencies, len(*in))
for key, val := range *in {
newVal := new(spec.SchemaOrStringArray)
if err := convertJSONSchemaPropsOrStringArray(&val, newVal, postProcess); err != nil {
return err
}
(*out)[key] = *newVal
}
}
if in.ExternalDocs != nil {
out.ExternalDocs = &spec.ExternalDocumentation{}
out.ExternalDocs.Description = in.ExternalDocs.Description
out.ExternalDocs.URL = in.ExternalDocs.URL
}
if postProcess != nil {
if err := postProcess(out); err != nil {
return err
}
}
return nil
} | go | func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, out *spec.Schema, postProcess PostProcessFunc) error {
if in == nil {
return nil
}
out.ID = in.ID
out.Schema = spec.SchemaURL(in.Schema)
out.Description = in.Description
if in.Type != "" {
out.Type = spec.StringOrArray([]string{in.Type})
if in.Nullable {
out.Type = append(out.Type, "null")
}
}
out.Format = in.Format
out.Title = in.Title
out.Maximum = in.Maximum
out.ExclusiveMaximum = in.ExclusiveMaximum
out.Minimum = in.Minimum
out.ExclusiveMinimum = in.ExclusiveMinimum
out.MaxLength = in.MaxLength
out.MinLength = in.MinLength
out.Pattern = in.Pattern
out.MaxItems = in.MaxItems
out.MinItems = in.MinItems
out.UniqueItems = in.UniqueItems
out.MultipleOf = in.MultipleOf
out.MaxProperties = in.MaxProperties
out.MinProperties = in.MinProperties
out.Required = in.Required
if in.Default != nil {
out.Default = *(in.Default)
}
if in.Example != nil {
out.Example = *(in.Example)
}
if in.Enum != nil {
out.Enum = make([]interface{}, len(in.Enum))
for k, v := range in.Enum {
out.Enum[k] = v
}
}
if err := convertSliceOfJSONSchemaProps(&in.AllOf, &out.AllOf, postProcess); err != nil {
return err
}
if err := convertSliceOfJSONSchemaProps(&in.OneOf, &out.OneOf, postProcess); err != nil {
return err
}
if err := convertSliceOfJSONSchemaProps(&in.AnyOf, &out.AnyOf, postProcess); err != nil {
return err
}
if in.Not != nil {
in, out := &in.Not, &out.Not
*out = new(spec.Schema)
if err := ConvertJSONSchemaPropsWithPostProcess(*in, *out, postProcess); err != nil {
return err
}
}
var err error
out.Properties, err = convertMapOfJSONSchemaProps(in.Properties, postProcess)
if err != nil {
return err
}
out.PatternProperties, err = convertMapOfJSONSchemaProps(in.PatternProperties, postProcess)
if err != nil {
return err
}
out.Definitions, err = convertMapOfJSONSchemaProps(in.Definitions, postProcess)
if err != nil {
return err
}
if in.Ref != nil {
out.Ref, err = spec.NewRef(*in.Ref)
if err != nil {
return err
}
}
if in.AdditionalProperties != nil {
in, out := &in.AdditionalProperties, &out.AdditionalProperties
*out = new(spec.SchemaOrBool)
if err := convertJSONSchemaPropsorBool(*in, *out, postProcess); err != nil {
return err
}
}
if in.AdditionalItems != nil {
in, out := &in.AdditionalItems, &out.AdditionalItems
*out = new(spec.SchemaOrBool)
if err := convertJSONSchemaPropsorBool(*in, *out, postProcess); err != nil {
return err
}
}
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = new(spec.SchemaOrArray)
if err := convertJSONSchemaPropsOrArray(*in, *out, postProcess); err != nil {
return err
}
}
if in.Dependencies != nil {
in, out := &in.Dependencies, &out.Dependencies
*out = make(spec.Dependencies, len(*in))
for key, val := range *in {
newVal := new(spec.SchemaOrStringArray)
if err := convertJSONSchemaPropsOrStringArray(&val, newVal, postProcess); err != nil {
return err
}
(*out)[key] = *newVal
}
}
if in.ExternalDocs != nil {
out.ExternalDocs = &spec.ExternalDocumentation{}
out.ExternalDocs.Description = in.ExternalDocs.Description
out.ExternalDocs.URL = in.ExternalDocs.URL
}
if postProcess != nil {
if err := postProcess(out); err != nil {
return err
}
}
return nil
} | [
"func",
"ConvertJSONSchemaPropsWithPostProcess",
"(",
"in",
"*",
"apiextensions",
".",
"JSONSchemaProps",
",",
"out",
"*",
"spec",
".",
"Schema",
",",
"postProcess",
"PostProcessFunc",
")",
"error",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}"... | // ConvertJSONSchemaPropsWithPostProcess converts the schema from apiextensions.JSONSchemaPropos to go-openapi/spec.Schema
// and run a post process step on each JSONSchemaProps node. | [
"ConvertJSONSchemaPropsWithPostProcess",
"converts",
"the",
"schema",
"from",
"apiextensions",
".",
"JSONSchemaPropos",
"to",
"go",
"-",
"openapi",
"/",
"spec",
".",
"Schema",
"and",
"run",
"a",
"post",
"process",
"step",
"on",
"each",
"JSONSchemaProps",
"node",
"... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go#L63-L198 | train | ConvertJSONSchemaPropsWithPostProcess converts a apiextensions. JSONSchemaProps to a spec. Schema. | [
30522,
4569,
2278,
10463,
22578,
5644,
5403,
2863,
21572,
4523,
24415,
19894,
21572,
9623,
2015,
1006,
1999,
1008,
17928,
10288,
29048,
2015,
1012,
1046,
23345,
5403,
2863,
21572,
4523,
1010,
2041,
1008,
28699,
1012,
8040,
28433,
1010,
2695,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/cloudprovider/providers/gce/gce_cert.go | GetSslCertificate | func (g *Cloud) GetSslCertificate(name string) (*compute.SslCertificate, error) {
ctx, cancel := cloud.ContextWithCallTimeout()
defer cancel()
mc := newCertMetricContext("get")
v, err := g.c.SslCertificates().Get(ctx, meta.GlobalKey(name))
return v, mc.Observe(err)
} | go | func (g *Cloud) GetSslCertificate(name string) (*compute.SslCertificate, error) {
ctx, cancel := cloud.ContextWithCallTimeout()
defer cancel()
mc := newCertMetricContext("get")
v, err := g.c.SslCertificates().Get(ctx, meta.GlobalKey(name))
return v, mc.Observe(err)
} | [
"func",
"(",
"g",
"*",
"Cloud",
")",
"GetSslCertificate",
"(",
"name",
"string",
")",
"(",
"*",
"compute",
".",
"SslCertificate",
",",
"error",
")",
"{",
"ctx",
",",
"cancel",
":=",
"cloud",
".",
"ContextWithCallTimeout",
"(",
")",
"\n",
"defer",
"cancel... | // GetSslCertificate returns the SslCertificate by name. | [
"GetSslCertificate",
"returns",
"the",
"SslCertificate",
"by",
"name",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_cert.go#L32-L39 | train | GetSslCertificate returns the SSL certificate with the given name. | [
30522,
4569,
2278,
1006,
1043,
1008,
6112,
1007,
4152,
14540,
17119,
3775,
8873,
16280,
1006,
2171,
5164,
1007,
1006,
1008,
24134,
1012,
7020,
23314,
28228,
8873,
16280,
1010,
7561,
1007,
1063,
14931,
2595,
1010,
17542,
1024,
1027,
6112,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/kubectl/cmd/autoscale/autoscale.go | Run | func (o *AutoscaleOptions) Run() error {
r := o.builder.
Unstructured().
ContinueOnError().
NamespaceParam(o.namespace).DefaultNamespace().
FilenameParam(o.enforceNamespace, o.FilenameOptions).
ResourceTypeOrNameArgs(false, o.args...).
Flatten().
Do()
if err := r.Err(); err != nil {
return err
}
count := 0
err := r.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
mapping := info.ResourceMapping()
gvr := mapping.GroupVersionKind.GroupVersion().WithResource(mapping.Resource.Resource)
if _, err := o.scaleKindResolver.ScaleForResource(gvr); err != nil {
return fmt.Errorf("cannot autoscale a %v: %v", mapping.GroupVersionKind.Kind, err)
}
generator, err := o.generatorFunc(info.Name, mapping)
if err != nil {
return err
}
// Generate new object
object, err := generator.StructuredGenerate()
if err != nil {
return err
}
hpa, ok := object.(*autoscalingv1.HorizontalPodAutoscaler)
if !ok {
return fmt.Errorf("generator made %T, not autoscalingv1.HorizontalPodAutoscaler", object)
}
if err := o.Recorder.Record(hpa); err != nil {
klog.V(4).Infof("error recording current command: %v", err)
}
if o.dryRun {
count++
printer, err := o.ToPrinter("created")
if err != nil {
return err
}
return printer.PrintObj(hpa, o.Out)
}
if err := kubectl.CreateOrUpdateAnnotation(o.createAnnotation, hpa, scheme.DefaultJSONEncoder()); err != nil {
return err
}
actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(hpa)
if err != nil {
return err
}
count++
printer, err := o.ToPrinter("autoscaled")
if err != nil {
return err
}
return printer.PrintObj(actualHPA, o.Out)
})
if err != nil {
return err
}
if count == 0 {
return fmt.Errorf("no objects passed to autoscale")
}
return nil
} | go | func (o *AutoscaleOptions) Run() error {
r := o.builder.
Unstructured().
ContinueOnError().
NamespaceParam(o.namespace).DefaultNamespace().
FilenameParam(o.enforceNamespace, o.FilenameOptions).
ResourceTypeOrNameArgs(false, o.args...).
Flatten().
Do()
if err := r.Err(); err != nil {
return err
}
count := 0
err := r.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
mapping := info.ResourceMapping()
gvr := mapping.GroupVersionKind.GroupVersion().WithResource(mapping.Resource.Resource)
if _, err := o.scaleKindResolver.ScaleForResource(gvr); err != nil {
return fmt.Errorf("cannot autoscale a %v: %v", mapping.GroupVersionKind.Kind, err)
}
generator, err := o.generatorFunc(info.Name, mapping)
if err != nil {
return err
}
// Generate new object
object, err := generator.StructuredGenerate()
if err != nil {
return err
}
hpa, ok := object.(*autoscalingv1.HorizontalPodAutoscaler)
if !ok {
return fmt.Errorf("generator made %T, not autoscalingv1.HorizontalPodAutoscaler", object)
}
if err := o.Recorder.Record(hpa); err != nil {
klog.V(4).Infof("error recording current command: %v", err)
}
if o.dryRun {
count++
printer, err := o.ToPrinter("created")
if err != nil {
return err
}
return printer.PrintObj(hpa, o.Out)
}
if err := kubectl.CreateOrUpdateAnnotation(o.createAnnotation, hpa, scheme.DefaultJSONEncoder()); err != nil {
return err
}
actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(hpa)
if err != nil {
return err
}
count++
printer, err := o.ToPrinter("autoscaled")
if err != nil {
return err
}
return printer.PrintObj(actualHPA, o.Out)
})
if err != nil {
return err
}
if count == 0 {
return fmt.Errorf("no objects passed to autoscale")
}
return nil
} | [
"func",
"(",
"o",
"*",
"AutoscaleOptions",
")",
"Run",
"(",
")",
"error",
"{",
"r",
":=",
"o",
".",
"builder",
".",
"Unstructured",
"(",
")",
".",
"ContinueOnError",
"(",
")",
".",
"NamespaceParam",
"(",
"o",
".",
"namespace",
")",
".",
"DefaultNamespa... | // Run performs the execution | [
"Run",
"performs",
"the",
"execution"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/autoscale/autoscale.go#L207-L284 | train | Run runs the autoscale command. | [
30522,
4569,
2278,
1006,
1051,
1008,
8285,
15782,
2571,
7361,
9285,
1007,
2448,
1006,
1007,
7561,
1063,
1054,
1024,
1027,
1051,
1012,
12508,
1012,
4895,
3367,
26134,
1006,
1007,
1012,
3613,
5643,
18933,
2099,
1006,
1007,
1012,
3415,
15327,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go | DebugError | func (e *StatusError) DebugError() (string, []interface{}) {
if out, err := json.MarshalIndent(e.ErrStatus, "", " "); err == nil {
return "server response object: %s", []interface{}{string(out)}
}
return "server response object: %#v", []interface{}{e.ErrStatus}
} | go | func (e *StatusError) DebugError() (string, []interface{}) {
if out, err := json.MarshalIndent(e.ErrStatus, "", " "); err == nil {
return "server response object: %s", []interface{}{string(out)}
}
return "server response object: %#v", []interface{}{e.ErrStatus}
} | [
"func",
"(",
"e",
"*",
"StatusError",
")",
"DebugError",
"(",
")",
"(",
"string",
",",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"if",
"out",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"e",
".",
"ErrStatus",
",",
"\"",
"\"",
",",
"\"",... | // DebugError reports extended info about the error to debug output. | [
"DebugError",
"reports",
"extended",
"info",
"about",
"the",
"error",
"to",
"debug",
"output",
"."
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/api/errors/errors.go#L64-L69 | train | DebugError returns a string with the error message | [
30522,
4569,
2278,
1006,
1041,
1008,
3570,
2121,
29165,
1007,
2139,
8569,
4590,
29165,
1006,
1007,
1006,
5164,
1010,
1031,
1033,
8278,
1063,
1065,
1007,
1063,
2065,
2041,
1010,
9413,
2099,
1024,
1027,
1046,
3385,
1012,
8610,
22254,
4765,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | pkg/volume/awsebs/aws_util.go | getDiskByIDPaths | func getDiskByIDPaths(volumeID aws.KubernetesVolumeID, partition string, devicePath string) []string {
devicePaths := []string{}
if devicePath != "" {
devicePaths = append(devicePaths, devicePath)
}
if partition != "" {
for i, path := range devicePaths {
devicePaths[i] = path + diskPartitionSuffix + partition
}
}
// We need to find NVME volumes, which are mounted on a "random" nvme path ("/dev/nvme0n1"),
// and we have to get the volume id from the nvme interface
awsVolumeID, err := volumeID.MapToAWSVolumeID()
if err != nil {
klog.Warningf("error mapping volume %q to AWS volume: %v", volumeID, err)
} else {
// This is the magic name on which AWS presents NVME devices under /dev/disk/by-id/
// For example, vol-0fab1d5e3f72a5e23 creates a symlink at /dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_vol0fab1d5e3f72a5e23
nvmeName := "nvme-Amazon_Elastic_Block_Store_" + strings.Replace(string(awsVolumeID), "-", "", -1)
nvmePath, err := findNvmeVolume(nvmeName)
if err != nil {
klog.Warningf("error looking for nvme volume %q: %v", volumeID, err)
} else if nvmePath != "" {
devicePaths = append(devicePaths, nvmePath)
}
}
return devicePaths
} | go | func getDiskByIDPaths(volumeID aws.KubernetesVolumeID, partition string, devicePath string) []string {
devicePaths := []string{}
if devicePath != "" {
devicePaths = append(devicePaths, devicePath)
}
if partition != "" {
for i, path := range devicePaths {
devicePaths[i] = path + diskPartitionSuffix + partition
}
}
// We need to find NVME volumes, which are mounted on a "random" nvme path ("/dev/nvme0n1"),
// and we have to get the volume id from the nvme interface
awsVolumeID, err := volumeID.MapToAWSVolumeID()
if err != nil {
klog.Warningf("error mapping volume %q to AWS volume: %v", volumeID, err)
} else {
// This is the magic name on which AWS presents NVME devices under /dev/disk/by-id/
// For example, vol-0fab1d5e3f72a5e23 creates a symlink at /dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_vol0fab1d5e3f72a5e23
nvmeName := "nvme-Amazon_Elastic_Block_Store_" + strings.Replace(string(awsVolumeID), "-", "", -1)
nvmePath, err := findNvmeVolume(nvmeName)
if err != nil {
klog.Warningf("error looking for nvme volume %q: %v", volumeID, err)
} else if nvmePath != "" {
devicePaths = append(devicePaths, nvmePath)
}
}
return devicePaths
} | [
"func",
"getDiskByIDPaths",
"(",
"volumeID",
"aws",
".",
"KubernetesVolumeID",
",",
"partition",
"string",
",",
"devicePath",
"string",
")",
"[",
"]",
"string",
"{",
"devicePaths",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"if",
"devicePath",
"!=",
"\"",
"... | // Returns list of all paths for given EBS mount
// This is more interesting on GCE (where we are able to identify volumes under /dev/disk-by-id)
// Here it is mostly about applying the partition path | [
"Returns",
"list",
"of",
"all",
"paths",
"for",
"given",
"EBS",
"mount",
"This",
"is",
"more",
"interesting",
"on",
"GCE",
"(",
"where",
"we",
"are",
"able",
"to",
"identify",
"volumes",
"under",
"/",
"dev",
"/",
"disk",
"-",
"by",
"-",
"id",
")",
"H... | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/awsebs/aws_util.go#L201-L231 | train | getDiskByIDPaths returns a list of paths to the device with the specified volume ID and partition. | [
30522,
4569,
2278,
2131,
10521,
2243,
3762,
3593,
15069,
2015,
1006,
3872,
3593,
22091,
2015,
1012,
13970,
5677,
7159,
2229,
6767,
12942,
7416,
2094,
1010,
13571,
5164,
1010,
5080,
15069,
5164,
1007,
1031,
1033,
5164,
1063,
5080,
15069,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kubernetes/kubernetes | staging/src/k8s.io/client-go/kubernetes/fake/clientset_generated.go | AutoscalingV2beta2 | func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
return &fakeautoscalingv2beta2.FakeAutoscalingV2beta2{Fake: &c.Fake}
} | go | func (c *Clientset) AutoscalingV2beta2() autoscalingv2beta2.AutoscalingV2beta2Interface {
return &fakeautoscalingv2beta2.FakeAutoscalingV2beta2{Fake: &c.Fake}
} | [
"func",
"(",
"c",
"*",
"Clientset",
")",
"AutoscalingV2beta2",
"(",
")",
"autoscalingv2beta2",
".",
"AutoscalingV2beta2Interface",
"{",
"return",
"&",
"fakeautoscalingv2beta2",
".",
"FakeAutoscalingV2beta2",
"{",
"Fake",
":",
"&",
"c",
".",
"Fake",
"}",
"\n",
"}... | // AutoscalingV2beta2 retrieves the AutoscalingV2beta2Client | [
"AutoscalingV2beta2",
"retrieves",
"the",
"AutoscalingV2beta2Client"
] | 6a8a3682919652ae668c389ed2f60efb770eed03 | https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/kubernetes/fake/clientset_generated.go#L205-L207 | train | AutoscalingV2beta2 returns a list of all AutoscalingV2beta2Interface | [
30522,
4569,
2278,
1006,
1039,
1008,
7846,
3388,
1007,
8285,
15782,
2989,
2615,
2475,
20915,
2050,
2475,
1006,
1007,
8285,
15782,
2989,
2615,
2475,
20915,
2050,
2475,
1012,
8285,
15782,
2989,
2615,
2475,
20915,
2050,
2475,
18447,
2121,
1217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.