// pairVersion takes an UnpairedVersion and attempts to pair it with an
// underlying Revision in the context of the provided ProjectIdentifier by
// consulting the canonical version list.
428019
func (vu versionUnifier) pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVersion {
	vl, err := vu.b.listVersions(id)
	if err != nil {
		return nil
	}

	vu.mtr.push("b-pair-version")
	// doing it like this is a bit sloppy
	for _, v2 := range vl {
		if p, ok := v2.(PairedVersion); ok {
			if p.Matches(v) {
				vu.mtr.pop()
				return p
			}
		}
	}

	vu.mtr.pop()
	return nil
}
945987
func IPVersion(b []byte) int {
	// Length must be at least offset+length of version field.
	if len(b) < versIHL+1 {
		return -1
	}
	return int(b[versIHL] >> 4)
}
392222
func (n *Node) GetVersion() *api.Version {
	n.stopMu.RLock()
	defer n.stopMu.RUnlock()

	if !n.IsMember() {
		return nil
	}

	status := n.Status()
	return &api.Version{Index: status.Commit}
}
609889
func (c *Client) ConfigVarInfoByReleaseVersion(appIdentity, version string) (map[string]string, error) {
	var configVar map[string]string
	return configVar, c.Get(&configVar, fmt.Sprintf("/apps/%s/config-vars/%s", appIdentity, version))
}
917950
func (s *WorkflowTypeFilter) SetVersion(v string) *WorkflowTypeFilter {
	s.Version = &v
	return s
}
527534
func (s Session) AddVersion(version int) Session {
	v := make([]byte, 0, 64)
	v = appendInt(v, version)
	return s.append(TypeProtocolVersion, v)
}
1256788
func compareVersionType(l, r Version) int {
	// Big fugly double type switch. No reflect, because this can be smack in a hot loop
	switch l.(type) {
	case Revision:
		switch r.(type) {
		case Revision:
			return 0
		case branchVersion, plainVersion, semVersion:
			return 1
		}

	case plainVersion:
		switch r.(type) {
		case Revision:
			return -1
		case plainVersion:
			return 0
		case branchVersion, semVersion:
			return 1
		}

	case branchVersion:
		switch r.(type) {
		case Revision, plainVersion:
			return -1
		case branchVersion:
			return 0
		case semVersion:
			return 1
		}

	case semVersion:
		switch r.(type) {
		case Revision, branchVersion, plainVersion:
			return -1
		case semVersion:
			return 0
		}
	}
	panic("unknown version type")
}
227418
func (wr *Wrangler) GetVersion(ctx context.Context, tabletAlias *topodatapb.TabletAlias) (string, error) {
	tablet, err := wr.ts.GetTablet(ctx, tabletAlias)
	if err != nil {
		return "", err
	}

	version, err := getVersionFromTablet(tablet.Addr())
	if err != nil {
		return "", err
	}
	log.Infof("Tablet %v is running version '%v'", topoproto.TabletAliasString(tabletAlias), version)
	return version, err
}
1076420
func IsAllowedVersion(v unversioned.GroupVersion) bool {
	if len(envRequestedVersions) == 0 {
		return true
	}
	_, found := envRequestedVersions[v]
	return found
}
303698
func (c *FakeClient) GetVersion(opts ...VersionOption) (*rls.GetVersionResponse, error) {
	return &rls.GetVersionResponse{
		Version: &version.Version{
			SemVer: "1.2.3-fakeclient+testonly",
		},
	}, nil
}
836280
func (v VersionsFile) ResolveVersion(pkg, ver string) (common.Pin, error) {
	if common.ValidateInstanceID(ver, common.AnyHash) == nil {
		return common.Pin{PackageName: pkg, InstanceID: ver}, nil
	}
	if iid, ok := v[unresolvedVer{pkg, ver}]; ok {
		return common.Pin{PackageName: pkg, InstanceID: iid}, nil
	}
	return common.Pin{}, errors.Reason("not in the versions file").Err()
}
79761
func StatusReleaseVersion(version int32) StatusOption {
	return func(opts *options) {
		opts.statusReq.Version = version
	}
}
715959
func (client DefaultClient) CreateVersion(projectID, versionName string) (Version, error) {
	i, err := strconv.Atoi(projectID)
	if err != nil {
		return Version{}, err
	}

	data, err := json.Marshal(&Version{Name: versionName, Description: "Version " + versionName, ProjectID: i, Archived: false, Released: false})
	if err != nil {
		return Version{}, err
	}
	req, err := http.NewRequest("POST", fmt.Sprintf("%s/rest/api/2/version", client.baseURL), bytes.NewBuffer(data))
	if err != nil {
		return Version{}, err
	}
	req.Header.Set("Content-type", "application/json")
	req.SetBasicAuth(client.username, client.password)

	responseCode, data, err := client.consumeResponse(req)
	if err != nil {
		return Version{}, err
	}
	if responseCode != http.StatusCreated {
		logger.Printf("JIRA response: %s\n", string(data))
		return Version{}, fmt.Errorf("error creating project version.  Status code: %d.\n", responseCode)
	}

	var v Version
	if err := json.Unmarshal(data, &v); err != nil {
		return Version{}, err
	}
	return v, nil
}
177661
func (s *Scheme) IsVersionRegistered(version schema.GroupVersion) bool {
	for _, observedVersion := range s.observedVersions {
		if observedVersion == version {
			return true
		}
	}

	return false
}
50365
func MustParseEtcdVersionPair(s string) *EtcdVersionPair {
	pair, err := ParseEtcdVersionPair(s)
	if err != nil {
		panic(err)
	}
	return pair
}
411913
func RegisteredVersionsForGroup(group string) (ret []unversioned.GroupVersion) {
	for v := range registeredVersions {
		if v.Group == group {
			ret = append(ret, v)
		}
	}
	return
}
1257560
func (i *ProviderInstaller) platformCompatibleVersions(versions []*response.TerraformProviderVersion) []*response.TerraformProviderVersion {
	var v []*response.TerraformProviderVersion
	for _, version := range versions {
		if err := i.checkPlatformCompatibility(version); err == nil {
			v = append(v, version)
		}
	}
	return v
}