MCPcopy
hub / github.com/kopia/kopia / GetUserProfile

Function GetUserProfile

internal/user/user_manager.go:80–99  ·  view source on GitHub ↗

GetUserProfile returns the user profile with a given username. Returns ErrUserNotFound when the user does not exist.

(ctx context.Context, r repo.Repository, username string)

Source from the content-addressed store, hash-verified

78// GetUserProfile returns the user profile with a given username.
79// Returns ErrUserNotFound when the user does not exist.
80func GetUserProfile(ctx context.Context, r repo.Repository, username string) (*Profile, error) {
81 manifests, err := r.FindManifests(ctx, map[string]string{
82 manifest.TypeLabelKey: ManifestType,
83 UsernameAtHostnameLabel: username,
84 })
85 if err != nil {
86 return nil, errors.Wrap(err, "error looking for user profile")
87 }
88
89 if len(manifests) == 0 {
90 return nil, errors.Wrap(ErrUserNotFound, username)
91 }
92
93 p := &Profile{}
94 if _, err := r.GetManifest(ctx, manifest.PickLatestID(manifests), p); err != nil {
95 return nil, errors.Wrap(err, "error loading user profile")
96 }
97
98 return p, nil
99}
100
101// GetNewProfile returns a profile for a new user with the given username.
102// Returns ErrUserAlreadyExists when the user already exists.

Callers 3

runMethod · 0.92
TestUserManagerFunction · 0.92

Calls 3

PickLatestIDFunction · 0.92
FindManifestsMethod · 0.65
GetManifestMethod · 0.65

Tested by 1

TestUserManagerFunction · 0.74