Skip to content

Commit

Permalink
Merge pull request #249 from jwessel/fix_host_inspect
Browse files Browse the repository at this point in the history
fix: host inspect causes db errors with later operations
  • Loading branch information
moul authored Mar 26, 2021
2 parents 7404704 + 3c32177 commit a5bade8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/bastion/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,14 @@ GLOBAL OPTIONS:
}

var hosts []*dbmodels.Host
db = db.Preload("Groups")
if myself.HasRole("admin") {
db = db.Preload("SSHKey")
}
if err := dbmodels.HostsByIdentifiers(db, c.Args()).Find(&hosts).Error; err != nil {
return err
if err := dbmodels.HostsByIdentifiers(db.Preload("Groups").Preload("SSHKey"), c.Args()).Find(&hosts).Error; err != nil {
return err
}
} else {
if err := dbmodels.HostsByIdentifiers(db.Preload("Groups"), c.Args()).Find(&hosts).Error; err != nil {
return err
}
}

if c.Bool("decrypt") {
Expand Down

0 comments on commit a5bade8

Please sign in to comment.