Beispiel #1
0
// Create a cluster
func (carina *CreateCommand) Create(pc *kingpin.ParseContext) (err error) {
	return carina.clusterApplyWait(func(clusterName string) (*libcarina.Cluster, error) {
		if carina.Nodes < 1 {
			return nil, errors.New("nodes must be >= 1")
		}
		nodes := libcarina.Number(carina.Nodes)

		c := libcarina.Cluster{
			ClusterName: carina.ClusterName,
			Nodes:       nodes,
			AutoScale:   carina.AutoScale,
		}
		return carina.ClusterClient.Create(c)
	})
}
Beispiel #2
0
func newCluster() {

	clusterNameLabel := ui.NewLabel("Cluster Name:")
	clusterNameTextField := ui.NewTextField()
	clusterNodeCountLabel := ui.NewLabel("Number of Nodes:")
	clusterNodeCountTextField := ui.NewTextField()
	clusterNodeCountTextField.SetText("1")
	autoscaleLabel := ui.NewLabel("Autoscale:")
	autoscaleCheckbox := ui.NewCheckbox("")
	newClusterBtn := ui.NewButton("Create Cluster")
	cancelBtn := ui.NewButton("Cancel")

	newClusterGrid := ui.NewSimpleGrid(2,
		clusterNameLabel, clusterNameTextField,
		clusterNodeCountLabel, clusterNodeCountTextField,
		autoscaleLabel, autoscaleCheckbox,
		newClusterBtn, cancelBtn)

	newClusterGrid.SetPadded(true)

	newClusterGrp := ui.NewGroup("", newClusterGrid)
	newClusterGrp.SetMargined(true)

	newWin := ui.NewWindow("New Cluster", 400, 300, newClusterGrp)
	newWin.SetMargined(true)
	newWin.Show()

	newClusterBtn.OnClicked(func() {
		var c libcarina.Cluster
		c.ClusterName = clusterNameTextField.Text()
		n, _ := strconv.Atoi(clusterNodeCountTextField.Text())
		c.Nodes = libcarina.Number(n)
		c.AutoScale = autoscaleCheckbox.Checked()
		carinaClient.Create(c)
		time.Sleep(250 * time.Millisecond)
		newWin.Close()
	})

	cancelBtn.OnClicked(func() {
		newWin.Close()
	})

	newWin.OnClosing(func() bool {
		newWin.Close()
		return true
	})

}