repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | CreatePV | func (u *FakeAPIUtil) CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) {
if u.shouldFail {
return nil, fmt.Errorf("API failed")
}
u.createdPVs[pv.Name] = pv
u.cache.AddPV(pv)
return pv, nil
} | go | func (u *FakeAPIUtil) CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) {
if u.shouldFail {
return nil, fmt.Errorf("API failed")
}
u.createdPVs[pv.Name] = pv
u.cache.AddPV(pv)
return pv, nil
} | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"CreatePV",
"(",
"pv",
"*",
"v1",
".",
"PersistentVolume",
")",
"(",
"*",
"v1",
".",
"PersistentVolume",
",",
"error",
")",
"{",
"if",
"u",
".",
"shouldFail",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",... | // CreatePV will add the PV to the created list and cache | [
"CreatePV",
"will",
"add",
"the",
"PV",
"to",
"the",
"created",
"list",
"and",
"cache"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L125-L133 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | DeletePV | func (u *FakeAPIUtil) DeletePV(pvName string) error {
if u.shouldFail {
return fmt.Errorf("API failed")
}
pv, exists := u.cache.GetPV(pvName)
if exists {
u.deletedPVs[pvName] = pv
delete(u.createdPVs, pvName)
u.cache.DeletePV(pvName)
return nil
}
return errors.NewNotFound(v1.Resource("persistentvolumes... | go | func (u *FakeAPIUtil) DeletePV(pvName string) error {
if u.shouldFail {
return fmt.Errorf("API failed")
}
pv, exists := u.cache.GetPV(pvName)
if exists {
u.deletedPVs[pvName] = pv
delete(u.createdPVs, pvName)
u.cache.DeletePV(pvName)
return nil
}
return errors.NewNotFound(v1.Resource("persistentvolumes... | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"DeletePV",
"(",
"pvName",
"string",
")",
"error",
"{",
"if",
"u",
".",
"shouldFail",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"pv",
",",
"exists",
":=",
"u",
".",
"c... | // DeletePV will delete the PV from the created list and cache, and also add it to the deleted list | [
"DeletePV",
"will",
"delete",
"the",
"PV",
"from",
"the",
"created",
"list",
"and",
"cache",
"and",
"also",
"add",
"it",
"to",
"the",
"deleted",
"list"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L136-L149 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | GetAndResetCreatedPVs | func (u *FakeAPIUtil) GetAndResetCreatedPVs() map[string]*v1.PersistentVolume {
createdPVs := u.createdPVs
u.createdPVs = map[string]*v1.PersistentVolume{}
return createdPVs
} | go | func (u *FakeAPIUtil) GetAndResetCreatedPVs() map[string]*v1.PersistentVolume {
createdPVs := u.createdPVs
u.createdPVs = map[string]*v1.PersistentVolume{}
return createdPVs
} | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"GetAndResetCreatedPVs",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"v1",
".",
"PersistentVolume",
"{",
"createdPVs",
":=",
"u",
".",
"createdPVs",
"\n",
"u",
".",
"createdPVs",
"=",
"map",
"[",
"string",
"]",
... | // GetAndResetCreatedPVs returns createdPVs and resets the map
// This is only for testing | [
"GetAndResetCreatedPVs",
"returns",
"createdPVs",
"and",
"resets",
"the",
"map",
"This",
"is",
"only",
"for",
"testing"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L153-L157 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | GetAndResetDeletedPVs | func (u *FakeAPIUtil) GetAndResetDeletedPVs() map[string]*v1.PersistentVolume {
deletedPVs := u.deletedPVs
u.deletedPVs = map[string]*v1.PersistentVolume{}
return deletedPVs
} | go | func (u *FakeAPIUtil) GetAndResetDeletedPVs() map[string]*v1.PersistentVolume {
deletedPVs := u.deletedPVs
u.deletedPVs = map[string]*v1.PersistentVolume{}
return deletedPVs
} | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"GetAndResetDeletedPVs",
"(",
")",
"map",
"[",
"string",
"]",
"*",
"v1",
".",
"PersistentVolume",
"{",
"deletedPVs",
":=",
"u",
".",
"deletedPVs",
"\n",
"u",
".",
"deletedPVs",
"=",
"map",
"[",
"string",
"]",
... | // GetAndResetDeletedPVs returns createdPVs and resets the map
// This is only for testing | [
"GetAndResetDeletedPVs",
"returns",
"createdPVs",
"and",
"resets",
"the",
"map",
"This",
"is",
"only",
"for",
"testing"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L161-L165 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | CreateJob | func (u *FakeAPIUtil) CreateJob(job *batch_v1.Job) error {
u.CreatedJobs[job.Namespace+"/"+job.Name] = job
return nil
} | go | func (u *FakeAPIUtil) CreateJob(job *batch_v1.Job) error {
u.CreatedJobs[job.Namespace+"/"+job.Name] = job
return nil
} | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"CreateJob",
"(",
"job",
"*",
"batch_v1",
".",
"Job",
")",
"error",
"{",
"u",
".",
"CreatedJobs",
"[",
"job",
".",
"Namespace",
"+",
"\"",
"\"",
"+",
"job",
".",
"Name",
"]",
"=",
"job",
"\n",
"return",
... | // CreateJob mocks job create method. | [
"CreateJob",
"mocks",
"job",
"create",
"method",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L168-L171 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/api_util.go | DeleteJob | func (u *FakeAPIUtil) DeleteJob(jobName string, namespace string) error {
u.DeletedJobs[namespace+"/"+jobName] = jobName
return nil
} | go | func (u *FakeAPIUtil) DeleteJob(jobName string, namespace string) error {
u.DeletedJobs[namespace+"/"+jobName] = jobName
return nil
} | [
"func",
"(",
"u",
"*",
"FakeAPIUtil",
")",
"DeleteJob",
"(",
"jobName",
"string",
",",
"namespace",
"string",
")",
"error",
"{",
"u",
".",
"DeletedJobs",
"[",
"namespace",
"+",
"\"",
"\"",
"+",
"jobName",
"]",
"=",
"jobName",
"\n",
"return",
"nil",
"\n... | // DeleteJob mocks delete jon method. | [
"DeleteJob",
"mocks",
"delete",
"jon",
"method",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L174-L177 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | getInstancesByRegex | func (c *Cloud) getInstancesByRegex(regex string) ([]types.NodeName, error) {
filters := []*ec2.Filter{newEc2Filter("instance-state-name", "running")}
instances, err := c.describeInstances(filters)
if err != nil {
return []types.NodeName{}, err
}
if len(instances) == 0 {
return []types.NodeName{}, fmt.Errorf... | go | func (c *Cloud) getInstancesByRegex(regex string) ([]types.NodeName, error) {
filters := []*ec2.Filter{newEc2Filter("instance-state-name", "running")}
instances, err := c.describeInstances(filters)
if err != nil {
return []types.NodeName{}, err
}
if len(instances) == 0 {
return []types.NodeName{}, fmt.Errorf... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"getInstancesByRegex",
"(",
"regex",
"string",
")",
"(",
"[",
"]",
"types",
".",
"NodeName",
",",
"error",
")",
"{",
"filters",
":=",
"[",
"]",
"*",
"ec2",
".",
"Filter",
"{",
"newEc2Filter",
"(",
"\"",
"\"",
",... | // Return a list of instances matching regex string. | [
"Return",
"a",
"list",
"of",
"instances",
"matching",
"regex",
"string",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1085-L1132 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | getMountDevice | func (c *Cloud) getMountDevice(
i *awsInstance,
info *ec2.Instance,
volumeID awsVolumeID,
assign bool) (assigned mountDevice, alreadyAttached bool, err error) {
instanceType := i.getInstanceType()
if instanceType == nil {
return "", false, fmt.Errorf("could not get instance type for instance: %s", i.awsID)
}
... | go | func (c *Cloud) getMountDevice(
i *awsInstance,
info *ec2.Instance,
volumeID awsVolumeID,
assign bool) (assigned mountDevice, alreadyAttached bool, err error) {
instanceType := i.getInstanceType()
if instanceType == nil {
return "", false, fmt.Errorf("could not get instance type for instance: %s", i.awsID)
}
... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"getMountDevice",
"(",
"i",
"*",
"awsInstance",
",",
"info",
"*",
"ec2",
".",
"Instance",
",",
"volumeID",
"awsVolumeID",
",",
"assign",
"bool",
")",
"(",
"assigned",
"mountDevice",
",",
"alreadyAttached",
"bool",
",",
... | // Gets the mountDevice already assigned to the volume, or assigns an unused mountDevice.
// If the volume is already assigned, this will return the existing mountDevice with alreadyAttached=true.
// Otherwise the mountDevice is assigned by finding the first available mountDevice, and it is returned with alreadyAttache... | [
"Gets",
"the",
"mountDevice",
"already",
"assigned",
"to",
"the",
"volume",
"or",
"assigns",
"an",
"unused",
"mountDevice",
".",
"If",
"the",
"volume",
"is",
"already",
"assigned",
"this",
"will",
"return",
"the",
"existing",
"mountDevice",
"with",
"alreadyAttac... | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1271-L1344 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | describeVolume | func (d *awsDisk) describeVolume() (*ec2.Volume, error) {
volumeID := d.awsID
request := &ec2.DescribeVolumesInput{
VolumeIds: []*string{volumeID.awsString()},
}
volumes, err := d.ec2.DescribeVolumes(request)
if err != nil {
return nil, fmt.Errorf("error querying ec2 for volume %q: %v", volumeID, err)
}
if... | go | func (d *awsDisk) describeVolume() (*ec2.Volume, error) {
volumeID := d.awsID
request := &ec2.DescribeVolumesInput{
VolumeIds: []*string{volumeID.awsString()},
}
volumes, err := d.ec2.DescribeVolumes(request)
if err != nil {
return nil, fmt.Errorf("error querying ec2 for volume %q: %v", volumeID, err)
}
if... | [
"func",
"(",
"d",
"*",
"awsDisk",
")",
"describeVolume",
"(",
")",
"(",
"*",
"ec2",
".",
"Volume",
",",
"error",
")",
"{",
"volumeID",
":=",
"d",
".",
"awsID",
"\n\n",
"request",
":=",
"&",
"ec2",
".",
"DescribeVolumesInput",
"{",
"VolumeIds",
":",
"... | // Gets the full information about this volume from the EC2 API | [
"Gets",
"the",
"full",
"information",
"about",
"this",
"volume",
"from",
"the",
"EC2",
"API"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1388-L1406 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | waitForAttachmentStatus | func (d *awsDisk) waitForAttachmentStatus(status string) (*ec2.VolumeAttachment, error) {
backoff := wait.Backoff{
Duration: volumeAttachmentStatusInitialDelay,
Factor: volumeAttachmentStatusFactor,
Steps: volumeAttachmentStatusSteps,
}
// Because of rate limiting, we often see errors from describeVolume... | go | func (d *awsDisk) waitForAttachmentStatus(status string) (*ec2.VolumeAttachment, error) {
backoff := wait.Backoff{
Duration: volumeAttachmentStatusInitialDelay,
Factor: volumeAttachmentStatusFactor,
Steps: volumeAttachmentStatusSteps,
}
// Because of rate limiting, we often see errors from describeVolume... | [
"func",
"(",
"d",
"*",
"awsDisk",
")",
"waitForAttachmentStatus",
"(",
"status",
"string",
")",
"(",
"*",
"ec2",
".",
"VolumeAttachment",
",",
"error",
")",
"{",
"backoff",
":=",
"wait",
".",
"Backoff",
"{",
"Duration",
":",
"volumeAttachmentStatusInitialDelay... | // waitForAttachmentStatus polls until the attachment status is the expected value
// On success, it returns the last attachment state. | [
"waitForAttachmentStatus",
"polls",
"until",
"the",
"attachment",
"status",
"is",
"the",
"expected",
"value",
"On",
"success",
"it",
"returns",
"the",
"last",
"attachment",
"state",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1410-L1466 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | deleteVolume | func (d *awsDisk) deleteVolume() (bool, error) {
request := &ec2.DeleteVolumeInput{VolumeId: d.awsID.awsString()}
_, err := d.ec2.DeleteVolume(request)
if err != nil {
if awsError, ok := err.(awserr.Error); ok {
if awsError.Code() == "InvalidVolume.NotFound" {
return false, nil
}
if awsError.Code() ==... | go | func (d *awsDisk) deleteVolume() (bool, error) {
request := &ec2.DeleteVolumeInput{VolumeId: d.awsID.awsString()}
_, err := d.ec2.DeleteVolume(request)
if err != nil {
if awsError, ok := err.(awserr.Error); ok {
if awsError.Code() == "InvalidVolume.NotFound" {
return false, nil
}
if awsError.Code() ==... | [
"func",
"(",
"d",
"*",
"awsDisk",
")",
"deleteVolume",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"request",
":=",
"&",
"ec2",
".",
"DeleteVolumeInput",
"{",
"VolumeId",
":",
"d",
".",
"awsID",
".",
"awsString",
"(",
")",
"}",
"\n",
"_",
",",
... | // Deletes the EBS disk | [
"Deletes",
"the",
"EBS",
"disk"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1469-L1484 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | getAwsInstance | func (c *Cloud) getAwsInstance(nodeName types.NodeName) (*awsInstance, error) {
var awsInstance *awsInstance
if nodeName == "" {
awsInstance = c.selfAWSInstance
} else {
instance, err := c.getInstanceByNodeName(nodeName)
if err != nil {
return nil, err
}
awsInstance = newAWSInstance(c.ec2, instance)
}... | go | func (c *Cloud) getAwsInstance(nodeName types.NodeName) (*awsInstance, error) {
var awsInstance *awsInstance
if nodeName == "" {
awsInstance = c.selfAWSInstance
} else {
instance, err := c.getInstanceByNodeName(nodeName)
if err != nil {
return nil, err
}
awsInstance = newAWSInstance(c.ec2, instance)
}... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"getAwsInstance",
"(",
"nodeName",
"types",
".",
"NodeName",
")",
"(",
"*",
"awsInstance",
",",
"error",
")",
"{",
"var",
"awsInstance",
"*",
"awsInstance",
"\n",
"if",
"nodeName",
"==",
"\"",
"\"",
"{",
"awsInstance"... | // Gets the awsInstance with for the node with the specified nodeName, or the 'self' instance if nodeName == "" | [
"Gets",
"the",
"awsInstance",
"with",
"for",
"the",
"node",
"with",
"the",
"specified",
"nodeName",
"or",
"the",
"self",
"instance",
"if",
"nodeName",
"=="
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1513-L1527 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | GetVolumeLabels | func (c *Cloud) GetVolumeLabels(volumeName KubernetesVolumeID) (map[string]string, error) {
awsDisk, err := newAWSDisk(c, volumeName)
if err != nil {
return nil, err
}
info, err := awsDisk.describeVolume()
if err != nil {
return nil, err
}
labels := make(map[string]string)
az := aws.StringValue(info.Availab... | go | func (c *Cloud) GetVolumeLabels(volumeName KubernetesVolumeID) (map[string]string, error) {
awsDisk, err := newAWSDisk(c, volumeName)
if err != nil {
return nil, err
}
info, err := awsDisk.describeVolume()
if err != nil {
return nil, err
}
labels := make(map[string]string)
az := aws.StringValue(info.Availab... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"GetVolumeLabels",
"(",
"volumeName",
"KubernetesVolumeID",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"awsDisk",
",",
"err",
":=",
"newAWSDisk",
"(",
"c",
",",
"volumeName",
")",
"\n",
"... | // GetVolumeLabels implements Volumes.GetVolumeLabels | [
"GetVolumeLabels",
"implements",
"Volumes",
".",
"GetVolumeLabels"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1772-L1795 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | DisksAreAttached | func (c *Cloud) DisksAreAttached(nodeDisks map[types.NodeName][]KubernetesVolumeID) (map[types.NodeName]map[KubernetesVolumeID]bool, error) {
attached := make(map[types.NodeName]map[KubernetesVolumeID]bool)
if len(nodeDisks) == 0 {
return attached, nil
}
dnsNameSlice := []string{}
for nodeName, diskNames := ra... | go | func (c *Cloud) DisksAreAttached(nodeDisks map[types.NodeName][]KubernetesVolumeID) (map[types.NodeName]map[KubernetesVolumeID]bool, error) {
attached := make(map[types.NodeName]map[KubernetesVolumeID]bool)
if len(nodeDisks) == 0 {
return attached, nil
}
dnsNameSlice := []string{}
for nodeName, diskNames := ra... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"DisksAreAttached",
"(",
"nodeDisks",
"map",
"[",
"types",
".",
"NodeName",
"]",
"[",
"]",
"KubernetesVolumeID",
")",
"(",
"map",
"[",
"types",
".",
"NodeName",
"]",
"map",
"[",
"KubernetesVolumeID",
"]",
"bool",
",",... | // DisksAreAttached checks whether disks are attached | [
"DisksAreAttached",
"checks",
"whether",
"disks",
"are",
"attached"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1844-L1908 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | CreateSnapshot | func (c *Cloud) CreateSnapshot(snapshotOptions *SnapshotOptions) (snapshotID string, status string, err error) {
request := &ec2.CreateSnapshotInput{}
request.VolumeId = aws.String(snapshotOptions.VolumeID)
request.DryRun = aws.Bool(false)
descriptions := "Created by Kubernetes for volume " + snapshotOptions.Volume... | go | func (c *Cloud) CreateSnapshot(snapshotOptions *SnapshotOptions) (snapshotID string, status string, err error) {
request := &ec2.CreateSnapshotInput{}
request.VolumeId = aws.String(snapshotOptions.VolumeID)
request.DryRun = aws.Bool(false)
descriptions := "Created by Kubernetes for volume " + snapshotOptions.Volume... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"CreateSnapshot",
"(",
"snapshotOptions",
"*",
"SnapshotOptions",
")",
"(",
"snapshotID",
"string",
",",
"status",
"string",
",",
"err",
"error",
")",
"{",
"request",
":=",
"&",
"ec2",
".",
"CreateSnapshotInput",
"{",
"... | // CreateSnapshot creates an EBS volume snapshot | [
"CreateSnapshot",
"creates",
"an",
"EBS",
"volume",
"snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1911-L1937 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | DeleteSnapshot | func (c *Cloud) DeleteSnapshot(snapshotID string) (bool, error) {
request := &ec2.DeleteSnapshotInput{}
request.SnapshotId = aws.String(snapshotID)
_, err := c.ec2.DeleteSnapshot(request)
if err != nil {
return false, err
}
return true, nil
} | go | func (c *Cloud) DeleteSnapshot(snapshotID string) (bool, error) {
request := &ec2.DeleteSnapshotInput{}
request.SnapshotId = aws.String(snapshotID)
_, err := c.ec2.DeleteSnapshot(request)
if err != nil {
return false, err
}
return true, nil
} | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"DeleteSnapshot",
"(",
"snapshotID",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"request",
":=",
"&",
"ec2",
".",
"DeleteSnapshotInput",
"{",
"}",
"\n",
"request",
".",
"SnapshotId",
"=",
"aws",
".",
"Strin... | // DeleteSnapshot deletes an EBS volume snapshot | [
"DeleteSnapshot",
"deletes",
"an",
"EBS",
"volume",
"snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1940-L1949 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | DescribeSnapshot | func (c *Cloud) DescribeSnapshot(snapshotID string) (status string, isCompleted bool, err error) {
request := &ec2.DescribeSnapshotsInput{
SnapshotIds: []*string{
aws.String(snapshotID),
},
}
result, err := c.ec2.DescribeSnapshots(request)
if err != nil {
return "", false, err
}
if len(result) != 1 {
r... | go | func (c *Cloud) DescribeSnapshot(snapshotID string) (status string, isCompleted bool, err error) {
request := &ec2.DescribeSnapshotsInput{
SnapshotIds: []*string{
aws.String(snapshotID),
},
}
result, err := c.ec2.DescribeSnapshots(request)
if err != nil {
return "", false, err
}
if len(result) != 1 {
r... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"DescribeSnapshot",
"(",
"snapshotID",
"string",
")",
"(",
"status",
"string",
",",
"isCompleted",
"bool",
",",
"err",
"error",
")",
"{",
"request",
":=",
"&",
"ec2",
".",
"DescribeSnapshotsInput",
"{",
"SnapshotIds",
"... | // DescribeSnapshot returns the status of the snapshot | [
"DescribeSnapshot",
"returns",
"the",
"status",
"of",
"the",
"snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1952-L1978 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | FindSnapshot | func (c *Cloud) FindSnapshot(tags map[string]string) ([]string, []string, error) {
request := &ec2.DescribeSnapshotsInput{}
for k, v := range tags {
filter := &ec2.Filter{}
filter.SetName(k)
filter.SetValues([]*string{&v})
request.Filters = append(request.Filters, filter)
}
result, err := c.ec2.DescribeSn... | go | func (c *Cloud) FindSnapshot(tags map[string]string) ([]string, []string, error) {
request := &ec2.DescribeSnapshotsInput{}
for k, v := range tags {
filter := &ec2.Filter{}
filter.SetName(k)
filter.SetValues([]*string{&v})
request.Filters = append(request.Filters, filter)
}
result, err := c.ec2.DescribeSn... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"FindSnapshot",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"request",
":=",
"&",
"ec2",
".",
"DescribeSnapshotsInput",
"{",
"... | // FindSnapshot returns the found snapshot | [
"FindSnapshot",
"returns",
"the",
"found",
"snapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L1981-L2004 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | findSecurityGroup | func (c *Cloud) findSecurityGroup(securityGroupID string) (*ec2.SecurityGroup, error) {
describeSecurityGroupsRequest := &ec2.DescribeSecurityGroupsInput{
GroupIds: []*string{&securityGroupID},
}
// We don't apply our tag filters because we are retrieving by ID
groups, err := c.ec2.DescribeSecurityGroups(describ... | go | func (c *Cloud) findSecurityGroup(securityGroupID string) (*ec2.SecurityGroup, error) {
describeSecurityGroupsRequest := &ec2.DescribeSecurityGroupsInput{
GroupIds: []*string{&securityGroupID},
}
// We don't apply our tag filters because we are retrieving by ID
groups, err := c.ec2.DescribeSecurityGroups(describ... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"findSecurityGroup",
"(",
"securityGroupID",
"string",
")",
"(",
"*",
"ec2",
".",
"SecurityGroup",
",",
"error",
")",
"{",
"describeSecurityGroupsRequest",
":=",
"&",
"ec2",
".",
"DescribeSecurityGroupsInput",
"{",
"GroupIds"... | // Retrieves the specified security group from the AWS API, or returns nil if not found | [
"Retrieves",
"the",
"specified",
"security",
"group",
"from",
"the",
"AWS",
"API",
"or",
"returns",
"nil",
"if",
"not",
"found"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L2054-L2075 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | setSecurityGroupIngress | func (c *Cloud) setSecurityGroupIngress(securityGroupID string, permissions IPPermissionSet) (bool, error) {
group, err := c.findSecurityGroup(securityGroupID)
if err != nil {
glog.Warning("Error retrieving security group", err)
return false, err
}
if group == nil {
return false, fmt.Errorf("security group n... | go | func (c *Cloud) setSecurityGroupIngress(securityGroupID string, permissions IPPermissionSet) (bool, error) {
group, err := c.findSecurityGroup(securityGroupID)
if err != nil {
glog.Warning("Error retrieving security group", err)
return false, err
}
if group == nil {
return false, fmt.Errorf("security group n... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"setSecurityGroupIngress",
"(",
"securityGroupID",
"string",
",",
"permissions",
"IPPermissionSet",
")",
"(",
"bool",
",",
"error",
")",
"{",
"group",
",",
"err",
":=",
"c",
".",
"findSecurityGroup",
"(",
"securityGroupID",... | // Makes sure the security group ingress is exactly the specified permissions
// Returns true if and only if changes were made
// The security group must already exist | [
"Makes",
"sure",
"the",
"security",
"group",
"ingress",
"is",
"exactly",
"the",
"specified",
"permissions",
"Returns",
"true",
"if",
"and",
"only",
"if",
"changes",
"were",
"made",
"The",
"security",
"group",
"must",
"already",
"exist"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L2156-L2221 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | findSecurityGroupForInstance | func findSecurityGroupForInstance(instance *ec2.Instance, taggedSecurityGroups map[string]*ec2.SecurityGroup) (*ec2.GroupIdentifier, error) {
instanceID := aws.StringValue(instance.InstanceId)
var tagged []*ec2.GroupIdentifier
var untagged []*ec2.GroupIdentifier
for _, group := range instance.SecurityGroups {
gr... | go | func findSecurityGroupForInstance(instance *ec2.Instance, taggedSecurityGroups map[string]*ec2.SecurityGroup) (*ec2.GroupIdentifier, error) {
instanceID := aws.StringValue(instance.InstanceId)
var tagged []*ec2.GroupIdentifier
var untagged []*ec2.GroupIdentifier
for _, group := range instance.SecurityGroups {
gr... | [
"func",
"findSecurityGroupForInstance",
"(",
"instance",
"*",
"ec2",
".",
"Instance",
",",
"taggedSecurityGroups",
"map",
"[",
"string",
"]",
"*",
"ec2",
".",
"SecurityGroup",
")",
"(",
"*",
"ec2",
".",
"GroupIdentifier",
",",
"error",
")",
"{",
"instanceID",
... | // Returns the first security group for an instance, or nil
// We only create instances with one security group, so we don't expect multiple security groups.
// However, if there are multiple security groups, we will choose the one tagged with our cluster filter.
// Otherwise we will return an error. | [
"Returns",
"the",
"first",
"security",
"group",
"for",
"an",
"instance",
"or",
"nil",
"We",
"only",
"create",
"instances",
"with",
"one",
"security",
"group",
"so",
"we",
"don",
"t",
"expect",
"multiple",
"security",
"groups",
".",
"However",
"if",
"there",
... | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L2957-L2995 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | getInstanceByID | func (c *Cloud) getInstanceByID(instanceID string) (*ec2.Instance, error) {
instances, err := c.getInstancesByIDs([]*string{&instanceID})
if err != nil {
return nil, err
}
if len(instances) == 0 {
return nil, cloudprovider.ErrInstanceNotFound
}
if len(instances) > 1 {
return nil, fmt.Errorf("multiple insta... | go | func (c *Cloud) getInstanceByID(instanceID string) (*ec2.Instance, error) {
instances, err := c.getInstancesByIDs([]*string{&instanceID})
if err != nil {
return nil, err
}
if len(instances) == 0 {
return nil, cloudprovider.ErrInstanceNotFound
}
if len(instances) > 1 {
return nil, fmt.Errorf("multiple insta... | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"getInstanceByID",
"(",
"instanceID",
"string",
")",
"(",
"*",
"ec2",
".",
"Instance",
",",
"error",
")",
"{",
"instances",
",",
"err",
":=",
"c",
".",
"getInstancesByIDs",
"(",
"[",
"]",
"*",
"string",
"{",
"&",
... | // Returns the instance with the specified ID | [
"Returns",
"the",
"instance",
"with",
"the",
"specified",
"ID"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L3282-L3296 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/aws.go | getInstanceByNodeName | func (c *Cloud) getInstanceByNodeName(nodeName types.NodeName) (*ec2.Instance, error) {
instance, err := c.findInstanceByNodeName(nodeName)
if err == nil && instance == nil {
return nil, cloudprovider.ErrInstanceNotFound
}
return instance, err
} | go | func (c *Cloud) getInstanceByNodeName(nodeName types.NodeName) (*ec2.Instance, error) {
instance, err := c.findInstanceByNodeName(nodeName)
if err == nil && instance == nil {
return nil, cloudprovider.ErrInstanceNotFound
}
return instance, err
} | [
"func",
"(",
"c",
"*",
"Cloud",
")",
"getInstanceByNodeName",
"(",
"nodeName",
"types",
".",
"NodeName",
")",
"(",
"*",
"ec2",
".",
"Instance",
",",
"error",
")",
"{",
"instance",
",",
"err",
":=",
"c",
".",
"findInstanceByNodeName",
"(",
"nodeName",
")"... | // Returns the instance with the specified node name
// Like findInstanceByNodeName, but returns error if node not found | [
"Returns",
"the",
"instance",
"with",
"the",
"specified",
"node",
"name",
"Like",
"findInstanceByNodeName",
"but",
"returns",
"error",
"if",
"node",
"not",
"found"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/aws.go#L3437-L3443 | train |
kubernetes-incubator/external-storage | gluster/glusterfs/pkg/volume/provision.go | NewGlusterfsProvisioner | func NewGlusterfsProvisioner(config *rest.Config, client kubernetes.Interface) controller.Provisioner {
klog.Infof("Creating NewGlusterfsProvisioner.")
return newGlusterfsProvisionerInternal(config, client)
} | go | func NewGlusterfsProvisioner(config *rest.Config, client kubernetes.Interface) controller.Provisioner {
klog.Infof("Creating NewGlusterfsProvisioner.")
return newGlusterfsProvisionerInternal(config, client)
} | [
"func",
"NewGlusterfsProvisioner",
"(",
"config",
"*",
"rest",
".",
"Config",
",",
"client",
"kubernetes",
".",
"Interface",
")",
"controller",
".",
"Provisioner",
"{",
"klog",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"newGlusterfsProvisionerInternal"... | // NewGlusterfsProvisioner creates a new glusterfs simple provisioner | [
"NewGlusterfsProvisioner",
"creates",
"a",
"new",
"glusterfs",
"simple",
"provisioner"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/gluster/glusterfs/pkg/volume/provision.go#L44-L47 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/cache/cache.go | GetPV | func (cache *VolumeCache) GetPV(pvName string) (*v1.PersistentVolume, bool) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
pv, exists := cache.pvs[pvName]
return pv, exists
} | go | func (cache *VolumeCache) GetPV(pvName string) (*v1.PersistentVolume, bool) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
pv, exists := cache.pvs[pvName]
return pv, exists
} | [
"func",
"(",
"cache",
"*",
"VolumeCache",
")",
"GetPV",
"(",
"pvName",
"string",
")",
"(",
"*",
"v1",
".",
"PersistentVolume",
",",
"bool",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cache",
".",
"mutex",
".",
"Unlock",
... | // GetPV returns the PV object given the PV name | [
"GetPV",
"returns",
"the",
"PV",
"object",
"given",
"the",
"PV",
"name"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/cache/cache.go#L41-L47 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/cache/cache.go | AddPV | func (cache *VolumeCache) AddPV(pv *v1.PersistentVolume) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
cache.pvs[pv.Name] = pv
glog.Infof("Added pv %q to cache", pv.Name)
} | go | func (cache *VolumeCache) AddPV(pv *v1.PersistentVolume) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
cache.pvs[pv.Name] = pv
glog.Infof("Added pv %q to cache", pv.Name)
} | [
"func",
"(",
"cache",
"*",
"VolumeCache",
")",
"AddPV",
"(",
"pv",
"*",
"v1",
".",
"PersistentVolume",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cache",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"cache",
".",
"pvs... | // AddPV adds the PV object to the cache | [
"AddPV",
"adds",
"the",
"PV",
"object",
"to",
"the",
"cache"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/cache/cache.go#L50-L56 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/cache/cache.go | DeletePV | func (cache *VolumeCache) DeletePV(pvName string) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
delete(cache.pvs, pvName)
glog.Infof("Deleted pv %q from cache", pvName)
} | go | func (cache *VolumeCache) DeletePV(pvName string) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
delete(cache.pvs, pvName)
glog.Infof("Deleted pv %q from cache", pvName)
} | [
"func",
"(",
"cache",
"*",
"VolumeCache",
")",
"DeletePV",
"(",
"pvName",
"string",
")",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cache",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"delete",
"(",
"cache",
".",
"pvs",
"... | // DeletePV deletes the PV object from the cache | [
"DeletePV",
"deletes",
"the",
"PV",
"object",
"from",
"the",
"cache"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/cache/cache.go#L68-L74 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/cache/cache.go | ListPVs | func (cache *VolumeCache) ListPVs() []*v1.PersistentVolume {
cache.mutex.Lock()
defer cache.mutex.Unlock()
pvs := []*v1.PersistentVolume{}
for _, pv := range cache.pvs {
pvs = append(pvs, pv)
}
return pvs
} | go | func (cache *VolumeCache) ListPVs() []*v1.PersistentVolume {
cache.mutex.Lock()
defer cache.mutex.Unlock()
pvs := []*v1.PersistentVolume{}
for _, pv := range cache.pvs {
pvs = append(pvs, pv)
}
return pvs
} | [
"func",
"(",
"cache",
"*",
"VolumeCache",
")",
"ListPVs",
"(",
")",
"[",
"]",
"*",
"v1",
".",
"PersistentVolume",
"{",
"cache",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"cache",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"pvs",
":=",... | // ListPVs returns a list of all the PVs in the cache | [
"ListPVs",
"returns",
"a",
"list",
"of",
"all",
"the",
"PVs",
"in",
"the",
"cache"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/cache/cache.go#L77-L86 | train |
kubernetes-incubator/external-storage | nfs/pkg/server/server.go | Setup | func Setup(ganeshaConfig string, gracePeriod uint) error {
// Start rpcbind if it is not started yet
cmd := exec.Command("/usr/sbin/rpcinfo", "127.0.0.1")
if err := cmd.Run(); err != nil {
cmd = exec.Command("/usr/sbin/rpcbind", "-w")
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("Starti... | go | func Setup(ganeshaConfig string, gracePeriod uint) error {
// Start rpcbind if it is not started yet
cmd := exec.Command("/usr/sbin/rpcinfo", "127.0.0.1")
if err := cmd.Run(); err != nil {
cmd = exec.Command("/usr/sbin/rpcbind", "-w")
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("Starti... | [
"func",
"Setup",
"(",
"ganeshaConfig",
"string",
",",
"gracePeriod",
"uint",
")",
"error",
"{",
"// Start rpcbind if it is not started yet",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"cmd",
".",
"R... | // Setup sets up various prerequisites and settings for the server. If an error
// is encountered at any point it returns it instantly | [
"Setup",
"sets",
"up",
"various",
"prerequisites",
"and",
"settings",
"for",
"the",
"server",
".",
"If",
"an",
"error",
"is",
"encountered",
"at",
"any",
"point",
"it",
"returns",
"it",
"instantly"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/nfs/pkg/server/server.go#L77-L120 | train |
kubernetes-incubator/external-storage | gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go | NewGlusterBlockProvisioner | func NewGlusterBlockProvisioner(client kubernetes.Interface, id string) controller.Provisioner {
return &glusterBlockProvisioner{
client: client,
identity: id,
}
} | go | func NewGlusterBlockProvisioner(client kubernetes.Interface, id string) controller.Provisioner {
return &glusterBlockProvisioner{
client: client,
identity: id,
}
} | [
"func",
"NewGlusterBlockProvisioner",
"(",
"client",
"kubernetes",
".",
"Interface",
",",
"id",
"string",
")",
"controller",
".",
"Provisioner",
"{",
"return",
"&",
"glusterBlockProvisioner",
"{",
"client",
":",
"client",
",",
"identity",
":",
"id",
",",
"}",
... | //NewGlusterBlockProvisioner create a new provisioner. | [
"NewGlusterBlockProvisioner",
"create",
"a",
"new",
"provisioner",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go#L150-L155 | train |
kubernetes-incubator/external-storage | gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go | createVolume | func (p *glusterBlockProvisioner) createVolume(volSizeInt int, blockVol string, config *provisionerConfig) (*glusterBlockVolume, error) {
blockRes := &glusterBlockVolume{}
sizeStr := strconv.Itoa(volSizeInt)
haCountStr := strconv.Itoa(config.haCount)
klog.V(2).Infof("create block volume of size %d and configurat... | go | func (p *glusterBlockProvisioner) createVolume(volSizeInt int, blockVol string, config *provisionerConfig) (*glusterBlockVolume, error) {
blockRes := &glusterBlockVolume{}
sizeStr := strconv.Itoa(volSizeInt)
haCountStr := strconv.Itoa(config.haCount)
klog.V(2).Infof("create block volume of size %d and configurat... | [
"func",
"(",
"p",
"*",
"glusterBlockProvisioner",
")",
"createVolume",
"(",
"volSizeInt",
"int",
",",
"blockVol",
"string",
",",
"config",
"*",
"provisionerConfig",
")",
"(",
"*",
"glusterBlockVolume",
",",
"error",
")",
"{",
"blockRes",
":=",
"&",
"glusterBlo... | // createVolume creates a gluster block volume i.e. the storage asset. | [
"createVolume",
"creates",
"a",
"gluster",
"block",
"volume",
"i",
".",
"e",
".",
"the",
"storage",
"asset",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go#L374-L405 | train |
kubernetes-incubator/external-storage | gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go | sortTargetPortal | func (p *glusterBlockProvisioner) sortTargetPortal(vol *iscsiSpec) error {
if len(vol.Portals) == 0 {
return fmt.Errorf("portal is empty")
}
if len(vol.Portals) == 1 && vol.Portals[0] != "" {
vol.TargetPortal = vol.Portals[0]
vol.Portals = nil
} else {
portals := vol.Portals
vol.Portals = nil
for _, v ... | go | func (p *glusterBlockProvisioner) sortTargetPortal(vol *iscsiSpec) error {
if len(vol.Portals) == 0 {
return fmt.Errorf("portal is empty")
}
if len(vol.Portals) == 1 && vol.Portals[0] != "" {
vol.TargetPortal = vol.Portals[0]
vol.Portals = nil
} else {
portals := vol.Portals
vol.Portals = nil
for _, v ... | [
"func",
"(",
"p",
"*",
"glusterBlockProvisioner",
")",
"sortTargetPortal",
"(",
"vol",
"*",
"iscsiSpec",
")",
"error",
"{",
"if",
"len",
"(",
"vol",
".",
"Portals",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",... | //sortTargetPortal extract TP | [
"sortTargetPortal",
"extract",
"TP"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/gluster/block/cmd/glusterblock-provisioner/glusterblock-provisioner.go#L660-L681 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/util/volume_util_unsupported.go | IsBlock | func (u *volumeUtil) IsBlock(fullPath string) (bool, error) {
return false, fmt.Errorf("IsBlock is unsupported in this build")
} | go | func (u *volumeUtil) IsBlock(fullPath string) (bool, error) {
return false, fmt.Errorf("IsBlock is unsupported in this build")
} | [
"func",
"(",
"u",
"*",
"volumeUtil",
")",
"IsBlock",
"(",
"fullPath",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // IsBlock for unsupported platform returns error. | [
"IsBlock",
"for",
"unsupported",
"platform",
"returns",
"error",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util_unsupported.go#L32-L34 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/aws/volumes.go | mapToAWSVolumeID | func (name KubernetesVolumeID) mapToAWSVolumeID() (awsVolumeID, error) {
// name looks like aws://availability-zone/awsVolumeId
// The original idea of the URL-style name was to put the AZ into the
// host, so we could find the AZ immediately from the name without
// querying the API. But it turns out we don't ac... | go | func (name KubernetesVolumeID) mapToAWSVolumeID() (awsVolumeID, error) {
// name looks like aws://availability-zone/awsVolumeId
// The original idea of the URL-style name was to put the AZ into the
// host, so we could find the AZ immediately from the name without
// querying the API. But it turns out we don't ac... | [
"func",
"(",
"name",
"KubernetesVolumeID",
")",
"mapToAWSVolumeID",
"(",
")",
"(",
"awsVolumeID",
",",
"error",
")",
"{",
"// name looks like aws://availability-zone/awsVolumeId",
"// The original idea of the URL-style name was to put the AZ into the",
"// host, so we could find the ... | // mapToAWSVolumeID extracts the awsVolumeID from the KubernetesVolumeID | [
"mapToAWSVolumeID",
"extracts",
"the",
"awsVolumeID",
"from",
"the",
"KubernetesVolumeID"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/aws/volumes.go#L46-L84 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/openstack/openstack.go | LoadBalancer | func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
glog.V(4).Info("openstack.LoadBalancer() called")
// TODO: Search for and support Rackspace loadbalancer API, and others.
network, err := os.NewNetworkV2()
if err != nil {
return nil, false
}
compute, err := os.NewComputeV2()
if err != ... | go | func (os *OpenStack) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
glog.V(4).Info("openstack.LoadBalancer() called")
// TODO: Search for and support Rackspace loadbalancer API, and others.
network, err := os.NewNetworkV2()
if err != nil {
return nil, false
}
compute, err := os.NewComputeV2()
if err != ... | [
"func",
"(",
"os",
"*",
"OpenStack",
")",
"LoadBalancer",
"(",
")",
"(",
"cloudprovider",
".",
"LoadBalancer",
",",
"bool",
")",
"{",
"glog",
".",
"V",
"(",
"4",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"// TODO: Search for and support Rackspace loa... | // LoadBalancer returns a load balancer | [
"LoadBalancer",
"returns",
"a",
"load",
"balancer"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack.go#L250-L294 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/openstack/openstack.go | Routes | func (os *OpenStack) Routes() (cloudprovider.Routes, bool) {
glog.V(4).Info("openstack.Routes() called")
network, err := os.NewNetworkV2()
if err != nil {
return nil, false
}
netExts, err := networkExtensions(network)
if err != nil {
glog.Warningf("Failed to list neutron extensions: %v", err)
return nil, ... | go | func (os *OpenStack) Routes() (cloudprovider.Routes, bool) {
glog.V(4).Info("openstack.Routes() called")
network, err := os.NewNetworkV2()
if err != nil {
return nil, false
}
netExts, err := networkExtensions(network)
if err != nil {
glog.Warningf("Failed to list neutron extensions: %v", err)
return nil, ... | [
"func",
"(",
"os",
"*",
"OpenStack",
")",
"Routes",
"(",
")",
"(",
"cloudprovider",
".",
"Routes",
",",
"bool",
")",
"{",
"glog",
".",
"V",
"(",
"4",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"network",
",",
"err",
":=",
"os",
".",
"NewNe... | // Routes returns cloud provider routes | [
"Routes",
"returns",
"cloud",
"provider",
"routes"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack.go#L497-L530 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/openstack/openstack.go | Zones | func (os *OpenStack) Zones() (cloudprovider.Zones, bool) {
glog.V(1).Info("Claiming to support Zones")
return os, true
} | go | func (os *OpenStack) Zones() (cloudprovider.Zones, bool) {
glog.V(1).Info("Claiming to support Zones")
return os, true
} | [
"func",
"(",
"os",
"*",
"OpenStack",
")",
"Zones",
"(",
")",
"(",
"cloudprovider",
".",
"Zones",
",",
"bool",
")",
"{",
"glog",
".",
"V",
"(",
"1",
")",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"return",
"os",
",",
"true",
"\n",
"}"
] | // Zones returns cloud provider zones | [
"Zones",
"returns",
"cloud",
"provider",
"zones"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack.go#L533-L537 | train |
kubernetes-incubator/external-storage | snapshot/pkg/cloudprovider/providers/openstack/openstack.go | GetZone | func (os *OpenStack) GetZone() (cloudprovider.Zone, error) {
md, err := getMetadata()
if err != nil {
return cloudprovider.Zone{}, err
}
zone := cloudprovider.Zone{
FailureDomain: md.AvailabilityZone,
Region: os.region,
}
glog.V(1).Infof("Current zone is %v", zone)
return zone, nil
} | go | func (os *OpenStack) GetZone() (cloudprovider.Zone, error) {
md, err := getMetadata()
if err != nil {
return cloudprovider.Zone{}, err
}
zone := cloudprovider.Zone{
FailureDomain: md.AvailabilityZone,
Region: os.region,
}
glog.V(1).Infof("Current zone is %v", zone)
return zone, nil
} | [
"func",
"(",
"os",
"*",
"OpenStack",
")",
"GetZone",
"(",
")",
"(",
"cloudprovider",
".",
"Zone",
",",
"error",
")",
"{",
"md",
",",
"err",
":=",
"getMetadata",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"cloudprovider",
".",
"Zone",
... | // GetZone gets a zone from cloud provider | [
"GetZone",
"gets",
"a",
"zone",
"from",
"cloud",
"provider"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack.go#L540-L553 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | NewVolumeSnapshotter | func NewVolumeSnapshotter(
restClient *rest.RESTClient,
scheme *runtime.Scheme,
clientset kubernetes.Interface,
asw cache.ActualStateOfWorld,
volumePlugins *map[string]volume.Plugin) VolumeSnapshotter {
return &volumeSnapshotter{
restClient: restClient,
coreClient: clientset,
scheme: ... | go | func NewVolumeSnapshotter(
restClient *rest.RESTClient,
scheme *runtime.Scheme,
clientset kubernetes.Interface,
asw cache.ActualStateOfWorld,
volumePlugins *map[string]volume.Plugin) VolumeSnapshotter {
return &volumeSnapshotter{
restClient: restClient,
coreClient: clientset,
scheme: ... | [
"func",
"NewVolumeSnapshotter",
"(",
"restClient",
"*",
"rest",
".",
"RESTClient",
",",
"scheme",
"*",
"runtime",
".",
"Scheme",
",",
"clientset",
"kubernetes",
".",
"Interface",
",",
"asw",
"cache",
".",
"ActualStateOfWorld",
",",
"volumePlugins",
"*",
"map",
... | // NewVolumeSnapshotter create a new VolumeSnapshotter | [
"NewVolumeSnapshotter",
"create",
"a",
"new",
"VolumeSnapshotter"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L100-L114 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | getPVFromVolumeSnapshot | func (vs *volumeSnapshotter) getPVFromVolumeSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) (*v1.PersistentVolume, error) {
pvcName := snapshot.Spec.PersistentVolumeClaimName
if pvcName == "" {
return nil, fmt.Errorf("The PVC name is not specified in snapshot %s", uniqueSnapshotName)
}
pvc, e... | go | func (vs *volumeSnapshotter) getPVFromVolumeSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) (*v1.PersistentVolume, error) {
pvcName := snapshot.Spec.PersistentVolumeClaimName
if pvcName == "" {
return nil, fmt.Errorf("The PVC name is not specified in snapshot %s", uniqueSnapshotName)
}
pvc, e... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"getPVFromVolumeSnapshot",
"(",
"uniqueSnapshotName",
"string",
",",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"(",
"*",
"v1",
".",
"PersistentVolume",
",",
"error",
")",
"{",
"pvcName",
":=",
"snap... | // Helper function to get PV from VolumeSnapshot | [
"Helper",
"function",
"to",
"get",
"PV",
"from",
"VolumeSnapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L117-L137 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | getPVFromName | func (vs *volumeSnapshotter) getPVFromName(pvName string) (*v1.PersistentVolume, error) {
return vs.coreClient.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
} | go | func (vs *volumeSnapshotter) getPVFromName(pvName string) (*v1.PersistentVolume, error) {
return vs.coreClient.CoreV1().PersistentVolumes().Get(pvName, metav1.GetOptions{})
} | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"getPVFromName",
"(",
"pvName",
"string",
")",
"(",
"*",
"v1",
".",
"PersistentVolume",
",",
"error",
")",
"{",
"return",
"vs",
".",
"coreClient",
".",
"CoreV1",
"(",
")",
".",
"PersistentVolumes",
"(",
"... | // Helper function to get PV from PV name | [
"Helper",
"function",
"to",
"get",
"PV",
"from",
"PV",
"name"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L140-L142 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | getSnapshotDataFromSnapshot | func (vs *volumeSnapshotter) getSnapshotDataFromSnapshot(snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshotData, error) {
var snapshotDataObj crdv1.VolumeSnapshotData
snapshotDataName := snapshot.Spec.SnapshotDataName
if snapshotDataName == "" {
return nil, fmt.Errorf("Could not find snapshot data object: Snap... | go | func (vs *volumeSnapshotter) getSnapshotDataFromSnapshot(snapshot *crdv1.VolumeSnapshot) (*crdv1.VolumeSnapshotData, error) {
var snapshotDataObj crdv1.VolumeSnapshotData
snapshotDataName := snapshot.Spec.SnapshotDataName
if snapshotDataName == "" {
return nil, fmt.Errorf("Could not find snapshot data object: Snap... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"getSnapshotDataFromSnapshot",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"(",
"*",
"crdv1",
".",
"VolumeSnapshotData",
",",
"error",
")",
"{",
"var",
"snapshotDataObj",
"crdv1",
".",
"VolumeSnaps... | // Helper function that looks up VolumeSnapshotData from a VolumeSnapshot | [
"Helper",
"function",
"that",
"looks",
"up",
"VolumeSnapshotData",
"from",
"a",
"VolumeSnapshot"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L182-L197 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | updateSnapshotIfExists | func (vs *volumeSnapshotter) updateSnapshotIfExists(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) (string, *crdv1.VolumeSnapshot, error) {
snapshotName := snapshot.Metadata.Name
var snapshotDataObj *crdv1.VolumeSnapshotData
var snapshotDataSource *crdv1.VolumeSnapshotDataSource
var conditions *[]crdv1.... | go | func (vs *volumeSnapshotter) updateSnapshotIfExists(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) (string, *crdv1.VolumeSnapshot, error) {
snapshotName := snapshot.Metadata.Name
var snapshotDataObj *crdv1.VolumeSnapshotData
var snapshotDataSource *crdv1.VolumeSnapshotDataSource
var conditions *[]crdv1.... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"updateSnapshotIfExists",
"(",
"uniqueSnapshotName",
"string",
",",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"(",
"string",
",",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"error",
")",
"{",
"snapsh... | // Exame the given snapshot in detail and then return the status | [
"Exame",
"the",
"given",
"snapshot",
"in",
"detail",
"and",
"then",
"return",
"the",
"status"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L365-L409 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | syncSnapshot | func (vs *volumeSnapshotter) syncSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) func() error {
return func() error {
snapshotObj := snapshot
status := vs.getSimplifiedSnapshotStatus(snapshot.Status.Conditions)
var err error
// When the condition is new, it is still possible that snapshot i... | go | func (vs *volumeSnapshotter) syncSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) func() error {
return func() error {
snapshotObj := snapshot
status := vs.getSimplifiedSnapshotStatus(snapshot.Status.Conditions)
var err error
// When the condition is new, it is still possible that snapshot i... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"syncSnapshot",
"(",
"uniqueSnapshotName",
"string",
",",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"func",
"(",
")",
"error",
"{",
"return",
"func",
"(",
")",
"error",
"{",
"snapshotObj",
":=",
... | // Below are the closures meant to build the functions for the GoRoutineMap operations.
// syncSnapshot is the main controller method to decide what to do to create a snapshot. | [
"Below",
"are",
"the",
"closures",
"meant",
"to",
"build",
"the",
"functions",
"for",
"the",
"GoRoutineMap",
"operations",
".",
"syncSnapshot",
"is",
"the",
"main",
"controller",
"method",
"to",
"decide",
"what",
"to",
"do",
"to",
"create",
"a",
"snapshot",
... | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L413-L455 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | createSnapshot | func (vs *volumeSnapshotter) createSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) error {
var snapshotDataSource *crdv1.VolumeSnapshotDataSource
var snapStatus *[]crdv1.VolumeSnapshotCondition
var err error
var tags *map[string]string
glog.Infof("createSnapshot: Creating snapshot %s through th... | go | func (vs *volumeSnapshotter) createSnapshot(uniqueSnapshotName string, snapshot *crdv1.VolumeSnapshot) error {
var snapshotDataSource *crdv1.VolumeSnapshotDataSource
var snapStatus *[]crdv1.VolumeSnapshotCondition
var err error
var tags *map[string]string
glog.Infof("createSnapshot: Creating snapshot %s through th... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"createSnapshot",
"(",
"uniqueSnapshotName",
"string",
",",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"error",
"{",
"var",
"snapshotDataSource",
"*",
"crdv1",
".",
"VolumeSnapshotDataSource",
"\n",
"var... | // The function goes through the whole snapshot creation process.
// 1. Update VolumeSnapshot metadata to include the snapshotted PV name, timestamp and snapshot uid, also generate tag for cloud provider
// 2. Trigger the snapshot through cloud provider and attach the tag to the snapshot.
// 3. Create the VolumeSnapsho... | [
"The",
"function",
"goes",
"through",
"the",
"whole",
"snapshot",
"creation",
"process",
".",
"1",
".",
"Update",
"VolumeSnapshot",
"metadata",
"to",
"include",
"the",
"snapshotted",
"PV",
"name",
"timestamp",
"and",
"snapshot",
"uid",
"also",
"generate",
"tag",... | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L486-L528 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | updateVolumeSnapshotMetadata | func (vs *volumeSnapshotter) updateVolumeSnapshotMetadata(snapshot *crdv1.VolumeSnapshot, pvName string) (*map[string]string, error) {
glog.Infof("In updateVolumeSnapshotMetadata")
var snapshotObj crdv1.VolumeSnapshot
// Need to get a fresh copy of the VolumeSnapshot from the API server
err := vs.restClient.Get().
... | go | func (vs *volumeSnapshotter) updateVolumeSnapshotMetadata(snapshot *crdv1.VolumeSnapshot, pvName string) (*map[string]string, error) {
glog.Infof("In updateVolumeSnapshotMetadata")
var snapshotObj crdv1.VolumeSnapshot
// Need to get a fresh copy of the VolumeSnapshot from the API server
err := vs.restClient.Get().
... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"updateVolumeSnapshotMetadata",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"pvName",
"string",
")",
"(",
"*",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"glog",
".",
"Infof... | // Update VolumeSnapshot object with current timestamp and associated PersistentVolume name in object's metadata | [
"Update",
"VolumeSnapshot",
"object",
"with",
"current",
"timestamp",
"and",
"associated",
"PersistentVolume",
"name",
"in",
"object",
"s",
"metadata"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L700-L744 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | propagateVolumeSnapshotCondition | func (vs *volumeSnapshotter) propagateVolumeSnapshotCondition(snapshotDataName string, condition *crdv1.VolumeSnapshotCondition) error {
var snapshotDataObj crdv1.VolumeSnapshotData
err := vs.restClient.Get().
Name(snapshotDataName).
Resource(crdv1.VolumeSnapshotDataResourcePlural).
Do().Into(&snapshotDataObj)
... | go | func (vs *volumeSnapshotter) propagateVolumeSnapshotCondition(snapshotDataName string, condition *crdv1.VolumeSnapshotCondition) error {
var snapshotDataObj crdv1.VolumeSnapshotData
err := vs.restClient.Get().
Name(snapshotDataName).
Resource(crdv1.VolumeSnapshotDataResourcePlural).
Do().Into(&snapshotDataObj)
... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"propagateVolumeSnapshotCondition",
"(",
"snapshotDataName",
"string",
",",
"condition",
"*",
"crdv1",
".",
"VolumeSnapshotCondition",
")",
"error",
"{",
"var",
"snapshotDataObj",
"crdv1",
".",
"VolumeSnapshotData",
"\... | // Propagates the VolumeSnapshot condition to VolumeSnapshotData | [
"Propagates",
"the",
"VolumeSnapshot",
"condition",
"to",
"VolumeSnapshotData"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L747-L800 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | UpdateVolumeSnapshotStatus | func (vs *volumeSnapshotter) UpdateVolumeSnapshotStatus(snapshot *crdv1.VolumeSnapshot, condition *crdv1.VolumeSnapshotCondition) (*crdv1.VolumeSnapshot, error) {
var snapshotObj crdv1.VolumeSnapshot
err := vs.restClient.Get().
Name(snapshot.Metadata.Name).
Resource(crdv1.VolumeSnapshotResourcePlural).
Namespa... | go | func (vs *volumeSnapshotter) UpdateVolumeSnapshotStatus(snapshot *crdv1.VolumeSnapshot, condition *crdv1.VolumeSnapshotCondition) (*crdv1.VolumeSnapshot, error) {
var snapshotObj crdv1.VolumeSnapshot
err := vs.restClient.Get().
Name(snapshot.Metadata.Name).
Resource(crdv1.VolumeSnapshotResourcePlural).
Namespa... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"UpdateVolumeSnapshotStatus",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"condition",
"*",
"crdv1",
".",
"VolumeSnapshotCondition",
")",
"(",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"error",
")"... | // Update VolumeSnapshot status if the condition is changed. | [
"Update",
"VolumeSnapshot",
"status",
"if",
"the",
"condition",
"is",
"changed",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L803-L854 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/snapshotter/snapshotter.go | bindandUpdateVolumeSnapshot | func (vs *volumeSnapshotter) bindandUpdateVolumeSnapshot(snapshot *crdv1.VolumeSnapshot, snapshotDataName string, status *[]crdv1.VolumeSnapshotCondition) (*crdv1.VolumeSnapshot, error) {
var snapshotObj crdv1.VolumeSnapshot
glog.Infof("In bindVolumeSnapshotDataToVolumeSnapshot")
// Get a fresh copy of the VolumeSn... | go | func (vs *volumeSnapshotter) bindandUpdateVolumeSnapshot(snapshot *crdv1.VolumeSnapshot, snapshotDataName string, status *[]crdv1.VolumeSnapshotCondition) (*crdv1.VolumeSnapshot, error) {
var snapshotObj crdv1.VolumeSnapshot
glog.Infof("In bindVolumeSnapshotDataToVolumeSnapshot")
// Get a fresh copy of the VolumeSn... | [
"func",
"(",
"vs",
"*",
"volumeSnapshotter",
")",
"bindandUpdateVolumeSnapshot",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
",",
"snapshotDataName",
"string",
",",
"status",
"*",
"[",
"]",
"crdv1",
".",
"VolumeSnapshotCondition",
")",
"(",
"*",
"crdv1... | // Bind the VolumeSnapshot and VolumeSnapshotData and udpate the status | [
"Bind",
"the",
"VolumeSnapshot",
"and",
"VolumeSnapshotData",
"and",
"udpate",
"the",
"status"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/snapshotter/snapshotter.go#L857-L891 | train |
kubernetes-incubator/external-storage | nfs-client/cmd/nfs-client-provisioner/provisioner.go | getClassForVolume | func (p *nfsProvisioner) getClassForVolume(pv *v1.PersistentVolume) (*storage.StorageClass, error) {
if p.client == nil {
return nil, fmt.Errorf("Cannot get kube client")
}
className := helper.GetPersistentVolumeClass(pv)
if className == "" {
return nil, fmt.Errorf("Volume has no storage class")
}
class, err ... | go | func (p *nfsProvisioner) getClassForVolume(pv *v1.PersistentVolume) (*storage.StorageClass, error) {
if p.client == nil {
return nil, fmt.Errorf("Cannot get kube client")
}
className := helper.GetPersistentVolumeClass(pv)
if className == "" {
return nil, fmt.Errorf("Volume has no storage class")
}
class, err ... | [
"func",
"(",
"p",
"*",
"nfsProvisioner",
")",
"getClassForVolume",
"(",
"pv",
"*",
"v1",
".",
"PersistentVolume",
")",
"(",
"*",
"storage",
".",
"StorageClass",
",",
"error",
")",
"{",
"if",
"p",
".",
"client",
"==",
"nil",
"{",
"return",
"nil",
",",
... | // getClassForVolume returns StorageClass | [
"getClassForVolume",
"returns",
"StorageClass"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/nfs-client/cmd/nfs-client-provisioner/provisioner.go#L133-L146 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/populator/desired_state_of_world_populator.go | NewDesiredStateOfWorldPopulator | func NewDesiredStateOfWorldPopulator(
loopSleepDuration time.Duration,
listSnapshotsRetryDuration time.Duration,
snapshotStore k8scache.Store,
desiredStateOfWorld cache.DesiredStateOfWorld) DesiredStateOfWorldPopulator {
return &desiredStateOfWorldPopulator{
loopSleepDuration: loopSleepDuration,
listS... | go | func NewDesiredStateOfWorldPopulator(
loopSleepDuration time.Duration,
listSnapshotsRetryDuration time.Duration,
snapshotStore k8scache.Store,
desiredStateOfWorld cache.DesiredStateOfWorld) DesiredStateOfWorldPopulator {
return &desiredStateOfWorldPopulator{
loopSleepDuration: loopSleepDuration,
listS... | [
"func",
"NewDesiredStateOfWorldPopulator",
"(",
"loopSleepDuration",
"time",
".",
"Duration",
",",
"listSnapshotsRetryDuration",
"time",
".",
"Duration",
",",
"snapshotStore",
"k8scache",
".",
"Store",
",",
"desiredStateOfWorld",
"cache",
".",
"DesiredStateOfWorld",
")",
... | // NewDesiredStateOfWorldPopulator returns a new instance of DesiredStateOfWorldPopulator.
// loopSleepDuration - the amount of time the populator loop sleeps between
// successive executions
// desiredStateOfWorld - the cache to populate | [
"NewDesiredStateOfWorldPopulator",
"returns",
"a",
"new",
"instance",
"of",
"DesiredStateOfWorldPopulator",
".",
"loopSleepDuration",
"-",
"the",
"amount",
"of",
"time",
"the",
"populator",
"loop",
"sleeps",
"between",
"successive",
"executions",
"desiredStateOfWorld",
"-... | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/populator/desired_state_of_world_populator.go#L42-L53 | train |
kubernetes-incubator/external-storage | flex/pkg/volume/driver-call.go | NewDriverCall | func (plugin *flexProvisioner) NewDriverCall(execPath, command string) *DriverCall {
return plugin.NewDriverCallWithTimeout(execPath, command, 0)
} | go | func (plugin *flexProvisioner) NewDriverCall(execPath, command string) *DriverCall {
return plugin.NewDriverCallWithTimeout(execPath, command, 0)
} | [
"func",
"(",
"plugin",
"*",
"flexProvisioner",
")",
"NewDriverCall",
"(",
"execPath",
",",
"command",
"string",
")",
"*",
"DriverCall",
"{",
"return",
"plugin",
".",
"NewDriverCallWithTimeout",
"(",
"execPath",
",",
"command",
",",
"0",
")",
"\n",
"}"
] | // NewDriverCall initialize the DriverCall | [
"NewDriverCall",
"initialize",
"the",
"DriverCall"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/flex/pkg/volume/driver-call.go#L57-L59 | train |
kubernetes-incubator/external-storage | flex/pkg/volume/driver-call.go | NewDriverCallWithTimeout | func (plugin *flexProvisioner) NewDriverCallWithTimeout(execPath, command string, timeout time.Duration) *DriverCall {
return &DriverCall{
Execpath: execPath,
Command: command,
Timeout: timeout,
plugin: plugin,
args: []string{command},
}
} | go | func (plugin *flexProvisioner) NewDriverCallWithTimeout(execPath, command string, timeout time.Duration) *DriverCall {
return &DriverCall{
Execpath: execPath,
Command: command,
Timeout: timeout,
plugin: plugin,
args: []string{command},
}
} | [
"func",
"(",
"plugin",
"*",
"flexProvisioner",
")",
"NewDriverCallWithTimeout",
"(",
"execPath",
",",
"command",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"*",
"DriverCall",
"{",
"return",
"&",
"DriverCall",
"{",
"Execpath",
":",
"execPath",
",",... | //NewDriverCallWithTimeout return the DriverCall with timeout | [
"NewDriverCallWithTimeout",
"return",
"the",
"DriverCall",
"with",
"timeout"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/flex/pkg/volume/driver-call.go#L62-L70 | train |
kubernetes-incubator/external-storage | flex/pkg/volume/driver-call.go | AppendSpec | func (dc *DriverCall) AppendSpec(volumeOptions, extraOptions map[string]string) error {
optionsForDriver, err := NewOptionsForDriver(volumeOptions, extraOptions)
if err != nil {
return err
}
jsonBytes, err := json.Marshal(optionsForDriver)
if err != nil {
return fmt.Errorf("Failed to marshal spec, error: %s",... | go | func (dc *DriverCall) AppendSpec(volumeOptions, extraOptions map[string]string) error {
optionsForDriver, err := NewOptionsForDriver(volumeOptions, extraOptions)
if err != nil {
return err
}
jsonBytes, err := json.Marshal(optionsForDriver)
if err != nil {
return fmt.Errorf("Failed to marshal spec, error: %s",... | [
"func",
"(",
"dc",
"*",
"DriverCall",
")",
"AppendSpec",
"(",
"volumeOptions",
",",
"extraOptions",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"optionsForDriver",
",",
"err",
":=",
"NewOptionsForDriver",
"(",
"volumeOptions",
",",
"extraOptions",
... | //AppendSpec add all option parameters to DriverCall | [
"AppendSpec",
"add",
"all",
"option",
"parameters",
"to",
"DriverCall"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/flex/pkg/volume/driver-call.go#L78-L91 | train |
kubernetes-incubator/external-storage | flex/pkg/volume/driver-call.go | Run | func (dc *DriverCall) Run() (*DriverStatus, error) {
cmd := dc.plugin.runner.Command(dc.Execpath, dc.args...)
timeout := false
if dc.Timeout > 0 {
timer := time.AfterFunc(dc.Timeout, func() {
timeout = true
cmd.Stop()
})
defer timer.Stop()
}
output, execErr := cmd.CombinedOutput()
if execErr != nil ... | go | func (dc *DriverCall) Run() (*DriverStatus, error) {
cmd := dc.plugin.runner.Command(dc.Execpath, dc.args...)
timeout := false
if dc.Timeout > 0 {
timer := time.AfterFunc(dc.Timeout, func() {
timeout = true
cmd.Stop()
})
defer timer.Stop()
}
output, execErr := cmd.CombinedOutput()
if execErr != nil ... | [
"func",
"(",
"dc",
"*",
"DriverCall",
")",
"Run",
"(",
")",
"(",
"*",
"DriverStatus",
",",
"error",
")",
"{",
"cmd",
":=",
"dc",
".",
"plugin",
".",
"runner",
".",
"Command",
"(",
"dc",
".",
"Execpath",
",",
"dc",
".",
"args",
"...",
")",
"\n\n",... | //Run the command with option parameters | [
"Run",
"the",
"command",
"with",
"option",
"parameters"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/flex/pkg/volume/driver-call.go#L94-L127 | train |
kubernetes-incubator/external-storage | flex/pkg/volume/driver-call.go | NewOptionsForDriver | func NewOptionsForDriver(volumeOptions, extraOptions map[string]string) (OptionsForDriver, error) {
options := map[string]string{}
for key, value := range extraOptions {
options[key] = value
}
for key, value := range volumeOptions {
options[key] = value
}
return OptionsForDriver(options), nil
} | go | func NewOptionsForDriver(volumeOptions, extraOptions map[string]string) (OptionsForDriver, error) {
options := map[string]string{}
for key, value := range extraOptions {
options[key] = value
}
for key, value := range volumeOptions {
options[key] = value
}
return OptionsForDriver(options), nil
} | [
"func",
"NewOptionsForDriver",
"(",
"volumeOptions",
",",
"extraOptions",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"OptionsForDriver",
",",
"error",
")",
"{",
"options",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n\n",
"for",
"key",
",",
... | // NewOptionsForDriver assemble all option parameters | [
"NewOptionsForDriver",
"assemble",
"all",
"option",
"parameters"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/flex/pkg/volume/driver-call.go#L133-L145 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | NewJobController | func NewJobController(labelmap map[string]string, config *common.RuntimeConfig) (JobController, error) {
namespace := config.Namespace
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
labelset := labels.Set(labelmap)
optionsModifier := func(options *meta_v1.ListOptions) {
options.... | go | func NewJobController(labelmap map[string]string, config *common.RuntimeConfig) (JobController, error) {
namespace := config.Namespace
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter())
labelset := labels.Set(labelmap)
optionsModifier := func(options *meta_v1.ListOptions) {
options.... | [
"func",
"NewJobController",
"(",
"labelmap",
"map",
"[",
"string",
"]",
"string",
",",
"config",
"*",
"common",
".",
"RuntimeConfig",
")",
"(",
"JobController",
",",
"error",
")",
"{",
"namespace",
":=",
"config",
".",
"Namespace",
"\n",
"queue",
":=",
"wo... | // NewJobController instantiates a new job controller. | [
"NewJobController",
"instantiates",
"a",
"new",
"job",
"controller",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L76-L125 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | processNextItem | func (c *jobController) processNextItem() bool {
key, quit := c.queue.Get()
if quit {
return false
}
defer c.queue.Done(key)
err := c.processItem(key.(string))
if err == nil {
// No error, tell the queue to stop tracking history
c.queue.Forget(key)
} else if c.queue.NumRequeues(key) < maxRetries {
glog... | go | func (c *jobController) processNextItem() bool {
key, quit := c.queue.Get()
if quit {
return false
}
defer c.queue.Done(key)
err := c.processItem(key.(string))
if err == nil {
// No error, tell the queue to stop tracking history
c.queue.Forget(key)
} else if c.queue.NumRequeues(key) < maxRetries {
glog... | [
"func",
"(",
"c",
"*",
"jobController",
")",
"processNextItem",
"(",
")",
"bool",
"{",
"key",
",",
"quit",
":=",
"c",
".",
"queue",
".",
"Get",
"(",
")",
"\n",
"if",
"quit",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"defer",
"c",
".",
"queue",
"... | // processNextItem serially handles the events provided by the informer. | [
"processNextItem",
"serially",
"handles",
"the",
"events",
"provided",
"by",
"the",
"informer",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L146-L170 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | IsCleaningJobRunning | func (c *jobController) IsCleaningJobRunning(pvName string) bool {
jobName := generateCleaningJobName(pvName)
job, err := c.jobLister.Jobs(c.namespace).Get(jobName)
if errors.IsNotFound(err) {
return false
}
if err != nil {
glog.Warningf("Failed to check whether job %s is running (%s). Assuming its still runn... | go | func (c *jobController) IsCleaningJobRunning(pvName string) bool {
jobName := generateCleaningJobName(pvName)
job, err := c.jobLister.Jobs(c.namespace).Get(jobName)
if errors.IsNotFound(err) {
return false
}
if err != nil {
glog.Warningf("Failed to check whether job %s is running (%s). Assuming its still runn... | [
"func",
"(",
"c",
"*",
"jobController",
")",
"IsCleaningJobRunning",
"(",
"pvName",
"string",
")",
"bool",
"{",
"jobName",
":=",
"generateCleaningJobName",
"(",
"pvName",
")",
"\n",
"job",
",",
"err",
":=",
"c",
".",
"jobLister",
".",
"Jobs",
"(",
"c",
"... | // IsCleaningJobRunning returns true if a cleaning job is running for the specified PV. | [
"IsCleaningJobRunning",
"returns",
"true",
"if",
"a",
"cleaning",
"job",
"is",
"running",
"for",
"the",
"specified",
"PV",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L205-L219 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | RemoveJob | func (c *jobController) RemoveJob(pvName string) (CleanupState, *time.Time, error) {
jobName := generateCleaningJobName(pvName)
job, err := c.jobLister.Jobs(c.namespace).Get(jobName)
if err != nil {
if errors.IsNotFound(err) {
return CSNotFound, nil, nil
}
return CSUnknown, nil, fmt.Errorf("Failed to check ... | go | func (c *jobController) RemoveJob(pvName string) (CleanupState, *time.Time, error) {
jobName := generateCleaningJobName(pvName)
job, err := c.jobLister.Jobs(c.namespace).Get(jobName)
if err != nil {
if errors.IsNotFound(err) {
return CSNotFound, nil, nil
}
return CSUnknown, nil, fmt.Errorf("Failed to check ... | [
"func",
"(",
"c",
"*",
"jobController",
")",
"RemoveJob",
"(",
"pvName",
"string",
")",
"(",
"CleanupState",
",",
"*",
"time",
".",
"Time",
",",
"error",
")",
"{",
"jobName",
":=",
"generateCleaningJobName",
"(",
"pvName",
")",
"\n",
"job",
",",
"err",
... | // RemoveJob returns true and deletes the job if the cleaning job has completed. | [
"RemoveJob",
"returns",
"true",
"and",
"deletes",
"the",
"job",
"if",
"the",
"cleaning",
"job",
"has",
"completed",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L222-L253 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | NewCleanupJob | func NewCleanupJob(pv *apiv1.PersistentVolume, volMode apiv1.PersistentVolumeMode, imageName string, nodeName string, namespace string, mountPath string,
config common.MountConfig) (*batch_v1.Job, error) {
priv := true
// Container definition
jobContainer := apiv1.Container{
Name: JobContainerName,
Image: imag... | go | func NewCleanupJob(pv *apiv1.PersistentVolume, volMode apiv1.PersistentVolumeMode, imageName string, nodeName string, namespace string, mountPath string,
config common.MountConfig) (*batch_v1.Job, error) {
priv := true
// Container definition
jobContainer := apiv1.Container{
Name: JobContainerName,
Image: imag... | [
"func",
"NewCleanupJob",
"(",
"pv",
"*",
"apiv1",
".",
"PersistentVolume",
",",
"volMode",
"apiv1",
".",
"PersistentVolumeMode",
",",
"imageName",
"string",
",",
"nodeName",
"string",
",",
"namespace",
"string",
",",
"mountPath",
"string",
",",
"config",
"common... | // NewCleanupJob creates manifest for a cleaning job. | [
"NewCleanupJob",
"creates",
"manifest",
"for",
"a",
"cleaning",
"job",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L256-L325 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | IsCleaningJobRunning | func (c *FakeJobController) IsCleaningJobRunning(pvName string) bool {
c.IsRunningCount++
_, exists := c.pvCleanupRunning[pvName]
return exists
} | go | func (c *FakeJobController) IsCleaningJobRunning(pvName string) bool {
c.IsRunningCount++
_, exists := c.pvCleanupRunning[pvName]
return exists
} | [
"func",
"(",
"c",
"*",
"FakeJobController",
")",
"IsCleaningJobRunning",
"(",
"pvName",
"string",
")",
"bool",
"{",
"c",
".",
"IsRunningCount",
"++",
"\n",
"_",
",",
"exists",
":=",
"c",
".",
"pvCleanupRunning",
"[",
"pvName",
"]",
"\n",
"return",
"exists"... | // IsCleaningJobRunning mocks the interface method. | [
"IsCleaningJobRunning",
"mocks",
"the",
"interface",
"method",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L361-L365 | train |
kubernetes-incubator/external-storage | local-volume/provisioner/pkg/deleter/jobcontroller.go | RemoveJob | func (c *FakeJobController) RemoveJob(pvName string) (CleanupState, *time.Time, error) {
c.RemoveCompletedCount++
status, exists := c.pvCleanupRunning[pvName]
if !exists {
return CSNotFound, nil, nil
}
if status != CSSucceeded {
return CSUnknown, nil, fmt.Errorf("cannot remove job that has not yet completed %s... | go | func (c *FakeJobController) RemoveJob(pvName string) (CleanupState, *time.Time, error) {
c.RemoveCompletedCount++
status, exists := c.pvCleanupRunning[pvName]
if !exists {
return CSNotFound, nil, nil
}
if status != CSSucceeded {
return CSUnknown, nil, fmt.Errorf("cannot remove job that has not yet completed %s... | [
"func",
"(",
"c",
"*",
"FakeJobController",
")",
"RemoveJob",
"(",
"pvName",
"string",
")",
"(",
"CleanupState",
",",
"*",
"time",
".",
"Time",
",",
"error",
")",
"{",
"c",
".",
"RemoveCompletedCount",
"++",
"\n",
"status",
",",
"exists",
":=",
"c",
".... | // RemoveJob mocks the interface method. | [
"RemoveJob",
"mocks",
"the",
"interface",
"method",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/deleter/jobcontroller.go#L368-L378 | train |
kubernetes-incubator/external-storage | openebs/openebs-provisioner.go | NewOpenEBSProvisioner | func NewOpenEBSProvisioner(client kubernetes.Interface) controller.Provisioner {
nodeName := os.Getenv("NODE_NAME")
if nodeName == "" {
glog.Errorf("ENV variable 'NODE_NAME' is not set")
}
var openebsObj mApiv1.OpenEBSVolume
//Get maya-apiserver IP address from cluster
addr, err := openebsObj.GetMayaClusterIP... | go | func NewOpenEBSProvisioner(client kubernetes.Interface) controller.Provisioner {
nodeName := os.Getenv("NODE_NAME")
if nodeName == "" {
glog.Errorf("ENV variable 'NODE_NAME' is not set")
}
var openebsObj mApiv1.OpenEBSVolume
//Get maya-apiserver IP address from cluster
addr, err := openebsObj.GetMayaClusterIP... | [
"func",
"NewOpenEBSProvisioner",
"(",
"client",
"kubernetes",
".",
"Interface",
")",
"controller",
".",
"Provisioner",
"{",
"nodeName",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"if",
"nodeName",
"==",
"\"",
"\"",
"{",
"glog",
".",
"Errorf",
... | // NewOpenEBSProvisioner creates a new openebs provisioner | [
"NewOpenEBSProvisioner",
"creates",
"a",
"new",
"openebs",
"provisioner"
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/openebs/openebs-provisioner.go#L53-L77 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/cache/actual_state_of_world.go | AddSnapshot | func (asw *actualStateOfWorld) AddSnapshot(snapshot *crdv1.VolumeSnapshot) error {
asw.Lock()
defer asw.Unlock()
snapshotName := MakeSnapshotName(snapshot)
glog.Infof("Adding new snapshot to actual state of world: %s", snapshotName)
asw.snapshots[snapshotName] = snapshot
return nil
} | go | func (asw *actualStateOfWorld) AddSnapshot(snapshot *crdv1.VolumeSnapshot) error {
asw.Lock()
defer asw.Unlock()
snapshotName := MakeSnapshotName(snapshot)
glog.Infof("Adding new snapshot to actual state of world: %s", snapshotName)
asw.snapshots[snapshotName] = snapshot
return nil
} | [
"func",
"(",
"asw",
"*",
"actualStateOfWorld",
")",
"AddSnapshot",
"(",
"snapshot",
"*",
"crdv1",
".",
"VolumeSnapshot",
")",
"error",
"{",
"asw",
".",
"Lock",
"(",
")",
"\n",
"defer",
"asw",
".",
"Unlock",
"(",
")",
"\n\n",
"snapshotName",
":=",
"MakeSn... | // Adds a snapshot to the list of snapshots to be created. | [
"Adds",
"a",
"snapshot",
"to",
"the",
"list",
"of",
"snapshots",
"to",
"be",
"created",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/cache/actual_state_of_world.go#L69-L77 | train |
kubernetes-incubator/external-storage | snapshot/pkg/controller/cache/actual_state_of_world.go | DeleteSnapshot | func (asw *actualStateOfWorld) DeleteSnapshot(snapshotName string) error {
asw.Lock()
defer asw.Unlock()
glog.Infof("Deleting snapshot from actual state of world: %s", snapshotName)
delete(asw.snapshots, snapshotName)
return nil
} | go | func (asw *actualStateOfWorld) DeleteSnapshot(snapshotName string) error {
asw.Lock()
defer asw.Unlock()
glog.Infof("Deleting snapshot from actual state of world: %s", snapshotName)
delete(asw.snapshots, snapshotName)
return nil
} | [
"func",
"(",
"asw",
"*",
"actualStateOfWorld",
")",
"DeleteSnapshot",
"(",
"snapshotName",
"string",
")",
"error",
"{",
"asw",
".",
"Lock",
"(",
")",
"\n",
"defer",
"asw",
".",
"Unlock",
"(",
")",
"\n\n",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"... | // Removes the snapshot from the list of existing snapshots. | [
"Removes",
"the",
"snapshot",
"from",
"the",
"list",
"of",
"existing",
"snapshots",
"."
] | fbfedbf60da4e5ee25a3151bfe8504f3e3281319 | https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/controller/cache/actual_state_of_world.go#L80-L87 | train |
asaskevich/govalidator | arrays.go | Each | func Each(array []interface{}, iterator Iterator) {
for index, data := range array {
iterator(data, index)
}
} | go | func Each(array []interface{}, iterator Iterator) {
for index, data := range array {
iterator(data, index)
}
} | [
"func",
"Each",
"(",
"array",
"[",
"]",
"interface",
"{",
"}",
",",
"iterator",
"Iterator",
")",
"{",
"for",
"index",
",",
"data",
":=",
"range",
"array",
"{",
"iterator",
"(",
"data",
",",
"index",
")",
"\n",
"}",
"\n",
"}"
] | // Each iterates over the slice and apply Iterator to every item | [
"Each",
"iterates",
"over",
"the",
"slice",
"and",
"apply",
"Iterator",
"to",
"every",
"item"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/arrays.go#L13-L17 | train |
asaskevich/govalidator | arrays.go | Map | func Map(array []interface{}, iterator ResultIterator) []interface{} {
var result = make([]interface{}, len(array))
for index, data := range array {
result[index] = iterator(data, index)
}
return result
} | go | func Map(array []interface{}, iterator ResultIterator) []interface{} {
var result = make([]interface{}, len(array))
for index, data := range array {
result[index] = iterator(data, index)
}
return result
} | [
"func",
"Map",
"(",
"array",
"[",
"]",
"interface",
"{",
"}",
",",
"iterator",
"ResultIterator",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"var",
"result",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"array",
")",
")",
"\... | // Map iterates over the slice and apply ResultIterator to every item. Returns new slice as a result. | [
"Map",
"iterates",
"over",
"the",
"slice",
"and",
"apply",
"ResultIterator",
"to",
"every",
"item",
".",
"Returns",
"new",
"slice",
"as",
"a",
"result",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/arrays.go#L20-L26 | train |
asaskevich/govalidator | arrays.go | Find | func Find(array []interface{}, iterator ConditionIterator) interface{} {
for index, data := range array {
if iterator(data, index) {
return data
}
}
return nil
} | go | func Find(array []interface{}, iterator ConditionIterator) interface{} {
for index, data := range array {
if iterator(data, index) {
return data
}
}
return nil
} | [
"func",
"Find",
"(",
"array",
"[",
"]",
"interface",
"{",
"}",
",",
"iterator",
"ConditionIterator",
")",
"interface",
"{",
"}",
"{",
"for",
"index",
",",
"data",
":=",
"range",
"array",
"{",
"if",
"iterator",
"(",
"data",
",",
"index",
")",
"{",
"re... | // Find iterates over the slice and apply ConditionIterator to every item. Returns first item that meet ConditionIterator or nil otherwise. | [
"Find",
"iterates",
"over",
"the",
"slice",
"and",
"apply",
"ConditionIterator",
"to",
"every",
"item",
".",
"Returns",
"first",
"item",
"that",
"meet",
"ConditionIterator",
"or",
"nil",
"otherwise",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/arrays.go#L29-L36 | train |
asaskevich/govalidator | arrays.go | Filter | func Filter(array []interface{}, iterator ConditionIterator) []interface{} {
var result = make([]interface{}, 0)
for index, data := range array {
if iterator(data, index) {
result = append(result, data)
}
}
return result
} | go | func Filter(array []interface{}, iterator ConditionIterator) []interface{} {
var result = make([]interface{}, 0)
for index, data := range array {
if iterator(data, index) {
result = append(result, data)
}
}
return result
} | [
"func",
"Filter",
"(",
"array",
"[",
"]",
"interface",
"{",
"}",
",",
"iterator",
"ConditionIterator",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"var",
"result",
"=",
"make",
"(",
"[",
"]",
"interface",
"{",
"}",
",",
"0",
")",
"\n",
"for",
"index... | // Filter iterates over the slice and apply ConditionIterator to every item. Returns new slice. | [
"Filter",
"iterates",
"over",
"the",
"slice",
"and",
"apply",
"ConditionIterator",
"to",
"every",
"item",
".",
"Returns",
"new",
"slice",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/arrays.go#L39-L47 | train |
asaskevich/govalidator | arrays.go | Count | func Count(array []interface{}, iterator ConditionIterator) int {
count := 0
for index, data := range array {
if iterator(data, index) {
count = count + 1
}
}
return count
} | go | func Count(array []interface{}, iterator ConditionIterator) int {
count := 0
for index, data := range array {
if iterator(data, index) {
count = count + 1
}
}
return count
} | [
"func",
"Count",
"(",
"array",
"[",
"]",
"interface",
"{",
"}",
",",
"iterator",
"ConditionIterator",
")",
"int",
"{",
"count",
":=",
"0",
"\n",
"for",
"index",
",",
"data",
":=",
"range",
"array",
"{",
"if",
"iterator",
"(",
"data",
",",
"index",
")... | // Count iterates over the slice and apply ConditionIterator to every item. Returns count of items that meets ConditionIterator. | [
"Count",
"iterates",
"over",
"the",
"slice",
"and",
"apply",
"ConditionIterator",
"to",
"every",
"item",
".",
"Returns",
"count",
"of",
"items",
"that",
"meets",
"ConditionIterator",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/arrays.go#L50-L58 | train |
asaskevich/govalidator | utils.go | LeftTrim | func LeftTrim(str, chars string) string {
if chars == "" {
return strings.TrimLeftFunc(str, unicode.IsSpace)
}
r, _ := regexp.Compile("^[" + chars + "]+")
return r.ReplaceAllString(str, "")
} | go | func LeftTrim(str, chars string) string {
if chars == "" {
return strings.TrimLeftFunc(str, unicode.IsSpace)
}
r, _ := regexp.Compile("^[" + chars + "]+")
return r.ReplaceAllString(str, "")
} | [
"func",
"LeftTrim",
"(",
"str",
",",
"chars",
"string",
")",
"string",
"{",
"if",
"chars",
"==",
"\"",
"\"",
"{",
"return",
"strings",
".",
"TrimLeftFunc",
"(",
"str",
",",
"unicode",
".",
"IsSpace",
")",
"\n",
"}",
"\n",
"r",
",",
"_",
":=",
"rege... | // LeftTrim trim characters from the left-side of the input.
// If second argument is empty, it's will be remove leading spaces. | [
"LeftTrim",
"trim",
"characters",
"from",
"the",
"left",
"-",
"side",
"of",
"the",
"input",
".",
"If",
"second",
"argument",
"is",
"empty",
"it",
"s",
"will",
"be",
"remove",
"leading",
"spaces",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L29-L35 | train |
asaskevich/govalidator | utils.go | RightTrim | func RightTrim(str, chars string) string {
if chars == "" {
return strings.TrimRightFunc(str, unicode.IsSpace)
}
r, _ := regexp.Compile("[" + chars + "]+$")
return r.ReplaceAllString(str, "")
} | go | func RightTrim(str, chars string) string {
if chars == "" {
return strings.TrimRightFunc(str, unicode.IsSpace)
}
r, _ := regexp.Compile("[" + chars + "]+$")
return r.ReplaceAllString(str, "")
} | [
"func",
"RightTrim",
"(",
"str",
",",
"chars",
"string",
")",
"string",
"{",
"if",
"chars",
"==",
"\"",
"\"",
"{",
"return",
"strings",
".",
"TrimRightFunc",
"(",
"str",
",",
"unicode",
".",
"IsSpace",
")",
"\n",
"}",
"\n",
"r",
",",
"_",
":=",
"re... | // RightTrim trim characters from the right-side of the input.
// If second argument is empty, it's will be remove spaces. | [
"RightTrim",
"trim",
"characters",
"from",
"the",
"right",
"-",
"side",
"of",
"the",
"input",
".",
"If",
"second",
"argument",
"is",
"empty",
"it",
"s",
"will",
"be",
"remove",
"spaces",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L39-L45 | train |
asaskevich/govalidator | utils.go | Trim | func Trim(str, chars string) string {
return LeftTrim(RightTrim(str, chars), chars)
} | go | func Trim(str, chars string) string {
return LeftTrim(RightTrim(str, chars), chars)
} | [
"func",
"Trim",
"(",
"str",
",",
"chars",
"string",
")",
"string",
"{",
"return",
"LeftTrim",
"(",
"RightTrim",
"(",
"str",
",",
"chars",
")",
",",
"chars",
")",
"\n",
"}"
] | // Trim trim characters from both sides of the input.
// If second argument is empty, it's will be remove spaces. | [
"Trim",
"trim",
"characters",
"from",
"both",
"sides",
"of",
"the",
"input",
".",
"If",
"second",
"argument",
"is",
"empty",
"it",
"s",
"will",
"be",
"remove",
"spaces",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L49-L51 | train |
asaskevich/govalidator | utils.go | WhiteList | func WhiteList(str, chars string) string {
pattern := "[^" + chars + "]+"
r, _ := regexp.Compile(pattern)
return r.ReplaceAllString(str, "")
} | go | func WhiteList(str, chars string) string {
pattern := "[^" + chars + "]+"
r, _ := regexp.Compile(pattern)
return r.ReplaceAllString(str, "")
} | [
"func",
"WhiteList",
"(",
"str",
",",
"chars",
"string",
")",
"string",
"{",
"pattern",
":=",
"\"",
"\"",
"+",
"chars",
"+",
"\"",
"\"",
"\n",
"r",
",",
"_",
":=",
"regexp",
".",
"Compile",
"(",
"pattern",
")",
"\n",
"return",
"r",
".",
"ReplaceAll... | // WhiteList remove characters that do not appear in the whitelist. | [
"WhiteList",
"remove",
"characters",
"that",
"do",
"not",
"appear",
"in",
"the",
"whitelist",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L54-L58 | train |
asaskevich/govalidator | utils.go | ReplacePattern | func ReplacePattern(str, pattern, replace string) string {
r, _ := regexp.Compile(pattern)
return r.ReplaceAllString(str, replace)
} | go | func ReplacePattern(str, pattern, replace string) string {
r, _ := regexp.Compile(pattern)
return r.ReplaceAllString(str, replace)
} | [
"func",
"ReplacePattern",
"(",
"str",
",",
"pattern",
",",
"replace",
"string",
")",
"string",
"{",
"r",
",",
"_",
":=",
"regexp",
".",
"Compile",
"(",
"pattern",
")",
"\n",
"return",
"r",
".",
"ReplaceAllString",
"(",
"str",
",",
"replace",
")",
"\n",... | // ReplacePattern replace regular expression pattern in string | [
"ReplacePattern",
"replace",
"regular",
"expression",
"pattern",
"in",
"string"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L80-L83 | train |
asaskevich/govalidator | utils.go | Reverse | func Reverse(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
} | go | func Reverse(s string) string {
r := []rune(s)
for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
} | [
"func",
"Reverse",
"(",
"s",
"string",
")",
"string",
"{",
"r",
":=",
"[",
"]",
"rune",
"(",
"s",
")",
"\n",
"for",
"i",
",",
"j",
":=",
"0",
",",
"len",
"(",
"r",
")",
"-",
"1",
";",
"i",
"<",
"j",
";",
"i",
",",
"j",
"=",
"i",
"+",
... | // Reverse return reversed string | [
"Reverse",
"return",
"reversed",
"string"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L124-L130 | train |
asaskevich/govalidator | utils.go | GetLine | func GetLine(s string, index int) (string, error) {
lines := GetLines(s)
if index < 0 || index >= len(lines) {
return "", errors.New("line index out of bounds")
}
return lines[index], nil
} | go | func GetLine(s string, index int) (string, error) {
lines := GetLines(s)
if index < 0 || index >= len(lines) {
return "", errors.New("line index out of bounds")
}
return lines[index], nil
} | [
"func",
"GetLine",
"(",
"s",
"string",
",",
"index",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"lines",
":=",
"GetLines",
"(",
"s",
")",
"\n",
"if",
"index",
"<",
"0",
"||",
"index",
">=",
"len",
"(",
"lines",
")",
"{",
"return",
"\"",
... | // GetLine return specified line of multiline string | [
"GetLine",
"return",
"specified",
"line",
"of",
"multiline",
"string"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L138-L144 | train |
asaskevich/govalidator | utils.go | SafeFileName | func SafeFileName(str string) string {
name := strings.ToLower(str)
name = path.Clean(path.Base(name))
name = strings.Trim(name, " ")
separators, err := regexp.Compile(`[ &_=+:]`)
if err == nil {
name = separators.ReplaceAllString(name, "-")
}
legal, err := regexp.Compile(`[^[:alnum:]-.]`)
if err == nil {
n... | go | func SafeFileName(str string) string {
name := strings.ToLower(str)
name = path.Clean(path.Base(name))
name = strings.Trim(name, " ")
separators, err := regexp.Compile(`[ &_=+:]`)
if err == nil {
name = separators.ReplaceAllString(name, "-")
}
legal, err := regexp.Compile(`[^[:alnum:]-.]`)
if err == nil {
n... | [
"func",
"SafeFileName",
"(",
"str",
"string",
")",
"string",
"{",
"name",
":=",
"strings",
".",
"ToLower",
"(",
"str",
")",
"\n",
"name",
"=",
"path",
".",
"Clean",
"(",
"path",
".",
"Base",
"(",
"name",
")",
")",
"\n",
"name",
"=",
"strings",
".",... | // SafeFileName return safe string that can be used in file names | [
"SafeFileName",
"return",
"safe",
"string",
"that",
"can",
"be",
"used",
"in",
"file",
"names"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L152-L168 | train |
asaskevich/govalidator | utils.go | Truncate | func Truncate(str string, length int, ending string) string {
var aftstr, befstr string
if len(str) > length {
words := strings.Fields(str)
before, present := 0, 0
for i := range words {
befstr = aftstr
before = present
aftstr = aftstr + words[i] + " "
present = len(aftstr)
if present > length &&... | go | func Truncate(str string, length int, ending string) string {
var aftstr, befstr string
if len(str) > length {
words := strings.Fields(str)
before, present := 0, 0
for i := range words {
befstr = aftstr
before = present
aftstr = aftstr + words[i] + " "
present = len(aftstr)
if present > length &&... | [
"func",
"Truncate",
"(",
"str",
"string",
",",
"length",
"int",
",",
"ending",
"string",
")",
"string",
"{",
"var",
"aftstr",
",",
"befstr",
"string",
"\n",
"if",
"len",
"(",
"str",
")",
">",
"length",
"{",
"words",
":=",
"strings",
".",
"Fields",
"(... | // Truncate a string to the closest length without breaking words. | [
"Truncate",
"a",
"string",
"to",
"the",
"closest",
"length",
"without",
"breaking",
"words",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L191-L211 | train |
asaskevich/govalidator | utils.go | PadLeft | func PadLeft(str string, padStr string, padLen int) string {
return buildPadStr(str, padStr, padLen, true, false)
} | go | func PadLeft(str string, padStr string, padLen int) string {
return buildPadStr(str, padStr, padLen, true, false)
} | [
"func",
"PadLeft",
"(",
"str",
"string",
",",
"padStr",
"string",
",",
"padLen",
"int",
")",
"string",
"{",
"return",
"buildPadStr",
"(",
"str",
",",
"padStr",
",",
"padLen",
",",
"true",
",",
"false",
")",
"\n",
"}"
] | // PadLeft pad left side of string if size of string is less then indicated pad length | [
"PadLeft",
"pad",
"left",
"side",
"of",
"string",
"if",
"size",
"of",
"string",
"is",
"less",
"then",
"indicated",
"pad",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L214-L216 | train |
asaskevich/govalidator | utils.go | PadBoth | func PadBoth(str string, padStr string, padLen int) string {
return buildPadStr(str, padStr, padLen, true, true)
} | go | func PadBoth(str string, padStr string, padLen int) string {
return buildPadStr(str, padStr, padLen, true, true)
} | [
"func",
"PadBoth",
"(",
"str",
"string",
",",
"padStr",
"string",
",",
"padLen",
"int",
")",
"string",
"{",
"return",
"buildPadStr",
"(",
"str",
",",
"padStr",
",",
"padLen",
",",
"true",
",",
"true",
")",
"\n",
"}"
] | // PadBoth pad sides of string if size of string is less then indicated pad length | [
"PadBoth",
"pad",
"sides",
"of",
"string",
"if",
"size",
"of",
"string",
"is",
"less",
"then",
"indicated",
"pad",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L224-L226 | train |
asaskevich/govalidator | utils.go | buildPadStr | func buildPadStr(str string, padStr string, padLen int, padLeft bool, padRight bool) string {
// When padded length is less then the current string size
if padLen < utf8.RuneCountInString(str) {
return str
}
padLen -= utf8.RuneCountInString(str)
targetLen := padLen
targetLenLeft := targetLen
targetLenRight... | go | func buildPadStr(str string, padStr string, padLen int, padLeft bool, padRight bool) string {
// When padded length is less then the current string size
if padLen < utf8.RuneCountInString(str) {
return str
}
padLen -= utf8.RuneCountInString(str)
targetLen := padLen
targetLenLeft := targetLen
targetLenRight... | [
"func",
"buildPadStr",
"(",
"str",
"string",
",",
"padStr",
"string",
",",
"padLen",
"int",
",",
"padLeft",
"bool",
",",
"padRight",
"bool",
")",
"string",
"{",
"// When padded length is less then the current string size",
"if",
"padLen",
"<",
"utf8",
".",
"RuneCo... | // PadString either left, right or both sides, not the padding string can be unicode and more then one
// character | [
"PadString",
"either",
"left",
"right",
"or",
"both",
"sides",
"not",
"the",
"padding",
"string",
"can",
"be",
"unicode",
"and",
"more",
"then",
"one",
"character"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L230-L264 | train |
asaskevich/govalidator | utils.go | TruncatingErrorf | func TruncatingErrorf(str string, args ...interface{}) error {
n := strings.Count(str, "%s")
return fmt.Errorf(str, args[:n]...)
} | go | func TruncatingErrorf(str string, args ...interface{}) error {
n := strings.Count(str, "%s")
return fmt.Errorf(str, args[:n]...)
} | [
"func",
"TruncatingErrorf",
"(",
"str",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"n",
":=",
"strings",
".",
"Count",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"return",
"fmt",
".",
"Errorf",
"(",
"str",
",",
"args",
"["... | // TruncatingErrorf removes extra args from fmt.Errorf if not formatted in the str object | [
"TruncatingErrorf",
"removes",
"extra",
"args",
"from",
"fmt",
".",
"Errorf",
"if",
"not",
"formatted",
"in",
"the",
"str",
"object"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/utils.go#L267-L270 | train |
asaskevich/govalidator | converter.go | ToJSON | func ToJSON(obj interface{}) (string, error) {
res, err := json.Marshal(obj)
if err != nil {
res = []byte("")
}
return string(res), err
} | go | func ToJSON(obj interface{}) (string, error) {
res, err := json.Marshal(obj)
if err != nil {
res = []byte("")
}
return string(res), err
} | [
"func",
"ToJSON",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"string",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"res",
"=",
"[",
"]",
"byte",
"(",
"\"",
"... | // ToJSON convert the input to a valid JSON string | [
"ToJSON",
"convert",
"the",
"input",
"to",
"a",
"valid",
"JSON",
"string"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/converter.go#L17-L23 | train |
asaskevich/govalidator | converter.go | ToFloat | func ToFloat(str string) (float64, error) {
res, err := strconv.ParseFloat(str, 64)
if err != nil {
res = 0.0
}
return res, err
} | go | func ToFloat(str string) (float64, error) {
res, err := strconv.ParseFloat(str, 64)
if err != nil {
res = 0.0
}
return res, err
} | [
"func",
"ToFloat",
"(",
"str",
"string",
")",
"(",
"float64",
",",
"error",
")",
"{",
"res",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"str",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"res",
"=",
"0.0",
"\n",
"}",
"\n",
"r... | // ToFloat convert the input string to a float, or 0.0 if the input is not a float. | [
"ToFloat",
"convert",
"the",
"input",
"string",
"to",
"a",
"float",
"or",
"0",
".",
"0",
"if",
"the",
"input",
"is",
"not",
"a",
"float",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/converter.go#L26-L32 | train |
asaskevich/govalidator | converter.go | ToInt | func ToInt(value interface{}) (res int64, err error) {
val := reflect.ValueOf(value)
switch value.(type) {
case int, int8, int16, int32, int64:
res = val.Int()
case uint, uint8, uint16, uint32, uint64:
res = int64(val.Uint())
case string:
if IsInt(val.String()) {
res, err = strconv.ParseInt(val.String(),... | go | func ToInt(value interface{}) (res int64, err error) {
val := reflect.ValueOf(value)
switch value.(type) {
case int, int8, int16, int32, int64:
res = val.Int()
case uint, uint8, uint16, uint32, uint64:
res = int64(val.Uint())
case string:
if IsInt(val.String()) {
res, err = strconv.ParseInt(val.String(),... | [
"func",
"ToInt",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"res",
"int64",
",",
"err",
"error",
")",
"{",
"val",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n\n",
"switch",
"value",
".",
"(",
"type",
")",
"{",
"case",
"int",
",",
"... | // ToInt convert the input string or any int type to an integer type 64, or 0 if the input is not an integer. | [
"ToInt",
"convert",
"the",
"input",
"string",
"or",
"any",
"int",
"type",
"to",
"an",
"integer",
"type",
"64",
"or",
"0",
"if",
"the",
"input",
"is",
"not",
"an",
"integer",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/converter.go#L35-L59 | train |
asaskevich/govalidator | numerics.go | InRange | func InRange(value interface{}, left interface{}, right interface{}) bool {
reflectValue := reflect.TypeOf(value).Kind()
reflectLeft := reflect.TypeOf(left).Kind()
reflectRight := reflect.TypeOf(right).Kind()
if reflectValue == reflect.Int && reflectLeft == reflect.Int && reflectRight == reflect.Int {
return In... | go | func InRange(value interface{}, left interface{}, right interface{}) bool {
reflectValue := reflect.TypeOf(value).Kind()
reflectLeft := reflect.TypeOf(left).Kind()
reflectRight := reflect.TypeOf(right).Kind()
if reflectValue == reflect.Int && reflectLeft == reflect.Int && reflectRight == reflect.Int {
return In... | [
"func",
"InRange",
"(",
"value",
"interface",
"{",
"}",
",",
"left",
"interface",
"{",
"}",
",",
"right",
"interface",
"{",
"}",
")",
"bool",
"{",
"reflectValue",
":=",
"reflect",
".",
"TypeOf",
"(",
"value",
")",
".",
"Kind",
"(",
")",
"\n",
"reflec... | // InRange returns true if value lies between left and right border, generic type to handle int, float32 or float64, all types must the same type | [
"InRange",
"returns",
"true",
"if",
"value",
"lies",
"between",
"left",
"and",
"right",
"border",
"generic",
"type",
"to",
"handle",
"int",
"float32",
"or",
"float64",
"all",
"types",
"must",
"the",
"same",
"type"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/numerics.go#L72-L87 | train |
asaskevich/govalidator | validator.go | IsExistingEmail | func IsExistingEmail(email string) bool {
if len(email) < 6 || len(email) > 254 {
return false
}
at := strings.LastIndex(email, "@")
if at <= 0 || at > len(email)-3 {
return false
}
user := email[:at]
host := email[at+1:]
if len(user) > 64 {
return false
}
if userDotRegexp.MatchString(user) || !userReg... | go | func IsExistingEmail(email string) bool {
if len(email) < 6 || len(email) > 254 {
return false
}
at := strings.LastIndex(email, "@")
if at <= 0 || at > len(email)-3 {
return false
}
user := email[:at]
host := email[at+1:]
if len(user) > 64 {
return false
}
if userDotRegexp.MatchString(user) || !userReg... | [
"func",
"IsExistingEmail",
"(",
"email",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"email",
")",
"<",
"6",
"||",
"len",
"(",
"email",
")",
">",
"254",
"{",
"return",
"false",
"\n",
"}",
"\n",
"at",
":=",
"strings",
".",
"LastIndex",
"(",
"email... | // IsExistingEmail check if the string is an email of existing domain | [
"IsExistingEmail",
"check",
"if",
"the",
"string",
"is",
"an",
"email",
"of",
"existing",
"domain"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L73-L101 | train |
asaskevich/govalidator | validator.go | IsRequestURL | func IsRequestURL(rawurl string) bool {
url, err := url.ParseRequestURI(rawurl)
if err != nil {
return false //Couldn't even parse the rawurl
}
if len(url.Scheme) == 0 {
return false //No Scheme found
}
return true
} | go | func IsRequestURL(rawurl string) bool {
url, err := url.ParseRequestURI(rawurl)
if err != nil {
return false //Couldn't even parse the rawurl
}
if len(url.Scheme) == 0 {
return false //No Scheme found
}
return true
} | [
"func",
"IsRequestURL",
"(",
"rawurl",
"string",
")",
"bool",
"{",
"url",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"rawurl",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"//Couldn't even parse the rawurl",
"\n",
"}",
"\n",
"if"... | // IsRequestURL check if the string rawurl, assuming
// it was received in an HTTP request, is a valid
// URL confirm to RFC 3986 | [
"IsRequestURL",
"check",
"if",
"the",
"string",
"rawurl",
"assuming",
"it",
"was",
"received",
"in",
"an",
"HTTP",
"request",
"is",
"a",
"valid",
"URL",
"confirm",
"to",
"RFC",
"3986"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L130-L139 | train |
asaskevich/govalidator | validator.go | IsRequestURI | func IsRequestURI(rawurl string) bool {
_, err := url.ParseRequestURI(rawurl)
return err == nil
} | go | func IsRequestURI(rawurl string) bool {
_, err := url.ParseRequestURI(rawurl)
return err == nil
} | [
"func",
"IsRequestURI",
"(",
"rawurl",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"rawurl",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // IsRequestURI check if the string rawurl, assuming
// it was received in an HTTP request, is an
// absolute URI or an absolute path. | [
"IsRequestURI",
"check",
"if",
"the",
"string",
"rawurl",
"assuming",
"it",
"was",
"received",
"in",
"an",
"HTTP",
"request",
"is",
"an",
"absolute",
"URI",
"or",
"an",
"absolute",
"path",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L144-L147 | train |
asaskevich/govalidator | validator.go | IsLowerCase | func IsLowerCase(str string) bool {
if IsNull(str) {
return true
}
return str == strings.ToLower(str)
} | go | func IsLowerCase(str string) bool {
if IsNull(str) {
return true
}
return str == strings.ToLower(str)
} | [
"func",
"IsLowerCase",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"str",
"==",
"strings",
".",
"ToLower",
"(",
"str",
")",
"\n",
"}"
] | // IsLowerCase check if the string is lowercase. Empty string is valid. | [
"IsLowerCase",
"check",
"if",
"the",
"string",
"is",
"lowercase",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L262-L267 | train |
asaskevich/govalidator | validator.go | IsUpperCase | func IsUpperCase(str string) bool {
if IsNull(str) {
return true
}
return str == strings.ToUpper(str)
} | go | func IsUpperCase(str string) bool {
if IsNull(str) {
return true
}
return str == strings.ToUpper(str)
} | [
"func",
"IsUpperCase",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"str",
"==",
"strings",
".",
"ToUpper",
"(",
"str",
")",
"\n",
"}"
] | // IsUpperCase check if the string is uppercase. Empty string is valid. | [
"IsUpperCase",
"check",
"if",
"the",
"string",
"is",
"uppercase",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L270-L275 | train |
asaskevich/govalidator | validator.go | HasLowerCase | func HasLowerCase(str string) bool {
if IsNull(str) {
return true
}
return rxHasLowerCase.MatchString(str)
} | go | func HasLowerCase(str string) bool {
if IsNull(str) {
return true
}
return rxHasLowerCase.MatchString(str)
} | [
"func",
"HasLowerCase",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxHasLowerCase",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // HasLowerCase check if the string contains at least 1 lowercase. Empty string is valid. | [
"HasLowerCase",
"check",
"if",
"the",
"string",
"contains",
"at",
"least",
"1",
"lowercase",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L278-L283 | train |
asaskevich/govalidator | validator.go | HasUpperCase | func HasUpperCase(str string) bool {
if IsNull(str) {
return true
}
return rxHasUpperCase.MatchString(str)
} | go | func HasUpperCase(str string) bool {
if IsNull(str) {
return true
}
return rxHasUpperCase.MatchString(str)
} | [
"func",
"HasUpperCase",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxHasUpperCase",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // HasUpperCase check if the string contians as least 1 uppercase. Empty string is valid. | [
"HasUpperCase",
"check",
"if",
"the",
"string",
"contians",
"as",
"least",
"1",
"uppercase",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L286-L291 | train |
asaskevich/govalidator | validator.go | IsInt | func IsInt(str string) bool {
if IsNull(str) {
return true
}
return rxInt.MatchString(str)
} | go | func IsInt(str string) bool {
if IsNull(str) {
return true
}
return rxInt.MatchString(str)
} | [
"func",
"IsInt",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxInt",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // IsInt check if the string is an integer. Empty string is valid. | [
"IsInt",
"check",
"if",
"the",
"string",
"is",
"an",
"integer",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L294-L299 | train |
asaskevich/govalidator | validator.go | IsFullWidth | func IsFullWidth(str string) bool {
if IsNull(str) {
return true
}
return rxFullWidth.MatchString(str)
} | go | func IsFullWidth(str string) bool {
if IsNull(str) {
return true
}
return rxFullWidth.MatchString(str)
} | [
"func",
"IsFullWidth",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxFullWidth",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // IsFullWidth check if the string contains any full-width chars. Empty string is valid. | [
"IsFullWidth",
"check",
"if",
"the",
"string",
"contains",
"any",
"full",
"-",
"width",
"chars",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L464-L469 | train |
asaskevich/govalidator | validator.go | IsHalfWidth | func IsHalfWidth(str string) bool {
if IsNull(str) {
return true
}
return rxHalfWidth.MatchString(str)
} | go | func IsHalfWidth(str string) bool {
if IsNull(str) {
return true
}
return rxHalfWidth.MatchString(str)
} | [
"func",
"IsHalfWidth",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxHalfWidth",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // IsHalfWidth check if the string contains any half-width chars. Empty string is valid. | [
"IsHalfWidth",
"check",
"if",
"the",
"string",
"contains",
"any",
"half",
"-",
"width",
"chars",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L472-L477 | train |
asaskevich/govalidator | validator.go | IsVariableWidth | func IsVariableWidth(str string) bool {
if IsNull(str) {
return true
}
return rxHalfWidth.MatchString(str) && rxFullWidth.MatchString(str)
} | go | func IsVariableWidth(str string) bool {
if IsNull(str) {
return true
}
return rxHalfWidth.MatchString(str) && rxFullWidth.MatchString(str)
} | [
"func",
"IsVariableWidth",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"IsNull",
"(",
"str",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"rxHalfWidth",
".",
"MatchString",
"(",
"str",
")",
"&&",
"rxFullWidth",
".",
"MatchString",
"(",
"str",... | // IsVariableWidth check if the string contains a mixture of full and half-width chars. Empty string is valid. | [
"IsVariableWidth",
"check",
"if",
"the",
"string",
"contains",
"a",
"mixture",
"of",
"full",
"and",
"half",
"-",
"width",
"chars",
".",
"Empty",
"string",
"is",
"valid",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L480-L485 | train |
asaskevich/govalidator | validator.go | IsFilePath | func IsFilePath(str string) (bool, int) {
if rxWinPath.MatchString(str) {
//check windows path limit see:
// http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath
if len(str[3:]) > 32767 {
return false, Win
}
return true, Win
} else if rxUnixPath.MatchString(str) {
return true, Unix
}
... | go | func IsFilePath(str string) (bool, int) {
if rxWinPath.MatchString(str) {
//check windows path limit see:
// http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath
if len(str[3:]) > 32767 {
return false, Win
}
return true, Win
} else if rxUnixPath.MatchString(str) {
return true, Unix
}
... | [
"func",
"IsFilePath",
"(",
"str",
"string",
")",
"(",
"bool",
",",
"int",
")",
"{",
"if",
"rxWinPath",
".",
"MatchString",
"(",
"str",
")",
"{",
"//check windows path limit see:",
"// http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath",
"if",
"len",
... | // IsFilePath check is a string is Win or Unix file path and returns it's type. | [
"IsFilePath",
"check",
"is",
"a",
"string",
"is",
"Win",
"or",
"Unix",
"file",
"path",
"and",
"returns",
"it",
"s",
"type",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L493-L505 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.