32 lines
532 B
Go
32 lines
532 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
type Deployment struct {
|
||
|
Name string
|
||
|
Path string
|
||
|
}
|
||
|
|
||
|
var deployments map[string]*Deployment = make(map[string]*Deployment)
|
||
|
|
||
|
func addDeployment(d *Deployment) error {
|
||
|
// check if exists
|
||
|
if _, ok := deployments[d.Name]; ok {
|
||
|
return errors.New("Deployment with that name already exists")
|
||
|
}
|
||
|
|
||
|
// check if dir exists
|
||
|
if _, err := os.Stat(d.Path); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
// add to conf / save
|
||
|
deployments[d.Name] = d
|
||
|
|
||
|
// TODO: register with runner, like conf would
|
||
|
|
||
|
return nil
|
||
|
}
|