Inspect requirements by profile identity

This commit is contained in:
2026-10-09 00:38:01 +00:00
parent 74b91fae99
commit 6c5dec761c
4 changed files with 125 additions and 13 deletions

View File

@@ -15,16 +15,27 @@ type resolvedProfileSelection struct {
profile *domain.ExecutionProfile
}
type profileIdentityRepository interface {
GetProfileIdentity(context.Context, string) (string, error)
}
func (r *Runner) profileLookupID(profileID string) (string, error) {
if strings.TrimSpace(profileID) == "" {
return "", fmt.Errorf("%w: profile id is required", ErrInvalidRequest)
}
if r == nil || r.profiles == nil {
return "", fmt.Errorf("%w: profile repository is not configured", ErrProfileLoad)
}
return profileID, nil
}
func (r *Runner) resolveProfileSelection(
ctx context.Context,
profileID string,
) (*resolvedProfileSelection, error) {
lookupID := profileID
if strings.TrimSpace(lookupID) == "" {
return nil, fmt.Errorf("%w: profile id is required", ErrInvalidRequest)
}
if r == nil || r.profiles == nil {
return nil, fmt.Errorf("%w: profile repository is not configured", ErrProfileLoad)
lookupID, err := r.profileLookupID(profileID)
if err != nil {
return nil, err
}
selectedProfile, err := r.profiles.GetProfile(ctx, lookupID)
if err != nil {
@@ -45,6 +56,25 @@ func (r *Runner) resolveProfileSelection(
}, nil
}
func (r *Runner) resolveProfileIdentity(ctx context.Context, profileID string) (string, error) {
lookupID, err := r.profileLookupID(profileID)
if err != nil {
return "", err
}
if indexed, ok := r.profiles.(profileIdentityRepository); ok {
identity, err := indexed.GetProfileIdentity(ctx, lookupID)
if err != nil {
return "", fmt.Errorf("%w: %w", ErrProfileLoad, err)
}
return identity, nil
}
selection, err := r.resolveProfileSelection(ctx, lookupID)
if err != nil {
return "", err
}
return selection.id, nil
}
func normalizeResolvedExecutionTarget(target domain.ExecutionTarget) (domain.ExecutionTarget, error) {
endpoint, err := domain.NormalizeOpenAICompatibleBaseEndpoint(target.Endpoint)
if err != nil {