Fernand Galiana 2021-07-01 08:12:09 -06:00 committed by GitHub
parent 0f95aecc3f
commit 003ae042fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 16 deletions

View File

@ -112,8 +112,7 @@ func (c *CronJob) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, erro
// ToggleSuspend toggles suspend/resume on a CronJob.
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})
if err != nil {
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")
}
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()
if err != nil {
return err
}
cj, err := dial.BatchV1beta1().CronJobs(ns).Get(ctx, n, metav1.GetOptions{})
if err != nil {
return err
}
if cj.Spec.Suspend != nil {
current := !*cj.Spec.Suspend
cj.Spec.Suspend = &current
@ -143,7 +137,7 @@ func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error {
true := 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
}

View File

@ -102,7 +102,7 @@ func (c *ClusterInfo) fetchK9sLatestRev() string {
latestRev, err := fetchLatestRev()
if err != nil {
log.Warn().Err(err).Msgf("k9s latest rev fetch failed")
log.Warn().Msgf("k9s latest rev fetch failed %s", err)
} else {
c.cache.Add(k9sLatestRevKey, latestRev, cacheExpiry)
}

View File

@ -63,7 +63,7 @@ func (s *ScaleExtender) showScaleDialog(path string) {
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)
if !ok {
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) {
f := s.makeStyledForm()
replicas, err := s.valueOf("READY", s.GetTable().GetSelectedRowIndex()-1)
replicas, err := s.valueOf("READY")
if err != nil {
return nil, err
}