func (cgs *credentialGraphSet) HeadCredential(pe *pathexp.PathExp, name string) (*envelope.Signed, error) {
	var head *envelope.Signed
	version := -1

	gpe, err := pe.WithInstance("*")
	if err != nil {
		return nil, err
	}

	graphs, ok := cgs.graphs[gpe.String()]
	if !ok {
		return nil, nil
	}

	sort.Sort(graphSorter(graphs))
	for _, graph := range graphs {
		creds := graph.GetCredentials()
		for _, cred := range creds {
			base, err := baseCredential(&cred)
			if err != nil {
				return nil, err
			}

			if base.PathExp.Equal(pe) && base.Name == name && base.CredentialVersion > version {
				env := cred
				head = &env
				version = base.CredentialVersion
			}
		}
	}

	return head, nil
}
// HeadCredential returns the most recent version of a Credential that shares
// the provided PathExp and Name
//
// A Head Credential need not be in the Head of the CredentialGraph.
HeadCredential returns the most recent version of a Credential that shares
the provided PathExp and Name

A Head Credential need not be in the Head of the CredentialGraph.
// HeadCredential returns the most recent version of a Credential that shares // the provided PathExp and Name // // A Head Credential need not be in the Head of the CredentialGraph .
func (cgs *credentialGraphSet) HeadCredential(pe *pathexp.PathExp, name string) (*envelope.Signed, error) {
	var head *envelope.Signed
	version := -1
	gpe, err := pe.WithInstance("*")
	if err != nil {
		return nil, err
	}
	graphs, ok := cgs.graphs[gpe.String()]
	if !ok {
		return nil, nil
	}
	sort.Sort(graphSorter(graphs))
	for _, graph := range graphs {
		creds := graph.GetCredentials()
		for _, cred := range creds {
			base, err := baseCredential(&cred)
			if err != nil {
				return nil, err
			}
			if base.PathExp.Equal(pe) && base.Name == name && base.CredentialVersion > version {
				env := cred
				head = &env
				version = base.CredentialVersion
			}
		}
	}
	return head, nil
}
func ( cgs * credentialGraphSet ) HeadCredential ( pe * pathexp . PathExp , name string ) ( * envelope . Signed , error ) { var head * envelope . Signed version := - 1 gpe , err := pe . WithInstance ( " " ) if err != nil { return nil , err } graphs , ok := cgs . graphs [ gpe . String ( ) ] if ! ok { return nil , nil } sort . Sort ( graphSorter ( graphs ) ) for _ , graph := range graphs { creds := graph . GetCredentials ( ) for _ , cred := range creds { base , err := baseCredential ( & cred ) if err != nil { return nil , err } if base . PathExp . Equal ( pe ) && base . Name == name && base . CredentialVersion > version { env := cred head = & env version = base . CredentialVersion } } } return head , nil }
HeadCredential returns the most recent version of a Credential that shares
the provided PathExp and Name
HeadCredential returns the most recent version of a Credential that shares the provided PathExp and Name