272d3a47ae
Co-authored-by: Chaim Lev-Ari <chaim.lev-ari@portainer.io> Co-authored-by: andres-portainer <91705312+andres-portainer@users.noreply.github.com>
22 lines
746 B
Go
22 lines
746 B
Go
package source
|
|
|
|
import (
|
|
portainer "github.com/portainer/portainer/api"
|
|
"github.com/portainer/portainer/api/dataservices"
|
|
)
|
|
|
|
type userContext = dataservices.SourceServiceUserContext
|
|
|
|
// Create a new admin context
|
|
//
|
|
// # THIS FUNCTION MUST NOT BE USED IN A USER-AWARE FLOW, ONLY FOR MIGRATIONS AND TESTS
|
|
//
|
|
// The only flows outside of migrations/test allowed to use this func is the datastore.Import/Export for sources
|
|
func InsecureNewAdminContext() *userContext {
|
|
return NewUserContext(&portainer.User{Role: portainer.AdministratorRole}, []portainer.TeamMembership{})
|
|
}
|
|
|
|
func NewUserContext(user *portainer.User, userMemberships []portainer.TeamMembership) *userContext {
|
|
return &userContext{User: user, UserMemberships: userMemberships}
|
|
}
|