repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
CurrentNodeName
func (gce *Cloud) CurrentNodeName(hostname string) (types.NodeName, error) { return types.NodeName(hostname), nil }
go
func (gce *Cloud) CurrentNodeName(hostname string) (types.NodeName, error) { return types.NodeName(hostname), nil }
[ "func", "(", "gce", "*", "Cloud", ")", "CurrentNodeName", "(", "hostname", "string", ")", "(", "types", ".", "NodeName", ",", "error", ")", "{", "return", "types", ".", "NodeName", "(", "hostname", ")", ",", "nil", "\n", "}" ]
// CurrentNodeName is an implementation of Instances.CurrentNodeName
[ "CurrentNodeName", "is", "an", "implementation", "of", "Instances", ".", "CurrentNodeName" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2152-L2154
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
GetAllZones
func (gce *Cloud) GetAllZones() (sets.String, error) { // Fast-path for non-multizone if len(gce.managedZones) == 1 { return sets.NewString(gce.managedZones...), nil } // TODO: Caching, but this is currently only called when we are creating a volume, // which is a relatively infrequent operation, and this is only # zones API calls zones := sets.NewString() // TODO: Parallelize, although O(zones) so not too bad (N <= 3 typically) for _, zone := range gce.managedZones { // We only retrieve one page in each zone - we only care about existence listCall := gce.service.Instances.List(gce.projectID, zone) // No filter: We assume that a zone is either used or unused // We could only consider running nodes (like we do in List above), // but probably if instances are starting we still want to consider them. // I think we should wait until we have a reason to make the // call one way or the other; we generally can't guarantee correct // volume spreading if the set of zones is changing // (and volume spreading is currently only a heuristic). // Long term we want to replace GetAllZones (which primarily supports volume // spreading) with a scheduler policy that is able to see the global state of // volumes and the health of zones. // Just a minimal set of fields - we only care about existence listCall = listCall.Fields("items(name)") res, err := listCall.Do() if err != nil { return nil, err } if len(res.Items) != 0 { zones.Insert(zone) } } return zones, nil }
go
func (gce *Cloud) GetAllZones() (sets.String, error) { // Fast-path for non-multizone if len(gce.managedZones) == 1 { return sets.NewString(gce.managedZones...), nil } // TODO: Caching, but this is currently only called when we are creating a volume, // which is a relatively infrequent operation, and this is only # zones API calls zones := sets.NewString() // TODO: Parallelize, although O(zones) so not too bad (N <= 3 typically) for _, zone := range gce.managedZones { // We only retrieve one page in each zone - we only care about existence listCall := gce.service.Instances.List(gce.projectID, zone) // No filter: We assume that a zone is either used or unused // We could only consider running nodes (like we do in List above), // but probably if instances are starting we still want to consider them. // I think we should wait until we have a reason to make the // call one way or the other; we generally can't guarantee correct // volume spreading if the set of zones is changing // (and volume spreading is currently only a heuristic). // Long term we want to replace GetAllZones (which primarily supports volume // spreading) with a scheduler policy that is able to see the global state of // volumes and the health of zones. // Just a minimal set of fields - we only care about existence listCall = listCall.Fields("items(name)") res, err := listCall.Do() if err != nil { return nil, err } if len(res.Items) != 0 { zones.Insert(zone) } } return zones, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "GetAllZones", "(", ")", "(", "sets", ".", "String", ",", "error", ")", "{", "// Fast-path for non-multizone", "if", "len", "(", "gce", ".", "managedZones", ")", "==", "1", "{", "return", "sets", ".", "NewString", "(", "gce", ".", "managedZones", "...", ")", ",", "nil", "\n", "}", "\n\n", "// TODO: Caching, but this is currently only called when we are creating a volume,", "// which is a relatively infrequent operation, and this is only # zones API calls", "zones", ":=", "sets", ".", "NewString", "(", ")", "\n\n", "// TODO: Parallelize, although O(zones) so not too bad (N <= 3 typically)", "for", "_", ",", "zone", ":=", "range", "gce", ".", "managedZones", "{", "// We only retrieve one page in each zone - we only care about existence", "listCall", ":=", "gce", ".", "service", ".", "Instances", ".", "List", "(", "gce", ".", "projectID", ",", "zone", ")", "\n\n", "// No filter: We assume that a zone is either used or unused", "// We could only consider running nodes (like we do in List above),", "// but probably if instances are starting we still want to consider them.", "// I think we should wait until we have a reason to make the", "// call one way or the other; we generally can't guarantee correct", "// volume spreading if the set of zones is changing", "// (and volume spreading is currently only a heuristic).", "// Long term we want to replace GetAllZones (which primarily supports volume", "// spreading) with a scheduler policy that is able to see the global state of", "// volumes and the health of zones.", "// Just a minimal set of fields - we only care about existence", "listCall", "=", "listCall", ".", "Fields", "(", "\"", "\"", ")", "\n\n", "res", ",", "err", ":=", "listCall", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "res", ".", "Items", ")", "!=", "0", "{", "zones", ".", "Insert", "(", "zone", ")", "\n", "}", "\n", "}", "\n\n", "return", "zones", ",", "nil", "\n", "}" ]
// GetAllZones returns all the zones in which nodes are running
[ "GetAllZones", "returns", "all", "the", "zones", "in", "which", "nodes", "are", "running" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2296-L2335
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
ListRoutes
func (gce *Cloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) { var routes []*cloudprovider.Route pageToken := "" page := 0 for ; page == 0 || (pageToken != "" && page < maxPages); page++ { listCall := gce.service.Routes.List(gce.projectID) prefix := truncateClusterName(clusterName) listCall = listCall.Filter("name eq " + prefix + "-.*") if pageToken != "" { listCall = listCall.PageToken(pageToken) } res, err := listCall.Do() if err != nil { glog.Errorf("Error getting routes from GCE: %v", err) return nil, err } pageToken = res.NextPageToken for _, r := range res.Items { if r.Network != gce.networkURL { continue } // Not managed if route description != "k8s-node-route" if r.Description != k8sNodeRouteTag { continue } // Not managed if route name doesn't start with <clusterName> if !strings.HasPrefix(r.Name, prefix) { continue } target := path.Base(r.NextHopInstance) // TODO: Should we lastComponent(target) this? targetNodeName := types.NodeName(target) // NodeName == Instance Name on GCE routes = append(routes, &cloudprovider.Route{Name: r.Name, TargetNode: targetNodeName, DestinationCIDR: r.DestRange}) } } if page >= maxPages { glog.Errorf("ListRoutes exceeded maxPages=%d for Routes.List; truncating.", maxPages) } return routes, nil }
go
func (gce *Cloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, error) { var routes []*cloudprovider.Route pageToken := "" page := 0 for ; page == 0 || (pageToken != "" && page < maxPages); page++ { listCall := gce.service.Routes.List(gce.projectID) prefix := truncateClusterName(clusterName) listCall = listCall.Filter("name eq " + prefix + "-.*") if pageToken != "" { listCall = listCall.PageToken(pageToken) } res, err := listCall.Do() if err != nil { glog.Errorf("Error getting routes from GCE: %v", err) return nil, err } pageToken = res.NextPageToken for _, r := range res.Items { if r.Network != gce.networkURL { continue } // Not managed if route description != "k8s-node-route" if r.Description != k8sNodeRouteTag { continue } // Not managed if route name doesn't start with <clusterName> if !strings.HasPrefix(r.Name, prefix) { continue } target := path.Base(r.NextHopInstance) // TODO: Should we lastComponent(target) this? targetNodeName := types.NodeName(target) // NodeName == Instance Name on GCE routes = append(routes, &cloudprovider.Route{Name: r.Name, TargetNode: targetNodeName, DestinationCIDR: r.DestRange}) } } if page >= maxPages { glog.Errorf("ListRoutes exceeded maxPages=%d for Routes.List; truncating.", maxPages) } return routes, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "ListRoutes", "(", "clusterName", "string", ")", "(", "[", "]", "*", "cloudprovider", ".", "Route", ",", "error", ")", "{", "var", "routes", "[", "]", "*", "cloudprovider", ".", "Route", "\n", "pageToken", ":=", "\"", "\"", "\n", "page", ":=", "0", "\n", "for", ";", "page", "==", "0", "||", "(", "pageToken", "!=", "\"", "\"", "&&", "page", "<", "maxPages", ")", ";", "page", "++", "{", "listCall", ":=", "gce", ".", "service", ".", "Routes", ".", "List", "(", "gce", ".", "projectID", ")", "\n\n", "prefix", ":=", "truncateClusterName", "(", "clusterName", ")", "\n", "listCall", "=", "listCall", ".", "Filter", "(", "\"", "\"", "+", "prefix", "+", "\"", "\"", ")", "\n", "if", "pageToken", "!=", "\"", "\"", "{", "listCall", "=", "listCall", ".", "PageToken", "(", "pageToken", ")", "\n", "}", "\n", "res", ",", "err", ":=", "listCall", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "pageToken", "=", "res", ".", "NextPageToken", "\n", "for", "_", ",", "r", ":=", "range", "res", ".", "Items", "{", "if", "r", ".", "Network", "!=", "gce", ".", "networkURL", "{", "continue", "\n", "}", "\n", "// Not managed if route description != \"k8s-node-route\"", "if", "r", ".", "Description", "!=", "k8sNodeRouteTag", "{", "continue", "\n", "}", "\n", "// Not managed if route name doesn't start with <clusterName>", "if", "!", "strings", ".", "HasPrefix", "(", "r", ".", "Name", ",", "prefix", ")", "{", "continue", "\n", "}", "\n\n", "target", ":=", "path", ".", "Base", "(", "r", ".", "NextHopInstance", ")", "\n", "// TODO: Should we lastComponent(target) this?", "targetNodeName", ":=", "types", ".", "NodeName", "(", "target", ")", "// NodeName == Instance Name on GCE", "\n", "routes", "=", "append", "(", "routes", ",", "&", "cloudprovider", ".", "Route", "{", "Name", ":", "r", ".", "Name", ",", "TargetNode", ":", "targetNodeName", ",", "DestinationCIDR", ":", "r", ".", "DestRange", "}", ")", "\n", "}", "\n", "}", "\n", "if", "page", ">=", "maxPages", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "maxPages", ")", "\n", "}", "\n", "return", "routes", ",", "nil", "\n", "}" ]
// ListRoutes lists routes
[ "ListRoutes", "lists", "routes" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2345-L2386
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
GetZone
func (gce *Cloud) GetZone() (cloudprovider.Zone, error) { return cloudprovider.Zone{ FailureDomain: gce.localZone, Region: gce.region, }, nil }
go
func (gce *Cloud) GetZone() (cloudprovider.Zone, error) { return cloudprovider.Zone{ FailureDomain: gce.localZone, Region: gce.region, }, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "GetZone", "(", ")", "(", "cloudprovider", ".", "Zone", ",", "error", ")", "{", "return", "cloudprovider", ".", "Zone", "{", "FailureDomain", ":", "gce", ".", "localZone", ",", "Region", ":", "gce", ".", "region", ",", "}", ",", "nil", "\n", "}" ]
// GetZone gets a zone
[ "GetZone", "gets", "a", "zone" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2429-L2434
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
DeleteDisk
func (gce *Cloud) DeleteDisk(diskToDelete string) error { err := gce.doDeleteDisk(diskToDelete) if isGCEError(err, "resourceInUseByAnotherResource") { return volume.NewDeletedVolumeInUseError(err.Error()) } if err == cloudprovider.ErrDiskNotFound { return nil } return err }
go
func (gce *Cloud) DeleteDisk(diskToDelete string) error { err := gce.doDeleteDisk(diskToDelete) if isGCEError(err, "resourceInUseByAnotherResource") { return volume.NewDeletedVolumeInUseError(err.Error()) } if err == cloudprovider.ErrDiskNotFound { return nil } return err }
[ "func", "(", "gce", "*", "Cloud", ")", "DeleteDisk", "(", "diskToDelete", "string", ")", "error", "{", "err", ":=", "gce", ".", "doDeleteDisk", "(", "diskToDelete", ")", "\n", "if", "isGCEError", "(", "err", ",", "\"", "\"", ")", "{", "return", "volume", ".", "NewDeletedVolumeInUseError", "(", "err", ".", "Error", "(", ")", ")", "\n", "}", "\n\n", "if", "err", "==", "cloudprovider", ".", "ErrDiskNotFound", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
// DeleteDisk deletes a disk
[ "DeleteDisk", "deletes", "a", "disk" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2518-L2528
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
AttachDisk
func (gce *Cloud) AttachDisk(diskName string, nodeName types.NodeName, readOnly bool) error { instanceName := mapNodeNameToInstanceName(nodeName) instance, err := gce.getInstanceByName(instanceName) if err != nil { return fmt.Errorf("error getting instance %q", instanceName) } disk, err := gce.getDiskByName(diskName, instance.Zone) if err != nil { return err } readWrite := "READ_WRITE" if readOnly { readWrite = "READ_ONLY" } attachedDisk := gce.convertDiskToAttachedDisk(disk, readWrite) attachOp, err := gce.service.Instances.AttachDisk(gce.projectID, disk.Zone, instance.Name, attachedDisk).Do() if err != nil { return err } return gce.waitForZoneOp(attachOp, disk.Zone) }
go
func (gce *Cloud) AttachDisk(diskName string, nodeName types.NodeName, readOnly bool) error { instanceName := mapNodeNameToInstanceName(nodeName) instance, err := gce.getInstanceByName(instanceName) if err != nil { return fmt.Errorf("error getting instance %q", instanceName) } disk, err := gce.getDiskByName(diskName, instance.Zone) if err != nil { return err } readWrite := "READ_WRITE" if readOnly { readWrite = "READ_ONLY" } attachedDisk := gce.convertDiskToAttachedDisk(disk, readWrite) attachOp, err := gce.service.Instances.AttachDisk(gce.projectID, disk.Zone, instance.Name, attachedDisk).Do() if err != nil { return err } return gce.waitForZoneOp(attachOp, disk.Zone) }
[ "func", "(", "gce", "*", "Cloud", ")", "AttachDisk", "(", "diskName", "string", ",", "nodeName", "types", ".", "NodeName", ",", "readOnly", "bool", ")", "error", "{", "instanceName", ":=", "mapNodeNameToInstanceName", "(", "nodeName", ")", "\n", "instance", ",", "err", ":=", "gce", ".", "getInstanceByName", "(", "instanceName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "instanceName", ")", "\n", "}", "\n", "disk", ",", "err", ":=", "gce", ".", "getDiskByName", "(", "diskName", ",", "instance", ".", "Zone", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "readWrite", ":=", "\"", "\"", "\n", "if", "readOnly", "{", "readWrite", "=", "\"", "\"", "\n", "}", "\n", "attachedDisk", ":=", "gce", ".", "convertDiskToAttachedDisk", "(", "disk", ",", "readWrite", ")", "\n\n", "attachOp", ",", "err", ":=", "gce", ".", "service", ".", "Instances", ".", "AttachDisk", "(", "gce", ".", "projectID", ",", "disk", ".", "Zone", ",", "instance", ".", "Name", ",", "attachedDisk", ")", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "gce", ".", "waitForZoneOp", "(", "attachOp", ",", "disk", ".", "Zone", ")", "\n", "}" ]
// AttachDisk attaches a disk
[ "AttachDisk", "attaches", "a", "disk" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2594-L2616
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
DetachDisk
func (gce *Cloud) DetachDisk(devicePath string, nodeName types.NodeName) error { instanceName := mapNodeNameToInstanceName(nodeName) inst, err := gce.getInstanceByName(instanceName) if err != nil { if err == cloudprovider.ErrInstanceNotFound { // If instance no longer exists, safe to assume volume is not attached. glog.Warningf( "Instance %q does not exist. DetachDisk will assume PD %q is not attached to it.", instanceName, devicePath) return nil } return fmt.Errorf("error getting instance %q", instanceName) } detachOp, err := gce.service.Instances.DetachDisk(gce.projectID, inst.Zone, inst.Name, devicePath).Do() if err != nil { return err } return gce.waitForZoneOp(detachOp, inst.Zone) }
go
func (gce *Cloud) DetachDisk(devicePath string, nodeName types.NodeName) error { instanceName := mapNodeNameToInstanceName(nodeName) inst, err := gce.getInstanceByName(instanceName) if err != nil { if err == cloudprovider.ErrInstanceNotFound { // If instance no longer exists, safe to assume volume is not attached. glog.Warningf( "Instance %q does not exist. DetachDisk will assume PD %q is not attached to it.", instanceName, devicePath) return nil } return fmt.Errorf("error getting instance %q", instanceName) } detachOp, err := gce.service.Instances.DetachDisk(gce.projectID, inst.Zone, inst.Name, devicePath).Do() if err != nil { return err } return gce.waitForZoneOp(detachOp, inst.Zone) }
[ "func", "(", "gce", "*", "Cloud", ")", "DetachDisk", "(", "devicePath", "string", ",", "nodeName", "types", ".", "NodeName", ")", "error", "{", "instanceName", ":=", "mapNodeNameToInstanceName", "(", "nodeName", ")", "\n", "inst", ",", "err", ":=", "gce", ".", "getInstanceByName", "(", "instanceName", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "cloudprovider", ".", "ErrInstanceNotFound", "{", "// If instance no longer exists, safe to assume volume is not attached.", "glog", ".", "Warningf", "(", "\"", "\"", ",", "instanceName", ",", "devicePath", ")", "\n", "return", "nil", "\n", "}", "\n\n", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "instanceName", ")", "\n", "}", "\n\n", "detachOp", ",", "err", ":=", "gce", ".", "service", ".", "Instances", ".", "DetachDisk", "(", "gce", ".", "projectID", ",", "inst", ".", "Zone", ",", "inst", ".", "Name", ",", "devicePath", ")", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "gce", ".", "waitForZoneOp", "(", "detachOp", ",", "inst", ".", "Zone", ")", "\n", "}" ]
// DetachDisk detaches a disk
[ "DetachDisk", "detaches", "a", "disk" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2619-L2641
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
DiskIsAttached
func (gce *Cloud) DiskIsAttached(diskName string, nodeName types.NodeName) (bool, error) { instanceName := mapNodeNameToInstanceName(nodeName) instance, err := gce.getInstanceByName(instanceName) if err != nil { if err == cloudprovider.ErrInstanceNotFound { // If instance no longer exists, safe to assume volume is not attached. glog.Warningf( "Instance %q does not exist. DiskIsAttached will assume PD %q is not attached to it.", instanceName, diskName) return false, nil } return false, err } for _, disk := range instance.Disks { if disk.DeviceName == diskName { // Disk is still attached to node return true, nil } } return false, nil }
go
func (gce *Cloud) DiskIsAttached(diskName string, nodeName types.NodeName) (bool, error) { instanceName := mapNodeNameToInstanceName(nodeName) instance, err := gce.getInstanceByName(instanceName) if err != nil { if err == cloudprovider.ErrInstanceNotFound { // If instance no longer exists, safe to assume volume is not attached. glog.Warningf( "Instance %q does not exist. DiskIsAttached will assume PD %q is not attached to it.", instanceName, diskName) return false, nil } return false, err } for _, disk := range instance.Disks { if disk.DeviceName == diskName { // Disk is still attached to node return true, nil } } return false, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "DiskIsAttached", "(", "diskName", "string", ",", "nodeName", "types", ".", "NodeName", ")", "(", "bool", ",", "error", ")", "{", "instanceName", ":=", "mapNodeNameToInstanceName", "(", "nodeName", ")", "\n", "instance", ",", "err", ":=", "gce", ".", "getInstanceByName", "(", "instanceName", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "cloudprovider", ".", "ErrInstanceNotFound", "{", "// If instance no longer exists, safe to assume volume is not attached.", "glog", ".", "Warningf", "(", "\"", "\"", ",", "instanceName", ",", "diskName", ")", "\n", "return", "false", ",", "nil", "\n", "}", "\n\n", "return", "false", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "disk", ":=", "range", "instance", ".", "Disks", "{", "if", "disk", ".", "DeviceName", "==", "diskName", "{", "// Disk is still attached to node", "return", "true", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "false", ",", "nil", "\n", "}" ]
// DiskIsAttached checks if disk is attached
[ "DiskIsAttached", "checks", "if", "disk", "is", "attached" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2644-L2668
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
getDiskByNameUnknownZone
func (gce *Cloud) getDiskByNameUnknownZone(diskName string) (*gceDisk, error) { // Note: this is the gotcha right now with GCE PD support: // disk names are not unique per-region. // (I can create two volumes with name "myvol" in e.g. us-central1-b & us-central1-f) // For now, this is simply undefined behaviour. // // In future, we will have to require users to qualify their disk // "us-central1-a/mydisk". We could do this for them as part of // admission control, but that might be a little weird (values changing // on create) var found *gceDisk for _, zone := range gce.managedZones { disk, err := gce.findDiskByName(diskName, zone) if err != nil { return nil, err } // findDiskByName returns (nil,nil) if the disk doesn't exist, so we can't // assume that a disk was found unless disk is non-nil. if disk == nil { continue } if found != nil { return nil, fmt.Errorf("GCE persistent disk name was found in multiple zones: %q", diskName) } found = disk } if found != nil { return found, nil } glog.Warningf("GCE persistent disk %q not found in managed zones (%s)", diskName, strings.Join(gce.managedZones, ",")) return nil, cloudprovider.ErrDiskNotFound }
go
func (gce *Cloud) getDiskByNameUnknownZone(diskName string) (*gceDisk, error) { // Note: this is the gotcha right now with GCE PD support: // disk names are not unique per-region. // (I can create two volumes with name "myvol" in e.g. us-central1-b & us-central1-f) // For now, this is simply undefined behaviour. // // In future, we will have to require users to qualify their disk // "us-central1-a/mydisk". We could do this for them as part of // admission control, but that might be a little weird (values changing // on create) var found *gceDisk for _, zone := range gce.managedZones { disk, err := gce.findDiskByName(diskName, zone) if err != nil { return nil, err } // findDiskByName returns (nil,nil) if the disk doesn't exist, so we can't // assume that a disk was found unless disk is non-nil. if disk == nil { continue } if found != nil { return nil, fmt.Errorf("GCE persistent disk name was found in multiple zones: %q", diskName) } found = disk } if found != nil { return found, nil } glog.Warningf("GCE persistent disk %q not found in managed zones (%s)", diskName, strings.Join(gce.managedZones, ",")) return nil, cloudprovider.ErrDiskNotFound }
[ "func", "(", "gce", "*", "Cloud", ")", "getDiskByNameUnknownZone", "(", "diskName", "string", ")", "(", "*", "gceDisk", ",", "error", ")", "{", "// Note: this is the gotcha right now with GCE PD support:", "// disk names are not unique per-region.", "// (I can create two volumes with name \"myvol\" in e.g. us-central1-b & us-central1-f)", "// For now, this is simply undefined behaviour.", "//", "// In future, we will have to require users to qualify their disk", "// \"us-central1-a/mydisk\". We could do this for them as part of", "// admission control, but that might be a little weird (values changing", "// on create)", "var", "found", "*", "gceDisk", "\n", "for", "_", ",", "zone", ":=", "range", "gce", ".", "managedZones", "{", "disk", ",", "err", ":=", "gce", ".", "findDiskByName", "(", "diskName", ",", "zone", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// findDiskByName returns (nil,nil) if the disk doesn't exist, so we can't", "// assume that a disk was found unless disk is non-nil.", "if", "disk", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "found", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "diskName", ")", "\n", "}", "\n", "found", "=", "disk", "\n", "}", "\n", "if", "found", "!=", "nil", "{", "return", "found", ",", "nil", "\n", "}", "\n", "glog", ".", "Warningf", "(", "\"", "\"", ",", "diskName", ",", "strings", ".", "Join", "(", "gce", ".", "managedZones", ",", "\"", "\"", ")", ")", "\n", "return", "nil", ",", "cloudprovider", ".", "ErrDiskNotFound", "\n", "}" ]
// Scans all managed zones to return the GCE PD // Prefer getDiskByName, if the zone can be established // Return cloudprovider.ErrDiskNotFound if the given disk cannot be found in any zone
[ "Scans", "all", "managed", "zones", "to", "return", "the", "GCE", "PD", "Prefer", "getDiskByName", "if", "the", "zone", "can", "be", "established", "Return", "cloudprovider", ".", "ErrDiskNotFound", "if", "the", "given", "disk", "cannot", "be", "found", "in", "any", "zone" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2733-L2765
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
convertDiskToAttachedDisk
func (gce *Cloud) convertDiskToAttachedDisk(disk *gceDisk, readWrite string) *compute.AttachedDisk { return &compute.AttachedDisk{ DeviceName: disk.Name, Kind: disk.Kind, Mode: readWrite, Source: "https://" + path.Join("www.googleapis.com/compute/v1/projects/", gce.projectID, "zones", disk.Zone, "disks", disk.Name), Type: "PERSISTENT", } }
go
func (gce *Cloud) convertDiskToAttachedDisk(disk *gceDisk, readWrite string) *compute.AttachedDisk { return &compute.AttachedDisk{ DeviceName: disk.Name, Kind: disk.Kind, Mode: readWrite, Source: "https://" + path.Join("www.googleapis.com/compute/v1/projects/", gce.projectID, "zones", disk.Zone, "disks", disk.Name), Type: "PERSISTENT", } }
[ "func", "(", "gce", "*", "Cloud", ")", "convertDiskToAttachedDisk", "(", "disk", "*", "gceDisk", ",", "readWrite", "string", ")", "*", "compute", ".", "AttachedDisk", "{", "return", "&", "compute", ".", "AttachedDisk", "{", "DeviceName", ":", "disk", ".", "Name", ",", "Kind", ":", "disk", ".", "Kind", ",", "Mode", ":", "readWrite", ",", "Source", ":", "\"", "\"", "+", "path", ".", "Join", "(", "\"", "\"", ",", "gce", ".", "projectID", ",", "\"", "\"", ",", "disk", ".", "Zone", ",", "\"", "\"", ",", "disk", ".", "Name", ")", ",", "Type", ":", "\"", "\"", ",", "}", "\n", "}" ]
// Converts a Disk resource to an AttachedDisk resource.
[ "Converts", "a", "Disk", "resource", "to", "an", "AttachedDisk", "resource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2780-L2788
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
CreateDiskFromSnapshot
func (gce *Cloud) CreateDiskFromSnapshot(snapshot string, name string, diskType string, zone string, sizeGb int64, tags map[string]string) error { // Do not allow creation of PDs in zones that are not managed. Such PDs // then cannot be deleted by DeleteDisk. isManaged := false for _, managedZone := range gce.managedZones { if zone == managedZone { isManaged = true break } } if !isManaged { return fmt.Errorf("kubernetes does not manage zone %q", zone) } tagsStr, err := gce.encodeDiskTags(tags) if err != nil { return fmt.Errorf("encode disk tag error %v", err) } switch diskType { case DiskTypeSSD, DiskTypeStandard: // noop case "": diskType = diskTypeDefault default: return fmt.Errorf("invalid GCE disk type %q", diskType) } diskTypeURI := fmt.Sprintf(diskTypeURITemplate, gce.projectID, zone, diskType) snapshotName := "global/snapshots/" + snapshot diskToCreate := &compute.Disk{ Name: name, SizeGb: sizeGb, Description: tagsStr, Type: diskTypeURI, SourceSnapshot: snapshotName, } glog.Infof("Create disk from snapshot diskToCreate %+v", diskToCreate) createOp, err := gce.service.Disks.Insert(gce.projectID, zone, diskToCreate).Do() glog.Infof("Create disk from snapshot operation %v, err %v", createOp, err) if err != nil { if isGCEError(err, "alreadyExists") { glog.Warningf("GCE PD %q already exists, reusing", name) return nil } return err } err = gce.waitForZoneOp(createOp, zone) if isGCEError(err, "alreadyExists") { glog.Warningf("GCE PD %q already exists, reusing", name) return nil } return err }
go
func (gce *Cloud) CreateDiskFromSnapshot(snapshot string, name string, diskType string, zone string, sizeGb int64, tags map[string]string) error { // Do not allow creation of PDs in zones that are not managed. Such PDs // then cannot be deleted by DeleteDisk. isManaged := false for _, managedZone := range gce.managedZones { if zone == managedZone { isManaged = true break } } if !isManaged { return fmt.Errorf("kubernetes does not manage zone %q", zone) } tagsStr, err := gce.encodeDiskTags(tags) if err != nil { return fmt.Errorf("encode disk tag error %v", err) } switch diskType { case DiskTypeSSD, DiskTypeStandard: // noop case "": diskType = diskTypeDefault default: return fmt.Errorf("invalid GCE disk type %q", diskType) } diskTypeURI := fmt.Sprintf(diskTypeURITemplate, gce.projectID, zone, diskType) snapshotName := "global/snapshots/" + snapshot diskToCreate := &compute.Disk{ Name: name, SizeGb: sizeGb, Description: tagsStr, Type: diskTypeURI, SourceSnapshot: snapshotName, } glog.Infof("Create disk from snapshot diskToCreate %+v", diskToCreate) createOp, err := gce.service.Disks.Insert(gce.projectID, zone, diskToCreate).Do() glog.Infof("Create disk from snapshot operation %v, err %v", createOp, err) if err != nil { if isGCEError(err, "alreadyExists") { glog.Warningf("GCE PD %q already exists, reusing", name) return nil } return err } err = gce.waitForZoneOp(createOp, zone) if isGCEError(err, "alreadyExists") { glog.Warningf("GCE PD %q already exists, reusing", name) return nil } return err }
[ "func", "(", "gce", "*", "Cloud", ")", "CreateDiskFromSnapshot", "(", "snapshot", "string", ",", "name", "string", ",", "diskType", "string", ",", "zone", "string", ",", "sizeGb", "int64", ",", "tags", "map", "[", "string", "]", "string", ")", "error", "{", "// Do not allow creation of PDs in zones that are not managed. Such PDs", "// then cannot be deleted by DeleteDisk.", "isManaged", ":=", "false", "\n", "for", "_", ",", "managedZone", ":=", "range", "gce", ".", "managedZones", "{", "if", "zone", "==", "managedZone", "{", "isManaged", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "isManaged", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "zone", ")", "\n", "}", "\n\n", "tagsStr", ",", "err", ":=", "gce", ".", "encodeDiskTags", "(", "tags", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "switch", "diskType", "{", "case", "DiskTypeSSD", ",", "DiskTypeStandard", ":", "// noop", "case", "\"", "\"", ":", "diskType", "=", "diskTypeDefault", "\n", "default", ":", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "diskType", ")", "\n", "}", "\n", "diskTypeURI", ":=", "fmt", ".", "Sprintf", "(", "diskTypeURITemplate", ",", "gce", ".", "projectID", ",", "zone", ",", "diskType", ")", "\n\n", "snapshotName", ":=", "\"", "\"", "+", "snapshot", "\n", "diskToCreate", ":=", "&", "compute", ".", "Disk", "{", "Name", ":", "name", ",", "SizeGb", ":", "sizeGb", ",", "Description", ":", "tagsStr", ",", "Type", ":", "diskTypeURI", ",", "SourceSnapshot", ":", "snapshotName", ",", "}", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "diskToCreate", ")", "\n", "createOp", ",", "err", ":=", "gce", ".", "service", ".", "Disks", ".", "Insert", "(", "gce", ".", "projectID", ",", "zone", ",", "diskToCreate", ")", ".", "Do", "(", ")", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "createOp", ",", "err", ")", "\n", "if", "err", "!=", "nil", "{", "if", "isGCEError", "(", "err", ",", "\"", "\"", ")", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "name", ")", "\n", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}", "\n\n", "err", "=", "gce", ".", "waitForZoneOp", "(", "createOp", ",", "zone", ")", "\n", "if", "isGCEError", "(", "err", ",", "\"", "\"", ")", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "name", ")", "\n", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
// CreateDiskFromSnapshot create a disk from snapshot
[ "CreateDiskFromSnapshot", "create", "a", "disk", "from", "snapshot" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2797-L2853
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
DescribeSnapshot
func (gce *Cloud) DescribeSnapshot(snapshotToGet string) (status string, isCompleted bool, err error) { snapshot, err := gce.getSnapshotByName(snapshotToGet) if err != nil { return "", false, err } //no snapshot is found if snapshot == nil { return "", false, fmt.Errorf("snapshot %s is not found", snapshotToGet) } if snapshot.Status == "READY" { return snapshot.Status, true, nil } return snapshot.Status, false, nil }
go
func (gce *Cloud) DescribeSnapshot(snapshotToGet string) (status string, isCompleted bool, err error) { snapshot, err := gce.getSnapshotByName(snapshotToGet) if err != nil { return "", false, err } //no snapshot is found if snapshot == nil { return "", false, fmt.Errorf("snapshot %s is not found", snapshotToGet) } if snapshot.Status == "READY" { return snapshot.Status, true, nil } return snapshot.Status, false, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "DescribeSnapshot", "(", "snapshotToGet", "string", ")", "(", "status", "string", ",", "isCompleted", "bool", ",", "err", "error", ")", "{", "snapshot", ",", "err", ":=", "gce", ".", "getSnapshotByName", "(", "snapshotToGet", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "false", ",", "err", "\n", "}", "\n", "//no snapshot is found", "if", "snapshot", "==", "nil", "{", "return", "\"", "\"", ",", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "snapshotToGet", ")", "\n", "}", "\n", "if", "snapshot", ".", "Status", "==", "\"", "\"", "{", "return", "snapshot", ".", "Status", ",", "true", ",", "nil", "\n", "}", "\n", "return", "snapshot", ".", "Status", ",", "false", ",", "nil", "\n", "}" ]
// DescribeSnapshot checks the status of a snapshot
[ "DescribeSnapshot", "checks", "the", "status", "of", "a", "snapshot" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2856-L2869
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
FindSnapshot
func (gce *Cloud) FindSnapshot(tags map[string]string) ([]string, []string, error) { var snapshotIDs, statuses []string return snapshotIDs, statuses, nil }
go
func (gce *Cloud) FindSnapshot(tags map[string]string) ([]string, []string, error) { var snapshotIDs, statuses []string return snapshotIDs, statuses, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "FindSnapshot", "(", "tags", "map", "[", "string", "]", "string", ")", "(", "[", "]", "string", ",", "[", "]", "string", ",", "error", ")", "{", "var", "snapshotIDs", ",", "statuses", "[", "]", "string", "\n", "return", "snapshotIDs", ",", "statuses", ",", "nil", "\n", "}" ]
// FindSnapshot returns the found snapshots
[ "FindSnapshot", "returns", "the", "found", "snapshots" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2872-L2875
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
DeleteSnapshot
func (gce *Cloud) DeleteSnapshot(snapshotToDelete string) error { snapshot, err := gce.getSnapshotByName(snapshotToDelete) if err != nil { return err } //no snapshot is found if snapshot == nil { return nil } deleteOp, err := gce.service.Snapshots.Delete(gce.projectID, snapshotToDelete).Do() if err != nil { return err } return gce.waitForGlobalOp(deleteOp) }
go
func (gce *Cloud) DeleteSnapshot(snapshotToDelete string) error { snapshot, err := gce.getSnapshotByName(snapshotToDelete) if err != nil { return err } //no snapshot is found if snapshot == nil { return nil } deleteOp, err := gce.service.Snapshots.Delete(gce.projectID, snapshotToDelete).Do() if err != nil { return err } return gce.waitForGlobalOp(deleteOp) }
[ "func", "(", "gce", "*", "Cloud", ")", "DeleteSnapshot", "(", "snapshotToDelete", "string", ")", "error", "{", "snapshot", ",", "err", ":=", "gce", ".", "getSnapshotByName", "(", "snapshotToDelete", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "//no snapshot is found", "if", "snapshot", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "deleteOp", ",", "err", ":=", "gce", ".", "service", ".", "Snapshots", ".", "Delete", "(", "gce", ".", "projectID", ",", "snapshotToDelete", ")", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "gce", ".", "waitForGlobalOp", "(", "deleteOp", ")", "\n", "}" ]
// DeleteSnapshot deletes a snapshot
[ "DeleteSnapshot", "deletes", "a", "snapshot" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2878-L2894
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
CreateSnapshot
func (gce *Cloud) CreateSnapshot(diskName string, zone string, snapshotName string, tags map[string]string) error { isManaged := false for _, managedZone := range gce.managedZones { if zone == managedZone { isManaged = true break } } if !isManaged { return fmt.Errorf("kubernetes does not manage zone %q", zone) } tagsStr, err := gce.encodeDiskTags(tags) if err != nil { glog.Infof("CreateSnapshot err %v", err) return err } snapshotToCreate := &compute.Snapshot{ Name: snapshotName, Description: tagsStr, } glog.V(4).Infof("Create snapshot project %s, zone %s, diskName %s, snapshotToCreate %+v", gce.projectID, zone, diskName, snapshotToCreate) createOp, err := gce.service.Disks.CreateSnapshot(gce.projectID, zone, diskName, snapshotToCreate).Do() glog.V(4).Infof("Create snapshot operation %v", createOp) return err }
go
func (gce *Cloud) CreateSnapshot(diskName string, zone string, snapshotName string, tags map[string]string) error { isManaged := false for _, managedZone := range gce.managedZones { if zone == managedZone { isManaged = true break } } if !isManaged { return fmt.Errorf("kubernetes does not manage zone %q", zone) } tagsStr, err := gce.encodeDiskTags(tags) if err != nil { glog.Infof("CreateSnapshot err %v", err) return err } snapshotToCreate := &compute.Snapshot{ Name: snapshotName, Description: tagsStr, } glog.V(4).Infof("Create snapshot project %s, zone %s, diskName %s, snapshotToCreate %+v", gce.projectID, zone, diskName, snapshotToCreate) createOp, err := gce.service.Disks.CreateSnapshot(gce.projectID, zone, diskName, snapshotToCreate).Do() glog.V(4).Infof("Create snapshot operation %v", createOp) return err }
[ "func", "(", "gce", "*", "Cloud", ")", "CreateSnapshot", "(", "diskName", "string", ",", "zone", "string", ",", "snapshotName", "string", ",", "tags", "map", "[", "string", "]", "string", ")", "error", "{", "isManaged", ":=", "false", "\n", "for", "_", ",", "managedZone", ":=", "range", "gce", ".", "managedZones", "{", "if", "zone", "==", "managedZone", "{", "isManaged", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "isManaged", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "zone", ")", "\n", "}", "\n", "tagsStr", ",", "err", ":=", "gce", ".", "encodeDiskTags", "(", "tags", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Infof", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n\n", "snapshotToCreate", ":=", "&", "compute", ".", "Snapshot", "{", "Name", ":", "snapshotName", ",", "Description", ":", "tagsStr", ",", "}", "\n", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "gce", ".", "projectID", ",", "zone", ",", "diskName", ",", "snapshotToCreate", ")", "\n", "createOp", ",", "err", ":=", "gce", ".", "service", ".", "Disks", ".", "CreateSnapshot", "(", "gce", ".", "projectID", ",", "zone", ",", "diskName", ",", "snapshotToCreate", ")", ".", "Do", "(", ")", "\n", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "createOp", ")", "\n", "return", "err", "\n", "}" ]
// CreateSnapshot creates a snapshot
[ "CreateSnapshot", "creates", "a", "snapshot" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2913-L2938
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
ListClusters
func (gce *Cloud) ListClusters() ([]string, error) { allClusters := []string{} for _, zone := range gce.managedZones { clusters, err := gce.listClustersInZone(zone) if err != nil { return nil, err } // TODO: Scoping? Do we need to qualify the cluster name? allClusters = append(allClusters, clusters...) } return allClusters, nil }
go
func (gce *Cloud) ListClusters() ([]string, error) { allClusters := []string{} for _, zone := range gce.managedZones { clusters, err := gce.listClustersInZone(zone) if err != nil { return nil, err } // TODO: Scoping? Do we need to qualify the cluster name? allClusters = append(allClusters, clusters...) } return allClusters, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "ListClusters", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "allClusters", ":=", "[", "]", "string", "{", "}", "\n\n", "for", "_", ",", "zone", ":=", "range", "gce", ".", "managedZones", "{", "clusters", ",", "err", ":=", "gce", ".", "listClustersInZone", "(", "zone", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "// TODO: Scoping? Do we need to qualify the cluster name?", "allClusters", "=", "append", "(", "allClusters", ",", "clusters", "...", ")", "\n", "}", "\n\n", "return", "allClusters", ",", "nil", "\n", "}" ]
// ListClusters lists clusters
[ "ListClusters", "lists", "clusters" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2954-L2967
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
getInstancesByNames
func (gce *Cloud) getInstancesByNames(names []string) ([]*gceInstance, error) { instances := make(map[string]*gceInstance) remaining := len(names) nodeInstancePrefix := gce.nodeInstancePrefix for _, name := range names { name = canonicalizeInstanceName(name) if !strings.HasPrefix(name, gce.nodeInstancePrefix) { glog.Warningf("instance '%s' does not conform to prefix '%s', removing filter", name, gce.nodeInstancePrefix) nodeInstancePrefix = "" } instances[name] = nil } for _, zone := range gce.managedZones { if remaining == 0 { break } pageToken := "" page := 0 for ; page == 0 || (pageToken != "" && page < maxPages); page++ { listCall := gce.service.Instances.List(gce.projectID, zone) if nodeInstancePrefix != "" { // Add the filter for hosts listCall = listCall.Filter("name eq " + nodeInstancePrefix + ".*") } // TODO(zmerlynn): Internal bug 29524655 // listCall = listCall.Fields("items(name,id,disks,machineType)") if pageToken != "" { listCall.PageToken(pageToken) } res, err := listCall.Do() if err != nil { return nil, err } pageToken = res.NextPageToken for _, i := range res.Items { name := i.Name if _, ok := instances[name]; !ok { continue } instance := &gceInstance{ Zone: zone, Name: name, ID: i.Id, Disks: i.Disks, Type: lastComponent(i.MachineType), } instances[name] = instance remaining-- } } if page >= maxPages { glog.Errorf("getInstancesByNames exceeded maxPages=%d for Instances.List: truncating.", maxPages) } } instanceArray := make([]*gceInstance, len(names)) for i, name := range names { name = canonicalizeInstanceName(name) instance := instances[name] if instance == nil { glog.Errorf("Failed to retrieve instance: %q", name) return nil, cloudprovider.ErrInstanceNotFound } instanceArray[i] = instances[name] } return instanceArray, nil }
go
func (gce *Cloud) getInstancesByNames(names []string) ([]*gceInstance, error) { instances := make(map[string]*gceInstance) remaining := len(names) nodeInstancePrefix := gce.nodeInstancePrefix for _, name := range names { name = canonicalizeInstanceName(name) if !strings.HasPrefix(name, gce.nodeInstancePrefix) { glog.Warningf("instance '%s' does not conform to prefix '%s', removing filter", name, gce.nodeInstancePrefix) nodeInstancePrefix = "" } instances[name] = nil } for _, zone := range gce.managedZones { if remaining == 0 { break } pageToken := "" page := 0 for ; page == 0 || (pageToken != "" && page < maxPages); page++ { listCall := gce.service.Instances.List(gce.projectID, zone) if nodeInstancePrefix != "" { // Add the filter for hosts listCall = listCall.Filter("name eq " + nodeInstancePrefix + ".*") } // TODO(zmerlynn): Internal bug 29524655 // listCall = listCall.Fields("items(name,id,disks,machineType)") if pageToken != "" { listCall.PageToken(pageToken) } res, err := listCall.Do() if err != nil { return nil, err } pageToken = res.NextPageToken for _, i := range res.Items { name := i.Name if _, ok := instances[name]; !ok { continue } instance := &gceInstance{ Zone: zone, Name: name, ID: i.Id, Disks: i.Disks, Type: lastComponent(i.MachineType), } instances[name] = instance remaining-- } } if page >= maxPages { glog.Errorf("getInstancesByNames exceeded maxPages=%d for Instances.List: truncating.", maxPages) } } instanceArray := make([]*gceInstance, len(names)) for i, name := range names { name = canonicalizeInstanceName(name) instance := instances[name] if instance == nil { glog.Errorf("Failed to retrieve instance: %q", name) return nil, cloudprovider.ErrInstanceNotFound } instanceArray[i] = instances[name] } return instanceArray, nil }
[ "func", "(", "gce", "*", "Cloud", ")", "getInstancesByNames", "(", "names", "[", "]", "string", ")", "(", "[", "]", "*", "gceInstance", ",", "error", ")", "{", "instances", ":=", "make", "(", "map", "[", "string", "]", "*", "gceInstance", ")", "\n", "remaining", ":=", "len", "(", "names", ")", "\n\n", "nodeInstancePrefix", ":=", "gce", ".", "nodeInstancePrefix", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "name", "=", "canonicalizeInstanceName", "(", "name", ")", "\n", "if", "!", "strings", ".", "HasPrefix", "(", "name", ",", "gce", ".", "nodeInstancePrefix", ")", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "name", ",", "gce", ".", "nodeInstancePrefix", ")", "\n", "nodeInstancePrefix", "=", "\"", "\"", "\n", "}", "\n", "instances", "[", "name", "]", "=", "nil", "\n", "}", "\n\n", "for", "_", ",", "zone", ":=", "range", "gce", ".", "managedZones", "{", "if", "remaining", "==", "0", "{", "break", "\n", "}", "\n\n", "pageToken", ":=", "\"", "\"", "\n", "page", ":=", "0", "\n", "for", ";", "page", "==", "0", "||", "(", "pageToken", "!=", "\"", "\"", "&&", "page", "<", "maxPages", ")", ";", "page", "++", "{", "listCall", ":=", "gce", ".", "service", ".", "Instances", ".", "List", "(", "gce", ".", "projectID", ",", "zone", ")", "\n\n", "if", "nodeInstancePrefix", "!=", "\"", "\"", "{", "// Add the filter for hosts", "listCall", "=", "listCall", ".", "Filter", "(", "\"", "\"", "+", "nodeInstancePrefix", "+", "\"", "\"", ")", "\n", "}", "\n\n", "// TODO(zmerlynn): Internal bug 29524655", "// listCall = listCall.Fields(\"items(name,id,disks,machineType)\")", "if", "pageToken", "!=", "\"", "\"", "{", "listCall", ".", "PageToken", "(", "pageToken", ")", "\n", "}", "\n\n", "res", ",", "err", ":=", "listCall", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "pageToken", "=", "res", ".", "NextPageToken", "\n", "for", "_", ",", "i", ":=", "range", "res", ".", "Items", "{", "name", ":=", "i", ".", "Name", "\n", "if", "_", ",", "ok", ":=", "instances", "[", "name", "]", ";", "!", "ok", "{", "continue", "\n", "}", "\n\n", "instance", ":=", "&", "gceInstance", "{", "Zone", ":", "zone", ",", "Name", ":", "name", ",", "ID", ":", "i", ".", "Id", ",", "Disks", ":", "i", ".", "Disks", ",", "Type", ":", "lastComponent", "(", "i", ".", "MachineType", ")", ",", "}", "\n", "instances", "[", "name", "]", "=", "instance", "\n", "remaining", "--", "\n", "}", "\n", "}", "\n", "if", "page", ">=", "maxPages", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "maxPages", ")", "\n", "}", "\n", "}", "\n\n", "instanceArray", ":=", "make", "(", "[", "]", "*", "gceInstance", ",", "len", "(", "names", ")", ")", "\n", "for", "i", ",", "name", ":=", "range", "names", "{", "name", "=", "canonicalizeInstanceName", "(", "name", ")", "\n", "instance", ":=", "instances", "[", "name", "]", "\n", "if", "instance", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "return", "nil", ",", "cloudprovider", ".", "ErrInstanceNotFound", "\n", "}", "\n", "instanceArray", "[", "i", "]", "=", "instances", "[", "name", "]", "\n", "}", "\n\n", "return", "instanceArray", ",", "nil", "\n", "}" ]
// Gets the named instances, returning cloudprovider.ErrInstanceNotFound if any instance is not found
[ "Gets", "the", "named", "instances", "returning", "cloudprovider", ".", "ErrInstanceNotFound", "if", "any", "instance", "is", "not", "found" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L2989-L3063
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/gce/gce.go
getInstanceByName
func (gce *Cloud) getInstanceByName(name string) (*gceInstance, error) { // Avoid changing behaviour when not managing multiple zones for _, zone := range gce.managedZones { name = canonicalizeInstanceName(name) res, err := gce.service.Instances.Get(gce.projectID, zone, name).Do() if err != nil { glog.Errorf("getInstanceByName: failed to get instance %s; err: %v", name, err) if isHTTPErrorCode(err, http.StatusNotFound) { continue } return nil, err } return &gceInstance{ Zone: lastComponent(res.Zone), Name: res.Name, ID: res.Id, Disks: res.Disks, Type: lastComponent(res.MachineType), }, nil } return nil, cloudprovider.ErrInstanceNotFound }
go
func (gce *Cloud) getInstanceByName(name string) (*gceInstance, error) { // Avoid changing behaviour when not managing multiple zones for _, zone := range gce.managedZones { name = canonicalizeInstanceName(name) res, err := gce.service.Instances.Get(gce.projectID, zone, name).Do() if err != nil { glog.Errorf("getInstanceByName: failed to get instance %s; err: %v", name, err) if isHTTPErrorCode(err, http.StatusNotFound) { continue } return nil, err } return &gceInstance{ Zone: lastComponent(res.Zone), Name: res.Name, ID: res.Id, Disks: res.Disks, Type: lastComponent(res.MachineType), }, nil } return nil, cloudprovider.ErrInstanceNotFound }
[ "func", "(", "gce", "*", "Cloud", ")", "getInstanceByName", "(", "name", "string", ")", "(", "*", "gceInstance", ",", "error", ")", "{", "// Avoid changing behaviour when not managing multiple zones", "for", "_", ",", "zone", ":=", "range", "gce", ".", "managedZones", "{", "name", "=", "canonicalizeInstanceName", "(", "name", ")", "\n", "res", ",", "err", ":=", "gce", ".", "service", ".", "Instances", ".", "Get", "(", "gce", ".", "projectID", ",", "zone", ",", "name", ")", ".", "Do", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "name", ",", "err", ")", "\n", "if", "isHTTPErrorCode", "(", "err", ",", "http", ".", "StatusNotFound", ")", "{", "continue", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "gceInstance", "{", "Zone", ":", "lastComponent", "(", "res", ".", "Zone", ")", ",", "Name", ":", "res", ".", "Name", ",", "ID", ":", "res", ".", "Id", ",", "Disks", ":", "res", ".", "Disks", ",", "Type", ":", "lastComponent", "(", "res", ".", "MachineType", ")", ",", "}", ",", "nil", "\n", "}", "\n\n", "return", "nil", ",", "cloudprovider", ".", "ErrInstanceNotFound", "\n", "}" ]
// Gets the named instance, returning cloudprovider.ErrInstanceNotFound if the instance is not found
[ "Gets", "the", "named", "instance", "returning", "cloudprovider", ".", "ErrInstanceNotFound", "if", "the", "instance", "is", "not", "found" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/gce/gce.go#L3066-L3088
train
kubernetes-incubator/external-storage
repo-infra/kazel/kazel.go
Set
func (a Attrs) Set(name string, expr bzl.Expr) { a[name] = expr }
go
func (a Attrs) Set(name string, expr bzl.Expr) { a[name] = expr }
[ "func", "(", "a", "Attrs", ")", "Set", "(", "name", "string", ",", "expr", "bzl", ".", "Expr", ")", "{", "a", "[", "name", "]", "=", "expr", "\n", "}" ]
// Set sets the named attribute to the provided bazel expression.
[ "Set", "sets", "the", "named", "attribute", "to", "the", "provided", "bazel", "expression", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/kazel.go#L510-L512
train
kubernetes-incubator/external-storage
repo-infra/kazel/kazel.go
SetList
func (a Attrs) SetList(name string, expr *bzl.ListExpr) { if len(expr.List) == 0 { return } a[name] = expr }
go
func (a Attrs) SetList(name string, expr *bzl.ListExpr) { if len(expr.List) == 0 { return } a[name] = expr }
[ "func", "(", "a", "Attrs", ")", "SetList", "(", "name", "string", ",", "expr", "*", "bzl", ".", "ListExpr", ")", "{", "if", "len", "(", "expr", ".", "List", ")", "==", "0", "{", "return", "\n", "}", "\n", "a", "[", "name", "]", "=", "expr", "\n", "}" ]
// SetList sets the named attribute to the provided bazel expression list.
[ "SetList", "sets", "the", "named", "attribute", "to", "the", "provided", "bazel", "expression", "list", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/kazel.go#L515-L520
train
kubernetes-incubator/external-storage
repo-infra/kazel/kazel.go
findBuildFile
func findBuildFile(pkgPath string) (bool, string) { options := []string{"BUILD.bazel", "BUILD"} for _, b := range options { path := filepath.Join(pkgPath, b) info, err := os.Stat(path) if err == nil && !info.IsDir() { return true, path } } return false, filepath.Join(pkgPath, "BUILD") }
go
func findBuildFile(pkgPath string) (bool, string) { options := []string{"BUILD.bazel", "BUILD"} for _, b := range options { path := filepath.Join(pkgPath, b) info, err := os.Stat(path) if err == nil && !info.IsDir() { return true, path } } return false, filepath.Join(pkgPath, "BUILD") }
[ "func", "findBuildFile", "(", "pkgPath", "string", ")", "(", "bool", ",", "string", ")", "{", "options", ":=", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", "\n", "for", "_", ",", "b", ":=", "range", "options", "{", "path", ":=", "filepath", ".", "Join", "(", "pkgPath", ",", "b", ")", "\n", "info", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "==", "nil", "&&", "!", "info", ".", "IsDir", "(", ")", "{", "return", "true", ",", "path", "\n", "}", "\n", "}", "\n", "return", "false", ",", "filepath", ".", "Join", "(", "pkgPath", ",", "\"", "\"", ")", "\n", "}" ]
// findBuildFile determines the name of a preexisting BUILD file, returning // a default if no such file exists.
[ "findBuildFile", "determines", "the", "name", "of", "a", "preexisting", "BUILD", "file", "returning", "a", "default", "if", "no", "such", "file", "exists", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/kazel.go#L616-L626
train
kubernetes-incubator/external-storage
repo-infra/kazel/kazel.go
ReconcileRules
func ReconcileRules(pkgPath string, rules []*bzl.Rule, managedAttrs []string, dryRun bool) (bool, error) { _, path := findBuildFile(pkgPath) info, err := os.Stat(path) if err != nil && os.IsNotExist(err) { f := &bzl.File{} writeHeaders(f) reconcileLoad(f, rules) writeRules(f, rules) return writeFile(path, f, false, dryRun) } else if err != nil { return false, err } if info.IsDir() { return false, fmt.Errorf("%q cannot be a directory", path) } b, err := ioutil.ReadFile(path) if err != nil { return false, err } f, err := bzl.Parse(path, b) if err != nil { return false, err } oldRules := make(map[string]*bzl.Rule) for _, r := range f.Rules("") { oldRules[r.Name()] = r } for _, r := range rules { o, ok := oldRules[r.Name()] if !ok { f.Stmt = append(f.Stmt, r.Call) continue } if !RuleIsManaged(o) { continue } reconcileAttr := func(o, n *bzl.Rule, name string) { if e := n.Attr(name); e != nil { o.SetAttr(name, e) } else { o.DelAttr(name) } } for _, attr := range managedAttrs { reconcileAttr(o, r, attr) } delete(oldRules, r.Name()) } for _, r := range oldRules { if !RuleIsManaged(r) { continue } f.DelRules(r.Kind(), r.Name()) } reconcileLoad(f, f.Rules("")) return writeFile(path, f, true, dryRun) }
go
func ReconcileRules(pkgPath string, rules []*bzl.Rule, managedAttrs []string, dryRun bool) (bool, error) { _, path := findBuildFile(pkgPath) info, err := os.Stat(path) if err != nil && os.IsNotExist(err) { f := &bzl.File{} writeHeaders(f) reconcileLoad(f, rules) writeRules(f, rules) return writeFile(path, f, false, dryRun) } else if err != nil { return false, err } if info.IsDir() { return false, fmt.Errorf("%q cannot be a directory", path) } b, err := ioutil.ReadFile(path) if err != nil { return false, err } f, err := bzl.Parse(path, b) if err != nil { return false, err } oldRules := make(map[string]*bzl.Rule) for _, r := range f.Rules("") { oldRules[r.Name()] = r } for _, r := range rules { o, ok := oldRules[r.Name()] if !ok { f.Stmt = append(f.Stmt, r.Call) continue } if !RuleIsManaged(o) { continue } reconcileAttr := func(o, n *bzl.Rule, name string) { if e := n.Attr(name); e != nil { o.SetAttr(name, e) } else { o.DelAttr(name) } } for _, attr := range managedAttrs { reconcileAttr(o, r, attr) } delete(oldRules, r.Name()) } for _, r := range oldRules { if !RuleIsManaged(r) { continue } f.DelRules(r.Kind(), r.Name()) } reconcileLoad(f, f.Rules("")) return writeFile(path, f, true, dryRun) }
[ "func", "ReconcileRules", "(", "pkgPath", "string", ",", "rules", "[", "]", "*", "bzl", ".", "Rule", ",", "managedAttrs", "[", "]", "string", ",", "dryRun", "bool", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "path", ":=", "findBuildFile", "(", "pkgPath", ")", "\n", "info", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "&&", "os", ".", "IsNotExist", "(", "err", ")", "{", "f", ":=", "&", "bzl", ".", "File", "{", "}", "\n", "writeHeaders", "(", "f", ")", "\n", "reconcileLoad", "(", "f", ",", "rules", ")", "\n", "writeRules", "(", "f", ",", "rules", ")", "\n", "return", "writeFile", "(", "path", ",", "f", ",", "false", ",", "dryRun", ")", "\n", "}", "else", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "if", "info", ".", "IsDir", "(", ")", "{", "return", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "path", ")", "\n", "}", "\n", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "f", ",", "err", ":=", "bzl", ".", "Parse", "(", "path", ",", "b", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "oldRules", ":=", "make", "(", "map", "[", "string", "]", "*", "bzl", ".", "Rule", ")", "\n", "for", "_", ",", "r", ":=", "range", "f", ".", "Rules", "(", "\"", "\"", ")", "{", "oldRules", "[", "r", ".", "Name", "(", ")", "]", "=", "r", "\n", "}", "\n", "for", "_", ",", "r", ":=", "range", "rules", "{", "o", ",", "ok", ":=", "oldRules", "[", "r", ".", "Name", "(", ")", "]", "\n", "if", "!", "ok", "{", "f", ".", "Stmt", "=", "append", "(", "f", ".", "Stmt", ",", "r", ".", "Call", ")", "\n", "continue", "\n", "}", "\n", "if", "!", "RuleIsManaged", "(", "o", ")", "{", "continue", "\n", "}", "\n", "reconcileAttr", ":=", "func", "(", "o", ",", "n", "*", "bzl", ".", "Rule", ",", "name", "string", ")", "{", "if", "e", ":=", "n", ".", "Attr", "(", "name", ")", ";", "e", "!=", "nil", "{", "o", ".", "SetAttr", "(", "name", ",", "e", ")", "\n", "}", "else", "{", "o", ".", "DelAttr", "(", "name", ")", "\n", "}", "\n", "}", "\n", "for", "_", ",", "attr", ":=", "range", "managedAttrs", "{", "reconcileAttr", "(", "o", ",", "r", ",", "attr", ")", "\n", "}", "\n", "delete", "(", "oldRules", ",", "r", ".", "Name", "(", ")", ")", "\n", "}", "\n\n", "for", "_", ",", "r", ":=", "range", "oldRules", "{", "if", "!", "RuleIsManaged", "(", "r", ")", "{", "continue", "\n", "}", "\n", "f", ".", "DelRules", "(", "r", ".", "Kind", "(", ")", ",", "r", ".", "Name", "(", ")", ")", "\n", "}", "\n", "reconcileLoad", "(", "f", ",", "f", ".", "Rules", "(", "\"", "\"", ")", ")", "\n\n", "return", "writeFile", "(", "path", ",", "f", ",", "true", ",", "dryRun", ")", "\n", "}" ]
// ReconcileRules reconciles, simplifies, and writes the rules for the specified package, adding // additional dependency rules as needed.
[ "ReconcileRules", "reconciles", "simplifies", "and", "writes", "the", "rules", "for", "the", "specified", "package", "adding", "additional", "dependency", "rules", "as", "needed", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/kazel.go#L630-L688
train
kubernetes-incubator/external-storage
repo-infra/kazel/kazel.go
RuleIsManaged
func RuleIsManaged(r *bzl.Rule) bool { var automanaged bool for _, tag := range r.AttrStrings("tags") { if tag == automanagedTag { automanaged = true break } } return automanaged }
go
func RuleIsManaged(r *bzl.Rule) bool { var automanaged bool for _, tag := range r.AttrStrings("tags") { if tag == automanagedTag { automanaged = true break } } return automanaged }
[ "func", "RuleIsManaged", "(", "r", "*", "bzl", ".", "Rule", ")", "bool", "{", "var", "automanaged", "bool", "\n", "for", "_", ",", "tag", ":=", "range", "r", ".", "AttrStrings", "(", "\"", "\"", ")", "{", "if", "tag", "==", "automanagedTag", "{", "automanaged", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "return", "automanaged", "\n", "}" ]
// RuleIsManaged returns whether the provided rule is managed by this tool, // based on the tags set on the rule.
[ "RuleIsManaged", "returns", "whether", "the", "provided", "rule", "is", "managed", "by", "this", "tool", "based", "on", "the", "tags", "set", "on", "the", "rule", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/kazel.go#L729-L738
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/plugins.go
CloudProviders
func CloudProviders() []string { names := []string{} providersMutex.Lock() defer providersMutex.Unlock() for name := range providers { names = append(names, name) } return names }
go
func CloudProviders() []string { names := []string{} providersMutex.Lock() defer providersMutex.Unlock() for name := range providers { names = append(names, name) } return names }
[ "func", "CloudProviders", "(", ")", "[", "]", "string", "{", "names", ":=", "[", "]", "string", "{", "}", "\n", "providersMutex", ".", "Lock", "(", ")", "\n", "defer", "providersMutex", ".", "Unlock", "(", ")", "\n", "for", "name", ":=", "range", "providers", "{", "names", "=", "append", "(", "names", ",", "name", ")", "\n", "}", "\n", "return", "names", "\n", "}" ]
// CloudProviders returns the name of all registered cloud providers in a // string slice
[ "CloudProviders", "returns", "the", "name", "of", "all", "registered", "cloud", "providers", "in", "a", "string", "slice" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/plugins.go#L65-L73
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util_linux.go
GetBlockCapacityByte
func (u *volumeUtil) GetBlockCapacityByte(fullPath string) (int64, error) { file, err := os.OpenFile(fullPath, os.O_RDONLY, 0) if err != nil { return 0, err } defer file.Close() var size int64 // Get size of block device into 64 bit int. // Ref: http://www.microhowto.info/howto/get_the_size_of_a_linux_block_special_device_in_c.html if _, _, err := unix.Syscall(unix.SYS_IOCTL, file.Fd(), unix.BLKGETSIZE64, uintptr(unsafe.Pointer(&size))); err != 0 { return 0, err } return size, err }
go
func (u *volumeUtil) GetBlockCapacityByte(fullPath string) (int64, error) { file, err := os.OpenFile(fullPath, os.O_RDONLY, 0) if err != nil { return 0, err } defer file.Close() var size int64 // Get size of block device into 64 bit int. // Ref: http://www.microhowto.info/howto/get_the_size_of_a_linux_block_special_device_in_c.html if _, _, err := unix.Syscall(unix.SYS_IOCTL, file.Fd(), unix.BLKGETSIZE64, uintptr(unsafe.Pointer(&size))); err != 0 { return 0, err } return size, err }
[ "func", "(", "u", "*", "volumeUtil", ")", "GetBlockCapacityByte", "(", "fullPath", "string", ")", "(", "int64", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "fullPath", ",", "os", ".", "O_RDONLY", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "var", "size", "int64", "\n", "// Get size of block device into 64 bit int.", "// Ref: http://www.microhowto.info/howto/get_the_size_of_a_linux_block_special_device_in_c.html", "if", "_", ",", "_", ",", "err", ":=", "unix", ".", "Syscall", "(", "unix", ".", "SYS_IOCTL", ",", "file", ".", "Fd", "(", ")", ",", "unix", ".", "BLKGETSIZE64", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "size", ")", ")", ")", ";", "err", "!=", "0", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "size", ",", "err", "\n", "}" ]
// GetBlockCapacityByte returns capacity in bytes of a block device. // fullPath is the pathname of block device.
[ "GetBlockCapacityByte", "returns", "capacity", "in", "bytes", "of", "a", "block", "device", ".", "fullPath", "is", "the", "pathname", "of", "block", "device", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util_linux.go#L30-L45
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
CreateLocalPVSpec
func CreateLocalPVSpec(config *LocalPVConfig) *v1.PersistentVolume { pv := &v1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: config.Name, Labels: config.Labels, Annotations: map[string]string{ AnnProvisionedBy: config.ProvisionerName, }, }, Spec: v1.PersistentVolumeSpec{ PersistentVolumeReclaimPolicy: config.ReclaimPolicy, Capacity: v1.ResourceList{ v1.ResourceName(v1.ResourceStorage): *resource.NewQuantity(int64(config.Capacity), resource.BinarySI), }, PersistentVolumeSource: v1.PersistentVolumeSource{ Local: &v1.LocalVolumeSource{ Path: config.HostPath, FSType: config.FsType, }, }, AccessModes: []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, }, StorageClassName: config.StorageClass, VolumeMode: &config.VolumeMode, MountOptions: config.MountOptions, }, } if config.UseAlphaAPI { pv.ObjectMeta.Annotations[AlphaStorageNodeAffinityAnnotation] = config.AffinityAnn } else { pv.Spec.NodeAffinity = config.NodeAffinity } return pv }
go
func CreateLocalPVSpec(config *LocalPVConfig) *v1.PersistentVolume { pv := &v1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: config.Name, Labels: config.Labels, Annotations: map[string]string{ AnnProvisionedBy: config.ProvisionerName, }, }, Spec: v1.PersistentVolumeSpec{ PersistentVolumeReclaimPolicy: config.ReclaimPolicy, Capacity: v1.ResourceList{ v1.ResourceName(v1.ResourceStorage): *resource.NewQuantity(int64(config.Capacity), resource.BinarySI), }, PersistentVolumeSource: v1.PersistentVolumeSource{ Local: &v1.LocalVolumeSource{ Path: config.HostPath, FSType: config.FsType, }, }, AccessModes: []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, }, StorageClassName: config.StorageClass, VolumeMode: &config.VolumeMode, MountOptions: config.MountOptions, }, } if config.UseAlphaAPI { pv.ObjectMeta.Annotations[AlphaStorageNodeAffinityAnnotation] = config.AffinityAnn } else { pv.Spec.NodeAffinity = config.NodeAffinity } return pv }
[ "func", "CreateLocalPVSpec", "(", "config", "*", "LocalPVConfig", ")", "*", "v1", ".", "PersistentVolume", "{", "pv", ":=", "&", "v1", ".", "PersistentVolume", "{", "ObjectMeta", ":", "metav1", ".", "ObjectMeta", "{", "Name", ":", "config", ".", "Name", ",", "Labels", ":", "config", ".", "Labels", ",", "Annotations", ":", "map", "[", "string", "]", "string", "{", "AnnProvisionedBy", ":", "config", ".", "ProvisionerName", ",", "}", ",", "}", ",", "Spec", ":", "v1", ".", "PersistentVolumeSpec", "{", "PersistentVolumeReclaimPolicy", ":", "config", ".", "ReclaimPolicy", ",", "Capacity", ":", "v1", ".", "ResourceList", "{", "v1", ".", "ResourceName", "(", "v1", ".", "ResourceStorage", ")", ":", "*", "resource", ".", "NewQuantity", "(", "int64", "(", "config", ".", "Capacity", ")", ",", "resource", ".", "BinarySI", ")", ",", "}", ",", "PersistentVolumeSource", ":", "v1", ".", "PersistentVolumeSource", "{", "Local", ":", "&", "v1", ".", "LocalVolumeSource", "{", "Path", ":", "config", ".", "HostPath", ",", "FSType", ":", "config", ".", "FsType", ",", "}", ",", "}", ",", "AccessModes", ":", "[", "]", "v1", ".", "PersistentVolumeAccessMode", "{", "v1", ".", "ReadWriteOnce", ",", "}", ",", "StorageClassName", ":", "config", ".", "StorageClass", ",", "VolumeMode", ":", "&", "config", ".", "VolumeMode", ",", "MountOptions", ":", "config", ".", "MountOptions", ",", "}", ",", "}", "\n", "if", "config", ".", "UseAlphaAPI", "{", "pv", ".", "ObjectMeta", ".", "Annotations", "[", "AlphaStorageNodeAffinityAnnotation", "]", "=", "config", ".", "AffinityAnn", "\n", "}", "else", "{", "pv", ".", "Spec", ".", "NodeAffinity", "=", "config", ".", "NodeAffinity", "\n", "}", "\n", "return", "pv", "\n", "}" ]
// CreateLocalPVSpec returns a PV spec that can be used for PV creation
[ "CreateLocalPVSpec", "returns", "a", "PV", "spec", "that", "can", "be", "used", "for", "PV", "creation" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L201-L235
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
GetVolumeConfigFromConfigMap
func GetVolumeConfigFromConfigMap(client *kubernetes.Clientset, namespace, name string, provisionerConfig *ProvisionerConfiguration) error { configMap, err := client.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{}) if err != nil { return err } err = ConfigMapDataToVolumeConfig(configMap.Data, provisionerConfig) return err }
go
func GetVolumeConfigFromConfigMap(client *kubernetes.Clientset, namespace, name string, provisionerConfig *ProvisionerConfiguration) error { configMap, err := client.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{}) if err != nil { return err } err = ConfigMapDataToVolumeConfig(configMap.Data, provisionerConfig) return err }
[ "func", "GetVolumeConfigFromConfigMap", "(", "client", "*", "kubernetes", ".", "Clientset", ",", "namespace", ",", "name", "string", ",", "provisionerConfig", "*", "ProvisionerConfiguration", ")", "error", "{", "configMap", ",", "err", ":=", "client", ".", "CoreV1", "(", ")", ".", "ConfigMaps", "(", "namespace", ")", ".", "Get", "(", "name", ",", "metav1", ".", "GetOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "ConfigMapDataToVolumeConfig", "(", "configMap", ".", "Data", ",", "provisionerConfig", ")", "\n", "return", "err", "\n", "}" ]
// GetVolumeConfigFromConfigMap gets volume configuration from given configmap.
[ "GetVolumeConfigFromConfigMap", "gets", "volume", "configuration", "from", "given", "configmap", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L248-L255
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
VolumeConfigToConfigMapData
func VolumeConfigToConfigMapData(config *ProvisionerConfiguration) (map[string]string, error) { configMapData := make(map[string]string) val, err := yaml.Marshal(config.StorageClassConfig) if err != nil { return nil, fmt.Errorf("unable to Marshal volume config: %v", err) } configMapData[ProvisonerStorageClassConfig] = string(val) if len(config.NodeLabelsForPV) > 0 { nodeLabels, nlErr := yaml.Marshal(config.NodeLabelsForPV) if nlErr != nil { return nil, fmt.Errorf("unable to Marshal node label: %v", nlErr) } configMapData[ProvisionerNodeLabelsForPV] = string(nodeLabels) } ver, err := yaml.Marshal(config.UseAlphaAPI) if err != nil { return nil, fmt.Errorf("unable to Marshal API version config: %v", err) } configMapData[ProvisionerUseAlphaAPI] = string(ver) return configMapData, nil }
go
func VolumeConfigToConfigMapData(config *ProvisionerConfiguration) (map[string]string, error) { configMapData := make(map[string]string) val, err := yaml.Marshal(config.StorageClassConfig) if err != nil { return nil, fmt.Errorf("unable to Marshal volume config: %v", err) } configMapData[ProvisonerStorageClassConfig] = string(val) if len(config.NodeLabelsForPV) > 0 { nodeLabels, nlErr := yaml.Marshal(config.NodeLabelsForPV) if nlErr != nil { return nil, fmt.Errorf("unable to Marshal node label: %v", nlErr) } configMapData[ProvisionerNodeLabelsForPV] = string(nodeLabels) } ver, err := yaml.Marshal(config.UseAlphaAPI) if err != nil { return nil, fmt.Errorf("unable to Marshal API version config: %v", err) } configMapData[ProvisionerUseAlphaAPI] = string(ver) return configMapData, nil }
[ "func", "VolumeConfigToConfigMapData", "(", "config", "*", "ProvisionerConfiguration", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "configMapData", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "val", ",", "err", ":=", "yaml", ".", "Marshal", "(", "config", ".", "StorageClassConfig", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "configMapData", "[", "ProvisonerStorageClassConfig", "]", "=", "string", "(", "val", ")", "\n", "if", "len", "(", "config", ".", "NodeLabelsForPV", ")", ">", "0", "{", "nodeLabels", ",", "nlErr", ":=", "yaml", ".", "Marshal", "(", "config", ".", "NodeLabelsForPV", ")", "\n", "if", "nlErr", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "nlErr", ")", "\n", "}", "\n", "configMapData", "[", "ProvisionerNodeLabelsForPV", "]", "=", "string", "(", "nodeLabels", ")", "\n", "}", "\n", "ver", ",", "err", ":=", "yaml", ".", "Marshal", "(", "config", ".", "UseAlphaAPI", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "configMapData", "[", "ProvisionerUseAlphaAPI", "]", "=", "string", "(", "ver", ")", "\n\n", "return", "configMapData", ",", "nil", "\n", "}" ]
// VolumeConfigToConfigMapData converts volume config to configmap data.
[ "VolumeConfigToConfigMapData", "converts", "volume", "config", "to", "configmap", "data", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L258-L279
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
ConfigMapDataToVolumeConfig
func ConfigMapDataToVolumeConfig(data map[string]string, provisionerConfig *ProvisionerConfiguration) error { rawYaml := "" for key, val := range data { rawYaml += key rawYaml += ": \n" rawYaml += insertSpaces(string(val)) } if err := yaml.Unmarshal([]byte(rawYaml), provisionerConfig); err != nil { return fmt.Errorf("fail to Unmarshal yaml due to: %#v", err) } for class, config := range provisionerConfig.StorageClassConfig { if config.BlockCleanerCommand == nil { // Supply a default block cleaner command. config.BlockCleanerCommand = []string{DefaultBlockCleanerCommand} } else { // Validate that array is non empty. if len(config.BlockCleanerCommand) < 1 { return fmt.Errorf("Invalid empty block cleaner command for class %v", class) } } if config.MountDir == "" || config.HostDir == "" { return fmt.Errorf("Storage Class %v is misconfigured, missing HostDir or MountDir parameter", class) } if config.VolumeMode == "" { config.VolumeMode = DefaultVolumeMode } volumeMode := v1.PersistentVolumeMode(config.VolumeMode) if volumeMode != v1.PersistentVolumeBlock && volumeMode != v1.PersistentVolumeFilesystem { return fmt.Errorf("unsupported volume mode %s", config.VolumeMode) } provisionerConfig.StorageClassConfig[class] = config glog.Infof("StorageClass %q configured with MountDir %q, HostDir %q, VolumeMode %q, FsType %q, BlockCleanerCommand %q", class, config.MountDir, config.HostDir, config.VolumeMode, config.FsType, config.BlockCleanerCommand) } return nil }
go
func ConfigMapDataToVolumeConfig(data map[string]string, provisionerConfig *ProvisionerConfiguration) error { rawYaml := "" for key, val := range data { rawYaml += key rawYaml += ": \n" rawYaml += insertSpaces(string(val)) } if err := yaml.Unmarshal([]byte(rawYaml), provisionerConfig); err != nil { return fmt.Errorf("fail to Unmarshal yaml due to: %#v", err) } for class, config := range provisionerConfig.StorageClassConfig { if config.BlockCleanerCommand == nil { // Supply a default block cleaner command. config.BlockCleanerCommand = []string{DefaultBlockCleanerCommand} } else { // Validate that array is non empty. if len(config.BlockCleanerCommand) < 1 { return fmt.Errorf("Invalid empty block cleaner command for class %v", class) } } if config.MountDir == "" || config.HostDir == "" { return fmt.Errorf("Storage Class %v is misconfigured, missing HostDir or MountDir parameter", class) } if config.VolumeMode == "" { config.VolumeMode = DefaultVolumeMode } volumeMode := v1.PersistentVolumeMode(config.VolumeMode) if volumeMode != v1.PersistentVolumeBlock && volumeMode != v1.PersistentVolumeFilesystem { return fmt.Errorf("unsupported volume mode %s", config.VolumeMode) } provisionerConfig.StorageClassConfig[class] = config glog.Infof("StorageClass %q configured with MountDir %q, HostDir %q, VolumeMode %q, FsType %q, BlockCleanerCommand %q", class, config.MountDir, config.HostDir, config.VolumeMode, config.FsType, config.BlockCleanerCommand) } return nil }
[ "func", "ConfigMapDataToVolumeConfig", "(", "data", "map", "[", "string", "]", "string", ",", "provisionerConfig", "*", "ProvisionerConfiguration", ")", "error", "{", "rawYaml", ":=", "\"", "\"", "\n", "for", "key", ",", "val", ":=", "range", "data", "{", "rawYaml", "+=", "key", "\n", "rawYaml", "+=", "\"", "\\n", "\"", "\n", "rawYaml", "+=", "insertSpaces", "(", "string", "(", "val", ")", ")", "\n", "}", "\n\n", "if", "err", ":=", "yaml", ".", "Unmarshal", "(", "[", "]", "byte", "(", "rawYaml", ")", ",", "provisionerConfig", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "for", "class", ",", "config", ":=", "range", "provisionerConfig", ".", "StorageClassConfig", "{", "if", "config", ".", "BlockCleanerCommand", "==", "nil", "{", "// Supply a default block cleaner command.", "config", ".", "BlockCleanerCommand", "=", "[", "]", "string", "{", "DefaultBlockCleanerCommand", "}", "\n", "}", "else", "{", "// Validate that array is non empty.", "if", "len", "(", "config", ".", "BlockCleanerCommand", ")", "<", "1", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "class", ")", "\n", "}", "\n", "}", "\n", "if", "config", ".", "MountDir", "==", "\"", "\"", "||", "config", ".", "HostDir", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "class", ")", "\n", "}", "\n\n", "if", "config", ".", "VolumeMode", "==", "\"", "\"", "{", "config", ".", "VolumeMode", "=", "DefaultVolumeMode", "\n", "}", "\n", "volumeMode", ":=", "v1", ".", "PersistentVolumeMode", "(", "config", ".", "VolumeMode", ")", "\n", "if", "volumeMode", "!=", "v1", ".", "PersistentVolumeBlock", "&&", "volumeMode", "!=", "v1", ".", "PersistentVolumeFilesystem", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "config", ".", "VolumeMode", ")", "\n", "}", "\n\n", "provisionerConfig", ".", "StorageClassConfig", "[", "class", "]", "=", "config", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "class", ",", "config", ".", "MountDir", ",", "config", ".", "HostDir", ",", "config", ".", "VolumeMode", ",", "config", ".", "FsType", ",", "config", ".", "BlockCleanerCommand", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// ConfigMapDataToVolumeConfig converts configmap data to volume config.
[ "ConfigMapDataToVolumeConfig", "converts", "configmap", "data", "to", "volume", "config", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L282-L325
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
LoadProvisionerConfigs
func LoadProvisionerConfigs(configPath string, provisionerConfig *ProvisionerConfiguration) error { files, err := ioutil.ReadDir(configPath) if err != nil { return err } data := make(map[string]string) for _, file := range files { if !file.IsDir() { if strings.Compare(file.Name(), "..data") != 0 { fileContents, err := ioutil.ReadFile(path.Join(configPath, file.Name())) if err != nil { glog.Infof("Could not read file: %s due to: %v", path.Join(configPath, file.Name()), err) return err } data[file.Name()] = string(fileContents) } } } return ConfigMapDataToVolumeConfig(data, provisionerConfig) }
go
func LoadProvisionerConfigs(configPath string, provisionerConfig *ProvisionerConfiguration) error { files, err := ioutil.ReadDir(configPath) if err != nil { return err } data := make(map[string]string) for _, file := range files { if !file.IsDir() { if strings.Compare(file.Name(), "..data") != 0 { fileContents, err := ioutil.ReadFile(path.Join(configPath, file.Name())) if err != nil { glog.Infof("Could not read file: %s due to: %v", path.Join(configPath, file.Name()), err) return err } data[file.Name()] = string(fileContents) } } } return ConfigMapDataToVolumeConfig(data, provisionerConfig) }
[ "func", "LoadProvisionerConfigs", "(", "configPath", "string", ",", "provisionerConfig", "*", "ProvisionerConfiguration", ")", "error", "{", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "configPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "data", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for", "_", ",", "file", ":=", "range", "files", "{", "if", "!", "file", ".", "IsDir", "(", ")", "{", "if", "strings", ".", "Compare", "(", "file", ".", "Name", "(", ")", ",", "\"", "\"", ")", "!=", "0", "{", "fileContents", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ".", "Join", "(", "configPath", ",", "file", ".", "Name", "(", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Infof", "(", "\"", "\"", ",", "path", ".", "Join", "(", "configPath", ",", "file", ".", "Name", "(", ")", ")", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "data", "[", "file", ".", "Name", "(", ")", "]", "=", "string", "(", "fileContents", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "ConfigMapDataToVolumeConfig", "(", "data", ",", "provisionerConfig", ")", "\n", "}" ]
// LoadProvisionerConfigs loads all configuration into a string and unmarshal it into ProvisionerConfiguration struct. // The configuration is stored in the configmap which is mounted as a volume.
[ "LoadProvisionerConfigs", "loads", "all", "configuration", "into", "a", "string", "and", "unmarshal", "it", "into", "ProvisionerConfiguration", "struct", ".", "The", "configuration", "is", "stored", "in", "the", "configmap", "which", "is", "mounted", "as", "a", "volume", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L339-L358
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
SetupClient
func SetupClient() *kubernetes.Clientset { var config *rest.Config var err error kubeconfigFile := os.Getenv(KubeConfigEnv) if kubeconfigFile != "" { config, err = BuildConfigFromFlags("", kubeconfigFile) if err != nil { glog.Fatalf("Error creating config from %s specified file: %s %v\n", KubeConfigEnv, kubeconfigFile, err) } glog.Infof("Creating client using kubeconfig file %s", kubeconfigFile) } else { config, err = InClusterConfig() if err != nil { glog.Fatalf("Error creating InCluster config: %v\n", err) } glog.Infof("Creating client using in-cluster config") } clientset, err := kubernetes.NewForConfig(config) if err != nil { glog.Fatalf("Error creating clientset: %v\n", err) } return clientset }
go
func SetupClient() *kubernetes.Clientset { var config *rest.Config var err error kubeconfigFile := os.Getenv(KubeConfigEnv) if kubeconfigFile != "" { config, err = BuildConfigFromFlags("", kubeconfigFile) if err != nil { glog.Fatalf("Error creating config from %s specified file: %s %v\n", KubeConfigEnv, kubeconfigFile, err) } glog.Infof("Creating client using kubeconfig file %s", kubeconfigFile) } else { config, err = InClusterConfig() if err != nil { glog.Fatalf("Error creating InCluster config: %v\n", err) } glog.Infof("Creating client using in-cluster config") } clientset, err := kubernetes.NewForConfig(config) if err != nil { glog.Fatalf("Error creating clientset: %v\n", err) } return clientset }
[ "func", "SetupClient", "(", ")", "*", "kubernetes", ".", "Clientset", "{", "var", "config", "*", "rest", ".", "Config", "\n", "var", "err", "error", "\n\n", "kubeconfigFile", ":=", "os", ".", "Getenv", "(", "KubeConfigEnv", ")", "\n", "if", "kubeconfigFile", "!=", "\"", "\"", "{", "config", ",", "err", "=", "BuildConfigFromFlags", "(", "\"", "\"", ",", "kubeconfigFile", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Fatalf", "(", "\"", "\\n", "\"", ",", "KubeConfigEnv", ",", "kubeconfigFile", ",", "err", ")", "\n", "}", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "kubeconfigFile", ")", "\n", "}", "else", "{", "config", ",", "err", "=", "InClusterConfig", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Fatalf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "}", "\n", "glog", ".", "Infof", "(", "\"", "\"", ")", "\n", "}", "\n\n", "clientset", ",", "err", ":=", "kubernetes", ".", "NewForConfig", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Fatalf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "}", "\n", "return", "clientset", "\n", "}" ]
// SetupClient created client using either in-cluster configuration or if KUBECONFIG environment variable is specified then using that config.
[ "SetupClient", "created", "client", "using", "either", "in", "-", "cluster", "configuration", "or", "if", "KUBECONFIG", "environment", "variable", "is", "specified", "then", "using", "that", "config", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L361-L386
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
GenerateMountName
func GenerateMountName(mount *MountConfig) string { h := fnv.New32a() h.Write([]byte(mount.HostDir)) h.Write([]byte(mount.MountDir)) return fmt.Sprintf("mount-%x", h.Sum32()) }
go
func GenerateMountName(mount *MountConfig) string { h := fnv.New32a() h.Write([]byte(mount.HostDir)) h.Write([]byte(mount.MountDir)) return fmt.Sprintf("mount-%x", h.Sum32()) }
[ "func", "GenerateMountName", "(", "mount", "*", "MountConfig", ")", "string", "{", "h", ":=", "fnv", ".", "New32a", "(", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "mount", ".", "HostDir", ")", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "mount", ".", "MountDir", ")", ")", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ".", "Sum32", "(", ")", ")", "\n", "}" ]
// GenerateMountName generates a volumeMount.name for pod spec, based on volume configuration.
[ "GenerateMountName", "generates", "a", "volumeMount", ".", "name", "for", "pod", "spec", "based", "on", "volume", "configuration", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L389-L394
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/common/common.go
GetVolumeMode
func GetVolumeMode(volUtil util.VolumeUtil, fullPath string) (v1.PersistentVolumeMode, error) { isdir, errdir := volUtil.IsDir(fullPath) if isdir { return v1.PersistentVolumeFilesystem, nil } // check for Block before returning errdir isblk, errblk := volUtil.IsBlock(fullPath) if isblk { return v1.PersistentVolumeBlock, nil } if errdir == nil && errblk == nil { return "", fmt.Errorf("Skipping file %q: not a directory nor block device", fullPath) } // report the first error found if errdir != nil { return "", fmt.Errorf("Directory check for %q failed: %s", fullPath, errdir) } return "", fmt.Errorf("Block device check for %q failed: %s", fullPath, errblk) }
go
func GetVolumeMode(volUtil util.VolumeUtil, fullPath string) (v1.PersistentVolumeMode, error) { isdir, errdir := volUtil.IsDir(fullPath) if isdir { return v1.PersistentVolumeFilesystem, nil } // check for Block before returning errdir isblk, errblk := volUtil.IsBlock(fullPath) if isblk { return v1.PersistentVolumeBlock, nil } if errdir == nil && errblk == nil { return "", fmt.Errorf("Skipping file %q: not a directory nor block device", fullPath) } // report the first error found if errdir != nil { return "", fmt.Errorf("Directory check for %q failed: %s", fullPath, errdir) } return "", fmt.Errorf("Block device check for %q failed: %s", fullPath, errblk) }
[ "func", "GetVolumeMode", "(", "volUtil", "util", ".", "VolumeUtil", ",", "fullPath", "string", ")", "(", "v1", ".", "PersistentVolumeMode", ",", "error", ")", "{", "isdir", ",", "errdir", ":=", "volUtil", ".", "IsDir", "(", "fullPath", ")", "\n", "if", "isdir", "{", "return", "v1", ".", "PersistentVolumeFilesystem", ",", "nil", "\n", "}", "\n", "// check for Block before returning errdir", "isblk", ",", "errblk", ":=", "volUtil", ".", "IsBlock", "(", "fullPath", ")", "\n", "if", "isblk", "{", "return", "v1", ".", "PersistentVolumeBlock", ",", "nil", "\n", "}", "\n\n", "if", "errdir", "==", "nil", "&&", "errblk", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "fullPath", ")", "\n", "}", "\n\n", "// report the first error found", "if", "errdir", "!=", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "fullPath", ",", "errdir", ")", "\n", "}", "\n", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "fullPath", ",", "errblk", ")", "\n", "}" ]
// GetVolumeMode check volume mode of given path.
[ "GetVolumeMode", "check", "volume", "mode", "of", "given", "path", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/common/common.go#L397-L417
train
kubernetes-incubator/external-storage
nfs/pkg/volume/delete.go
Delete
func (p *nfsProvisioner) Delete(volume *v1.PersistentVolume) error { // Ignore the call if this provisioner was not the one to provision the // volume. It doesn't even attempt to delete it, so it's neither a success // (nil error) nor failure (any other error) provisioned, err := p.provisioned(volume) if err != nil { return fmt.Errorf("error determining if this provisioner was the one to provision volume %q: %v", volume.Name, err) } if !provisioned { strerr := fmt.Sprintf("this provisioner id %s didn't provision volume %q and so can't delete it; id %s did & can", p.identity, volume.Name, volume.Annotations[annProvisionerID]) return &controller.IgnoredError{Reason: strerr} } err = p.deleteDirectory(volume) if err != nil { return fmt.Errorf("error deleting volume's backing path: %v", err) } err = p.deleteExport(volume) if err != nil { return fmt.Errorf("deleted the volume's backing path but error deleting export: %v", err) } err = p.deleteQuota(volume) if err != nil { return fmt.Errorf("deleted the volume's backing path & export but error deleting quota: %v", err) } return nil }
go
func (p *nfsProvisioner) Delete(volume *v1.PersistentVolume) error { // Ignore the call if this provisioner was not the one to provision the // volume. It doesn't even attempt to delete it, so it's neither a success // (nil error) nor failure (any other error) provisioned, err := p.provisioned(volume) if err != nil { return fmt.Errorf("error determining if this provisioner was the one to provision volume %q: %v", volume.Name, err) } if !provisioned { strerr := fmt.Sprintf("this provisioner id %s didn't provision volume %q and so can't delete it; id %s did & can", p.identity, volume.Name, volume.Annotations[annProvisionerID]) return &controller.IgnoredError{Reason: strerr} } err = p.deleteDirectory(volume) if err != nil { return fmt.Errorf("error deleting volume's backing path: %v", err) } err = p.deleteExport(volume) if err != nil { return fmt.Errorf("deleted the volume's backing path but error deleting export: %v", err) } err = p.deleteQuota(volume) if err != nil { return fmt.Errorf("deleted the volume's backing path & export but error deleting quota: %v", err) } return nil }
[ "func", "(", "p", "*", "nfsProvisioner", ")", "Delete", "(", "volume", "*", "v1", ".", "PersistentVolume", ")", "error", "{", "// Ignore the call if this provisioner was not the one to provision the", "// volume. It doesn't even attempt to delete it, so it's neither a success", "// (nil error) nor failure (any other error)", "provisioned", ",", "err", ":=", "p", ".", "provisioned", "(", "volume", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "volume", ".", "Name", ",", "err", ")", "\n", "}", "\n", "if", "!", "provisioned", "{", "strerr", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "identity", ",", "volume", ".", "Name", ",", "volume", ".", "Annotations", "[", "annProvisionerID", "]", ")", "\n", "return", "&", "controller", ".", "IgnoredError", "{", "Reason", ":", "strerr", "}", "\n", "}", "\n\n", "err", "=", "p", ".", "deleteDirectory", "(", "volume", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "err", "=", "p", ".", "deleteExport", "(", "volume", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "err", "=", "p", ".", "deleteQuota", "(", "volume", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Delete removes the directory that was created by Provision backing the given // PV and removes its export from the NFS server.
[ "Delete", "removes", "the", "directory", "that", "was", "created", "by", "Provision", "backing", "the", "given", "PV", "and", "removes", "its", "export", "from", "the", "NFS", "server", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/nfs/pkg/volume/delete.go#L31-L60
train
kubernetes-incubator/external-storage
digitalocean/pkg/volume/provision.go
NewDigitalOceanProvisioner
func NewDigitalOceanProvisioner(ctx context.Context, client kubernetes.Interface, doClient *godo.Client) controller.Provisioner { var identity types.UID provisioner := &digitaloceanProvisioner{ client: client, doClient: doClient, ctx: ctx, identity: identity, } return provisioner }
go
func NewDigitalOceanProvisioner(ctx context.Context, client kubernetes.Interface, doClient *godo.Client) controller.Provisioner { var identity types.UID provisioner := &digitaloceanProvisioner{ client: client, doClient: doClient, ctx: ctx, identity: identity, } return provisioner }
[ "func", "NewDigitalOceanProvisioner", "(", "ctx", "context", ".", "Context", ",", "client", "kubernetes", ".", "Interface", ",", "doClient", "*", "godo", ".", "Client", ")", "controller", ".", "Provisioner", "{", "var", "identity", "types", ".", "UID", "\n\n", "provisioner", ":=", "&", "digitaloceanProvisioner", "{", "client", ":", "client", ",", "doClient", ":", "doClient", ",", "ctx", ":", "ctx", ",", "identity", ":", "identity", ",", "}", "\n\n", "return", "provisioner", "\n", "}" ]
// NewDigitalOceanProvisioner creates a new DigitalOcean provisioner
[ "NewDigitalOceanProvisioner", "creates", "a", "new", "DigitalOcean", "provisioner" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/digitalocean/pkg/volume/provision.go#L50-L61
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
getAccessModes
func (p *iscsiProvisioner) getAccessModes() []v1.PersistentVolumeAccessMode { return []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, v1.ReadOnlyMany, } }
go
func (p *iscsiProvisioner) getAccessModes() []v1.PersistentVolumeAccessMode { return []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, v1.ReadOnlyMany, } }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "getAccessModes", "(", ")", "[", "]", "v1", ".", "PersistentVolumeAccessMode", "{", "return", "[", "]", "v1", ".", "PersistentVolumeAccessMode", "{", "v1", ".", "ReadWriteOnce", ",", "v1", ".", "ReadOnlyMany", ",", "}", "\n", "}" ]
// getAccessModes returns access modes iscsi volume supported.
[ "getAccessModes", "returns", "access", "modes", "iscsi", "volume", "supported", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L104-L109
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
getFirstAvailableLun
func getFirstAvailableLun(exportList exportList) (int32, error) { sort.Sort(exportList) log.Debug("sorted export List: ", exportList) //this is sloppy way to remove duplicates uniqueExport := make(map[int32]export) for _, export := range exportList { uniqueExport[export.Lun] = export } log.Debug("unique luns sorted export List: ", uniqueExport) //this is a sloppy way to get the list of luns luns := make([]int, len(uniqueExport), len(uniqueExport)) i := 0 for _, export := range uniqueExport { luns[i] = int(export.Lun) i++ } log.Debug("lun list: ", luns) if len(luns) >= 255 { return -1, errors.New("255 luns allocated no more luns available") } var sluns sort.IntSlice sluns = luns[0:] sort.Sort(sluns) log.Debug("sorted lun list: ", sluns) lun := int32(len(sluns)) for i, clun := range sluns { if i < int(clun) { lun = int32(i) break } } return lun, nil }
go
func getFirstAvailableLun(exportList exportList) (int32, error) { sort.Sort(exportList) log.Debug("sorted export List: ", exportList) //this is sloppy way to remove duplicates uniqueExport := make(map[int32]export) for _, export := range exportList { uniqueExport[export.Lun] = export } log.Debug("unique luns sorted export List: ", uniqueExport) //this is a sloppy way to get the list of luns luns := make([]int, len(uniqueExport), len(uniqueExport)) i := 0 for _, export := range uniqueExport { luns[i] = int(export.Lun) i++ } log.Debug("lun list: ", luns) if len(luns) >= 255 { return -1, errors.New("255 luns allocated no more luns available") } var sluns sort.IntSlice sluns = luns[0:] sort.Sort(sluns) log.Debug("sorted lun list: ", sluns) lun := int32(len(sluns)) for i, clun := range sluns { if i < int(clun) { lun = int32(i) break } } return lun, nil }
[ "func", "getFirstAvailableLun", "(", "exportList", "exportList", ")", "(", "int32", ",", "error", ")", "{", "sort", ".", "Sort", "(", "exportList", ")", "\n", "log", ".", "Debug", "(", "\"", "\"", ",", "exportList", ")", "\n", "//this is sloppy way to remove duplicates", "uniqueExport", ":=", "make", "(", "map", "[", "int32", "]", "export", ")", "\n", "for", "_", ",", "export", ":=", "range", "exportList", "{", "uniqueExport", "[", "export", ".", "Lun", "]", "=", "export", "\n", "}", "\n", "log", ".", "Debug", "(", "\"", "\"", ",", "uniqueExport", ")", "\n\n", "//this is a sloppy way to get the list of luns", "luns", ":=", "make", "(", "[", "]", "int", ",", "len", "(", "uniqueExport", ")", ",", "len", "(", "uniqueExport", ")", ")", "\n", "i", ":=", "0", "\n", "for", "_", ",", "export", ":=", "range", "uniqueExport", "{", "luns", "[", "i", "]", "=", "int", "(", "export", ".", "Lun", ")", "\n", "i", "++", "\n", "}", "\n", "log", ".", "Debug", "(", "\"", "\"", ",", "luns", ")", "\n\n", "if", "len", "(", "luns", ")", ">=", "255", "{", "return", "-", "1", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "var", "sluns", "sort", ".", "IntSlice", "\n", "sluns", "=", "luns", "[", "0", ":", "]", "\n", "sort", ".", "Sort", "(", "sluns", ")", "\n", "log", ".", "Debug", "(", "\"", "\"", ",", "sluns", ")", "\n\n", "lun", ":=", "int32", "(", "len", "(", "sluns", ")", ")", "\n", "for", "i", ",", "clun", ":=", "range", "sluns", "{", "if", "i", "<", "int", "(", "clun", ")", "{", "lun", "=", "int32", "(", "i", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "return", "lun", ",", "nil", "\n", "}" ]
// getFirstAvailableLun gets first available Lun.
[ "getFirstAvailableLun", "gets", "first", "available", "Lun", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L312-L348
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
volDestroy
func (p *iscsiProvisioner) volDestroy(vol string, pool string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := volDestroyArgs{ Pool: pool, Name: vol, } err = client.Call("vol_destroy", args, nil) return err }
go
func (p *iscsiProvisioner) volDestroy(vol string, pool string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := volDestroyArgs{ Pool: pool, Name: vol, } err = client.Call("vol_destroy", args, nil) return err }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "volDestroy", "(", "vol", "string", ",", "pool", "string", ")", "error", "{", "client", ",", "err", ":=", "p", ".", "getConnection", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "err", ")", "\n", "return", "err", "\n", "}", "\n", "args", ":=", "volDestroyArgs", "{", "Pool", ":", "pool", ",", "Name", ":", "vol", ",", "}", "\n", "err", "=", "client", ".", "Call", "(", "\"", "\"", ",", "args", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// volDestroy removes calls vol_destroy targetd API to remove volume.
[ "volDestroy", "removes", "calls", "vol_destroy", "targetd", "API", "to", "remove", "volume", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L351-L364
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
exportDestroy
func (p *iscsiProvisioner) exportDestroy(vol string, pool string, initiator string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := exportDestroyArgs{ Pool: pool, Vol: vol, InitiatorWwn: initiator, } err = client.Call("export_destroy", args, nil) return err }
go
func (p *iscsiProvisioner) exportDestroy(vol string, pool string, initiator string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := exportDestroyArgs{ Pool: pool, Vol: vol, InitiatorWwn: initiator, } err = client.Call("export_destroy", args, nil) return err }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "exportDestroy", "(", "vol", "string", ",", "pool", "string", ",", "initiator", "string", ")", "error", "{", "client", ",", "err", ":=", "p", ".", "getConnection", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "err", ")", "\n", "return", "err", "\n", "}", "\n", "args", ":=", "exportDestroyArgs", "{", "Pool", ":", "pool", ",", "Vol", ":", "vol", ",", "InitiatorWwn", ":", "initiator", ",", "}", "\n", "err", "=", "client", ".", "Call", "(", "\"", "\"", ",", "args", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// exportDestroy calls export_destroy targetd API to remove export of volume.
[ "exportDestroy", "calls", "export_destroy", "targetd", "API", "to", "remove", "export", "of", "volume", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L367-L381
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
volCreate
func (p *iscsiProvisioner) volCreate(name string, size int64, pool string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := volCreateArgs{ Pool: pool, Name: name, Size: size, } err = client.Call("vol_create", args, nil) return err }
go
func (p *iscsiProvisioner) volCreate(name string, size int64, pool string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := volCreateArgs{ Pool: pool, Name: name, Size: size, } err = client.Call("vol_create", args, nil) return err }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "volCreate", "(", "name", "string", ",", "size", "int64", ",", "pool", "string", ")", "error", "{", "client", ",", "err", ":=", "p", ".", "getConnection", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "err", ")", "\n", "return", "err", "\n", "}", "\n", "args", ":=", "volCreateArgs", "{", "Pool", ":", "pool", ",", "Name", ":", "name", ",", "Size", ":", "size", ",", "}", "\n", "err", "=", "client", ".", "Call", "(", "\"", "\"", ",", "args", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// volCreate calls vol_create targetd API to create a volume.
[ "volCreate", "calls", "vol_create", "targetd", "API", "to", "create", "a", "volume", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L384-L398
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
exportCreate
func (p *iscsiProvisioner) exportCreate(vol string, lun int32, pool string, initiator string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := exportCreateArgs{ Pool: pool, Vol: vol, InitiatorWwn: initiator, Lun: lun, } err = client.Call("export_create", args, nil) return err }
go
func (p *iscsiProvisioner) exportCreate(vol string, lun int32, pool string, initiator string) error { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return err } args := exportCreateArgs{ Pool: pool, Vol: vol, InitiatorWwn: initiator, Lun: lun, } err = client.Call("export_create", args, nil) return err }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "exportCreate", "(", "vol", "string", ",", "lun", "int32", ",", "pool", "string", ",", "initiator", "string", ")", "error", "{", "client", ",", "err", ":=", "p", ".", "getConnection", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "err", ")", "\n", "return", "err", "\n", "}", "\n", "args", ":=", "exportCreateArgs", "{", "Pool", ":", "pool", ",", "Vol", ":", "vol", ",", "InitiatorWwn", ":", "initiator", ",", "Lun", ":", "lun", ",", "}", "\n", "err", "=", "client", ".", "Call", "(", "\"", "\"", ",", "args", ",", "nil", ")", "\n", "return", "err", "\n", "}" ]
// exportCreate calls export_create targetd API to create an export of volume.
[ "exportCreate", "calls", "export_create", "targetd", "API", "to", "create", "an", "export", "of", "volume", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L401-L416
train
kubernetes-incubator/external-storage
iscsi/targetd/provisioner/iscsi-provisioner.go
exportList
func (p *iscsiProvisioner) exportList() (exportList, error) { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return nil, err } var result1 exportList err = client.Call("export_list", nil, &result1) return result1, err }
go
func (p *iscsiProvisioner) exportList() (exportList, error) { client, err := p.getConnection() defer client.Close() if err != nil { log.Warnln(err) return nil, err } var result1 exportList err = client.Call("export_list", nil, &result1) return result1, err }
[ "func", "(", "p", "*", "iscsiProvisioner", ")", "exportList", "(", ")", "(", "exportList", ",", "error", ")", "{", "client", ",", "err", ":=", "p", ".", "getConnection", "(", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warnln", "(", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "var", "result1", "exportList", "\n", "err", "=", "client", ".", "Call", "(", "\"", "\"", ",", "nil", ",", "&", "result1", ")", "\n", "return", "result1", ",", "err", "\n", "}" ]
// exportList lists calls export_list targetd API to get export objects.
[ "exportList", "lists", "calls", "export_list", "targetd", "API", "to", "get", "export", "objects", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/iscsi/targetd/provisioner/iscsi-provisioner.go#L419-L429
train
kubernetes-incubator/external-storage
repo-infra/kazel/sourcerer.go
walkSource
func (v *Vendorer) walkSource(pkgPath string) ([]string, error) { // clean pkgPath since we access v.newRules directly pkgPath = filepath.Clean(pkgPath) for _, r := range v.skippedPaths { if r.Match([]byte(pkgPath)) { return nil, nil } } files, err := ioutil.ReadDir(pkgPath) if err != nil { return nil, err } // Find any children packages we need to include in an all-srcs rule. var children []string for _, f := range files { if f.IsDir() { c, err := v.walkSource(filepath.Join(pkgPath, f.Name())) if err != nil { return nil, err } children = append(children, c...) } } // This path is a package either if we've added rules or if a BUILD file already exists. _, hasRules := v.newRules[pkgPath] isPkg := hasRules if !isPkg { isPkg, _ = findBuildFile(pkgPath) } if !isPkg { // This directory isn't a package (doesn't contain a BUILD file), // but there might be subdirectories that are packages, // so pass that up to our parent. return children, nil } // Enforce formatting the BUILD file, even if we're not adding srcs rules if !hasRules { v.addRules(pkgPath, nil) } if !v.cfg.AddSourcesRules { return nil, nil } pkgSrcsExpr := &bzl.LiteralExpr{Token: `glob(["**"])`} if pkgPath == "." { pkgSrcsExpr = &bzl.LiteralExpr{Token: `glob(["**"], exclude=["bazel-*/**", ".git/**"])`} } v.addRules(pkgPath, []*bzl.Rule{ newRule(RuleTypeFileGroup, func(_ ruleType) string { return pkgSrcsTarget }, map[string]bzl.Expr{ "srcs": pkgSrcsExpr, "visibility": asExpr([]string{"//visibility:private"}), }), newRule(RuleTypeFileGroup, func(_ ruleType) string { return allSrcsTarget }, map[string]bzl.Expr{ "srcs": asExpr(append(children, fmt.Sprintf(":%s", pkgSrcsTarget))), }), }) return []string{fmt.Sprintf("//%s:%s", pkgPath, allSrcsTarget)}, nil }
go
func (v *Vendorer) walkSource(pkgPath string) ([]string, error) { // clean pkgPath since we access v.newRules directly pkgPath = filepath.Clean(pkgPath) for _, r := range v.skippedPaths { if r.Match([]byte(pkgPath)) { return nil, nil } } files, err := ioutil.ReadDir(pkgPath) if err != nil { return nil, err } // Find any children packages we need to include in an all-srcs rule. var children []string for _, f := range files { if f.IsDir() { c, err := v.walkSource(filepath.Join(pkgPath, f.Name())) if err != nil { return nil, err } children = append(children, c...) } } // This path is a package either if we've added rules or if a BUILD file already exists. _, hasRules := v.newRules[pkgPath] isPkg := hasRules if !isPkg { isPkg, _ = findBuildFile(pkgPath) } if !isPkg { // This directory isn't a package (doesn't contain a BUILD file), // but there might be subdirectories that are packages, // so pass that up to our parent. return children, nil } // Enforce formatting the BUILD file, even if we're not adding srcs rules if !hasRules { v.addRules(pkgPath, nil) } if !v.cfg.AddSourcesRules { return nil, nil } pkgSrcsExpr := &bzl.LiteralExpr{Token: `glob(["**"])`} if pkgPath == "." { pkgSrcsExpr = &bzl.LiteralExpr{Token: `glob(["**"], exclude=["bazel-*/**", ".git/**"])`} } v.addRules(pkgPath, []*bzl.Rule{ newRule(RuleTypeFileGroup, func(_ ruleType) string { return pkgSrcsTarget }, map[string]bzl.Expr{ "srcs": pkgSrcsExpr, "visibility": asExpr([]string{"//visibility:private"}), }), newRule(RuleTypeFileGroup, func(_ ruleType) string { return allSrcsTarget }, map[string]bzl.Expr{ "srcs": asExpr(append(children, fmt.Sprintf(":%s", pkgSrcsTarget))), }), }) return []string{fmt.Sprintf("//%s:%s", pkgPath, allSrcsTarget)}, nil }
[ "func", "(", "v", "*", "Vendorer", ")", "walkSource", "(", "pkgPath", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// clean pkgPath since we access v.newRules directly", "pkgPath", "=", "filepath", ".", "Clean", "(", "pkgPath", ")", "\n", "for", "_", ",", "r", ":=", "range", "v", ".", "skippedPaths", "{", "if", "r", ".", "Match", "(", "[", "]", "byte", "(", "pkgPath", ")", ")", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "}", "\n", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "pkgPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Find any children packages we need to include in an all-srcs rule.", "var", "children", "[", "]", "string", "\n", "for", "_", ",", "f", ":=", "range", "files", "{", "if", "f", ".", "IsDir", "(", ")", "{", "c", ",", "err", ":=", "v", ".", "walkSource", "(", "filepath", ".", "Join", "(", "pkgPath", ",", "f", ".", "Name", "(", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "children", "=", "append", "(", "children", ",", "c", "...", ")", "\n", "}", "\n", "}", "\n\n", "// This path is a package either if we've added rules or if a BUILD file already exists.", "_", ",", "hasRules", ":=", "v", ".", "newRules", "[", "pkgPath", "]", "\n", "isPkg", ":=", "hasRules", "\n", "if", "!", "isPkg", "{", "isPkg", ",", "_", "=", "findBuildFile", "(", "pkgPath", ")", "\n", "}", "\n\n", "if", "!", "isPkg", "{", "// This directory isn't a package (doesn't contain a BUILD file),", "// but there might be subdirectories that are packages,", "// so pass that up to our parent.", "return", "children", ",", "nil", "\n", "}", "\n\n", "// Enforce formatting the BUILD file, even if we're not adding srcs rules", "if", "!", "hasRules", "{", "v", ".", "addRules", "(", "pkgPath", ",", "nil", ")", "\n", "}", "\n\n", "if", "!", "v", ".", "cfg", ".", "AddSourcesRules", "{", "return", "nil", ",", "nil", "\n", "}", "\n\n", "pkgSrcsExpr", ":=", "&", "bzl", ".", "LiteralExpr", "{", "Token", ":", "`glob([\"**\"])`", "}", "\n", "if", "pkgPath", "==", "\"", "\"", "{", "pkgSrcsExpr", "=", "&", "bzl", ".", "LiteralExpr", "{", "Token", ":", "`glob([\"**\"], exclude=[\"bazel-*/**\", \".git/**\"])`", "}", "\n", "}", "\n\n", "v", ".", "addRules", "(", "pkgPath", ",", "[", "]", "*", "bzl", ".", "Rule", "{", "newRule", "(", "RuleTypeFileGroup", ",", "func", "(", "_", "ruleType", ")", "string", "{", "return", "pkgSrcsTarget", "}", ",", "map", "[", "string", "]", "bzl", ".", "Expr", "{", "\"", "\"", ":", "pkgSrcsExpr", ",", "\"", "\"", ":", "asExpr", "(", "[", "]", "string", "{", "\"", "\"", "}", ")", ",", "}", ")", ",", "newRule", "(", "RuleTypeFileGroup", ",", "func", "(", "_", "ruleType", ")", "string", "{", "return", "allSrcsTarget", "}", ",", "map", "[", "string", "]", "bzl", ".", "Expr", "{", "\"", "\"", ":", "asExpr", "(", "append", "(", "children", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pkgSrcsTarget", ")", ")", ")", ",", "}", ")", ",", "}", ")", "\n", "return", "[", "]", "string", "{", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pkgPath", ",", "allSrcsTarget", ")", "}", ",", "nil", "\n", "}" ]
// walkSource walks the source tree recursively from pkgPath, adding // any BUILD files to v.newRules to be formatted. // // If AddSourcesRules is enabled in the kazel config, then we additionally add // package-sources and recursive all-srcs filegroups rules to every BUILD file. // // Returns the list of children all-srcs targets that should be added to the // all-srcs rule of the enclosing package.
[ "walkSource", "walks", "the", "source", "tree", "recursively", "from", "pkgPath", "adding", "any", "BUILD", "files", "to", "v", ".", "newRules", "to", "be", "formatted", ".", "If", "AddSourcesRules", "is", "enabled", "in", "the", "kazel", "config", "then", "we", "additionally", "add", "package", "-", "sources", "and", "recursive", "all", "-", "srcs", "filegroups", "rules", "to", "every", "BUILD", "file", ".", "Returns", "the", "list", "of", "children", "all", "-", "srcs", "targets", "that", "should", "be", "added", "to", "the", "all", "-", "srcs", "rule", "of", "the", "enclosing", "package", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/sourcerer.go#L40-L107
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_client.go
NewNetworkV2
func (os *OpenStack) NewNetworkV2() (*gophercloud.ServiceClient, error) { network, err := openstack.NewNetworkV2(os.provider, gophercloud.EndpointOpts{ Region: os.region, }) if err != nil { glog.Warningf("Failed to find network v2 endpoint: %v", err) return nil, err } return network, nil }
go
func (os *OpenStack) NewNetworkV2() (*gophercloud.ServiceClient, error) { network, err := openstack.NewNetworkV2(os.provider, gophercloud.EndpointOpts{ Region: os.region, }) if err != nil { glog.Warningf("Failed to find network v2 endpoint: %v", err) return nil, err } return network, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "NewNetworkV2", "(", ")", "(", "*", "gophercloud", ".", "ServiceClient", ",", "error", ")", "{", "network", ",", "err", ":=", "openstack", ".", "NewNetworkV2", "(", "os", ".", "provider", ",", "gophercloud", ".", "EndpointOpts", "{", "Region", ":", "os", ".", "region", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "network", ",", "nil", "\n", "}" ]
// NewNetworkV2 creates a new Network V2 endpoint
[ "NewNetworkV2", "creates", "a", "new", "Network", "V2", "endpoint" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_client.go#L27-L36
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_client.go
NewComputeV2
func (os *OpenStack) NewComputeV2() (*gophercloud.ServiceClient, error) { compute, err := openstack.NewComputeV2(os.provider, gophercloud.EndpointOpts{ Region: os.region, }) if err != nil { glog.Warningf("Failed to find compute v2 endpoint: %v", err) return nil, err } return compute, nil }
go
func (os *OpenStack) NewComputeV2() (*gophercloud.ServiceClient, error) { compute, err := openstack.NewComputeV2(os.provider, gophercloud.EndpointOpts{ Region: os.region, }) if err != nil { glog.Warningf("Failed to find compute v2 endpoint: %v", err) return nil, err } return compute, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "NewComputeV2", "(", ")", "(", "*", "gophercloud", ".", "ServiceClient", ",", "error", ")", "{", "compute", ",", "err", ":=", "openstack", ".", "NewComputeV2", "(", "os", ".", "provider", ",", "gophercloud", ".", "EndpointOpts", "{", "Region", ":", "os", ".", "region", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "compute", ",", "nil", "\n", "}" ]
// NewComputeV2 creates a new Compute V2 endpoint
[ "NewComputeV2", "creates", "a", "new", "Compute", "V2", "endpoint" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_client.go#L39-L48
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go
OperationPending
func (os *OpenStack) OperationPending(diskName string) (bool, string, error) { volume, err := os.getVolume(diskName) if err != nil { return false, "", err } volumeStatus := volume.Status if volumeStatus == VolumeErrorStatus { glog.Errorf("status of volume %s is %s", diskName, volumeStatus) return false, volumeStatus, nil } if volumeStatus == VolumeAvailableStatus || volumeStatus == VolumeInUseStatus || volumeStatus == VolumeDeletedStatus { return false, volume.Status, nil } return true, volumeStatus, nil }
go
func (os *OpenStack) OperationPending(diskName string) (bool, string, error) { volume, err := os.getVolume(diskName) if err != nil { return false, "", err } volumeStatus := volume.Status if volumeStatus == VolumeErrorStatus { glog.Errorf("status of volume %s is %s", diskName, volumeStatus) return false, volumeStatus, nil } if volumeStatus == VolumeAvailableStatus || volumeStatus == VolumeInUseStatus || volumeStatus == VolumeDeletedStatus { return false, volume.Status, nil } return true, volumeStatus, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "OperationPending", "(", "diskName", "string", ")", "(", "bool", ",", "string", ",", "error", ")", "{", "volume", ",", "err", ":=", "os", ".", "getVolume", "(", "diskName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "volumeStatus", ":=", "volume", ".", "Status", "\n", "if", "volumeStatus", "==", "VolumeErrorStatus", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "diskName", ",", "volumeStatus", ")", "\n", "return", "false", ",", "volumeStatus", ",", "nil", "\n", "}", "\n", "if", "volumeStatus", "==", "VolumeAvailableStatus", "||", "volumeStatus", "==", "VolumeInUseStatus", "||", "volumeStatus", "==", "VolumeDeletedStatus", "{", "return", "false", ",", "volume", ".", "Status", ",", "nil", "\n", "}", "\n", "return", "true", ",", "volumeStatus", ",", "nil", "\n", "}" ]
// OperationPending checks status, makes sure we're not in error state
[ "OperationPending", "checks", "status", "makes", "sure", "we", "re", "not", "in", "error", "state" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go#L135-L149
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go
AttachDisk
func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) { volume, err := os.getVolume(volumeID) if err != nil { return "", err } if volume.Status != VolumeAvailableStatus { errmsg := fmt.Sprintf("volume %s status is %s, not %s, can not be attached to instance %s.", volume.Name, volume.Status, VolumeAvailableStatus, instanceID) glog.Error(errmsg) return "", errors.New(errmsg) } cClient, err := os.NewComputeV2() if err != nil { return "", err } if volume.AttachedServerID != "" { if instanceID == volume.AttachedServerID { glog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) return volume.ID, nil } glog.V(2).Infof("Disk %s is attached to a different instance (%s), detaching", volumeID, volume.AttachedServerID) err = os.DetachDisk(volume.AttachedServerID, volumeID) if err != nil { return "", err } } // add read only flag here if possible spothanis _, err = volumeattach.Create(cClient, instanceID, &volumeattach.CreateOpts{ VolumeID: volume.ID, }).Extract() if err != nil { glog.Errorf("Failed to attach %s volume to %s compute: %v", volumeID, instanceID, err) return "", err } glog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) return volume.ID, nil }
go
func (os *OpenStack) AttachDisk(instanceID, volumeID string) (string, error) { volume, err := os.getVolume(volumeID) if err != nil { return "", err } if volume.Status != VolumeAvailableStatus { errmsg := fmt.Sprintf("volume %s status is %s, not %s, can not be attached to instance %s.", volume.Name, volume.Status, VolumeAvailableStatus, instanceID) glog.Error(errmsg) return "", errors.New(errmsg) } cClient, err := os.NewComputeV2() if err != nil { return "", err } if volume.AttachedServerID != "" { if instanceID == volume.AttachedServerID { glog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID) return volume.ID, nil } glog.V(2).Infof("Disk %s is attached to a different instance (%s), detaching", volumeID, volume.AttachedServerID) err = os.DetachDisk(volume.AttachedServerID, volumeID) if err != nil { return "", err } } // add read only flag here if possible spothanis _, err = volumeattach.Create(cClient, instanceID, &volumeattach.CreateOpts{ VolumeID: volume.ID, }).Extract() if err != nil { glog.Errorf("Failed to attach %s volume to %s compute: %v", volumeID, instanceID, err) return "", err } glog.V(2).Infof("Successfully attached %s volume to %s compute", volumeID, instanceID) return volume.ID, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "AttachDisk", "(", "instanceID", ",", "volumeID", "string", ")", "(", "string", ",", "error", ")", "{", "volume", ",", "err", ":=", "os", ".", "getVolume", "(", "volumeID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "volume", ".", "Status", "!=", "VolumeAvailableStatus", "{", "errmsg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volume", ".", "Name", ",", "volume", ".", "Status", ",", "VolumeAvailableStatus", ",", "instanceID", ")", "\n", "glog", ".", "Error", "(", "errmsg", ")", "\n", "return", "\"", "\"", ",", "errors", ".", "New", "(", "errmsg", ")", "\n", "}", "\n", "cClient", ",", "err", ":=", "os", ".", "NewComputeV2", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "volume", ".", "AttachedServerID", "!=", "\"", "\"", "{", "if", "instanceID", "==", "volume", ".", "AttachedServerID", "{", "glog", ".", "V", "(", "4", ")", ".", "Infof", "(", "\"", "\"", ",", "volumeID", ",", "instanceID", ")", "\n", "return", "volume", ".", "ID", ",", "nil", "\n", "}", "\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "volumeID", ",", "volume", ".", "AttachedServerID", ")", "\n", "err", "=", "os", ".", "DetachDisk", "(", "volume", ".", "AttachedServerID", ",", "volumeID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "}", "\n\n", "// add read only flag here if possible spothanis", "_", ",", "err", "=", "volumeattach", ".", "Create", "(", "cClient", ",", "instanceID", ",", "&", "volumeattach", ".", "CreateOpts", "{", "VolumeID", ":", "volume", ".", "ID", ",", "}", ")", ".", "Extract", "(", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "volumeID", ",", "instanceID", ",", "err", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "volumeID", ",", "instanceID", ")", "\n", "return", "volume", ".", "ID", ",", "nil", "\n", "}" ]
// AttachDisk attaches specified cinder volume to the compute running kubelet
[ "AttachDisk", "attaches", "specified", "cinder", "volume", "to", "the", "compute", "running", "kubelet" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go#L152-L189
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go
DeleteVolume
func (os *OpenStack) DeleteVolume(volumeID string) error { used, err := os.diskIsUsed(volumeID) if err != nil { return err } if used { msg := fmt.Sprintf("Cannot delete the volume %q, it's still attached to a node", volumeID) return k8sVolume.NewDeletedVolumeInUseError(msg) } volumes, err := os.volumeService("") if err != nil || volumes == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return err } err = volumes.deleteVolume(volumeID) if err != nil { glog.Errorf("Cannot delete volume %s: %v", volumeID, err) } return nil }
go
func (os *OpenStack) DeleteVolume(volumeID string) error { used, err := os.diskIsUsed(volumeID) if err != nil { return err } if used { msg := fmt.Sprintf("Cannot delete the volume %q, it's still attached to a node", volumeID) return k8sVolume.NewDeletedVolumeInUseError(msg) } volumes, err := os.volumeService("") if err != nil || volumes == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return err } err = volumes.deleteVolume(volumeID) if err != nil { glog.Errorf("Cannot delete volume %s: %v", volumeID, err) } return nil }
[ "func", "(", "os", "*", "OpenStack", ")", "DeleteVolume", "(", "volumeID", "string", ")", "error", "{", "used", ",", "err", ":=", "os", ".", "diskIsUsed", "(", "volumeID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "used", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeID", ")", "\n", "return", "k8sVolume", ".", "NewDeletedVolumeInUseError", "(", "msg", ")", "\n", "}", "\n\n", "volumes", ",", "err", ":=", "os", ".", "volumeService", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "||", "volumes", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "os", ".", "region", ")", "\n", "return", "err", "\n", "}", "\n\n", "err", "=", "volumes", ".", "deleteVolume", "(", "volumeID", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "volumeID", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n\n", "}" ]
// DeleteVolume deletes the specified volume
[ "DeleteVolume", "deletes", "the", "specified", "volume" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go#L291-L313
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go
GetAttachmentDiskPath
func (os *OpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, error) { // See issue #33128 - Cinder does not always tell you the right device path, as such // we must only use this value as a last resort. volume, err := os.getVolume(volumeID) if err != nil { return "", err } if volume.Status != VolumeInUseStatus { errmsg := fmt.Sprintf("can not get device path of volume %s, its status is %s.", volume.Name, volume.Status) glog.Error(errmsg) return "", errors.New(errmsg) } if volume.AttachedServerID != "" { if instanceID == volume.AttachedServerID { // Attachment[0]["device"] points to the device path // see http://developer.openstack.org/api-ref-blockstorage-v1.html return volume.AttachedDevice, nil } errMsg := fmt.Sprintf("Disk %q is attached to a different compute: %q, should be detached before proceeding", volumeID, volume.AttachedServerID) glog.Error(errMsg) return "", errors.New(errMsg) } return "", fmt.Errorf("volume %s has no ServerId", volumeID) }
go
func (os *OpenStack) GetAttachmentDiskPath(instanceID, volumeID string) (string, error) { // See issue #33128 - Cinder does not always tell you the right device path, as such // we must only use this value as a last resort. volume, err := os.getVolume(volumeID) if err != nil { return "", err } if volume.Status != VolumeInUseStatus { errmsg := fmt.Sprintf("can not get device path of volume %s, its status is %s.", volume.Name, volume.Status) glog.Error(errmsg) return "", errors.New(errmsg) } if volume.AttachedServerID != "" { if instanceID == volume.AttachedServerID { // Attachment[0]["device"] points to the device path // see http://developer.openstack.org/api-ref-blockstorage-v1.html return volume.AttachedDevice, nil } errMsg := fmt.Sprintf("Disk %q is attached to a different compute: %q, should be detached before proceeding", volumeID, volume.AttachedServerID) glog.Error(errMsg) return "", errors.New(errMsg) } return "", fmt.Errorf("volume %s has no ServerId", volumeID) }
[ "func", "(", "os", "*", "OpenStack", ")", "GetAttachmentDiskPath", "(", "instanceID", ",", "volumeID", "string", ")", "(", "string", ",", "error", ")", "{", "// See issue #33128 - Cinder does not always tell you the right device path, as such", "// we must only use this value as a last resort.", "volume", ",", "err", ":=", "os", ".", "getVolume", "(", "volumeID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "volume", ".", "Status", "!=", "VolumeInUseStatus", "{", "errmsg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volume", ".", "Name", ",", "volume", ".", "Status", ")", "\n", "glog", ".", "Error", "(", "errmsg", ")", "\n", "return", "\"", "\"", ",", "errors", ".", "New", "(", "errmsg", ")", "\n", "}", "\n", "if", "volume", ".", "AttachedServerID", "!=", "\"", "\"", "{", "if", "instanceID", "==", "volume", ".", "AttachedServerID", "{", "// Attachment[0][\"device\"] points to the device path", "// see http://developer.openstack.org/api-ref-blockstorage-v1.html", "return", "volume", ".", "AttachedDevice", ",", "nil", "\n", "}", "\n", "errMsg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "volumeID", ",", "volume", ".", "AttachedServerID", ")", "\n", "glog", ".", "Error", "(", "errMsg", ")", "\n", "return", "\"", "\"", ",", "errors", ".", "New", "(", "errMsg", ")", "\n", "}", "\n", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "volumeID", ")", "\n", "}" ]
// GetAttachmentDiskPath retrieves device path of attached volume to the compute running kubelet, as known by cinder
[ "GetAttachmentDiskPath", "retrieves", "device", "path", "of", "attached", "volume", "to", "the", "compute", "running", "kubelet", "as", "known", "by", "cinder" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_volumes.go#L316-L339
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/populator/populator.go
NewPopulator
func NewPopulator(config *common.RuntimeConfig) *Populator { p := &Populator{RuntimeConfig: config} sharedInformer := config.InformerFactory.Core().V1().PersistentVolumes() sharedInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { pv, ok := obj.(*v1.PersistentVolume) if !ok { glog.Errorf("Added object is not a v1.PersistentVolume type") return } p.handlePVUpdate(pv) }, UpdateFunc: func(oldObj, newObj interface{}) { newPV, ok := newObj.(*v1.PersistentVolume) if !ok { glog.Errorf("Updated object is not a v1.PersistentVolume type") return } p.handlePVUpdate(newPV) }, DeleteFunc: func(obj interface{}) { pv, ok := obj.(*v1.PersistentVolume) if !ok { glog.Errorf("Added object is not a v1.PersistentVolume type") return } p.handlePVDelete(pv) }, }) return p }
go
func NewPopulator(config *common.RuntimeConfig) *Populator { p := &Populator{RuntimeConfig: config} sharedInformer := config.InformerFactory.Core().V1().PersistentVolumes() sharedInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { pv, ok := obj.(*v1.PersistentVolume) if !ok { glog.Errorf("Added object is not a v1.PersistentVolume type") return } p.handlePVUpdate(pv) }, UpdateFunc: func(oldObj, newObj interface{}) { newPV, ok := newObj.(*v1.PersistentVolume) if !ok { glog.Errorf("Updated object is not a v1.PersistentVolume type") return } p.handlePVUpdate(newPV) }, DeleteFunc: func(obj interface{}) { pv, ok := obj.(*v1.PersistentVolume) if !ok { glog.Errorf("Added object is not a v1.PersistentVolume type") return } p.handlePVDelete(pv) }, }) return p }
[ "func", "NewPopulator", "(", "config", "*", "common", ".", "RuntimeConfig", ")", "*", "Populator", "{", "p", ":=", "&", "Populator", "{", "RuntimeConfig", ":", "config", "}", "\n", "sharedInformer", ":=", "config", ".", "InformerFactory", ".", "Core", "(", ")", ".", "V1", "(", ")", ".", "PersistentVolumes", "(", ")", "\n", "sharedInformer", ".", "Informer", "(", ")", ".", "AddEventHandler", "(", "cache", ".", "ResourceEventHandlerFuncs", "{", "AddFunc", ":", "func", "(", "obj", "interface", "{", "}", ")", "{", "pv", ",", "ok", ":=", "obj", ".", "(", "*", "v1", ".", "PersistentVolume", ")", "\n", "if", "!", "ok", "{", "glog", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "p", ".", "handlePVUpdate", "(", "pv", ")", "\n", "}", ",", "UpdateFunc", ":", "func", "(", "oldObj", ",", "newObj", "interface", "{", "}", ")", "{", "newPV", ",", "ok", ":=", "newObj", ".", "(", "*", "v1", ".", "PersistentVolume", ")", "\n", "if", "!", "ok", "{", "glog", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "p", ".", "handlePVUpdate", "(", "newPV", ")", "\n", "}", ",", "DeleteFunc", ":", "func", "(", "obj", "interface", "{", "}", ")", "{", "pv", ",", "ok", ":=", "obj", ".", "(", "*", "v1", ".", "PersistentVolume", ")", "\n", "if", "!", "ok", "{", "glog", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "p", ".", "handlePVDelete", "(", "pv", ")", "\n", "}", ",", "}", ")", "\n", "return", "p", "\n", "}" ]
// NewPopulator returns a Populator object to update the PV cache
[ "NewPopulator", "returns", "a", "Populator", "object", "to", "update", "the", "PV", "cache" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/populator/populator.go#L33-L63
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
IsDir
func (u *volumeUtil) IsDir(fullPath string) (bool, error) { dir, err := os.Open(fullPath) if err != nil { return false, err } defer dir.Close() stat, err := dir.Stat() if err != nil { return false, err } return stat.IsDir(), nil }
go
func (u *volumeUtil) IsDir(fullPath string) (bool, error) { dir, err := os.Open(fullPath) if err != nil { return false, err } defer dir.Close() stat, err := dir.Stat() if err != nil { return false, err } return stat.IsDir(), nil }
[ "func", "(", "u", "*", "volumeUtil", ")", "IsDir", "(", "fullPath", "string", ")", "(", "bool", ",", "error", ")", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "defer", "dir", ".", "Close", "(", ")", "\n\n", "stat", ",", "err", ":=", "dir", ".", "Stat", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n\n", "return", "stat", ".", "IsDir", "(", ")", ",", "nil", "\n", "}" ]
// IsDir checks if the given path is a directory
[ "IsDir", "checks", "if", "the", "given", "path", "is", "a", "directory" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L61-L74
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
ReadDir
func (u *volumeUtil) ReadDir(fullPath string) ([]string, error) { dir, err := os.Open(fullPath) if err != nil { return nil, err } defer dir.Close() files, err := dir.Readdirnames(-1) if err != nil { return nil, err } return files, nil }
go
func (u *volumeUtil) ReadDir(fullPath string) ([]string, error) { dir, err := os.Open(fullPath) if err != nil { return nil, err } defer dir.Close() files, err := dir.Readdirnames(-1) if err != nil { return nil, err } return files, nil }
[ "func", "(", "u", "*", "volumeUtil", ")", "ReadDir", "(", "fullPath", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "dir", ".", "Close", "(", ")", "\n\n", "files", ",", "err", ":=", "dir", ".", "Readdirnames", "(", "-", "1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "files", ",", "nil", "\n", "}" ]
// ReadDir returns a list all the files under the given directory
[ "ReadDir", "returns", "a", "list", "all", "the", "files", "under", "the", "given", "directory" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L77-L89
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
DeleteContents
func (u *volumeUtil) DeleteContents(fullPath string) error { dir, err := os.Open(fullPath) if err != nil { return err } defer dir.Close() files, err := dir.Readdirnames(-1) if err != nil { return err } errList := []error{} for _, file := range files { err = os.RemoveAll(filepath.Join(fullPath, file)) if err != nil { errList = append(errList, err) } } return utilerrors.NewAggregate(errList) }
go
func (u *volumeUtil) DeleteContents(fullPath string) error { dir, err := os.Open(fullPath) if err != nil { return err } defer dir.Close() files, err := dir.Readdirnames(-1) if err != nil { return err } errList := []error{} for _, file := range files { err = os.RemoveAll(filepath.Join(fullPath, file)) if err != nil { errList = append(errList, err) } } return utilerrors.NewAggregate(errList) }
[ "func", "(", "u", "*", "volumeUtil", ")", "DeleteContents", "(", "fullPath", "string", ")", "error", "{", "dir", ",", "err", ":=", "os", ".", "Open", "(", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "dir", ".", "Close", "(", ")", "\n\n", "files", ",", "err", ":=", "dir", ".", "Readdirnames", "(", "-", "1", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "errList", ":=", "[", "]", "error", "{", "}", "\n", "for", "_", ",", "file", ":=", "range", "files", "{", "err", "=", "os", ".", "RemoveAll", "(", "filepath", ".", "Join", "(", "fullPath", ",", "file", ")", ")", "\n", "if", "err", "!=", "nil", "{", "errList", "=", "append", "(", "errList", ",", "err", ")", "\n", "}", "\n", "}", "\n\n", "return", "utilerrors", ".", "NewAggregate", "(", "errList", ")", "\n", "}" ]
// DeleteContents deletes all the contents under the given directory
[ "DeleteContents", "deletes", "all", "the", "contents", "under", "the", "given", "directory" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L92-L112
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
GetFsCapacityByte
func (u *volumeUtil) GetFsCapacityByte(fullPath string) (int64, error) { _, capacity, _, _, _, _, err := fs.FsInfo(fullPath) return capacity, err }
go
func (u *volumeUtil) GetFsCapacityByte(fullPath string) (int64, error) { _, capacity, _, _, _, _, err := fs.FsInfo(fullPath) return capacity, err }
[ "func", "(", "u", "*", "volumeUtil", ")", "GetFsCapacityByte", "(", "fullPath", "string", ")", "(", "int64", ",", "error", ")", "{", "_", ",", "capacity", ",", "_", ",", "_", ",", "_", ",", "_", ",", "err", ":=", "fs", ".", "FsInfo", "(", "fullPath", ")", "\n", "return", "capacity", ",", "err", "\n", "}" ]
// GetFsCapacityByte returns capacity in bytes about a mounted filesystem. // fullPath is the pathname of any file within the mounted filesystem. Capacity // returned here is total capacity.
[ "GetFsCapacityByte", "returns", "capacity", "in", "bytes", "about", "a", "mounted", "filesystem", ".", "fullPath", "is", "the", "pathname", "of", "any", "file", "within", "the", "mounted", "filesystem", ".", "Capacity", "returned", "here", "is", "total", "capacity", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L117-L120
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
NewFakeVolumeUtil
func NewFakeVolumeUtil(deleteShouldFail bool, dirFiles map[string][]*FakeDirEntry) *FakeVolumeUtil { return &FakeVolumeUtil{ directoryFiles: dirFiles, deleteShouldFail: deleteShouldFail, } }
go
func NewFakeVolumeUtil(deleteShouldFail bool, dirFiles map[string][]*FakeDirEntry) *FakeVolumeUtil { return &FakeVolumeUtil{ directoryFiles: dirFiles, deleteShouldFail: deleteShouldFail, } }
[ "func", "NewFakeVolumeUtil", "(", "deleteShouldFail", "bool", ",", "dirFiles", "map", "[", "string", "]", "[", "]", "*", "FakeDirEntry", ")", "*", "FakeVolumeUtil", "{", "return", "&", "FakeVolumeUtil", "{", "directoryFiles", ":", "dirFiles", ",", "deleteShouldFail", ":", "deleteShouldFail", ",", "}", "\n", "}" ]
// NewFakeVolumeUtil returns a VolumeUtil object for use in unit testing
[ "NewFakeVolumeUtil", "returns", "a", "VolumeUtil", "object", "for", "use", "in", "unit", "testing" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L151-L156
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
ReadDir
func (u *FakeVolumeUtil) ReadDir(fullPath string) ([]string, error) { fileNames := []string{} files, found := u.directoryFiles[fullPath] if !found { return nil, fmt.Errorf("Directory %q not found", fullPath) } for _, file := range files { fileNames = append(fileNames, file.Name) } return fileNames, nil }
go
func (u *FakeVolumeUtil) ReadDir(fullPath string) ([]string, error) { fileNames := []string{} files, found := u.directoryFiles[fullPath] if !found { return nil, fmt.Errorf("Directory %q not found", fullPath) } for _, file := range files { fileNames = append(fileNames, file.Name) } return fileNames, nil }
[ "func", "(", "u", "*", "FakeVolumeUtil", ")", "ReadDir", "(", "fullPath", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "fileNames", ":=", "[", "]", "string", "{", "}", "\n", "files", ",", "found", ":=", "u", ".", "directoryFiles", "[", "fullPath", "]", "\n", "if", "!", "found", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "fullPath", ")", "\n", "}", "\n", "for", "_", ",", "file", ":=", "range", "files", "{", "fileNames", "=", "append", "(", "fileNames", ",", "file", ".", "Name", ")", "\n", "}", "\n", "return", "fileNames", ",", "nil", "\n", "}" ]
// ReadDir returns the list of all files under the given directory
[ "ReadDir", "returns", "the", "list", "of", "all", "files", "under", "the", "given", "directory" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L197-L207
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
DeleteContents
func (u *FakeVolumeUtil) DeleteContents(fullPath string) error { if u.deleteShouldFail { return fmt.Errorf("Fake delete contents failed") } return nil }
go
func (u *FakeVolumeUtil) DeleteContents(fullPath string) error { if u.deleteShouldFail { return fmt.Errorf("Fake delete contents failed") } return nil }
[ "func", "(", "u", "*", "FakeVolumeUtil", ")", "DeleteContents", "(", "fullPath", "string", ")", "error", "{", "if", "u", ".", "deleteShouldFail", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DeleteContents removes all the contents under the given directory
[ "DeleteContents", "removes", "all", "the", "contents", "under", "the", "given", "directory" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L210-L215
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
GetFsCapacityByte
func (u *FakeVolumeUtil) GetFsCapacityByte(fullPath string) (int64, error) { return u.getDirEntryCapacity(fullPath, FakeEntryFile) }
go
func (u *FakeVolumeUtil) GetFsCapacityByte(fullPath string) (int64, error) { return u.getDirEntryCapacity(fullPath, FakeEntryFile) }
[ "func", "(", "u", "*", "FakeVolumeUtil", ")", "GetFsCapacityByte", "(", "fullPath", "string", ")", "(", "int64", ",", "error", ")", "{", "return", "u", ".", "getDirEntryCapacity", "(", "fullPath", ",", "FakeEntryFile", ")", "\n", "}" ]
// GetFsCapacityByte returns capacity in byte about a mounted filesystem.
[ "GetFsCapacityByte", "returns", "capacity", "in", "byte", "about", "a", "mounted", "filesystem", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L218-L220
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
GetBlockCapacityByte
func (u *FakeVolumeUtil) GetBlockCapacityByte(fullPath string) (int64, error) { return u.getDirEntryCapacity(fullPath, FakeEntryBlock) }
go
func (u *FakeVolumeUtil) GetBlockCapacityByte(fullPath string) (int64, error) { return u.getDirEntryCapacity(fullPath, FakeEntryBlock) }
[ "func", "(", "u", "*", "FakeVolumeUtil", ")", "GetBlockCapacityByte", "(", "fullPath", "string", ")", "(", "int64", ",", "error", ")", "{", "return", "u", ".", "getDirEntryCapacity", "(", "fullPath", ",", "FakeEntryBlock", ")", "\n", "}" ]
// GetBlockCapacityByte returns the space in the specified block device.
[ "GetBlockCapacityByte", "returns", "the", "space", "in", "the", "specified", "block", "device", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L223-L225
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/volume_util.go
AddNewDirEntries
func (u *FakeVolumeUtil) AddNewDirEntries(mountDir string, dirFiles map[string][]*FakeDirEntry) { for dir, files := range dirFiles { mountedPath := filepath.Join(mountDir, dir) curFiles := u.directoryFiles[mountedPath] if curFiles == nil { curFiles = []*FakeDirEntry{} } glog.Infof("Adding to directory %q: files %v\n", dir, files) u.directoryFiles[mountedPath] = append(curFiles, files...) } }
go
func (u *FakeVolumeUtil) AddNewDirEntries(mountDir string, dirFiles map[string][]*FakeDirEntry) { for dir, files := range dirFiles { mountedPath := filepath.Join(mountDir, dir) curFiles := u.directoryFiles[mountedPath] if curFiles == nil { curFiles = []*FakeDirEntry{} } glog.Infof("Adding to directory %q: files %v\n", dir, files) u.directoryFiles[mountedPath] = append(curFiles, files...) } }
[ "func", "(", "u", "*", "FakeVolumeUtil", ")", "AddNewDirEntries", "(", "mountDir", "string", ",", "dirFiles", "map", "[", "string", "]", "[", "]", "*", "FakeDirEntry", ")", "{", "for", "dir", ",", "files", ":=", "range", "dirFiles", "{", "mountedPath", ":=", "filepath", ".", "Join", "(", "mountDir", ",", "dir", ")", "\n", "curFiles", ":=", "u", ".", "directoryFiles", "[", "mountedPath", "]", "\n", "if", "curFiles", "==", "nil", "{", "curFiles", "=", "[", "]", "*", "FakeDirEntry", "{", "}", "\n", "}", "\n", "glog", ".", "Infof", "(", "\"", "\\n", "\"", ",", "dir", ",", "files", ")", "\n", "u", ".", "directoryFiles", "[", "mountedPath", "]", "=", "append", "(", "curFiles", ",", "files", "...", ")", "\n", "}", "\n", "}" ]
// AddNewDirEntries adds the given files to the current directory listing // This is only for testing
[ "AddNewDirEntries", "adds", "the", "given", "files", "to", "the", "current", "directory", "listing", "This", "is", "only", "for", "testing" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/volume_util.go#L248-L258
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/types.go
GetSupportedVolumeFromPVSpec
func GetSupportedVolumeFromPVSpec(spec *core_v1.PersistentVolumeSpec) string { if spec.HostPath != nil { return "hostPath" } if spec.AWSElasticBlockStore != nil { return "aws_ebs" } if spec.GCEPersistentDisk != nil { return "gce-pd" } if spec.Cinder != nil { return "cinder" } if spec.Glusterfs != nil { return "glusterfs" } return "" }
go
func GetSupportedVolumeFromPVSpec(spec *core_v1.PersistentVolumeSpec) string { if spec.HostPath != nil { return "hostPath" } if spec.AWSElasticBlockStore != nil { return "aws_ebs" } if spec.GCEPersistentDisk != nil { return "gce-pd" } if spec.Cinder != nil { return "cinder" } if spec.Glusterfs != nil { return "glusterfs" } return "" }
[ "func", "GetSupportedVolumeFromPVSpec", "(", "spec", "*", "core_v1", ".", "PersistentVolumeSpec", ")", "string", "{", "if", "spec", ".", "HostPath", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "AWSElasticBlockStore", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "GCEPersistentDisk", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "Cinder", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "Glusterfs", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// GetSupportedVolumeFromPVSpec gets supported volume from PV spec
[ "GetSupportedVolumeFromPVSpec", "gets", "supported", "volume", "from", "PV", "spec" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/types.go#L261-L278
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/types.go
GetSupportedVolumeFromSnapshotDataSpec
func GetSupportedVolumeFromSnapshotDataSpec(spec *VolumeSnapshotDataSpec) string { if spec.HostPath != nil { return "hostPath" } if spec.AWSElasticBlockStore != nil { return "aws_ebs" } if spec.GCEPersistentDiskSnapshot != nil { return "gce-pd" } if spec.CinderSnapshot != nil { return "cinder" } if spec.GlusterSnapshotVolume != nil { return "glusterfs" } return "" }
go
func GetSupportedVolumeFromSnapshotDataSpec(spec *VolumeSnapshotDataSpec) string { if spec.HostPath != nil { return "hostPath" } if spec.AWSElasticBlockStore != nil { return "aws_ebs" } if spec.GCEPersistentDiskSnapshot != nil { return "gce-pd" } if spec.CinderSnapshot != nil { return "cinder" } if spec.GlusterSnapshotVolume != nil { return "glusterfs" } return "" }
[ "func", "GetSupportedVolumeFromSnapshotDataSpec", "(", "spec", "*", "VolumeSnapshotDataSpec", ")", "string", "{", "if", "spec", ".", "HostPath", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "AWSElasticBlockStore", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "GCEPersistentDiskSnapshot", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "CinderSnapshot", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "spec", ".", "GlusterSnapshotVolume", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// GetSupportedVolumeFromSnapshotDataSpec gets supported volume from snapshot data spec
[ "GetSupportedVolumeFromSnapshotDataSpec", "gets", "supported", "volume", "from", "snapshot", "data", "spec" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/types.go#L281-L298
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/types.go
UnmarshalJSON
func (v *VolumeSnapshot) UnmarshalJSON(data []byte) error { tmp := VolumeSnapshotCopy{} err := json.Unmarshal(data, &tmp) if err != nil { return err } tmp2 := VolumeSnapshot(tmp) *v = tmp2 return nil }
go
func (v *VolumeSnapshot) UnmarshalJSON(data []byte) error { tmp := VolumeSnapshotCopy{} err := json.Unmarshal(data, &tmp) if err != nil { return err } tmp2 := VolumeSnapshot(tmp) *v = tmp2 return nil }
[ "func", "(", "v", "*", "VolumeSnapshot", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "tmp", ":=", "VolumeSnapshotCopy", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "tmp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "tmp2", ":=", "VolumeSnapshot", "(", "tmp", ")", "\n", "*", "v", "=", "tmp2", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON unmarshalls json data
[ "UnmarshalJSON", "unmarshalls", "json", "data" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/types.go#L353-L362
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go
CreateSnapshot
func (os *OpenStack) CreateSnapshot(sourceVolumeID, name, description string, tags map[string]string) (string, string, error) { snapshots, err := os.snapshotService() if err != nil || snapshots == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return "", "", fmt.Errorf("Failed to create snapshot for volume %s: %v", sourceVolumeID, err) } opts := SnapshotCreateOpts{ VolumeID: sourceVolumeID, Name: name, Description: description, } if tags != nil { opts.Metadata = tags } snapshotID, status, err := snapshots.createSnapshot(opts) if err != nil { glog.Errorf("Failed to snapshot volume %s : %v", sourceVolumeID, err) return "", "", err } glog.Infof("Created snapshot %v from volume: %v", snapshotID, sourceVolumeID) return snapshotID, status, nil }
go
func (os *OpenStack) CreateSnapshot(sourceVolumeID, name, description string, tags map[string]string) (string, string, error) { snapshots, err := os.snapshotService() if err != nil || snapshots == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return "", "", fmt.Errorf("Failed to create snapshot for volume %s: %v", sourceVolumeID, err) } opts := SnapshotCreateOpts{ VolumeID: sourceVolumeID, Name: name, Description: description, } if tags != nil { opts.Metadata = tags } snapshotID, status, err := snapshots.createSnapshot(opts) if err != nil { glog.Errorf("Failed to snapshot volume %s : %v", sourceVolumeID, err) return "", "", err } glog.Infof("Created snapshot %v from volume: %v", snapshotID, sourceVolumeID) return snapshotID, status, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "CreateSnapshot", "(", "sourceVolumeID", ",", "name", ",", "description", "string", ",", "tags", "map", "[", "string", "]", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "snapshots", ",", "err", ":=", "os", ".", "snapshotService", "(", ")", "\n", "if", "err", "!=", "nil", "||", "snapshots", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "os", ".", "region", ")", "\n", "return", "\"", "\"", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "sourceVolumeID", ",", "err", ")", "\n", "}", "\n\n", "opts", ":=", "SnapshotCreateOpts", "{", "VolumeID", ":", "sourceVolumeID", ",", "Name", ":", "name", ",", "Description", ":", "description", ",", "}", "\n", "if", "tags", "!=", "nil", "{", "opts", ".", "Metadata", "=", "tags", "\n", "}", "\n\n", "snapshotID", ",", "status", ",", "err", ":=", "snapshots", ".", "createSnapshot", "(", "opts", ")", "\n\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "sourceVolumeID", ",", "err", ")", "\n", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "snapshotID", ",", "sourceVolumeID", ")", "\n", "return", "snapshotID", ",", "status", ",", "nil", "\n", "}" ]
// CreateSnapshot from the specified volume
[ "CreateSnapshot", "from", "the", "specified", "volume" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go#L144-L169
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go
DeleteSnapshot
func (os *OpenStack) DeleteSnapshot(snapshotID string) error { snapshots, err := os.snapshotService() if err != nil || snapshots == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return err } err = snapshots.deleteSnapshot(snapshotID) if err != nil { glog.Errorf("Cannot delete snapshot %s: %v", snapshotID, err) } return nil }
go
func (os *OpenStack) DeleteSnapshot(snapshotID string) error { snapshots, err := os.snapshotService() if err != nil || snapshots == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return err } err = snapshots.deleteSnapshot(snapshotID) if err != nil { glog.Errorf("Cannot delete snapshot %s: %v", snapshotID, err) } return nil }
[ "func", "(", "os", "*", "OpenStack", ")", "DeleteSnapshot", "(", "snapshotID", "string", ")", "error", "{", "snapshots", ",", "err", ":=", "os", ".", "snapshotService", "(", ")", "\n", "if", "err", "!=", "nil", "||", "snapshots", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "os", ".", "region", ")", "\n", "return", "err", "\n", "}", "\n\n", "err", "=", "snapshots", ".", "deleteSnapshot", "(", "snapshotID", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "snapshotID", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DeleteSnapshot deletes the specified snapshot
[ "DeleteSnapshot", "deletes", "the", "specified", "snapshot" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go#L172-L184
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go
FindSnapshot
func (os *OpenStack) FindSnapshot(tags map[string]string) ([]string, []string, error) { var snapshotIDs, statuses []string ss, err := os.snapshotService() if err != nil || ss == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return snapshotIDs, statuses, fmt.Errorf("Failed to find snapshot by tags %v: %v", tags, err) } opts := SnapshotListOpts{} snapshots, err := ss.listSnapshots(opts) if err != nil { glog.Errorf("Failed to list snapshots. Error: %v", err) return snapshotIDs, statuses, err } glog.Infof("Listed [%v] snapshots.", len(snapshots)) glog.Infof("Looking for matching tags [%#v] in snapshots.", tags) // Loop around to find the snapshot with the matching input metadata // NOTE(xyang): Metadata based filtering for snapshots is supported by Cinder volume API // microversion 3.21 and above. Currently the OpenStack Cloud Provider only supports V2.0. // Revisit this later when V3.0 is supported. for _, snapshot := range snapshots { glog.Infof("Looking for matching tags in snapshot [%#v].", snapshot) namespaceVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNamespaceTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNamespaceTag] == namespaceVal { nameVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNameTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNameTag] == nameVal { uidVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag] == uidVal { timeVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotTimestampTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotTimestampTag] == timeVal { snapshotIDs = append(snapshotIDs, snapshot.ID) statuses = append(statuses, snapshot.Status) glog.Infof("Add snapshot [%#v].", snapshot) } } } } } } } } } return snapshotIDs, statuses, nil }
go
func (os *OpenStack) FindSnapshot(tags map[string]string) ([]string, []string, error) { var snapshotIDs, statuses []string ss, err := os.snapshotService() if err != nil || ss == nil { glog.Errorf("Unable to initialize cinder client for region: %s", os.region) return snapshotIDs, statuses, fmt.Errorf("Failed to find snapshot by tags %v: %v", tags, err) } opts := SnapshotListOpts{} snapshots, err := ss.listSnapshots(opts) if err != nil { glog.Errorf("Failed to list snapshots. Error: %v", err) return snapshotIDs, statuses, err } glog.Infof("Listed [%v] snapshots.", len(snapshots)) glog.Infof("Looking for matching tags [%#v] in snapshots.", tags) // Loop around to find the snapshot with the matching input metadata // NOTE(xyang): Metadata based filtering for snapshots is supported by Cinder volume API // microversion 3.21 and above. Currently the OpenStack Cloud Provider only supports V2.0. // Revisit this later when V3.0 is supported. for _, snapshot := range snapshots { glog.Infof("Looking for matching tags in snapshot [%#v].", snapshot) namespaceVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNamespaceTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNamespaceTag] == namespaceVal { nameVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNameTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNameTag] == nameVal { uidVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag] == uidVal { timeVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotTimestampTag] if ok { if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotTimestampTag] == timeVal { snapshotIDs = append(snapshotIDs, snapshot.ID) statuses = append(statuses, snapshot.Status) glog.Infof("Add snapshot [%#v].", snapshot) } } } } } } } } } return snapshotIDs, statuses, nil }
[ "func", "(", "os", "*", "OpenStack", ")", "FindSnapshot", "(", "tags", "map", "[", "string", "]", "string", ")", "(", "[", "]", "string", ",", "[", "]", "string", ",", "error", ")", "{", "var", "snapshotIDs", ",", "statuses", "[", "]", "string", "\n", "ss", ",", "err", ":=", "os", ".", "snapshotService", "(", ")", "\n", "if", "err", "!=", "nil", "||", "ss", "==", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "os", ".", "region", ")", "\n", "return", "snapshotIDs", ",", "statuses", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "tags", ",", "err", ")", "\n", "}", "\n\n", "opts", ":=", "SnapshotListOpts", "{", "}", "\n", "snapshots", ",", "err", ":=", "ss", ".", "listSnapshots", "(", "opts", ")", "\n\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "snapshotIDs", ",", "statuses", ",", "err", "\n", "}", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "len", "(", "snapshots", ")", ")", "\n\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "tags", ")", "\n", "// Loop around to find the snapshot with the matching input metadata", "// NOTE(xyang): Metadata based filtering for snapshots is supported by Cinder volume API", "// microversion 3.21 and above. Currently the OpenStack Cloud Provider only supports V2.0.", "// Revisit this later when V3.0 is supported.", "for", "_", ",", "snapshot", ":=", "range", "snapshots", "{", "glog", ".", "Infof", "(", "\"", "\"", ",", "snapshot", ")", "\n", "namespaceVal", ",", "ok", ":=", "snapshot", ".", "Metadata", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotNamespaceTag", "]", "\n", "if", "ok", "{", "if", "tags", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotNamespaceTag", "]", "==", "namespaceVal", "{", "nameVal", ",", "ok", ":=", "snapshot", ".", "Metadata", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotNameTag", "]", "\n", "if", "ok", "{", "if", "tags", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotNameTag", "]", "==", "nameVal", "{", "uidVal", ",", "ok", ":=", "snapshot", ".", "Metadata", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotUIDTag", "]", "\n", "if", "ok", "{", "if", "tags", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotUIDTag", "]", "==", "uidVal", "{", "timeVal", ",", "ok", ":=", "snapshot", ".", "Metadata", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotTimestampTag", "]", "\n", "if", "ok", "{", "if", "tags", "[", "ctrlsnap", ".", "CloudSnapshotCreatedForVolumeSnapshotTimestampTag", "]", "==", "timeVal", "{", "snapshotIDs", "=", "append", "(", "snapshotIDs", ",", "snapshot", ".", "ID", ")", "\n", "statuses", "=", "append", "(", "statuses", ",", "snapshot", ".", "Status", ")", "\n", "glog", ".", "Infof", "(", "\"", "\"", ",", "snapshot", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "snapshotIDs", ",", "statuses", ",", "nil", "\n", "}" ]
// FindSnapshot finds snapshot by metadata
[ "FindSnapshot", "finds", "snapshot", "by", "metadata" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_snapshots.go#L210-L261
train
kubernetes-incubator/external-storage
repo-infra/kazel/config.go
ReadCfg
func ReadCfg(cfgPath string) (*Cfg, error) { b, err := ioutil.ReadFile(cfgPath) if err != nil { return nil, err } var cfg Cfg if err := json.Unmarshal(b, &cfg); err != nil { return nil, err } defaultCfg(&cfg) return &cfg, nil }
go
func ReadCfg(cfgPath string) (*Cfg, error) { b, err := ioutil.ReadFile(cfgPath) if err != nil { return nil, err } var cfg Cfg if err := json.Unmarshal(b, &cfg); err != nil { return nil, err } defaultCfg(&cfg) return &cfg, nil }
[ "func", "ReadCfg", "(", "cfgPath", "string", ")", "(", "*", "Cfg", ",", "error", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "cfgPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "cfg", "Cfg", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "cfg", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defaultCfg", "(", "&", "cfg", ")", "\n", "return", "&", "cfg", ",", "nil", "\n", "}" ]
// ReadCfg reads and unmarshals the specified json file into a Cfg struct.
[ "ReadCfg", "reads", "and", "unmarshals", "the", "specified", "json", "file", "into", "a", "Cfg", "struct", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/config.go#L41-L52
train
kubernetes-incubator/external-storage
repo-infra/kazel/generator.go
findOpenAPI
func (v *Vendorer) findOpenAPI(root string) ([]string, error) { finfos, err := ioutil.ReadDir(root) if err != nil { return nil, err } var res []string var includeMe bool for _, finfo := range finfos { path := filepath.Join(root, finfo.Name()) if finfo.IsDir() && (finfo.Mode()&os.ModeSymlink == 0) { children, err := v.findOpenAPI(path) if err != nil { return nil, err } res = append(res, children...) } else if strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, "_test.go") { b, err := ioutil.ReadFile(path) if err != nil { return nil, err } if bytes.Contains(b, []byte(openAPIGenTag)) { includeMe = true } } } if includeMe { pkg, err := v.ctx.ImportDir(root, 0) if err != nil { return nil, err } res = append(res, pkg.ImportPath) } return res, nil }
go
func (v *Vendorer) findOpenAPI(root string) ([]string, error) { finfos, err := ioutil.ReadDir(root) if err != nil { return nil, err } var res []string var includeMe bool for _, finfo := range finfos { path := filepath.Join(root, finfo.Name()) if finfo.IsDir() && (finfo.Mode()&os.ModeSymlink == 0) { children, err := v.findOpenAPI(path) if err != nil { return nil, err } res = append(res, children...) } else if strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, "_test.go") { b, err := ioutil.ReadFile(path) if err != nil { return nil, err } if bytes.Contains(b, []byte(openAPIGenTag)) { includeMe = true } } } if includeMe { pkg, err := v.ctx.ImportDir(root, 0) if err != nil { return nil, err } res = append(res, pkg.ImportPath) } return res, nil }
[ "func", "(", "v", "*", "Vendorer", ")", "findOpenAPI", "(", "root", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "finfos", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "root", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "res", "[", "]", "string", "\n", "var", "includeMe", "bool", "\n", "for", "_", ",", "finfo", ":=", "range", "finfos", "{", "path", ":=", "filepath", ".", "Join", "(", "root", ",", "finfo", ".", "Name", "(", ")", ")", "\n", "if", "finfo", ".", "IsDir", "(", ")", "&&", "(", "finfo", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "0", ")", "{", "children", ",", "err", ":=", "v", ".", "findOpenAPI", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "res", "=", "append", "(", "res", ",", "children", "...", ")", "\n", "}", "else", "if", "strings", ".", "HasSuffix", "(", "path", ",", "\"", "\"", ")", "&&", "!", "strings", ".", "HasSuffix", "(", "path", ",", "\"", "\"", ")", "{", "b", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "bytes", ".", "Contains", "(", "b", ",", "[", "]", "byte", "(", "openAPIGenTag", ")", ")", "{", "includeMe", "=", "true", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "includeMe", "{", "pkg", ",", "err", ":=", "v", ".", "ctx", ".", "ImportDir", "(", "root", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "res", "=", "append", "(", "res", ",", "pkg", ".", "ImportPath", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// findOpenAPI searches for all packages under root that request OpenAPI. It // returns the go import paths. It does not follow symlinks.
[ "findOpenAPI", "searches", "for", "all", "packages", "under", "root", "that", "request", "OpenAPI", ".", "It", "returns", "the", "go", "import", "paths", ".", "It", "does", "not", "follow", "symlinks", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/repo-infra/kazel/generator.go#L54-L87
train
kubernetes-incubator/external-storage
ceph/rbd/pkg/provision/provision.go
NewRBDProvisioner
func NewRBDProvisioner(client kubernetes.Interface, id string, timeout int, usePVName bool) controller.Provisioner { return &rbdProvisioner{ client: client, identity: id, rbdUtil: &RBDUtil{ timeout: timeout, }, usePVName: usePVName, } }
go
func NewRBDProvisioner(client kubernetes.Interface, id string, timeout int, usePVName bool) controller.Provisioner { return &rbdProvisioner{ client: client, identity: id, rbdUtil: &RBDUtil{ timeout: timeout, }, usePVName: usePVName, } }
[ "func", "NewRBDProvisioner", "(", "client", "kubernetes", ".", "Interface", ",", "id", "string", ",", "timeout", "int", ",", "usePVName", "bool", ")", "controller", ".", "Provisioner", "{", "return", "&", "rbdProvisioner", "{", "client", ":", "client", ",", "identity", ":", "id", ",", "rbdUtil", ":", "&", "RBDUtil", "{", "timeout", ":", "timeout", ",", "}", ",", "usePVName", ":", "usePVName", ",", "}", "\n", "}" ]
// NewRBDProvisioner creates a Provisioner that provisions Ceph RBD PVs backed by Ceph RBD images.
[ "NewRBDProvisioner", "creates", "a", "Provisioner", "that", "provisions", "Ceph", "RBD", "PVs", "backed", "by", "Ceph", "RBD", "images", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/ceph/rbd/pkg/provision/provision.go#L94-L103
train
kubernetes-incubator/external-storage
ceph/rbd/pkg/provision/provision.go
getAccessModes
func (p *rbdProvisioner) getAccessModes() []v1.PersistentVolumeAccessMode { return []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, v1.ReadOnlyMany, } }
go
func (p *rbdProvisioner) getAccessModes() []v1.PersistentVolumeAccessMode { return []v1.PersistentVolumeAccessMode{ v1.ReadWriteOnce, v1.ReadOnlyMany, } }
[ "func", "(", "p", "*", "rbdProvisioner", ")", "getAccessModes", "(", ")", "[", "]", "v1", ".", "PersistentVolumeAccessMode", "{", "return", "[", "]", "v1", ".", "PersistentVolumeAccessMode", "{", "v1", ".", "ReadWriteOnce", ",", "v1", ".", "ReadOnlyMany", ",", "}", "\n", "}" ]
// getAccessModes returns access modes RBD volume supported.
[ "getAccessModes", "returns", "access", "modes", "RBD", "volume", "supported", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/ceph/rbd/pkg/provision/provision.go#L108-L113
train
kubernetes-incubator/external-storage
ceph/rbd/pkg/provision/provision.go
parsePVSecret
func (p *rbdProvisioner) parsePVSecret(namespace, secretName string) (string, error) { if p.client == nil { return "", fmt.Errorf("Cannot get kube client") } secrets, err := p.client.CoreV1().Secrets(namespace).Get(secretName, metav1.GetOptions{}) if err != nil { return "", err } // TODO: Should we check secret.Type, like `k8s.io/kubernetes/pkg/volume/util.GetSecretForPV` function? secret := "" for k, v := range secrets.Data { if k == secretKeyName { return string(v), nil } secret = string(v) } // If not found, the last secret in the map wins as done before return secret, nil }
go
func (p *rbdProvisioner) parsePVSecret(namespace, secretName string) (string, error) { if p.client == nil { return "", fmt.Errorf("Cannot get kube client") } secrets, err := p.client.CoreV1().Secrets(namespace).Get(secretName, metav1.GetOptions{}) if err != nil { return "", err } // TODO: Should we check secret.Type, like `k8s.io/kubernetes/pkg/volume/util.GetSecretForPV` function? secret := "" for k, v := range secrets.Data { if k == secretKeyName { return string(v), nil } secret = string(v) } // If not found, the last secret in the map wins as done before return secret, nil }
[ "func", "(", "p", "*", "rbdProvisioner", ")", "parsePVSecret", "(", "namespace", ",", "secretName", "string", ")", "(", "string", ",", "error", ")", "{", "if", "p", ".", "client", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "secrets", ",", "err", ":=", "p", ".", "client", ".", "CoreV1", "(", ")", ".", "Secrets", "(", "namespace", ")", ".", "Get", "(", "secretName", ",", "metav1", ".", "GetOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "// TODO: Should we check secret.Type, like `k8s.io/kubernetes/pkg/volume/util.GetSecretForPV` function?", "secret", ":=", "\"", "\"", "\n", "for", "k", ",", "v", ":=", "range", "secrets", ".", "Data", "{", "if", "k", "==", "secretKeyName", "{", "return", "string", "(", "v", ")", ",", "nil", "\n", "}", "\n", "secret", "=", "string", "(", "v", ")", "\n", "}", "\n\n", "// If not found, the last secret in the map wins as done before", "return", "secret", ",", "nil", "\n", "}" ]
// parsePVSecret retrives secret value for a given namespace and name.
[ "parsePVSecret", "retrives", "secret", "value", "for", "a", "given", "namespace", "and", "name", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/ceph/rbd/pkg/provision/provision.go#L310-L329
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *AWSElasticBlockStoreVolumeSnapshotSource) DeepCopy() *AWSElasticBlockStoreVolumeSnapshotSource { if in == nil { return nil } out := new(AWSElasticBlockStoreVolumeSnapshotSource) in.DeepCopyInto(out) return out }
go
func (in *AWSElasticBlockStoreVolumeSnapshotSource) DeepCopy() *AWSElasticBlockStoreVolumeSnapshotSource { if in == nil { return nil } out := new(AWSElasticBlockStoreVolumeSnapshotSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "AWSElasticBlockStoreVolumeSnapshotSource", ")", "DeepCopy", "(", ")", "*", "AWSElasticBlockStoreVolumeSnapshotSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "AWSElasticBlockStoreVolumeSnapshotSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSElasticBlockStoreVolumeSnapshotSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "AWSElasticBlockStoreVolumeSnapshotSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L34-L41
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *CinderVolumeSnapshotSource) DeepCopy() *CinderVolumeSnapshotSource { if in == nil { return nil } out := new(CinderVolumeSnapshotSource) in.DeepCopyInto(out) return out }
go
func (in *CinderVolumeSnapshotSource) DeepCopy() *CinderVolumeSnapshotSource { if in == nil { return nil } out := new(CinderVolumeSnapshotSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "CinderVolumeSnapshotSource", ")", "DeepCopy", "(", ")", "*", "CinderVolumeSnapshotSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "CinderVolumeSnapshotSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CinderVolumeSnapshotSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "CinderVolumeSnapshotSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L50-L57
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *GCEPersistentDiskSnapshotSource) DeepCopy() *GCEPersistentDiskSnapshotSource { if in == nil { return nil } out := new(GCEPersistentDiskSnapshotSource) in.DeepCopyInto(out) return out }
go
func (in *GCEPersistentDiskSnapshotSource) DeepCopy() *GCEPersistentDiskSnapshotSource { if in == nil { return nil } out := new(GCEPersistentDiskSnapshotSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "GCEPersistentDiskSnapshotSource", ")", "DeepCopy", "(", ")", "*", "GCEPersistentDiskSnapshotSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "GCEPersistentDiskSnapshotSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCEPersistentDiskSnapshotSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "GCEPersistentDiskSnapshotSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L66-L73
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *GlusterVolumeSnapshotSource) DeepCopy() *GlusterVolumeSnapshotSource { if in == nil { return nil } out := new(GlusterVolumeSnapshotSource) in.DeepCopyInto(out) return out }
go
func (in *GlusterVolumeSnapshotSource) DeepCopy() *GlusterVolumeSnapshotSource { if in == nil { return nil } out := new(GlusterVolumeSnapshotSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "GlusterVolumeSnapshotSource", ")", "DeepCopy", "(", ")", "*", "GlusterVolumeSnapshotSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "GlusterVolumeSnapshotSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlusterVolumeSnapshotSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "GlusterVolumeSnapshotSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L82-L89
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *HostPathVolumeSnapshotSource) DeepCopy() *HostPathVolumeSnapshotSource { if in == nil { return nil } out := new(HostPathVolumeSnapshotSource) in.DeepCopyInto(out) return out }
go
func (in *HostPathVolumeSnapshotSource) DeepCopy() *HostPathVolumeSnapshotSource { if in == nil { return nil } out := new(HostPathVolumeSnapshotSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "HostPathVolumeSnapshotSource", ")", "DeepCopy", "(", ")", "*", "HostPathVolumeSnapshotSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "HostPathVolumeSnapshotSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPathVolumeSnapshotSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "HostPathVolumeSnapshotSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L98-L105
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshot) DeepCopy() *VolumeSnapshot { if in == nil { return nil } out := new(VolumeSnapshot) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshot) DeepCopy() *VolumeSnapshot { if in == nil { return nil } out := new(VolumeSnapshot) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshot", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshot", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshot", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshot.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshot", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L118-L125
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotCondition) DeepCopy() *VolumeSnapshotCondition { if in == nil { return nil } out := new(VolumeSnapshotCondition) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotCondition) DeepCopy() *VolumeSnapshotCondition { if in == nil { return nil } out := new(VolumeSnapshotCondition) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotCondition", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotCondition", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotCondition", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotCondition.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotCondition", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L137-L144
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotCopy) DeepCopy() *VolumeSnapshotCopy { if in == nil { return nil } out := new(VolumeSnapshotCopy) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotCopy) DeepCopy() *VolumeSnapshotCopy { if in == nil { return nil } out := new(VolumeSnapshotCopy) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotCopy", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotCopy", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotCopy", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotCopy.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotCopy", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L157-L164
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotData) DeepCopy() *VolumeSnapshotData { if in == nil { return nil } out := new(VolumeSnapshotData) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotData) DeepCopy() *VolumeSnapshotData { if in == nil { return nil } out := new(VolumeSnapshotData) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotData", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotData", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotData", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotData.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotData", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L177-L184
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataCondition) DeepCopy() *VolumeSnapshotDataCondition { if in == nil { return nil } out := new(VolumeSnapshotDataCondition) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataCondition) DeepCopy() *VolumeSnapshotDataCondition { if in == nil { return nil } out := new(VolumeSnapshotDataCondition) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataCondition", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataCondition", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataCondition", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataCondition.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataCondition", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L196-L203
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataCopy) DeepCopy() *VolumeSnapshotDataCopy { if in == nil { return nil } out := new(VolumeSnapshotDataCopy) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataCopy) DeepCopy() *VolumeSnapshotDataCopy { if in == nil { return nil } out := new(VolumeSnapshotDataCopy) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataCopy", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataCopy", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataCopy", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataCopy.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataCopy", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L216-L223
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataList) DeepCopy() *VolumeSnapshotDataList { if in == nil { return nil } out := new(VolumeSnapshotDataList) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataList) DeepCopy() *VolumeSnapshotDataList { if in == nil { return nil } out := new(VolumeSnapshotDataList) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataList", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataList", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataList", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataList.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataList", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L241-L248
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataListCopy) DeepCopy() *VolumeSnapshotDataListCopy { if in == nil { return nil } out := new(VolumeSnapshotDataListCopy) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataListCopy) DeepCopy() *VolumeSnapshotDataListCopy { if in == nil { return nil } out := new(VolumeSnapshotDataListCopy) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataListCopy", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataListCopy", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataListCopy", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataListCopy.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataListCopy", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L275-L282
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataSource) DeepCopy() *VolumeSnapshotDataSource { if in == nil { return nil } out := new(VolumeSnapshotDataSource) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataSource) DeepCopy() *VolumeSnapshotDataSource { if in == nil { return nil } out := new(VolumeSnapshotDataSource) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataSource", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataSource", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataSource", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataSource.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataSource", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L336-L343
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataSpec) DeepCopy() *VolumeSnapshotDataSpec { if in == nil { return nil } out := new(VolumeSnapshotDataSpec) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataSpec) DeepCopy() *VolumeSnapshotDataSpec { if in == nil { return nil } out := new(VolumeSnapshotDataSpec) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataSpec", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataSpec", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataSpec.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataSpec", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L346-L353
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotDataStatus) DeepCopy() *VolumeSnapshotDataStatus { if in == nil { return nil } out := new(VolumeSnapshotDataStatus) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotDataStatus) DeepCopy() *VolumeSnapshotDataStatus { if in == nil { return nil } out := new(VolumeSnapshotDataStatus) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotDataStatus", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotDataStatus", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotDataStatus", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotDataStatus.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotDataStatus", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L370-L377
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotList) DeepCopy() *VolumeSnapshotList { if in == nil { return nil } out := new(VolumeSnapshotList) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotList) DeepCopy() *VolumeSnapshotList { if in == nil { return nil } out := new(VolumeSnapshotList) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotList", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotList", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotList", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotList.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotList", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L395-L402
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotListCopy) DeepCopy() *VolumeSnapshotListCopy { if in == nil { return nil } out := new(VolumeSnapshotListCopy) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotListCopy) DeepCopy() *VolumeSnapshotListCopy { if in == nil { return nil } out := new(VolumeSnapshotListCopy) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotListCopy", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotListCopy", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotListCopy", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotListCopy.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotListCopy", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L429-L436
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotSpec) DeepCopy() *VolumeSnapshotSpec { if in == nil { return nil } out := new(VolumeSnapshotSpec) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotSpec) DeepCopy() *VolumeSnapshotSpec { if in == nil { return nil } out := new(VolumeSnapshotSpec) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotSpec", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotSpec", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotSpec", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotSpec.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotSpec", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L445-L452
train
kubernetes-incubator/external-storage
snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go
DeepCopy
func (in *VolumeSnapshotStatus) DeepCopy() *VolumeSnapshotStatus { if in == nil { return nil } out := new(VolumeSnapshotStatus) in.DeepCopyInto(out) return out }
go
func (in *VolumeSnapshotStatus) DeepCopy() *VolumeSnapshotStatus { if in == nil { return nil } out := new(VolumeSnapshotStatus) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "VolumeSnapshotStatus", ")", "DeepCopy", "(", ")", "*", "VolumeSnapshotStatus", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "VolumeSnapshotStatus", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return", "out", "\n", "}" ]
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeSnapshotStatus.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "VolumeSnapshotStatus", "." ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/apis/crd/v1/zz_generated.deepcopy.go#L469-L476
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
GetLoadBalancer
func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) { loadBalancerName := cloudprovider.GetLoadBalancerName(service) loadbalancer, err := getLoadbalancerByName(lbaas.network, loadBalancerName) if err == ErrNotFound { return nil, false, nil } if loadbalancer == nil { return nil, false, err } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}} return status, true, err }
go
func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) { loadBalancerName := cloudprovider.GetLoadBalancerName(service) loadbalancer, err := getLoadbalancerByName(lbaas.network, loadBalancerName) if err == ErrNotFound { return nil, false, nil } if loadbalancer == nil { return nil, false, err } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}} return status, true, err }
[ "func", "(", "lbaas", "*", "LbaasV2", ")", "GetLoadBalancer", "(", "clusterName", "string", ",", "service", "*", "v1", ".", "Service", ")", "(", "*", "v1", ".", "LoadBalancerStatus", ",", "bool", ",", "error", ")", "{", "loadBalancerName", ":=", "cloudprovider", ".", "GetLoadBalancerName", "(", "service", ")", "\n", "loadbalancer", ",", "err", ":=", "getLoadbalancerByName", "(", "lbaas", ".", "network", ",", "loadBalancerName", ")", "\n", "if", "err", "==", "ErrNotFound", "{", "return", "nil", ",", "false", ",", "nil", "\n", "}", "\n", "if", "loadbalancer", "==", "nil", "{", "return", "nil", ",", "false", ",", "err", "\n", "}", "\n\n", "status", ":=", "&", "v1", ".", "LoadBalancerStatus", "{", "}", "\n", "status", ".", "Ingress", "=", "[", "]", "v1", ".", "LoadBalancerIngress", "{", "{", "IP", ":", "loadbalancer", ".", "VipAddress", "}", "}", "\n\n", "return", "status", ",", "true", ",", "err", "\n", "}" ]
// GetLoadBalancer gets the status of the load balancer
[ "GetLoadBalancer", "gets", "the", "status", "of", "the", "load", "balancer" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go#L548-L562
train
kubernetes-incubator/external-storage
snapshot/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go
GetLoadBalancer
func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) { loadBalancerName := cloudprovider.GetLoadBalancerName(service) vip, err := getVipByName(lb.network, loadBalancerName) if err == ErrNotFound { return nil, false, nil } if vip == nil { return nil, false, err } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}} return status, true, err }
go
func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1.LoadBalancerStatus, bool, error) { loadBalancerName := cloudprovider.GetLoadBalancerName(service) vip, err := getVipByName(lb.network, loadBalancerName) if err == ErrNotFound { return nil, false, nil } if vip == nil { return nil, false, err } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}} return status, true, err }
[ "func", "(", "lb", "*", "LbaasV1", ")", "GetLoadBalancer", "(", "clusterName", "string", ",", "service", "*", "v1", ".", "Service", ")", "(", "*", "v1", ".", "LoadBalancerStatus", ",", "bool", ",", "error", ")", "{", "loadBalancerName", ":=", "cloudprovider", ".", "GetLoadBalancerName", "(", "service", ")", "\n", "vip", ",", "err", ":=", "getVipByName", "(", "lb", ".", "network", ",", "loadBalancerName", ")", "\n", "if", "err", "==", "ErrNotFound", "{", "return", "nil", ",", "false", ",", "nil", "\n", "}", "\n", "if", "vip", "==", "nil", "{", "return", "nil", ",", "false", ",", "err", "\n", "}", "\n\n", "status", ":=", "&", "v1", ".", "LoadBalancerStatus", "{", "}", "\n", "status", ".", "Ingress", "=", "[", "]", "v1", ".", "LoadBalancerIngress", "{", "{", "IP", ":", "vip", ".", "Address", "}", "}", "\n\n", "return", "status", ",", "true", ",", "err", "\n", "}" ]
// GetLoadBalancer gets a load balancer
[ "GetLoadBalancer", "gets", "a", "load", "balancer" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/snapshot/pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go#L1201-L1215
train
kubernetes-incubator/external-storage
openebs/pkg/v1/maya_api.go
GetMayaClusterIP
func (v OpenEBSVolume) GetMayaClusterIP(client kubernetes.Interface) (string, error) { clusterIP := "127.0.0.1" namespace := os.Getenv("OPENEBS_NAMESPACE") if namespace == "" { namespace = "default" } glog.Info("OpenEBS volume provisioner namespace ", namespace) //Fetch the Maya ClusterIP using the Maya API Server Service sc, err := client.CoreV1().Services(namespace).Get("maya-apiserver-service", metav1.GetOptions{}) if err != nil { glog.Errorf("Error getting maya-apiserver IP Address: %v", err) } clusterIP = sc.Spec.ClusterIP glog.V(2).Infof("Maya Cluster IP: %v", clusterIP) return clusterIP, err }
go
func (v OpenEBSVolume) GetMayaClusterIP(client kubernetes.Interface) (string, error) { clusterIP := "127.0.0.1" namespace := os.Getenv("OPENEBS_NAMESPACE") if namespace == "" { namespace = "default" } glog.Info("OpenEBS volume provisioner namespace ", namespace) //Fetch the Maya ClusterIP using the Maya API Server Service sc, err := client.CoreV1().Services(namespace).Get("maya-apiserver-service", metav1.GetOptions{}) if err != nil { glog.Errorf("Error getting maya-apiserver IP Address: %v", err) } clusterIP = sc.Spec.ClusterIP glog.V(2).Infof("Maya Cluster IP: %v", clusterIP) return clusterIP, err }
[ "func", "(", "v", "OpenEBSVolume", ")", "GetMayaClusterIP", "(", "client", "kubernetes", ".", "Interface", ")", "(", "string", ",", "error", ")", "{", "clusterIP", ":=", "\"", "\"", "\n\n", "namespace", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "namespace", "==", "\"", "\"", "{", "namespace", "=", "\"", "\"", "\n", "}", "\n\n", "glog", ".", "Info", "(", "\"", "\"", ",", "namespace", ")", "\n", "//Fetch the Maya ClusterIP using the Maya API Server Service", "sc", ",", "err", ":=", "client", ".", "CoreV1", "(", ")", ".", "Services", "(", "namespace", ")", ".", "Get", "(", "\"", "\"", ",", "metav1", ".", "GetOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "clusterIP", "=", "sc", ".", "Spec", ".", "ClusterIP", "\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "clusterIP", ")", "\n\n", "return", "clusterIP", ",", "err", "\n", "}" ]
//GetMayaClusterIP returns maya-apiserver IP address
[ "GetMayaClusterIP", "returns", "maya", "-", "apiserver", "IP", "address" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/openebs/pkg/v1/maya_api.go#L55-L74
train
kubernetes-incubator/external-storage
openebs/pkg/v1/maya_api.go
CreateVolume
func (v OpenEBSVolume) CreateVolume(vs mayav1.VolumeSpec) (string, error) { addr := os.Getenv("MAPI_ADDR") if addr == "" { err := errors.New("MAPI_ADDR environment variable not set") glog.Errorf("Error getting maya-apiserver IP Address: %v", err) return "Error getting maya-apiserver IP Address", err } url := addr + "/latest/volumes/" vs.Kind = "PersistentVolumeClaim" vs.APIVersion = "v1" //Marshal serializes the value provided into a YAML document yamlValue, _ := yaml.Marshal(vs) glog.V(2).Infof("[DEBUG] volume Spec Created:\n%v\n", string(yamlValue)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(yamlValue)) req.Header.Add("Content-Type", "application/yaml") c := &http.Client{ Timeout: timeout, } resp, err := c.Do(req) if err != nil { glog.Errorf("Error when connecting maya-apiserver %v", err) return "Could not connect to maya-apiserver", err } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { glog.Errorf("Unable to read response from maya-apiserver %v", err) return "Unable to read response from maya-apiserver", err } code := resp.StatusCode if code != http.StatusOK { glog.Errorf("Status error: %v\n", http.StatusText(code)) return "HTTP Status error from maya-apiserver", err } glog.Infof("volume Successfully Created:\n%v\n", string(data)) return "volume Successfully Created", nil }
go
func (v OpenEBSVolume) CreateVolume(vs mayav1.VolumeSpec) (string, error) { addr := os.Getenv("MAPI_ADDR") if addr == "" { err := errors.New("MAPI_ADDR environment variable not set") glog.Errorf("Error getting maya-apiserver IP Address: %v", err) return "Error getting maya-apiserver IP Address", err } url := addr + "/latest/volumes/" vs.Kind = "PersistentVolumeClaim" vs.APIVersion = "v1" //Marshal serializes the value provided into a YAML document yamlValue, _ := yaml.Marshal(vs) glog.V(2).Infof("[DEBUG] volume Spec Created:\n%v\n", string(yamlValue)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(yamlValue)) req.Header.Add("Content-Type", "application/yaml") c := &http.Client{ Timeout: timeout, } resp, err := c.Do(req) if err != nil { glog.Errorf("Error when connecting maya-apiserver %v", err) return "Could not connect to maya-apiserver", err } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { glog.Errorf("Unable to read response from maya-apiserver %v", err) return "Unable to read response from maya-apiserver", err } code := resp.StatusCode if code != http.StatusOK { glog.Errorf("Status error: %v\n", http.StatusText(code)) return "HTTP Status error from maya-apiserver", err } glog.Infof("volume Successfully Created:\n%v\n", string(data)) return "volume Successfully Created", nil }
[ "func", "(", "v", "OpenEBSVolume", ")", "CreateVolume", "(", "vs", "mayav1", ".", "VolumeSpec", ")", "(", "string", ",", "error", ")", "{", "addr", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "addr", "==", "\"", "\"", "{", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "url", ":=", "addr", "+", "\"", "\"", "\n\n", "vs", ".", "Kind", "=", "\"", "\"", "\n", "vs", ".", "APIVersion", "=", "\"", "\"", "\n\n", "//Marshal serializes the value provided into a YAML document", "yamlValue", ",", "_", ":=", "yaml", ".", "Marshal", "(", "vs", ")", "\n\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\\n", "\\n", "\"", ",", "string", "(", "yamlValue", ")", ")", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "bytes", ".", "NewBuffer", "(", "yamlValue", ")", ")", "\n\n", "req", ".", "Header", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "c", ":=", "&", "http", ".", "Client", "{", "Timeout", ":", "timeout", ",", "}", "\n", "resp", ",", "err", ":=", "c", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n\n", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "resp", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "code", ":=", "resp", ".", "StatusCode", "\n", "if", "code", "!=", "http", ".", "StatusOK", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "http", ".", "StatusText", "(", "code", ")", ")", "\n", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "glog", ".", "Infof", "(", "\"", "\\n", "\\n", "\"", ",", "string", "(", "data", ")", ")", "\n", "return", "\"", "\"", ",", "nil", "\n", "}" ]
// CreateVolume to create the Vsm through a API call to m-apiserver
[ "CreateVolume", "to", "create", "the", "Vsm", "through", "a", "API", "call", "to", "m", "-", "apiserver" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/openebs/pkg/v1/maya_api.go#L77-L123
train
kubernetes-incubator/external-storage
openebs/pkg/v1/maya_api.go
ListVolume
func (v OpenEBSVolume) ListVolume(vname string, obj interface{}) error { addr := os.Getenv("MAPI_ADDR") if addr == "" { err := errors.New("MAPI_ADDR environment variable not set") glog.Errorf("Error getting mayaapi-server IP Address: %v", err) return err } url := addr + "/latest/volumes/info/" + vname glog.V(2).Infof("[DEBUG] Get details for Volume :%v", string(vname)) req, err := http.NewRequest("GET", url, nil) c := &http.Client{ Timeout: timeout, } resp, err := c.Do(req) if err != nil { glog.Errorf("Error when connecting to maya-apiserver %v", err) return err } defer resp.Body.Close() code := resp.StatusCode if code != http.StatusOK { glog.Errorf("HTTP Status error from maya-apiserver: %v\n", http.StatusText(code)) return err } glog.V(2).Info("volume Details Successfully Retrieved") return json.NewDecoder(resp.Body).Decode(obj) }
go
func (v OpenEBSVolume) ListVolume(vname string, obj interface{}) error { addr := os.Getenv("MAPI_ADDR") if addr == "" { err := errors.New("MAPI_ADDR environment variable not set") glog.Errorf("Error getting mayaapi-server IP Address: %v", err) return err } url := addr + "/latest/volumes/info/" + vname glog.V(2).Infof("[DEBUG] Get details for Volume :%v", string(vname)) req, err := http.NewRequest("GET", url, nil) c := &http.Client{ Timeout: timeout, } resp, err := c.Do(req) if err != nil { glog.Errorf("Error when connecting to maya-apiserver %v", err) return err } defer resp.Body.Close() code := resp.StatusCode if code != http.StatusOK { glog.Errorf("HTTP Status error from maya-apiserver: %v\n", http.StatusText(code)) return err } glog.V(2).Info("volume Details Successfully Retrieved") return json.NewDecoder(resp.Body).Decode(obj) }
[ "func", "(", "v", "OpenEBSVolume", ")", "ListVolume", "(", "vname", "string", ",", "obj", "interface", "{", "}", ")", "error", "{", "addr", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "addr", "==", "\"", "\"", "{", "err", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "url", ":=", "addr", "+", "\"", "\"", "+", "vname", "\n\n", "glog", ".", "V", "(", "2", ")", ".", "Infof", "(", "\"", "\"", ",", "string", "(", "vname", ")", ")", "\n\n", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "nil", ")", "\n", "c", ":=", "&", "http", ".", "Client", "{", "Timeout", ":", "timeout", ",", "}", "\n", "resp", ",", "err", ":=", "c", ".", "Do", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "(", ")", "\n\n", "code", ":=", "resp", ".", "StatusCode", "\n", "if", "code", "!=", "http", ".", "StatusOK", "{", "glog", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "http", ".", "StatusText", "(", "code", ")", ")", "\n", "return", "err", "\n", "}", "\n", "glog", ".", "V", "(", "2", ")", ".", "Info", "(", "\"", "\"", ")", "\n", "return", "json", ".", "NewDecoder", "(", "resp", ".", "Body", ")", ".", "Decode", "(", "obj", ")", "\n", "}" ]
// ListVolume to get the info of Vsm through a API call to m-apiserver
[ "ListVolume", "to", "get", "the", "info", "of", "Vsm", "through", "a", "API", "call", "to", "m", "-", "apiserver" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/openebs/pkg/v1/maya_api.go#L126-L156
train
kubernetes-incubator/external-storage
aws/efs/cmd/efs-provisioner/efs-provisioner.go
NewEFSProvisioner
func NewEFSProvisioner(client kubernetes.Interface) controller.Provisioner { fileSystemID := os.Getenv(fileSystemIDKey) if fileSystemID == "" { klog.Fatalf("environment variable %s is not set! Please set it.", fileSystemIDKey) } awsRegion := os.Getenv(awsRegionKey) if awsRegion == "" { klog.Fatalf("environment variable %s is not set! Please set it.", awsRegionKey) } dnsName := os.Getenv(dnsNameKey) klog.Errorf("%v", dnsName) if dnsName == "" { dnsName = getDNSName(fileSystemID, awsRegion) } mountpoint, source, err := getMount(dnsName) if err != nil { klog.Fatal(err) } sess, err := session.NewSession() if err != nil { klog.Warningf("couldn't create an AWS session: %v", err) } svc := efs.New(sess, &aws.Config{Region: aws.String(awsRegion)}) params := &efs.DescribeFileSystemsInput{ FileSystemId: aws.String(fileSystemID), } _, err = svc.DescribeFileSystems(params) if err != nil { klog.Warningf("couldn't confirm that the EFS file system exists: %v", err) } return &efsProvisioner{ dnsName: dnsName, mountpoint: mountpoint, source: source, allocator: gidallocator.New(client), } }
go
func NewEFSProvisioner(client kubernetes.Interface) controller.Provisioner { fileSystemID := os.Getenv(fileSystemIDKey) if fileSystemID == "" { klog.Fatalf("environment variable %s is not set! Please set it.", fileSystemIDKey) } awsRegion := os.Getenv(awsRegionKey) if awsRegion == "" { klog.Fatalf("environment variable %s is not set! Please set it.", awsRegionKey) } dnsName := os.Getenv(dnsNameKey) klog.Errorf("%v", dnsName) if dnsName == "" { dnsName = getDNSName(fileSystemID, awsRegion) } mountpoint, source, err := getMount(dnsName) if err != nil { klog.Fatal(err) } sess, err := session.NewSession() if err != nil { klog.Warningf("couldn't create an AWS session: %v", err) } svc := efs.New(sess, &aws.Config{Region: aws.String(awsRegion)}) params := &efs.DescribeFileSystemsInput{ FileSystemId: aws.String(fileSystemID), } _, err = svc.DescribeFileSystems(params) if err != nil { klog.Warningf("couldn't confirm that the EFS file system exists: %v", err) } return &efsProvisioner{ dnsName: dnsName, mountpoint: mountpoint, source: source, allocator: gidallocator.New(client), } }
[ "func", "NewEFSProvisioner", "(", "client", "kubernetes", ".", "Interface", ")", "controller", ".", "Provisioner", "{", "fileSystemID", ":=", "os", ".", "Getenv", "(", "fileSystemIDKey", ")", "\n", "if", "fileSystemID", "==", "\"", "\"", "{", "klog", ".", "Fatalf", "(", "\"", "\"", ",", "fileSystemIDKey", ")", "\n", "}", "\n\n", "awsRegion", ":=", "os", ".", "Getenv", "(", "awsRegionKey", ")", "\n", "if", "awsRegion", "==", "\"", "\"", "{", "klog", ".", "Fatalf", "(", "\"", "\"", ",", "awsRegionKey", ")", "\n", "}", "\n\n", "dnsName", ":=", "os", ".", "Getenv", "(", "dnsNameKey", ")", "\n", "klog", ".", "Errorf", "(", "\"", "\"", ",", "dnsName", ")", "\n", "if", "dnsName", "==", "\"", "\"", "{", "dnsName", "=", "getDNSName", "(", "fileSystemID", ",", "awsRegion", ")", "\n", "}", "\n\n", "mountpoint", ",", "source", ",", "err", ":=", "getMount", "(", "dnsName", ")", "\n", "if", "err", "!=", "nil", "{", "klog", ".", "Fatal", "(", "err", ")", "\n", "}", "\n\n", "sess", ",", "err", ":=", "session", ".", "NewSession", "(", ")", "\n", "if", "err", "!=", "nil", "{", "klog", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "svc", ":=", "efs", ".", "New", "(", "sess", ",", "&", "aws", ".", "Config", "{", "Region", ":", "aws", ".", "String", "(", "awsRegion", ")", "}", ")", "\n", "params", ":=", "&", "efs", ".", "DescribeFileSystemsInput", "{", "FileSystemId", ":", "aws", ".", "String", "(", "fileSystemID", ")", ",", "}", "\n\n", "_", ",", "err", "=", "svc", ".", "DescribeFileSystems", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "klog", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "return", "&", "efsProvisioner", "{", "dnsName", ":", "dnsName", ",", "mountpoint", ":", "mountpoint", ",", "source", ":", "source", ",", "allocator", ":", "gidallocator", ".", "New", "(", "client", ")", ",", "}", "\n", "}" ]
// NewEFSProvisioner creates an AWS EFS volume provisioner
[ "NewEFSProvisioner", "creates", "an", "AWS", "EFS", "volume", "provisioner" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/aws/efs/cmd/efs-provisioner/efs-provisioner.go#L57-L100
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/api_util.go
CreatePV
func (u *apiUtil) CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { startTime := time.Now() metrics.APIServerRequestsTotal.WithLabelValues(metrics.APIServerRequestCreate).Inc() pv, err := u.client.CoreV1().PersistentVolumes().Create(pv) metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestCreate).Observe(time.Since(startTime).Seconds()) if err != nil { metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestCreate).Inc() } return pv, err }
go
func (u *apiUtil) CreatePV(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { startTime := time.Now() metrics.APIServerRequestsTotal.WithLabelValues(metrics.APIServerRequestCreate).Inc() pv, err := u.client.CoreV1().PersistentVolumes().Create(pv) metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestCreate).Observe(time.Since(startTime).Seconds()) if err != nil { metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestCreate).Inc() } return pv, err }
[ "func", "(", "u", "*", "apiUtil", ")", "CreatePV", "(", "pv", "*", "v1", ".", "PersistentVolume", ")", "(", "*", "v1", ".", "PersistentVolume", ",", "error", ")", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "metrics", ".", "APIServerRequestsTotal", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestCreate", ")", ".", "Inc", "(", ")", "\n", "pv", ",", "err", ":=", "u", ".", "client", ".", "CoreV1", "(", ")", ".", "PersistentVolumes", "(", ")", ".", "Create", "(", "pv", ")", "\n", "metrics", ".", "APIServerRequestsDurationSeconds", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestCreate", ")", ".", "Observe", "(", "time", ".", "Since", "(", "startTime", ")", ".", "Seconds", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "metrics", ".", "APIServerRequestsFailedTotal", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestCreate", ")", ".", "Inc", "(", ")", "\n", "}", "\n", "return", "pv", ",", "err", "\n", "}" ]
// CreatePV will create a PersistentVolume
[ "CreatePV", "will", "create", "a", "PersistentVolume" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L60-L69
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/api_util.go
DeletePV
func (u *apiUtil) DeletePV(pvName string) error { startTime := time.Now() metrics.APIServerRequestsTotal.WithLabelValues(metrics.APIServerRequestDelete).Inc() err := u.client.CoreV1().PersistentVolumes().Delete(pvName, &metav1.DeleteOptions{}) metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestDelete).Observe(time.Since(startTime).Seconds()) if err != nil { metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestDelete).Inc() } return err }
go
func (u *apiUtil) DeletePV(pvName string) error { startTime := time.Now() metrics.APIServerRequestsTotal.WithLabelValues(metrics.APIServerRequestDelete).Inc() err := u.client.CoreV1().PersistentVolumes().Delete(pvName, &metav1.DeleteOptions{}) metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestDelete).Observe(time.Since(startTime).Seconds()) if err != nil { metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestDelete).Inc() } return err }
[ "func", "(", "u", "*", "apiUtil", ")", "DeletePV", "(", "pvName", "string", ")", "error", "{", "startTime", ":=", "time", ".", "Now", "(", ")", "\n", "metrics", ".", "APIServerRequestsTotal", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestDelete", ")", ".", "Inc", "(", ")", "\n", "err", ":=", "u", ".", "client", ".", "CoreV1", "(", ")", ".", "PersistentVolumes", "(", ")", ".", "Delete", "(", "pvName", ",", "&", "metav1", ".", "DeleteOptions", "{", "}", ")", "\n", "metrics", ".", "APIServerRequestsDurationSeconds", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestDelete", ")", ".", "Observe", "(", "time", ".", "Since", "(", "startTime", ")", ".", "Seconds", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "metrics", ".", "APIServerRequestsFailedTotal", ".", "WithLabelValues", "(", "metrics", ".", "APIServerRequestDelete", ")", ".", "Inc", "(", ")", "\n", "}", "\n", "return", "err", "\n", "}" ]
// DeletePV will delete a PersistentVolume
[ "DeletePV", "will", "delete", "a", "PersistentVolume" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L72-L81
train
kubernetes-incubator/external-storage
local-volume/provisioner/pkg/util/api_util.go
NewFakeAPIUtil
func NewFakeAPIUtil(shouldFail bool, cache *cache.VolumeCache) *FakeAPIUtil { return &FakeAPIUtil{ createdPVs: map[string]*v1.PersistentVolume{}, deletedPVs: map[string]*v1.PersistentVolume{}, CreatedJobs: map[string]*batch_v1.Job{}, DeletedJobs: map[string]string{}, shouldFail: shouldFail, cache: cache, } }
go
func NewFakeAPIUtil(shouldFail bool, cache *cache.VolumeCache) *FakeAPIUtil { return &FakeAPIUtil{ createdPVs: map[string]*v1.PersistentVolume{}, deletedPVs: map[string]*v1.PersistentVolume{}, CreatedJobs: map[string]*batch_v1.Job{}, DeletedJobs: map[string]string{}, shouldFail: shouldFail, cache: cache, } }
[ "func", "NewFakeAPIUtil", "(", "shouldFail", "bool", ",", "cache", "*", "cache", ".", "VolumeCache", ")", "*", "FakeAPIUtil", "{", "return", "&", "FakeAPIUtil", "{", "createdPVs", ":", "map", "[", "string", "]", "*", "v1", ".", "PersistentVolume", "{", "}", ",", "deletedPVs", ":", "map", "[", "string", "]", "*", "v1", ".", "PersistentVolume", "{", "}", ",", "CreatedJobs", ":", "map", "[", "string", "]", "*", "batch_v1", ".", "Job", "{", "}", ",", "DeletedJobs", ":", "map", "[", "string", "]", "string", "{", "}", ",", "shouldFail", ":", "shouldFail", ",", "cache", ":", "cache", ",", "}", "\n", "}" ]
// NewFakeAPIUtil returns an APIUtil object that can be used for unit testing
[ "NewFakeAPIUtil", "returns", "an", "APIUtil", "object", "that", "can", "be", "used", "for", "unit", "testing" ]
fbfedbf60da4e5ee25a3151bfe8504f3e3281319
https://github.com/kubernetes-incubator/external-storage/blob/fbfedbf60da4e5ee25a3151bfe8504f3e3281319/local-volume/provisioner/pkg/util/api_util.go#L113-L122
train