// VolumeInspect inspects a single volume.
970923
func (d *driver) VolumeInspect(
	ctx types.Context,
	volumeID string,
	opts *types.VolumeInspectOpts) (*types.Volume, error) {
	// Get volume corresponding to volume ID via EC2 API
	ec2vols, err := d.getVolume(ctx, volumeID, "")
	if err != nil {
		return nil, goof.WithError("error getting volume", err)
	}
	if len(ec2vols) == 0 {
		return nil, apiUtils.NewNotFoundError(volumeID)
	}
	vols, convErr := d.toTypesVolume(ctx, ec2vols, opts.Attachments)
	if convErr != nil {
		return nil, goof.WithError("error converting to types.Volume", convErr)
	}

	// Because getVolume returns an array
	// and we only expect the 1st element to be a match, return 1st element
	return vols[0], nil
}
924392
func (s *VolumeServer) Inspect(
	ctx context.Context,
	req *api.SdkVolumeInspectRequest,
) (*api.SdkVolumeInspectResponse, error) {
	if s.cluster() == nil || s.driver(ctx) == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetVolumeId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must supply volume id")
	}

	var v *api.Volume
	if !req.GetOptions().GetDeep() {
		vols, err := s.driver(ctx).Enumerate(&api.VolumeLocator{
			VolumeIds: []string{req.GetVolumeId()},
		}, nil)
		if err != nil {
			return nil, status.Errorf(
				codes.Internal,
				"Failed to inspect volume %s: %v",
				req.GetVolumeId(), err)
		}
		if len(vols) == 0 {
			return nil, status.Errorf(
				codes.NotFound,
				"Volume id %s not found",
				req.GetVolumeId())
		}
		v = vols[0]
	} else {
		vols, err := s.driver(ctx).Inspect([]string{req.GetVolumeId()})
		if err == kvdb.ErrNotFound || (err == nil && len(vols) == 0) {
			return nil, status.Errorf(
				codes.NotFound,
				"Volume id %s not found",
				req.GetVolumeId())
		} else if err != nil {
			return nil, status.Errorf(
				codes.Internal,
				"Failed to inspect volume %s: %v",
				req.GetVolumeId(), err)
		}
		v = vols[0]
	}

	// Check ownership
	if !v.IsPermitted(ctx, api.Ownership_Read) {
		return nil, status.Errorf(codes.PermissionDenied, "Access denied to volume %s", v.GetId())
	}

	return &api.SdkVolumeInspectResponse{
		Volume: v,
		Name:   v.GetLocator().GetName(),
		Labels: v.GetLocator().GetVolumeLabels(),
	}, nil
}
985196
func httpInspectVolumeProfile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	var obj VolumeProfileInspect
	log.Debugf("Received httpInspectVolumeProfile: %+v", vars)

	key := vars["key"]

	collections.volumeProfileMutex.Lock()
	defer collections.volumeProfileMutex.Unlock()
	objConfig := collections.volumeProfiles[key]
	if objConfig == nil {
		log.Errorf("volumeProfile %s not found", key)
		return nil, errors.New("volumeProfile not found")
	}
	obj.Config = *objConfig

	// Return the obj
	return &obj, nil
}
790516
func (_m *API) VirtualizationInspect(ctx context.Context, ID string) (*types.VirtualizationInfo, error) {
	ret := _m.Called(ctx, ID)

	var r0 *types.VirtualizationInfo
	if rf, ok := ret.Get(0).(func(context.Context, string) *types.VirtualizationInfo); ok {
		r0 = rf(ctx, ID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*types.VirtualizationInfo)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
		r1 = rf(ctx, ID)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
679850
func (plugin *localVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
	fs := v1.PersistentVolumeFilesystem
	localVolume := &v1.PersistentVolume{
		ObjectMeta: metav1.ObjectMeta{
			Name: volumeName,
		},
		Spec: v1.PersistentVolumeSpec{
			PersistentVolumeSource: v1.PersistentVolumeSource{
				Local: &v1.LocalVolumeSource{
					Path: "",
				},
			},
			VolumeMode: &fs,
		},
	}
	return volume.NewSpecFromPersistentVolume(localVolume, false), nil
}
145038
func (cli *Client) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) {
	if volumeID == "" {
		return types.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}
	}

	var volume types.Volume
	resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil)
	defer ensureReaderClosed(resp)
	if err != nil {
		return volume, nil, wrapResponseError(err, resp, "volume", volumeID)
	}

	body, err := ioutil.ReadAll(resp.body)
	if err != nil {
		return volume, nil, err
	}
	rdr := bytes.NewReader(body)
	err = json.NewDecoder(rdr).Decode(&volume)
	return volume, body, err
}
77621
func validateVolumeSpec(path *field.Path, v *kops.VolumeSpec) error {
	if v.Device == "" {
		return field.Required(path.Child("device"), "device name required")
	}
	if v.Size <= 0 {
		return field.Invalid(path.Child("size"), v.Size, "must be greater than zero")
	}

	return nil
}
398733
func (d *driver) SnapshotInspect(
	ctx types.Context,
	snapshotID string,
	opts types.Store) (*types.Snapshot, error) {
	// TODO Snapshots are not implemented yet
	return nil, types.ErrNotImplemented
}
650997
func volumeDevicesInUse(podSpec *api.PodSpec) bool {
	if podSpec == nil {
		return false
	}
	for i := range podSpec.Containers {
		if podSpec.Containers[i].VolumeDevices != nil {
			return true
		}
	}
	for i := range podSpec.InitContainers {
		if podSpec.InitContainers[i].VolumeDevices != nil {
			return true
		}
	}
	return false
}
976821
func (mr *MockContainerAPIClientMockRecorder) ContainerInspect(ctx, container interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerInspect", reflect.TypeOf((*MockContainerAPIClient)(nil).ContainerInspect), ctx, container)
}
1038031
func (c *Client) ResizeVolume(p *ResizeVolumeParameter) (*Volume, error) {
	obj, err := c.Request("resizeVolume", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Volume), err
}
365769
func (m *MockContainerAPIClient) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) {
	ret := m.ctrl.Call(m, "ContainerInspect", ctx, container)
	ret0, _ := ret[0].(types.ContainerJSON)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
445109
func (e *defaultStoreEnumerator) Inspect(ids []string) ([]*api.Volume, error) {
	volumes := make([]*api.Volume, 0, len(ids))
	for _, id := range ids {
		volume, err := e.GetVol(id)
		// XXX Distinguish between ENOENT and an internal error from KVDB
		if err != nil {
			continue
		}
		volumes = append(volumes, volume)
	}
	return volumes, nil
}
749610
func (d *driver) InstanceInspect(
	ctx types.Context,
	opts types.Store) (*types.Instance, error) {

	return &types.Instance{
		InstanceID: context.MustInstanceID(ctx),
	}, nil
}
1003973
func (v *Volume) Inspect(ctx context.Context) (types.Volume, error) {
	return v.client.VolumeInspect(ctx, v.fullName())
}
817824
func VolumeFromState(v state.Volume) (params.Volume, error) {
	info, err := v.Info()
	if err != nil {
		return params.Volume{}, errors.Trace(err)
	}
	return params.Volume{
		v.VolumeTag().String(),
		VolumeInfoFromState(info),
	}, nil
}
221195
func TaskInspect(ctx types.Context, taskID int) *types.Task {
	return getTaskService(ctx).TaskInspect(taskID)
}