// initDriverAndReadMigrationFilesAndGetVersionsAndGetVersion is a small helper
// function that is common to most of the migration funcs.
15951
func initDriverAndReadMigrationFilesAndGetVersions(url, migrationsPath string) (driver.Driver, file.MigrationFiles, file.Versions, error) {
	d, err := driver.New(url)
	if err != nil {
		return nil, nil, file.Versions{}, err
	}
	files, err := file.ReadMigrationFiles(migrationsPath, file.FilenameRegex(d.FilenameExtension()))
	if err != nil {
		d.Close() // TODO what happens with errors from this func?
		return nil, nil, file.Versions{}, err
	}

	versions, err := d.Versions()
	if err != nil {
		d.Close() // TODO what happens with errors from this func?
		return nil, nil, file.Versions{}, err

	}

	return d, files, versions, nil
}
103151
func highestSupportedVersion(versions []string) (*utilversion.Version, error) {
	if len(versions) == 0 {
		return nil, fmt.Errorf("CSI driver reporting empty array for supported versions")
	}

	// Sort by lowest to highest version
	sort.Slice(versions, func(i, j int) bool {
		parsedVersionI, err := utilversion.ParseGeneric(versions[i])
		if err != nil {
			// Push bad values to the bottom
			return true
		}

		parsedVersionJ, err := utilversion.ParseGeneric(versions[j])
		if err != nil {
			// Push bad values to the bottom
			return false
		}

		return parsedVersionI.LessThan(parsedVersionJ)
	})

	for i := len(versions) - 1; i >= 0; i-- {
		highestSupportedVersion, err := utilversion.ParseGeneric(versions[i])
		if err != nil {
			return nil, err
		}

		if highestSupportedVersion.Major() <= 1 {
			return highestSupportedVersion, nil
		}
	}

	return nil, fmt.Errorf("None of the CSI versions reported by this driver are supported")
}
73158
func getBootstrapVersion(s Session) (int64, error) {
	sVal, isNull, err := getTiDBVar(s, tidbServerVersionVar)
	if err != nil {
		return 0, errors.Trace(err)
	}
	if isNull {
		return 0, nil
	}
	return strconv.ParseInt(sVal, 10, 64)
}
517744
func (s *PolicyVersion) SetIsDefaultVersion(v bool) *PolicyVersion {
	s.IsDefaultVersion = &v
	return s
}
307527
func (r *EtcdRegistry) EngineVersion() (int, error) {
	res, err := r.kAPI.Get(context.Background(), r.engineVersionPath(), nil)
	if err != nil {
		// no big deal, either the cluster is new or is just
		// upgrading from old unversioned code
		if isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
			err = nil
		}
		return 0, err
	}

	return strconv.Atoi(res.Node.Value)
}
302886
func DeploymentNameForConfigVersion(name string, version int64) string {
	return fmt.Sprintf("%s-%d", name, version)
}
1244967
func (fi VS_FIXEDFILEINFO) FileVersion() uint64 {
	return uint64(fi.FileVersionMS)<<32 | uint64(fi.FileVersionLS)
}
328632
func (s *CreateCoreDefinitionInput) SetInitialVersion(v *CoreDefinitionVersion) *CreateCoreDefinitionInput {
	s.InitialVersion = v
	return s
}
1278509
func getStage1InterfaceVersion(cdir string) (int, error) {
	b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
	if err != nil {
		return -1, errwrap.Wrap(errors.New("error reading pod manifest"), err)
	}

	s1m := schema.ImageManifest{}
	if err := json.Unmarshal(b, &s1m); err != nil {
		return -1, errwrap.Wrap(errors.New("error unmarshaling stage1 manifest"), err)
	}

	if iv, ok := s1m.Annotations.Get(interfaceVersion); ok {
		v, err := strconv.Atoi(iv)
		if err != nil {
			return -1, errwrap.Wrap(errors.New("error parsing interface version"), err)
		}
		return v, nil
	}

	// "interface-version" annotation not found, assume version 1
	return 1, nil
}
979600
func (s *TrafficPolicyInstance) SetTrafficPolicyVersion(v int64) *TrafficPolicyInstance {
	s.TrafficPolicyVersion = &v
	return s
}
1038994
func (r Network_Storage) GetRecycleBinFileByIdentifier(fileId *string) (resp datatypes.Container_Utility_File_Entity, err error) {
	params := []interface{}{
		fileId,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage", "getRecycleBinFileByIdentifier", params, &r.Options, &resp)
	return
}
4456
func hasIdenticalPerVersionColumns(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	if len(versions) == 0 {
		return false
	}
	value := versions[0].AdditionalPrinterColumns
	for _, v := range versions {
		if len(v.AdditionalPrinterColumns) == 0 || !apiequality.Semantic.DeepEqual(v.AdditionalPrinterColumns, value) {
			return false
		}
	}
	return true
}
233282
func generateReservedVersion() VersionNumber {
	b := make([]byte, 4)
	_, _ = rand.Read(b) // ignore the error here. Failure to read random data doesn't break anything
	return VersionNumber((binary.BigEndian.Uint32(b) | 0x0a0a0a0a) & 0xfafafafa)
}
688086
func (f *Facade) getPreviousRegistryVersion() (isMigrated bool, version int, err error) {
	for i := currentRegistryVersion - 1; i > 0; i-- {
		logger := plog.WithField("version", i)
		plog.Info("Checking docker registry")
		versionInfo := registryVersionInfos[i]
		registryPath := versionInfo.getStoragePath(f.isvcsPath)
		logger = logger.WithField("registrypath", registryPath)
		if _, err := os.Stat(registryPath); os.IsNotExist(err) {
			continue
		} else if err != nil {
			logger.WithError(err).Debug("Could not stat registry path")
			return false, 0, err
		}
		markerFilePath := versionInfo.getUpgradedMarkerPath(f.isvcsPath)
		logger = logger.WithField("markerfilepath", markerFilePath)
		if _, err := os.Stat(markerFilePath); os.IsNotExist(err) {
			return false, i, nil
		} else if err != nil {
			logger.WithError(err).Debug("Could not stat registry marker file")
			return false, 0, err
		}
		return true, i, nil
	}
	return false, currentRegistryVersion, nil
}
6286
func (s *CreateDeviceDefinitionInput) SetInitialVersion(v *DeviceDefinitionVersion) *CreateDeviceDefinitionInput {
	s.InitialVersion = v
	return s
}
1115898
func (t *Template) GetAWSRoboMakerSimulationApplicationVersionWithName(name string) (*resources.AWSRoboMakerSimulationApplicationVersion, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSRoboMakerSimulationApplicationVersion:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSRoboMakerSimulationApplicationVersion not found", name)
}
360953
func (s *CreateFunctionDefinitionInput) SetInitialVersion(v *FunctionDefinitionVersion) *CreateFunctionDefinitionInput {
	s.InitialVersion = v
	return s
}