github.com/technosophos/deis@v1.7.1-0.20150915173815-f9005256004b/deisctl/backend/fleet/fleet.go (about) 1 package fleet 2 3 import ( 4 "io" 5 "os" 6 "path" 7 "text/tabwriter" 8 9 "github.com/deis/deis/deisctl/config" 10 11 "github.com/coreos/fleet/client" 12 "github.com/coreos/fleet/machine" 13 ) 14 15 // FleetClient used to wrap Fleet API calls 16 type FleetClient struct { 17 Fleet client.API 18 configBackend config.Backend 19 20 // used to cache MachineStates 21 machineStates map[string]*machine.MachineState 22 23 templatePaths []string 24 runner commandRunner 25 out *tabwriter.Writer 26 errWriter io.Writer 27 } 28 29 // NewClient returns a client used to communicate with Fleet 30 // using the Registry API 31 func NewClient(cb config.Backend) (*FleetClient, error) { 32 client, err := getRegistryClient() 33 if err != nil { 34 return nil, err 35 } 36 37 // path hierarchy for finding systemd service templates 38 templatePaths := []string{ 39 os.Getenv("DEISCTL_UNITS"), 40 path.Join(os.Getenv("HOME"), ".deis", "units"), 41 "/var/lib/deis/units", 42 } 43 44 out := new(tabwriter.Writer) 45 out.Init(os.Stdout, 0, 8, 1, '\t', 0) 46 47 return &FleetClient{Fleet: client, configBackend: cb, templatePaths: templatePaths, runner: sshCommandRunner{}, 48 out: out, errWriter: os.Stderr}, nil 49 }