// StorageProviderTypes implements storage.ProviderRegistry.
425136
func (e *Environ) StorageProviderTypes() ([]storage.ProviderType, error) {
	return []storage.ProviderType{ociStorageProviderType}, nil
}
646946
func storageConstraintsWithDefaults(
	modelType ModelType,
	cfg *config.Config,
	charmStorage charm.Storage,
	name string,
	cons StorageConstraints,
) (StorageConstraints, error) {
	withDefaults := cons

	// If no pool is specified, determine the pool from the env config and other constraints.
	if cons.Pool == "" {
		kind := storageKind(charmStorage.Type)
		poolName, err := defaultStoragePool(modelType, cfg, kind, cons)
		if err != nil {
			return withDefaults, errors.Annotatef(err, "finding default pool for %q storage", name)
		}
		withDefaults.Pool = poolName
	}

	// If no size is specified, we default to the min size specified by the
	// charm, or 1GiB.
	if cons.Size == 0 {
		if charmStorage.MinimumSize > 0 {
			withDefaults.Size = charmStorage.MinimumSize
		} else {
			withDefaults.Size = 1024
		}
	}
	if cons.Count == 0 {
		withDefaults.Count = uint64(charmStorage.CountMin)
	}
	return withDefaults, nil
}
803220
func (cs *CSCloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) {
	instance, count, err := cs.client.VirtualMachine.GetVirtualMachineByID(
		providerID,
		cloudstack.WithProject(cs.projectID),
	)
	if err != nil {
		if count == 0 {
			return "", cloudprovider.InstanceNotFound
		}
		return "", fmt.Errorf("error retrieving instance type: %v", err)
	}

	return instance.Serviceofferingname, nil
}
700900
func WithStorageService(
	parent context.Context, service types.StorageService) types.Context {

	var (
		serviceName = strings.ToLower(service.Name())
		driver      = service.Driver()
		driverName  = strings.ToLower(driver.Name())
	)

	parent = newContext(parent, DriverKey, driver, nil, nil)

	// set the service's InstanceID if present
	if iidm, ok := parent.Value(AllInstanceIDsKey).(types.InstanceIDMap); ok {
		if iid, ok := iidm[serviceName]; ok {
			parent = newContext(parent, InstanceIDKey, iid, nil, nil)
		}
	}

	// set the service's LocalDevices if present
	if ldm, ok := parent.Value(AllLocalDevicesKey).(types.LocalDevicesMap); ok {
		if ld, ok := ldm[driverName]; ok {
			parent = newContext(parent, LocalDevicesKey, ld, nil, nil)
		}
	}

	return newContext(parent, ServiceKey, service, nil, nil)
}
7300
func NewStorageProviderRegistry(reg storage.ProviderRegistry) storage.ProviderRegistry {
	return storage.ChainedProviderRegistry{reg, provider.CommonStorageProviders()}
}
1066875
func NewEncryptedStorageProvider(storageProvider StorageProvider, encryptionKey string) (encryptedStorageProvider *EncryptedStorageProvider, err error) {
	if encryptionKey != "" {
		encryptedStorageProvider = &EncryptedStorageProvider{
			EncryptionKey:          encryptionKey,
			wrappedStorageProvider: storageProvider,
		}

	} else {
		errMsg := "no encryption key provided"
		lo.G.Error(errMsg)
		err = errors.New(errMsg)
	}
	return
}
804402
func logProviders(pod *coreapi.Pod, providers []scc.SecurityContextConstraintsProvider, providerCreationErrs []error) {
	names := make([]string, len(providers))
	for i, p := range providers {
		names[i] = p.GetSCCName()
	}
	klog.V(4).Infof("validating pod %s (generate: %s) against providers %s", pod.Name, pod.GenerateName, strings.Join(names, ","))

	for _, err := range providerCreationErrs {
		klog.V(4).Infof("provider creation error: %v", err)
	}
}
89456
func (f *FakeCloud) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) {
	f.addCall("instance-type-by-provider-id")
	return f.InstanceTypes[types.NodeName(providerID)], nil
}
716798
func (*maasEnviron) StorageProvider(t storage.ProviderType) (storage.Provider, error) {
	if t == maasStorageProviderType {
		return maasStorageProvider{}, nil
	}
	return nil, errors.NotFoundf("storage provider %q", t)
}
1294709
func providerService(c *Config) *sc.ProviderService {
	ret := &sc.ProviderService{
		Service:        c.Service,
		ServiceVersion: c.Version,
		Capabilities:   map[string]int{},
		Meta:           c.Meta,
		ResourceType:   c.ResourceType,
	}

	return ret
}
879701
func (c *Client) ListStorageProviders(p *ListStorageProvidersParameter) ([]*StorageProvider, error) {
	obj, err := c.Request("listStorageProviders", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*StorageProvider), err
}
1325278
func (m *MockStorageV1Interface) StorageClasses() v11.StorageClassInterface {
	ret := m.ctrl.Call(m, "StorageClasses")
	ret0, _ := ret[0].(v11.StorageClassInterface)
	return ret0
}
507629
func CloudProviders() []string {
	names := []string{}
	providersMutex.Lock()
	defer providersMutex.Unlock()
	for name := range providers {
		names = append(names, name)
	}
	return names
}
1056690
func (s *StoragePoolService) NewListStorageProvidersParams(storagePoolType string) *ListStorageProvidersParams {
	p := &ListStorageProvidersParams{}
	p.p = make(map[string]interface{})
	p.p["type"] = storagePoolType
	return p
}
217116
func (sb *storageBackend) AllStorageInstances() ([]StorageInstance, error) {
	storageInstances, err := sb.storageInstances(nil)
	if err != nil {
		return nil, errors.Trace(err)
	}
	out := make([]StorageInstance, len(storageInstances))
	for i, s := range storageInstances {
		out[i] = s
	}
	return out, nil
}
871670
func (s *ProviderDescription) SetProviderType(v string) *ProviderDescription {
	s.ProviderType = &v
	return s
}
1207872
func ValidateStorageProvider(providerType storage.ProviderType, attributes map[string]interface{}) error {
	switch providerType {
	case K8s_ProviderType:
	case provider.RootfsProviderType:
	case provider.TmpfsProviderType:
	default:
		return errors.NotValidf("storage provider type %q", providerType)
	}
	if attributes == nil {
		return nil
	}
	if mediumValue, ok := attributes[storageMedium]; ok {
		medium := core.StorageMedium(fmt.Sprintf("%v", mediumValue))
		if medium != core.StorageMediumMemory && medium != core.StorageMediumHugePages {
			return errors.NotValidf("storage medium %q", mediumValue)
		}
	}
	if providerType == K8s_ProviderType {
		if _, err := newStorageConfig(attributes); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}