id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,700 | 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 |
25,701 | 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 |
25,702 | 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 |
25,703 | 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 |
25,704 | 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 |
25,705 | 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 |
25,706 | 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 |
25,707 | 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 |
25,708 | 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 |
25,709 | 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 |
25,710 | 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 |
25,711 | 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 |
25,712 | 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 |
25,713 | 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 |
25,714 | 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 |
25,715 | 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 |
25,716 | 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 |
25,717 | 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 |
25,718 | 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 |
25,719 | 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 |
25,720 | 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 |
25,721 | 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 |
25,722 | 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 |
25,723 | 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 |
25,724 | 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 |
25,725 | 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 |
25,726 | 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 |
25,727 | 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 |
25,728 | 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 |
25,729 | 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 |
25,730 | 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 |
25,731 | 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 |
25,732 | 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 |
25,733 | 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 |
25,734 | 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 |
25,735 | 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 |
25,736 | 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 |
25,737 | 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 |
25,738 | 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 |
25,739 | 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 |
25,740 | 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 |
25,741 | 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 |
25,742 | 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 |
25,743 | 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 |
25,744 | 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 |
25,745 | 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 |
25,746 | 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 |
25,747 | 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 |
25,748 | 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 |
25,749 | 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 |
25,750 | 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 |
25,751 | 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 |
25,752 | 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 |
25,753 | 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 |
25,754 | 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 |
25,755 | 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 |
25,756 | 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 |
25,757 | 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 |
25,758 | 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 |
25,759 | 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 |
25,760 | 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 |
25,761 | 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 |
25,762 | 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 |
25,763 | 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 |
25,764 | 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 |
25,765 | 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 |
25,766 | 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 |
25,767 | 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 |
25,768 | 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 |
25,769 | 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 |
25,770 | 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 |
25,771 | 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 |
25,772 | 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 |
25,773 | 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 |
25,774 | 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 |
25,775 | 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 |
25,776 | asaskevich/govalidator | validator.go | IsDataURI | func IsDataURI(str string) bool {
dataURI := strings.Split(str, ",")
if !rxDataURI.MatchString(dataURI[0]) {
return false
}
return IsBase64(dataURI[1])
} | go | func IsDataURI(str string) bool {
dataURI := strings.Split(str, ",")
if !rxDataURI.MatchString(dataURI[0]) {
return false
}
return IsBase64(dataURI[1])
} | [
"func",
"IsDataURI",
"(",
"str",
"string",
")",
"bool",
"{",
"dataURI",
":=",
"strings",
".",
"Split",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"if",
"!",
"rxDataURI",
".",
"MatchString",
"(",
"dataURI",
"[",
"0",
"]",
")",
"{",
"return",
"false",
"... | // IsDataURI checks if a string is base64 encoded data URI such as an image | [
"IsDataURI",
"checks",
"if",
"a",
"string",
"is",
"base64",
"encoded",
"data",
"URI",
"such",
"as",
"an",
"image"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L508-L514 |
25,777 | asaskevich/govalidator | validator.go | IsISO3166Alpha2 | func IsISO3166Alpha2(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | go | func IsISO3166Alpha2(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | [
"func",
"IsISO3166Alpha2",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO3166List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha2Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO3166Alpha2 checks if a string is valid two-letter country code | [
"IsISO3166Alpha2",
"checks",
"if",
"a",
"string",
"is",
"valid",
"two",
"-",
"letter",
"country",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L517-L524 |
25,778 | asaskevich/govalidator | validator.go | IsISO3166Alpha3 | func IsISO3166Alpha3(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha3Code {
return true
}
}
return false
} | go | func IsISO3166Alpha3(str string) bool {
for _, entry := range ISO3166List {
if str == entry.Alpha3Code {
return true
}
}
return false
} | [
"func",
"IsISO3166Alpha3",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO3166List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha3Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO3166Alpha3 checks if a string is valid three-letter country code | [
"IsISO3166Alpha3",
"checks",
"if",
"a",
"string",
"is",
"valid",
"three",
"-",
"letter",
"country",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L527-L534 |
25,779 | asaskevich/govalidator | validator.go | IsISO693Alpha2 | func IsISO693Alpha2(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | go | func IsISO693Alpha2(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha2Code {
return true
}
}
return false
} | [
"func",
"IsISO693Alpha2",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO693List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha2Code",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"... | // IsISO693Alpha2 checks if a string is valid two-letter language code | [
"IsISO693Alpha2",
"checks",
"if",
"a",
"string",
"is",
"valid",
"two",
"-",
"letter",
"language",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L537-L544 |
25,780 | asaskevich/govalidator | validator.go | IsISO693Alpha3b | func IsISO693Alpha3b(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha3bCode {
return true
}
}
return false
} | go | func IsISO693Alpha3b(str string) bool {
for _, entry := range ISO693List {
if str == entry.Alpha3bCode {
return true
}
}
return false
} | [
"func",
"IsISO693Alpha3b",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"entry",
":=",
"range",
"ISO693List",
"{",
"if",
"str",
"==",
"entry",
".",
"Alpha3bCode",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
... | // IsISO693Alpha3b checks if a string is valid three-letter language code | [
"IsISO693Alpha3b",
"checks",
"if",
"a",
"string",
"is",
"valid",
"three",
"-",
"letter",
"language",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L547-L554 |
25,781 | asaskevich/govalidator | validator.go | IsPort | func IsPort(str string) bool {
if i, err := strconv.Atoi(str); err == nil && i > 0 && i < 65536 {
return true
}
return false
} | go | func IsPort(str string) bool {
if i, err := strconv.Atoi(str); err == nil && i > 0 && i < 65536 {
return true
}
return false
} | [
"func",
"IsPort",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"i",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"str",
")",
";",
"err",
"==",
"nil",
"&&",
"i",
">",
"0",
"&&",
"i",
"<",
"65536",
"{",
"return",
"true",
"\n",
"}",
"\n",
"re... | // IsPort checks if a string represents a valid port | [
"IsPort",
"checks",
"if",
"a",
"string",
"represents",
"a",
"valid",
"port"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L608-L613 |
25,782 | asaskevich/govalidator | validator.go | IsIPv4 | func IsIPv4(str string) bool {
ip := net.ParseIP(str)
return ip != nil && strings.Contains(str, ".")
} | go | func IsIPv4(str string) bool {
ip := net.ParseIP(str)
return ip != nil && strings.Contains(str, ".")
} | [
"func",
"IsIPv4",
"(",
"str",
"string",
")",
"bool",
"{",
"ip",
":=",
"net",
".",
"ParseIP",
"(",
"str",
")",
"\n",
"return",
"ip",
"!=",
"nil",
"&&",
"strings",
".",
"Contains",
"(",
"str",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // IsIPv4 check if the string is an IP version 4. | [
"IsIPv4",
"check",
"if",
"the",
"string",
"is",
"an",
"IP",
"version",
"4",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L616-L619 |
25,783 | asaskevich/govalidator | validator.go | IsRsaPublicKey | func IsRsaPublicKey(str string, keylen int) bool {
bb := bytes.NewBufferString(str)
pemBytes, err := ioutil.ReadAll(bb)
if err != nil {
return false
}
block, _ := pem.Decode(pemBytes)
if block != nil && block.Type != "PUBLIC KEY" {
return false
}
var der []byte
if block != nil {
der = block.Bytes
} els... | go | func IsRsaPublicKey(str string, keylen int) bool {
bb := bytes.NewBufferString(str)
pemBytes, err := ioutil.ReadAll(bb)
if err != nil {
return false
}
block, _ := pem.Decode(pemBytes)
if block != nil && block.Type != "PUBLIC KEY" {
return false
}
var der []byte
if block != nil {
der = block.Bytes
} els... | [
"func",
"IsRsaPublicKey",
"(",
"str",
"string",
",",
"keylen",
"int",
")",
"bool",
"{",
"bb",
":=",
"bytes",
".",
"NewBufferString",
"(",
"str",
")",
"\n",
"pemBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"bb",
")",
"\n",
"if",
"err",
"!=... | // IsRsaPublicKey check if a string is valid public key with provided length | [
"IsRsaPublicKey",
"check",
"if",
"a",
"string",
"is",
"valid",
"public",
"key",
"with",
"provided",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L667-L698 |
25,784 | asaskevich/govalidator | validator.go | ValidateStruct | func ValidateStruct(s interface{}) (bool, error) {
if s == nil {
return true, nil
}
result := true
var err error
val := reflect.ValueOf(s)
if val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr {
val = val.Elem()
}
// we only accept structs
if val.Kind() != reflect.Struct {
return false, fmt.Err... | go | func ValidateStruct(s interface{}) (bool, error) {
if s == nil {
return true, nil
}
result := true
var err error
val := reflect.ValueOf(s)
if val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr {
val = val.Elem()
}
// we only accept structs
if val.Kind() != reflect.Struct {
return false, fmt.Err... | [
"func",
"ValidateStruct",
"(",
"s",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"result",
":=",
"true",
"\n",
"var",
"err",
"error",
"\n",
"val",
":=... | // ValidateStruct use tags for fields.
// result will be equal to `false` if there are any errors. | [
"ValidateStruct",
"use",
"tags",
"for",
"fields",
".",
"result",
"will",
"be",
"equal",
"to",
"false",
"if",
"there",
"are",
"any",
"errors",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L738-L804 |
25,785 | asaskevich/govalidator | validator.go | IsSSN | func IsSSN(str string) bool {
if str == "" || len(str) != 11 {
return false
}
return rxSSN.MatchString(str)
} | go | func IsSSN(str string) bool {
if str == "" || len(str) != 11 {
return false
}
return rxSSN.MatchString(str)
} | [
"func",
"IsSSN",
"(",
"str",
"string",
")",
"bool",
"{",
"if",
"str",
"==",
"\"",
"\"",
"||",
"len",
"(",
"str",
")",
"!=",
"11",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"rxSSN",
".",
"MatchString",
"(",
"str",
")",
"\n",
"}"
] | // IsSSN will validate the given string as a U.S. Social Security Number | [
"IsSSN",
"will",
"validate",
"the",
"given",
"string",
"as",
"a",
"U",
".",
"S",
".",
"Social",
"Security",
"Number"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L847-L852 |
25,786 | asaskevich/govalidator | validator.go | IsTime | func IsTime(str string, format string) bool {
_, err := time.Parse(format, str)
return err == nil
} | go | func IsTime(str string, format string) bool {
_, err := time.Parse(format, str)
return err == nil
} | [
"func",
"IsTime",
"(",
"str",
"string",
",",
"format",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"time",
".",
"Parse",
"(",
"format",
",",
"str",
")",
"\n",
"return",
"err",
"==",
"nil",
"\n",
"}"
] | // IsTime check if string is valid according to given format | [
"IsTime",
"check",
"if",
"string",
"is",
"valid",
"according",
"to",
"given",
"format"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L860-L863 |
25,787 | asaskevich/govalidator | validator.go | IsISO4217 | func IsISO4217(str string) bool {
for _, currency := range ISO4217List {
if str == currency {
return true
}
}
return false
} | go | func IsISO4217(str string) bool {
for _, currency := range ISO4217List {
if str == currency {
return true
}
}
return false
} | [
"func",
"IsISO4217",
"(",
"str",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"currency",
":=",
"range",
"ISO4217List",
"{",
"if",
"str",
"==",
"currency",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // IsISO4217 check if string is valid ISO currency code | [
"IsISO4217",
"check",
"if",
"string",
"is",
"valid",
"ISO",
"currency",
"code"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L876-L884 |
25,788 | asaskevich/govalidator | validator.go | ByteLength | func ByteLength(str string, params ...string) bool {
if len(params) == 2 {
min, _ := ToInt(params[0])
max, _ := ToInt(params[1])
return len(str) >= int(min) && len(str) <= int(max)
}
return false
} | go | func ByteLength(str string, params ...string) bool {
if len(params) == 2 {
min, _ := ToInt(params[0])
max, _ := ToInt(params[1])
return len(str) >= int(min) && len(str) <= int(max)
}
return false
} | [
"func",
"ByteLength",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"2",
"{",
"min",
",",
"_",
":=",
"ToInt",
"(",
"params",
"[",
"0",
"]",
")",
"\n",
"max",
",",
"_",
":=",
"ToIn... | // ByteLength check string's length | [
"ByteLength",
"check",
"string",
"s",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L887-L895 |
25,789 | asaskevich/govalidator | validator.go | IsRsaPub | func IsRsaPub(str string, params ...string) bool {
if len(params) == 1 {
len, _ := ToInt(params[0])
return IsRsaPublicKey(str, int(len))
}
return false
} | go | func IsRsaPub(str string, params ...string) bool {
if len(params) == 1 {
len, _ := ToInt(params[0])
return IsRsaPublicKey(str, int(len))
}
return false
} | [
"func",
"IsRsaPub",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"1",
"{",
"len",
",",
"_",
":=",
"ToInt",
"(",
"params",
"[",
"0",
"]",
")",
"\n",
"return",
"IsRsaPublicKey",
"(",
... | // IsRsaPub check whether string is valid RSA key
// Alias for IsRsaPublicKey | [
"IsRsaPub",
"check",
"whether",
"string",
"is",
"valid",
"RSA",
"key",
"Alias",
"for",
"IsRsaPublicKey"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L905-L912 |
25,790 | asaskevich/govalidator | validator.go | StringMatches | func StringMatches(s string, params ...string) bool {
if len(params) == 1 {
pattern := params[0]
return Matches(s, pattern)
}
return false
} | go | func StringMatches(s string, params ...string) bool {
if len(params) == 1 {
pattern := params[0]
return Matches(s, pattern)
}
return false
} | [
"func",
"StringMatches",
"(",
"s",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"1",
"{",
"pattern",
":=",
"params",
"[",
"0",
"]",
"\n",
"return",
"Matches",
"(",
"s",
",",
"pattern",
")",
"\n"... | // StringMatches checks if a string matches a given pattern. | [
"StringMatches",
"checks",
"if",
"a",
"string",
"matches",
"a",
"given",
"pattern",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L915-L921 |
25,791 | asaskevich/govalidator | validator.go | Range | func Range(str string, params ...string) bool {
if len(params) == 2 {
value, _ := ToFloat(str)
min, _ := ToFloat(params[0])
max, _ := ToFloat(params[1])
return InRange(value, min, max)
}
return false
} | go | func Range(str string, params ...string) bool {
if len(params) == 2 {
value, _ := ToFloat(str)
min, _ := ToFloat(params[0])
max, _ := ToFloat(params[1])
return InRange(value, min, max)
}
return false
} | [
"func",
"Range",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"if",
"len",
"(",
"params",
")",
"==",
"2",
"{",
"value",
",",
"_",
":=",
"ToFloat",
"(",
"str",
")",
"\n",
"min",
",",
"_",
":=",
"ToFloat",
"(",
"params",
... | // Range check string's length | [
"Range",
"check",
"string",
"s",
"length"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L937-L946 |
25,792 | asaskevich/govalidator | validator.go | IsIn | func IsIn(str string, params ...string) bool {
for _, param := range params {
if str == param {
return true
}
}
return false
} | go | func IsIn(str string, params ...string) bool {
for _, param := range params {
if str == param {
return true
}
}
return false
} | [
"func",
"IsIn",
"(",
"str",
"string",
",",
"params",
"...",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"param",
":=",
"range",
"params",
"{",
"if",
"str",
"==",
"param",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"false",
"\n"... | // IsIn check if string str is a member of the set of strings params | [
"IsIn",
"check",
"if",
"string",
"str",
"is",
"a",
"member",
"of",
"the",
"set",
"of",
"strings",
"params"
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L961-L969 |
25,793 | asaskevich/govalidator | validator.go | ErrorByField | func ErrorByField(e error, field string) string {
if e == nil {
return ""
}
return ErrorsByField(e)[field]
} | go | func ErrorByField(e error, field string) string {
if e == nil {
return ""
}
return ErrorsByField(e)[field]
} | [
"func",
"ErrorByField",
"(",
"e",
"error",
",",
"field",
"string",
")",
"string",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"ErrorsByField",
"(",
"e",
")",
"[",
"field",
"]",
"\n",
"}"
] | // ErrorByField returns error for specified field of the struct
// validated by ValidateStruct or empty string if there are no errors
// or this field doesn't exists or doesn't have any errors. | [
"ErrorByField",
"returns",
"error",
"for",
"specified",
"field",
"of",
"the",
"struct",
"validated",
"by",
"ValidateStruct",
"or",
"empty",
"string",
"if",
"there",
"are",
"no",
"errors",
"or",
"this",
"field",
"doesn",
"t",
"exists",
"or",
"doesn",
"t",
"ha... | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L1239-L1244 |
25,794 | asaskevich/govalidator | validator.go | ErrorsByField | func ErrorsByField(e error) map[string]string {
m := make(map[string]string)
if e == nil {
return m
}
// prototype for ValidateStruct
switch e.(type) {
case Error:
m[e.(Error).Name] = e.(Error).Err.Error()
case Errors:
for _, item := range e.(Errors).Errors() {
n := ErrorsByField(item)
for k, v := r... | go | func ErrorsByField(e error) map[string]string {
m := make(map[string]string)
if e == nil {
return m
}
// prototype for ValidateStruct
switch e.(type) {
case Error:
m[e.(Error).Name] = e.(Error).Err.Error()
case Errors:
for _, item := range e.(Errors).Errors() {
n := ErrorsByField(item)
for k, v := r... | [
"func",
"ErrorsByField",
"(",
"e",
"error",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"e",
"==",
"nil",
"{",
"return",
"m",
"\n",
"}",
"\n",
"// prototype for Validate... | // ErrorsByField returns map of errors of the struct validated
// by ValidateStruct or empty map if there are no errors. | [
"ErrorsByField",
"returns",
"map",
"of",
"errors",
"of",
"the",
"struct",
"validated",
"by",
"ValidateStruct",
"or",
"empty",
"map",
"if",
"there",
"are",
"no",
"errors",
"."
] | f61b66f89f4a311bef65f13e575bcf1a2ffadda6 | https://github.com/asaskevich/govalidator/blob/f61b66f89f4a311bef65f13e575bcf1a2ffadda6/validator.go#L1248-L1268 |
25,795 | beego/bee | cmd/commands/dlv/dlv_amd64.go | buildDebug | func buildDebug() (string, error) {
args := []string{"-gcflags", "-N -l", "-o", "debug"}
args = append(args, utils.SplitQuotedFields("-ldflags='-linkmode internal'")...)
args = append(args, packageName)
if err := utils.GoCommand("build", args...); err != nil {
return "", err
}
fp, err := filepath.Abs("./debug"... | go | func buildDebug() (string, error) {
args := []string{"-gcflags", "-N -l", "-o", "debug"}
args = append(args, utils.SplitQuotedFields("-ldflags='-linkmode internal'")...)
args = append(args, packageName)
if err := utils.GoCommand("build", args...); err != nil {
return "", err
}
fp, err := filepath.Abs("./debug"... | [
"func",
"buildDebug",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"args",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"args",
"=",
"append",
"(",
"args",
",",
"utils",
".",
"Sp... | // buildDebug builds a debug binary in the current working directory | [
"buildDebug",
"builds",
"a",
"debug",
"binary",
"in",
"the",
"current",
"working",
"directory"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L86-L99 |
25,796 | beego/bee | cmd/commands/dlv/dlv_amd64.go | loadPathsToWatch | func loadPathsToWatch(paths *[]string) error {
directory, err := os.Getwd()
if err != nil {
return err
}
filepath.Walk(directory, func(path string, info os.FileInfo, _ error) error {
if strings.HasSuffix(info.Name(), "docs") {
return filepath.SkipDir
}
if strings.HasSuffix(info.Name(), "swagger") {
re... | go | func loadPathsToWatch(paths *[]string) error {
directory, err := os.Getwd()
if err != nil {
return err
}
filepath.Walk(directory, func(path string, info os.FileInfo, _ error) error {
if strings.HasSuffix(info.Name(), "docs") {
return filepath.SkipDir
}
if strings.HasSuffix(info.Name(), "swagger") {
re... | [
"func",
"loadPathsToWatch",
"(",
"paths",
"*",
"[",
"]",
"string",
")",
"error",
"{",
"directory",
",",
"err",
":=",
"os",
".",
"Getwd",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"filepath",
".",
"Walk",
"(",
... | // loadPathsToWatch loads the paths that needs to be watched for changes | [
"loadPathsToWatch",
"loads",
"the",
"paths",
"that",
"needs",
"to",
"be",
"watched",
"for",
"changes"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L102-L124 |
25,797 | beego/bee | cmd/commands/dlv/dlv_amd64.go | startDelveDebugger | func startDelveDebugger(addr string, ch chan int) int {
beeLogger.Log.Info("Starting Delve Debugger...")
fp, err := buildDebug()
if err != nil {
beeLogger.Log.Fatalf("Error while building debug binary: %v", err)
}
defer os.Remove(fp)
abs, err := filepath.Abs("./debug")
if err != nil {
beeLogger.Log.Fatalf(... | go | func startDelveDebugger(addr string, ch chan int) int {
beeLogger.Log.Info("Starting Delve Debugger...")
fp, err := buildDebug()
if err != nil {
beeLogger.Log.Fatalf("Error while building debug binary: %v", err)
}
defer os.Remove(fp)
abs, err := filepath.Abs("./debug")
if err != nil {
beeLogger.Log.Fatalf(... | [
"func",
"startDelveDebugger",
"(",
"addr",
"string",
",",
"ch",
"chan",
"int",
")",
"int",
"{",
"beeLogger",
".",
"Log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"fp",
",",
"err",
":=",
"buildDebug",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // startDelveDebugger starts the Delve debugger server | [
"startDelveDebugger",
"starts",
"the",
"Delve",
"debugger",
"server"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L127-L189 |
25,798 | beego/bee | cmd/commands/dlv/dlv_amd64.go | startWatcher | func startWatcher(paths []string, ch chan int) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Could not start the watcher: %v", err)
}
defer watcher.Close()
// Feed the paths to the watcher
for _, path := range paths {
if err := watcher.Add(path); err != nil {
beeLogger.Log.... | go | func startWatcher(paths []string, ch chan int) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
beeLogger.Log.Fatalf("Could not start the watcher: %v", err)
}
defer watcher.Close()
// Feed the paths to the watcher
for _, path := range paths {
if err := watcher.Add(path); err != nil {
beeLogger.Log.... | [
"func",
"startWatcher",
"(",
"paths",
"[",
"]",
"string",
",",
"ch",
"chan",
"int",
")",
"{",
"watcher",
",",
"err",
":=",
"fsnotify",
".",
"NewWatcher",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"beeLogger",
".",
"Log",
".",
"Fatalf",
"(",
"\... | // startWatcher starts the fsnotify watcher on the passed paths | [
"startWatcher",
"starts",
"the",
"fsnotify",
"watcher",
"on",
"the",
"passed",
"paths"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/cmd/commands/dlv/dlv_amd64.go#L194-L245 |
25,799 | beego/bee | generate/swaggergen/g_docs.go | ParsePackagesFromDir | func ParsePackagesFromDir(dirpath string) {
c := make(chan error)
go func() {
filepath.Walk(dirpath, func(fpath string, fileInfo os.FileInfo, err error) error {
if err != nil {
return nil
}
if !fileInfo.IsDir() {
return nil
}
// skip folder if it's a 'vendor' folder within dirpath or its ch... | go | func ParsePackagesFromDir(dirpath string) {
c := make(chan error)
go func() {
filepath.Walk(dirpath, func(fpath string, fileInfo os.FileInfo, err error) error {
if err != nil {
return nil
}
if !fileInfo.IsDir() {
return nil
}
// skip folder if it's a 'vendor' folder within dirpath or its ch... | [
"func",
"ParsePackagesFromDir",
"(",
"dirpath",
"string",
")",
"{",
"c",
":=",
"make",
"(",
"chan",
"error",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"filepath",
".",
"Walk",
"(",
"dirpath",
",",
"func",
"(",
"fpath",
"string",
",",
"fileInfo",
"os",
... | // ParsePackagesFromDir parses packages from a given directory | [
"ParsePackagesFromDir",
"parses",
"packages",
"from",
"a",
"given",
"directory"
] | 6a86284cec9a17f9aae6fe82ecf3c436aafed68d | https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/generate/swaggergen/g_docs.go#L106-L139 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.