示例#1
0
文件: client.go 项目: tob1k/deisctl
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
}
示例#2
0
文件: client.go 项目: tob1k/deisctl
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
}