// WithUser returns new context with given user
325409
func WithUser(parent context.Context, user User) context.Context {
	return context.WithValue(parent, userKey, user)
}
751722
func (p *OAuth) User(ctx echo.Context) (u goth.User) {
	u, _ = ctx.Get(p.Config.ContextKey).(goth.User)
	return u
}
445522
func SetUser(ctx context.Context, user string) context.Context {
	return context.WithValue(ctx, UserIdentityKey, user)
}
237901
func hasUserContext(ctx context.Context) (*chronograf.User, bool) {
	// prevents panic in case of nil context
	if ctx == nil {
		return nil, false
	}
	u, ok := ctx.Value(UserContextKey).(*chronograf.User)
	// should never happen
	if !ok {
		return nil, false
	}
	if u == nil {
		return nil, false
	}
	return u, true
}
731887
func (r *Request) WithContext(ctx context.Context) *Request {
	r.Request = r.Request.WithContext(ctx)
	return r
}
81220
func (call *LinkUserRichMenuCall) WithContext(ctx context.Context) *LinkUserRichMenuCall {
	call.ctx = ctx
	return call
}
809232
func (s *AdminDisableProviderForUserInput) SetUser(v *ProviderUserIdentifierType) *AdminDisableProviderForUserInput {
	s.User = v
	return s
}
546670
func (o *CreateOAuth2ClientParams) WithContext(ctx context.Context) *CreateOAuth2ClientParams {
	o.SetContext(ctx)
	return o
}
271750
func WithUserMessage(e error, msg string) Error {
	if e == nil {
		return nil
	}
	return WrapSkipping(e, 1).WithUserMessage(msg)
}
98669
func (call *GetUserRichMenuCall) WithContext(ctx context.Context) *GetUserRichMenuCall {
	call.ctx = ctx
	return call
}
747243
func (o *IntrospectOAuth2TokenParams) WithContext(ctx context.Context) *IntrospectOAuth2TokenParams {
	o.SetContext(ctx)
	return o
}
233933
func (c *CloudPersister) AddUser(b *models.User) (*models.User, error) {
	ctx := context.Background()
	k := datastore.NewIncompleteKey(ctx, "User", nil)
	k, err := c.DatastoreClient().Put(ctx, k, b)
	if err != nil {
		return nil, fmt.Errorf("datastoredb: could not put User: %v", err)
	}
	b.ID = k.ID()
	return b, nil
}
929874
func (o *DeleteOAuth2ClientParams) WithContext(ctx context.Context) *DeleteOAuth2ClientParams {
	o.SetContext(ctx)
	return o
}
981177
func (s *VirtualMFADevice) SetUser(v *User) *VirtualMFADevice {
	s.User = v
	return s
}
479573
func WithUser(userstr string) SpecOpts {
	return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
		setProcess(s)
		parts := strings.Split(userstr, ":")
		switch len(parts) {
		case 1:
			v, err := strconv.Atoi(parts[0])
			if err != nil {
				// if we cannot parse as a uint they try to see if it is a username
				return WithUsername(userstr)(ctx, client, c, s)
			}
			return WithUserID(uint32(v))(ctx, client, c, s)
		case 2:
			var (
				username  string
				groupname string
			)
			var uid, gid uint32
			v, err := strconv.Atoi(parts[0])
			if err != nil {
				username = parts[0]
			} else {
				uid = uint32(v)
			}
			if v, err = strconv.Atoi(parts[1]); err != nil {
				groupname = parts[1]
			} else {
				gid = uint32(v)
			}
			if username == "" && groupname == "" {
				s.Process.User.UID, s.Process.User.GID = uid, gid
				return nil
			}
			f := func(root string) error {
				if username != "" {
					user, err := getUserFromPath(root, func(u user.User) bool {
						return u.Name == username
					})
					if err != nil {
						return err
					}
					uid = uint32(user.Uid)
				}
				if groupname != "" {
					gid, err = getGIDFromPath(root, func(g user.Group) bool {
						return g.Name == groupname
					})
					if err != nil {
						return err
					}
				}
				s.Process.User.UID, s.Process.User.GID = uid, gid
				return nil
			}
			if c.Snapshotter == "" && c.SnapshotKey == "" {
				if !isRootfsAbs(s.Root.Path) {
					return errors.New("rootfs absolute path is required")
				}
				return f(s.Root.Path)
			}
			if c.Snapshotter == "" {
				return errors.New("no snapshotter set for container")
			}
			if c.SnapshotKey == "" {
				return errors.New("rootfs snapshot not created for container")
			}
			snapshotter := client.SnapshotService(c.Snapshotter)
			mounts, err := snapshotter.Mounts(ctx, c.SnapshotKey)
			if err != nil {
				return err
			}
			return mount.WithTempMount(ctx, mounts, f)
		default:
			return fmt.Errorf("invalid USER value %s", userstr)
		}
	}
}
408670
func (_m *FacadeInterface) AddUser(ctx datastore.Context, newUser user.User) error {
	ret := _m.Called(ctx, newUser)

	var r0 error
	if rf, ok := ret.Get(0).(func(datastore.Context, user.User) error); ok {
		r0 = rf(ctx, newUser)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1000844
func (o *GetIdentityEndpointsParams) WithContext(ctx context.Context) *GetIdentityEndpointsParams {
	o.SetContext(ctx)
	return o
}