Semaphore/api/tasks/inventory.go
tom whiston 17fa7bb407 add gometalinter to tools and run it in circle.
extract some error checking and logging in places where linting needed or errors not checked
2018-04-05 21:24:19 +00:00

33 lines
616 B
Go

package tasks
import (
"io/ioutil"
"strconv"
"github.com/ansible-semaphore/semaphore/util"
)
func (t *task) installInventory() error {
if t.inventory.SSHKeyID != nil {
// write inventory key
err := t.installKey(t.inventory.SSHKey)
if err != nil {
return err
}
}
switch t.inventory.Type {
case "static":
return t.installStaticInventory()
}
return nil
}
func (t *task) installStaticInventory() error {
t.log("installing static inventory")
// create inventory file
return ioutil.WriteFile(util.Config.TmpPath+"/inventory_"+strconv.Itoa(t.task.ID), []byte(t.inventory.Inventory), 0664)
}