// resourceObjectstorageTempurlV1Read performs the image lookup.
17873
func resourceObjectstorageTempurlV1Read(d *schema.ResourceData, meta interface{}) error {
	turl := d.Get("url").(string)
	u, err := url.Parse(turl)
	if err != nil {
		return fmt.Errorf("Failed to read the temporary url %s: %s", turl, err)
	}

	qp, err := url.ParseQuery(u.RawQuery)
	if err != nil {
		return fmt.Errorf("Failed to parse the temporary url %s query string: %s", turl, err)
	}

	tempURLExpires := qp.Get("temp_url_expires")
	expiry, err := strconv.ParseInt(tempURLExpires, 10, 64)
	if err != nil {
		return fmt.Errorf(
			"Failed to parse the temporary url %s expiration time %s: %s",
			turl, tempURLExpires, err)
	}

	// Regenerate the URL if it has expired and if the user requested it to be.
	regen := d.Get("regenerate").(bool)
	now := time.Now().Unix()
	if expiry < now && regen {
		log.Printf("[DEBUG] temporary url %s expired, generating a new one", turl)
		d.SetId("")
	}

	return nil
}
1043796
func (iter *Iterator) ReadObject() (ret string) {
	c := iter.nextToken()
	switch c {
	case 'n':
		iter.skipThreeBytes('u', 'l', 'l')
		return "" // null
	case '{':
		c = iter.nextToken()
		if c == '"' {
			iter.unreadByte()
			field := iter.ReadString()
			c = iter.nextToken()
			if c != ':' {
				iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
			}
			return field
		}
		if c == '}' {
			return "" // end of object
		}
		iter.ReportError("ReadObject", `expect " after {, but found `+string([]byte{c}))
		return
	case ',':
		field := iter.ReadString()
		c = iter.nextToken()
		if c != ':' {
			iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
		}
		return field
	case '}':
		return "" // end of object
	default:
		iter.ReportError("ReadObject", fmt.Sprintf(`expect { or , or } or n, but found %s`, string([]byte{c})))
		return
	}
}
614490
func (o *ObjectStorage) IterEncodedObjects(t plumbing.ObjectType) (storer.EncodedObjectIter, error) {
	baseIter, err := o.EncodedObjectStorer.IterEncodedObjects(t)
	if err != nil {
		return nil, err
	}

	temporalIter, err := o.temporal.IterEncodedObjects(t)
	if err != nil {
		return nil, err
	}

	return storer.NewMultiEncodedObjectIter([]storer.EncodedObjectIter{
		baseIter,
		temporalIter,
	}), nil
}
929843
func Convert_v1_StorageOSPersistentVolumeSource_To_core_StorageOSPersistentVolumeSource(in *v1.StorageOSPersistentVolumeSource, out *core.StorageOSPersistentVolumeSource, s conversion.Scope) error {
	return autoConvert_v1_StorageOSPersistentVolumeSource_To_core_StorageOSPersistentVolumeSource(in, out, s)
}
770505
func GetDatastorePathObjFromVMDiskPath(vmDiskPath string) (*object.DatastorePath, error) {
	datastorePathObj := new(object.DatastorePath)
	isSuccess := datastorePathObj.FromString(vmDiskPath)
	if !isSuccess {
		klog.Errorf("Failed to parse volPath: %s", vmDiskPath)
		return nil, fmt.Errorf("Failed to parse volPath: %s", vmDiskPath)
	}
	return datastorePathObj, nil
}
790156
func (c *Clientset) StorageV1() storagev1.StorageV1Interface {
	return &fakestoragev1.FakeStorageV1{Fake: &c.Fake}
}
891040
func (a APIObjectVersioner) PrepareObjectForStorage(obj runtime.Object) error {
	accessor, err := meta.Accessor(obj)
	if err != nil {
		return err
	}
	accessor.SetResourceVersion("")
	accessor.SetSelfLink("")
	return nil
}
230573
func (c *Connect) LookupStorageVolByKey(key string) (*StorageVol, error) {
	cKey := C.CString(key)
	defer C.free(unsafe.Pointer(cKey))
	var err C.virError
	ptr := C.virStorageVolLookupByKeyWrapper(c.ptr, cKey, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &StorageVol{ptr: ptr}, nil
}
305784
func LoadResource(db *mgo.Database, resourceType string, id bson.ObjectId) (interface{}, error) {
	// Determine the collection expected to hold the resource
	c := db.C(GetCollectionName(resourceType))
	result := NewStructForResourceName(resourceType)
	err := c.Find(bson.M{"_id": id}).One(result)
	if err != nil {
		return nil, err
	}
	logger.Log.WithFields(logrus.Fields{"result": result}).Debug("LoadResource")
	return result, nil
}
117063
func GetResourceKind(groupVersion schema.GroupVersion, storage rest.Storage, typer runtime.ObjectTyper) (schema.GroupVersionKind, error) {
	// Let the storage tell us exactly what GVK it has
	if gvkProvider, ok := storage.(rest.GroupVersionKindProvider); ok {
		return gvkProvider.GroupVersionKind(groupVersion), nil
	}

	object := storage.New()
	fqKinds, _, err := typer.ObjectKinds(object)
	if err != nil {
		return schema.GroupVersionKind{}, err
	}

	// a given go type can have multiple potential fully qualified kinds.  Find the one that corresponds with the group
	// we're trying to register here
	fqKindToRegister := schema.GroupVersionKind{}
	for _, fqKind := range fqKinds {
		if fqKind.Group == groupVersion.Group {
			fqKindToRegister = groupVersion.WithKind(fqKind.Kind)
			break
		}
	}
	if fqKindToRegister.Empty() {
		return schema.GroupVersionKind{}, fmt.Errorf("unable to locate fully qualified kind for %v: found %v when registering for %v", reflect.TypeOf(object), fqKinds, groupVersion)
	}

	// group is guaranteed to match based on the check above
	return fqKindToRegister, nil
}
951712
func resourceAzureRMCosmosDBAccountFailoverPolicyHash(v interface{}) int {
	var buf bytes.Buffer

	if m, ok := v.(map[string]interface{}); ok {
		location := azureRMNormalizeLocation(m["location"].(string))
		priority := int32(m["priority"].(int))

		buf.WriteString(fmt.Sprintf("%s-%d", location, priority))
	}

	return hashcode.String(buf.String())
}
212258
func (p *propCopySource) GetSourceArchiveID() int64 {
	if p.SourceArchive != nil {
		return p.SourceArchive.GetID()
	}
	return EmptyID
}
13815
func (gov *Governmint) getObject(store base.KVStore, key []byte, objPtr interface{}) interface{} {
	valueBytes := store.Get(key)
	if len(valueBytes) == 0 {
		return nil // NOTE must use return value
	}
	err := wire.ReadBinaryBytes(valueBytes, objPtr)
	if err != nil {
		panic("Error parsing obj: " + err.Error())
	}
	return objPtr
}
127756
func (rm *StateResourceManager) AllocateResourceVal(id, desc string, reqValue interface{}) (interface{},
	error) {
	// XXX: need to take care of distibuted updates, locks etc here
	rsrc, alreadyExists, err := rm.findResource(id, desc)
	if err != nil {
		return nil, err
	}

	if !alreadyExists {
		return nil, core.Errorf("No resource found for description: %q and id: %q",
			desc, id)
	}

	return rsrc.Allocate(reqValue)
}
1174011
func (v *StorageVol) LookupPoolByVolume() (*StoragePool, error) {
	var err C.virError
	poolPtr := C.virStoragePoolLookupByVolumeWrapper(v.ptr, &err)
	if poolPtr == nil {
		return nil, makeError(&err)
	}
	return &StoragePool{ptr: poolPtr}, nil
}
297693
func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) error {
	armClient := meta.(*ArmClient)
	ctx := armClient.StopContext

	id, err := parseStorageContainerID(d.Id(), armClient.environment)
	if err != nil {
		return err
	}

	resourceGroup, err := determineResourceGroupForStorageAccount(id.storageAccountName, armClient)
	if err != nil {
		return err
	}
	if resourceGroup == nil {
		log.Printf("Cannot locate Resource Group for Storage Account %q (presuming it's gone) - removing from state", id.storageAccountName)
		d.SetId("")
		return nil
	}

	blobClient, accountExists, err := armClient.getBlobStorageClientForStorageAccount(ctx, *resourceGroup, id.storageAccountName)
	if err != nil {
		return err
	}
	if !accountExists {
		log.Printf("[DEBUG] Storage account %q not found, removing container %q from state", id.storageAccountName, d.Id())
		d.SetId("")
		return nil
	}

	var container *storage.Container
	listParams := storage.ListContainersParameters{
		Prefix:  id.containerName,
		Timeout: 90,
	}

	for {
		resp, err := blobClient.ListContainers(listParams)
		if err != nil {
			return fmt.Errorf("Failed to retrieve storage resp in account %q: %s", id.containerName, err)
		}

		for _, c := range resp.Containers {
			if c.Name == id.containerName {
				container = &c
				break
			}
		}

		if resp.NextMarker == "" {
			break
		}

		listParams.Marker = resp.NextMarker
	}

	if container == nil {
		log.Printf("[INFO] Storage container %q does not exist in account %q, removing from state...", id.containerName, id.storageAccountName)
		d.SetId("")
		return nil
	}

	d.Set("name", id.containerName)
	d.Set("storage_account_name", id.storageAccountName)
	d.Set("resource_group_name", resourceGroup)

	// for historical reasons, "private" above is an empty string in the API
	if container.Properties.PublicAccess == storage.ContainerAccessTypePrivate {
		d.Set("container_access_type", "private")
	} else {
		d.Set("container_access_type", string(container.Properties.PublicAccess))
	}

	output := make(map[string]interface{})

	output["last_modified"] = container.Properties.LastModified
	output["lease_status"] = container.Properties.LeaseStatus
	output["lease_state"] = container.Properties.LeaseState
	output["lease_duration"] = container.Properties.LeaseDuration

	if err := d.Set("properties", output); err != nil {
		return fmt.Errorf("Error setting `properties`: %+v", err)
	}

	return nil
}
223746
func resourceInfoToObject(info *resource.Info, c *Client) runtime.Object {
	internalObj, err := asInternal(info)
	if err != nil {
		// If the problem is just that the resource is not registered, don't print any
		// error. This is normal for custom resources.
		if !runtime.IsNotRegisteredError(err) {
			c.Log("Warning: conversion to internal type failed: %v", err)
		}
		// Add the unstructured object in this situation. It will still get listed, just
		// with less information.
		return info.Object
	}

	return internalObj
}