Files
threshold/internal/alias/repository_alias.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

29 lines
846 B
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package alias
import (
"context"
"fmt"
"github.com/hashicorp/boundary/internal/errors"
)
// lookupAliasByValue returns the Alias for the provided value. Returns nil, nil
// if no Alias is found for the provided value. No Options are currently supported
func (r *Repository) lookupAliasByValue(ctx context.Context, value string) (*Alias, error) {
const op = "alias.(Repository).LookupAliasByValue"
if value == "" {
return nil, errors.New(ctx, errors.InvalidParameter, op, "value is empty")
}
a := allocAlias()
if err := r.reader.LookupWhere(ctx, a, "value = $1", []any{value}); err != nil {
if errors.IsNotFoundError(err) {
return nil, nil
}
return nil, errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("failed for %q", value)))
}
return a, nil
}