//GetVolumeConfig creates a new VolumeConfig struct by
// parsing and merging the configuration provided in the PVC
// annotation - cas.openebs.io/config with the
// default configuration of the provisioner.
GetVolumeConfig creates a new VolumeConfig struct by
parsing and merging the configuration provided in the PVC
annotation - cas.openebs.io/config with the
default configuration of the provisioner.
// GetVolumeConfig creates a new VolumeConfig struct by // parsing and merging the configuration provided in the PVC // annotation - cas . openebs . io / config with the // default configuration of the provisioner .
func (p *Provisioner) GetVolumeConfig(pvName string, pvc *v1.PersistentVolumeClaim) (*VolumeConfig, error) {
	pvConfig := p.defaultConfig
	scName := GetStorageClassNameFromPVC(pvc)
	sc, err := p.kubeClient.StorageV1().StorageClasses().Get(*scName, metav1.GetOptions{})
	if err != nil {
		return nil, errors.Wrapf(err, "failed to get storageclass: missing sc name {%v}", scName)
	}
	scCASConfigStr := sc.ObjectMeta.Annotations[string(mconfig.CASConfigKey)]
	klog.V(4).Infof("SC %v has config:%v", *scName, scCASConfigStr)
	if len(strings.TrimSpace(scCASConfigStr)) != 0 {
		scCASConfig, err := cast.UnMarshallToConfig(scCASConfigStr)
		if err == nil {
			pvConfig = cast.MergeConfig(scCASConfig, pvConfig)
		} else {
			return nil, errors.Wrapf(err, "failed to get config: invalid sc config {%v}", scCASConfigStr)
		}
	}
	pvConfigMap, err := cast.ConfigToMap(pvConfig)
	if err != nil {
		return nil, errors.Wrapf(err, "unable to read volume config: pvc {%v}", pvc.ObjectMeta.Name)
	}
	c := &VolumeConfig{
		pvName:  pvName,
		pvcName: pvc.ObjectMeta.Name,
		scName:  *scName,
		options: pvConfigMap,
	}
	return c, nil
}
func ( p * Provisioner ) GetVolumeConfig ( pvName string , pvc * v1 . PersistentVolumeClaim ) ( * VolumeConfig , error ) { pvConfig := p . defaultConfig scName := GetStorageClassNameFromPVC ( pvc ) sc , err := p . kubeClient . StorageV1 ( ) . StorageClasses ( ) . Get ( * scName , metav1 . GetOptions { } ) if err != nil { return nil , errors . Wrapf ( err , " " , scName ) } scCASConfigStr := sc . ObjectMeta . Annotations [ string ( mconfig . CASConfigKey ) ] klog . V ( 4 ) . Infof ( " " , * scName , scCASConfigStr ) if len ( strings . TrimSpace ( scCASConfigStr ) ) != 0 { scCASConfig , err := cast . UnMarshallToConfig ( scCASConfigStr ) if err == nil { pvConfig = cast . MergeConfig ( scCASConfig , pvConfig ) } else { return nil , errors . Wrapf ( err , " " , scCASConfigStr ) } } pvConfigMap , err := cast . ConfigToMap ( pvConfig ) if err != nil { return nil , errors . Wrapf ( err , " " , pvc . ObjectMeta . Name ) } c := & VolumeConfig { pvName : pvName , pvcName : pvc . ObjectMeta . Name , scName : * scName , options : pvConfigMap , } return c , nil }
GetVolumeConfig creates a new VolumeConfig struct by
parsing and merging the configuration provided in the PVC
annotation - cas.openebs.io/config with the
default configuration of the provisioner.
GetVolumeConfig creates a new VolumeConfig struct by parsing and merging the configuration provided in the PVC annotation - cas . openebs . io / config with the default configuration of the provisioner .
//Fetch the SC // extract and merge the cas config from storageclass //TODO : extract and merge the cas volume config from pvc //This block can be added once validation checks are added // as to the type of config that can be passed via PVC //pvcCASConfigStr := pvc.ObjectMeta.Annotations[string(mconfig.CASConfigKey)] //if len(strings.TrimSpace(pvcCASConfigStr)) != 0 { //	pvcCASConfig, err := cast.UnMarshallToConfig(pvcCASConfigStr) //	if err == nil { //		pvConfig = cast.MergeConfig(pvcCASConfig, pvConfig) //	} //}