mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-25 06:15:56 +01:00
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package bolt
|
|
|
|
import (
|
|
"github.com/ansible-semaphore/semaphore/db"
|
|
)
|
|
|
|
|
|
func (d *BoltDb) GetInventory(projectID int, inventoryID int) (inventory db.Inventory, err error) {
|
|
err = d.getObject(projectID, db.InventoryProps, intObjectID(inventoryID), &inventory)
|
|
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if inventory.KeyID != nil {
|
|
inventory.Key, err = d.GetAccessKey(projectID, *inventory.KeyID)
|
|
if err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
if inventory.SSHKeyID != nil {
|
|
inventory.SSHKey, err = d.GetAccessKey(projectID, *inventory.SSHKeyID)
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (d *BoltDb) GetInventories(projectID int, params db.RetrieveQueryParams) (inventories []db.Inventory, err error) {
|
|
err = d.getObjects(projectID, db.InventoryProps, params, nil, &inventories)
|
|
return
|
|
}
|
|
|
|
func (d *BoltDb) DeleteInventory(projectID int, inventoryID int) error {
|
|
|
|
return d.deleteObject(projectID, db.InventoryProps, intObjectID(inventoryID))
|
|
}
|
|
|
|
func (d *BoltDb) DeleteInventorySoft(projectID int, inventoryID int) error {
|
|
return d.deleteObjectSoft(projectID, db.InventoryProps, intObjectID(inventoryID))
|
|
}
|
|
|
|
func (d *BoltDb) UpdateInventory(inventory db.Inventory) error {
|
|
return d.updateObject(inventory.ProjectID, db.InventoryProps, inventory)
|
|
}
|
|
|
|
func (d *BoltDb) CreateInventory(inventory db.Inventory) (db.Inventory, error) {
|
|
newInventory, err := d.createObject(inventory.ProjectID, db.InventoryProps, inventory)
|
|
return newInventory.(db.Inventory), err
|
|
}
|
|
|
|
|
|
|