2014-05-10 07:36:26 +04:00
|
|
|
package initialize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/coreos/coreos-cloudinit/system"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FleetEnvironment map[string]string
|
|
|
|
|
|
|
|
func (fe FleetEnvironment) String() (out string) {
|
|
|
|
norm := normalizeSvcEnv(fe)
|
|
|
|
out += "[Service]\n"
|
|
|
|
|
|
|
|
for key, val := range norm {
|
|
|
|
out += fmt.Sprintf("Environment=\"FLEET_%s=%s\"\n", key, val)
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-06-06 03:12:40 +04:00
|
|
|
// Units generates a Unit file drop-in for fleet, if any fleet options were
|
2014-05-10 07:36:26 +04:00
|
|
|
// configured in cloud-config
|
2014-06-06 03:12:40 +04:00
|
|
|
func (fe FleetEnvironment) Units(root string) ([]system.Unit, error) {
|
2014-05-10 07:36:26 +04:00
|
|
|
if len(fe) < 1 {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2014-06-06 03:12:40 +04:00
|
|
|
fleet := system.Unit{
|
2014-05-10 07:36:26 +04:00
|
|
|
Name: "fleet.service",
|
|
|
|
Runtime: true,
|
|
|
|
DropIn: true,
|
|
|
|
Content: fe.String(),
|
2014-06-06 03:12:40 +04:00
|
|
|
}
|
|
|
|
return []system.Unit{fleet}, nil
|
2014-05-10 07:36:26 +04:00
|
|
|
}
|