// CheckDiskFormatSupported checks if the diskFormat is valid
428534
func CheckDiskFormatSupported(diskFormat string) bool {
	if DiskFormatValidType[diskFormat] == "" {
		klog.Errorf("Not a valid Disk Format. Valid options are %+q", DiskformatValidOptions())
		return false
	}
	return true
}
101201
func loadFormatXL(disk StorageAPI) (format *formatXLV3, err error) {
	buf, err := disk.ReadAll(minioMetaBucket, formatConfigFile)
	if err != nil {
		// 'file not found' and 'volume not found' as
		// same. 'volume not found' usually means its a fresh disk.
		if err == errFileNotFound || err == errVolumeNotFound {
			var vols []VolInfo
			vols, err = disk.ListVols()
			if err != nil {
				return nil, err
			}
			if len(vols) > 1 || (len(vols) == 1 && !isIgnoreHiddenDirectories(vols[0].Name)) {
				// 'format.json' not found, but we
				// found user data.
				return nil, errCorruptedFormat
			}
			// No other data found, its a fresh disk.
			return nil, errUnformattedDisk
		}
		return nil, err
	}

	// Try to decode format json into formatConfigV1 struct.
	format = &formatXLV3{}
	if err = json.Unmarshal(buf, format); err != nil {
		return nil, err
	}

	// Success.
	return format, nil
}
1282993
func CheckVolumeModeFilesystem(volumeSpec *volume.Spec) (bool, error) {
	if utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) {
		volumeMode, err := GetVolumeMode(volumeSpec)
		if err != nil {
			return true, err
		}
		if volumeMode == v1.PersistentVolumeBlock {
			return false, nil
		}
	}
	return true, nil
}
1133314
func (e *lxdStorageProvider) Supports(k storage.StorageKind) bool {
	return k == storage.StorageKindFilesystem
}
748900
func isSupportedAPIVersion(version string) (msg string, ok bool) {
	versionParts := strings.Split(version, ".")
	if len(versionParts) < 2 {
		return fmt.Sprintf("LXD API version %q: expected format <major>.<minor>", version), false
	}

	major, err := strconv.Atoi(versionParts[0])
	if err != nil {
		return fmt.Sprintf("LXD API version %q: unexpected major number: %v", version, err), false
	}

	if major < 1 {
		return fmt.Sprintf("LXD API version %q: expected major version 1 or later", version), false
	}

	return "", true
}
811120
func formatXLMigrate(export string) error {
	formatPath := pathJoin(export, minioMetaBucket, formatConfigFile)
	backend, err := formatMetaGetFormatBackendXL(formatPath)
	if err != nil {
		return err
	}
	if backend != formatBackendXL {
		return fmt.Errorf(`Disk %s: found backend %s, expected %s`, export, backend, formatBackendXL)
	}
	version, err := formatXLGetVersion(formatPath)
	if err != nil {
		return err
	}
	switch version {
	case formatXLVersionV1:
		if err = formatXLMigrateV1ToV2(export); err != nil {
			return err
		}
		fallthrough
	case formatXLVersionV2:
		if err = formatXLMigrateV2ToV3(export); err != nil {
			return err
		}
		fallthrough
	case formatXLVersionV3:
		// format-V3 is the latest verion.
		return nil
	}
	return fmt.Errorf(`%s: unknown format version %s`, export, version)
}
951954
func (f RegexFormatChecker) IsFormat(input interface{}) bool {
	asString, ok := input.(string)
	if !ok {
		return false
	}

	if asString == "" {
		return true
	}
	_, err := regexp.Compile(asString)
	return err == nil
}
484808
func (c *FormatCheckerChain) IsFormat(name string, input interface{}) bool {
	lock.Lock()
	f, ok := c.formatters[name]
	lock.Unlock()

	if !ok {
		return false
	}

	return f.IsFormat(input)
}
712166
func IsFormat(s string) bool {
	r := []rune(s)
	if len(r) != 2 {
		return false
	}
	switch r[1] {
	case 107, 108, 109, 110, 111, 114:
		return true
	}
	return false
}
972804
func (f IPV4FormatChecker) IsFormat(input interface{}) bool {
	asString, ok := input.(string)
	if !ok {
		return false
	}

	// Credit: https://github.com/asaskevich/govalidator
	ip := net.ParseIP(asString)
	return ip != nil && strings.Contains(asString, ".")
}
141421
func checkIfTaintsAlreadyExists(oldTaints []corev1.Taint, taints []corev1.Taint) string {
	var existingTaintList = make([]string, 0)
	for _, taint := range taints {
		for _, oldTaint := range oldTaints {
			if taint.Key == oldTaint.Key && taint.Effect == oldTaint.Effect {
				existingTaintList = append(existingTaintList, taint.Key)
			}
		}
	}
	return strings.Join(existingTaintList, ",")
}
713049
func IsValidDiskSize(name string, disksize string) error {
	_, err := units.FromHumanSize(disksize)
	if err != nil {
		return fmt.Errorf("Not valid disk size: %v", err)
	}
	return nil
}
953604
func GetSupportedClusterVersions(host string) ([]string, error) {
	if host == "" {
		host = client.GetUnixServerPath(OsdSocket, cluster.APIBase)
	}
	client, err := client.NewClient(host, "", "")
	if err != nil {
		return []string{}, err
	}
	versions, err := client.Versions("cluster")
	if err != nil {
		return []string{}, err
	}
	return versions, nil
}
674288
func sortValidDisksInfo(disksInfo []DiskInfo) []DiskInfo {
	var validDisksInfo []DiskInfo
	for _, diskInfo := range disksInfo {
		if diskInfo.Total == 0 {
			continue
		}
		validDisksInfo = append(validDisksInfo, diskInfo)
	}
	sort.Sort(byDiskTotal(validDisksInfo))
	return validDisksInfo
}
724464
func IsSupported(ext string) bool {
	for name := range Types {
		if name == ext {
			return true
		}
	}
	return false
}
627273
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 ""
}
382720
func (f UUIDFormatChecker) IsFormat(input interface{}) bool {
	asString, ok := input.(string)
	if !ok {
		return false
	}

	return rxUUID.MatchString(asString)
}