1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-10 16:25:22 +02:00

fix team create

This commit is contained in:
Prabhat Khera 2023-05-13 15:43:47 +12:00
parent 1e9250eccf
commit d60b187d6c
2 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,8 @@
package team package team
import ( import (
"fmt"
portainer "github.com/portainer/portainer/api" portainer "github.com/portainer/portainer/api"
) )
@ -30,15 +32,15 @@ func (service *Service) Team(ID portainer.TeamID) (*portainer.Team, error) {
// TeamByName returns a team by name. // TeamByName returns a team by name.
func (service *Service) TeamByName(name string) (*portainer.Team, error) { func (service *Service) TeamByName(name string) (*portainer.Team, error) {
var team *portainer.Team var team portainer.Team
db := service.connection.GetDB() db := service.connection.GetDB()
tx := db.First(team, `name = ?`, name) tx := db.First(&team, `name = ?`, name)
if tx.Error != nil { if tx.Error != nil {
return nil, tx.Error return nil, tx.Error
} }
return team, nil return &team, nil
} }
// Teams return an array containing all the teams. // Teams return an array containing all the teams.
@ -68,10 +70,13 @@ func (service *Service) UpdateTeam(ID portainer.TeamID, team *portainer.Team) er
// CreateTeam creates a new Team. // CreateTeam creates a new Team.
func (service *Service) Create(team *portainer.Team) error { func (service *Service) Create(team *portainer.Team) error {
db := service.connection.GetDB() db := service.connection.GetDB()
tx := db.Create(&team) tx := db.Create(&team)
if tx.Error != nil { if tx.Error != nil {
fmt.Println(tx.Error)
return tx.Error return tx.Error
} }
return nil return nil
} }

View file

@ -30,7 +30,7 @@ func (service *Service) User(ID portainer.UserID) (*portainer.User, error) {
// UserByUsername returns a user by username. // UserByUsername returns a user by username.
func (service *Service) UserByUsername(username string) (*portainer.User, error) { func (service *Service) UserByUsername(username string) (*portainer.User, error) {
u := portainer.User{} var u portainer.User
db := service.connection.GetDB() db := service.connection.GetDB()
tx := db.First(&u, `username = ?`, username) tx := db.First(&u, `username = ?`, username)