func (c *Client) Update() (err error) { deis, _ := fleet.NewClient() localServices := deis.GetLocaljobs() fmt.Printf("local services: %v\n", localServices) if localServices.Len() == 0 { fmt.Println("no local services") } for _, service := range localServices { if strings.HasSuffix(service, "-data.service") { continue } localService := strings.Split(strings.Split(service, "-")[1], ".service")[0] fmt.Printf("destroying %v\n", localService) err := deis.Destroy([]string{localService}) if err != nil { return err } fmt.Printf("re-creating %v\n", localService) err = deis.Create([]string{localService}) if err != nil { return err } fmt.Printf("starting %v\n", localService) err = deis.Start([]string{localService}) if err != nil { return err } } return nil }
func NewClient(requestedBackend string) (*Client, error) { var backend backend.Backend if requestedBackend == "" { requestedBackend = "fleet" } switch requestedBackend { case "fleet": b, err := fleet.NewClient() if err != nil { return nil, err } backend = b default: return nil, errors.New("invalid backend") } return &Client{Backend: backend}, nil }