parent
0f95aecc3f
commit
003ae042fb
|
|
@ -112,8 +112,7 @@ func (c *CronJob) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, erro
|
||||||
|
|
||||||
// ToggleSuspend toggles suspend/resume on a CronJob.
|
// ToggleSuspend toggles suspend/resume on a CronJob.
|
||||||
func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
||||||
ns, _ := client.Namespaced(path)
|
ns, n := client.Namespaced(path)
|
||||||
|
|
||||||
auth, err := c.Client().CanI(cronJobGVR, ns, []string{client.GetVerb, client.UpdateVerb})
|
auth, err := c.Client().CanI(cronJobGVR, ns, []string{client.GetVerb, client.UpdateVerb})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -122,20 +121,15 @@ func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
||||||
return fmt.Errorf("user is not authorized to run jobs")
|
return fmt.Errorf("user is not authorized to run jobs")
|
||||||
}
|
}
|
||||||
|
|
||||||
o, err := c.Get(ctx, path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
var cj batchv1.CronJob
|
|
||||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, &cj)
|
|
||||||
if err != nil {
|
|
||||||
return errors.New("expecting CronJob resource")
|
|
||||||
}
|
|
||||||
|
|
||||||
dial, err := c.Client().Dial()
|
dial, err := c.Client().Dial()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
cj, err := dial.BatchV1beta1().CronJobs(ns).Get(ctx, n, metav1.GetOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if cj.Spec.Suspend != nil {
|
if cj.Spec.Suspend != nil {
|
||||||
current := !*cj.Spec.Suspend
|
current := !*cj.Spec.Suspend
|
||||||
cj.Spec.Suspend = ¤t
|
cj.Spec.Suspend = ¤t
|
||||||
|
|
@ -143,7 +137,7 @@ func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
|
||||||
true := true
|
true := true
|
||||||
cj.Spec.Suspend = &true
|
cj.Spec.Suspend = &true
|
||||||
}
|
}
|
||||||
_, err = dial.BatchV1().CronJobs(ns).Update(ctx, &cj, metav1.UpdateOptions{})
|
_, err = dial.BatchV1beta1().CronJobs(ns).Update(ctx, cj, metav1.UpdateOptions{})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ func (c *ClusterInfo) fetchK9sLatestRev() string {
|
||||||
|
|
||||||
latestRev, err := fetchLatestRev()
|
latestRev, err := fetchLatestRev()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msgf("k9s latest rev fetch failed")
|
log.Warn().Msgf("k9s latest rev fetch failed %s", err)
|
||||||
} else {
|
} else {
|
||||||
c.cache.Add(k9sLatestRevKey, latestRev, cacheExpiry)
|
c.cache.Add(k9sLatestRevKey, latestRev, cacheExpiry)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func (s *ScaleExtender) showScaleDialog(path string) {
|
||||||
s.App().Content.ShowPage(scaleDialogKey)
|
s.App().Content.ShowPage(scaleDialogKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ScaleExtender) valueOf(col string, rowIndex int) (string, error) {
|
func (s *ScaleExtender) valueOf(col string) (string, error) {
|
||||||
colIdx, ok := s.GetTable().HeaderIndex(col)
|
colIdx, ok := s.GetTable().HeaderIndex(col)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("no column index for %s", col)
|
return "", fmt.Errorf("no column index for %s", col)
|
||||||
|
|
@ -74,7 +74,7 @@ func (s *ScaleExtender) valueOf(col string, rowIndex int) (string, error) {
|
||||||
func (s *ScaleExtender) makeScaleForm(sel string) (*tview.Form, error) {
|
func (s *ScaleExtender) makeScaleForm(sel string) (*tview.Form, error) {
|
||||||
f := s.makeStyledForm()
|
f := s.makeStyledForm()
|
||||||
|
|
||||||
replicas, err := s.valueOf("READY", s.GetTable().GetSelectedRowIndex()-1)
|
replicas, err := s.valueOf("READY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue