Skip to content

Commit

Permalink
rollback labels and valid field and add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wjiec committed Oct 19, 2023
1 parent 724cb20 commit cbd0591
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions internal/render/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import (
"strings"
"time"

"github.com/derailed/k9s/internal/client"
"github.com/derailed/tview"
runewidth "github.com/mattn/go-runewidth"
"github.com/rs/zerolog/log"
"golang.org/x/text/language"
"golang.org/x/text/message"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/duration"

"github.com/derailed/k9s/internal/client"
)

func runesToNum(rr []rune) int64 {
Expand Down
7 changes: 5 additions & 2 deletions internal/render/sc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package render
import (
"fmt"

"github.com/derailed/k9s/internal/client"
storagev1 "k8s.io/api/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubectl/pkg/util/storage"

"github.com/derailed/k9s/internal/client"
)

// StorageClass renders a K8s StorageClass to screen.
Expand All @@ -25,6 +24,8 @@ func (StorageClass) Header(ns string) Header {
HeaderColumn{Name: "RECLAIMPOLICY"},
HeaderColumn{Name: "VOLUMEBINDINGMODE"},
HeaderColumn{Name: "ALLOWVOLUMEEXPANSION"},
HeaderColumn{Name: "LABELS", Wide: true},
HeaderColumn{Name: "VALID", Wide: true},
HeaderColumn{Name: "AGE", Time: true},
}
}
Expand All @@ -48,6 +49,8 @@ func (s StorageClass) Render(o interface{}, ns string, r *Row) error {
strPtrToStr((*string)(sc.ReclaimPolicy)),
strPtrToStr((*string)(sc.VolumeBindingMode)),
boolPtrToStr(sc.AllowVolumeExpansion),
mapToStr(sc.Labels),
"",
toAge(sc.GetCreationTimestamp()),
}

Expand Down
5 changes: 2 additions & 3 deletions internal/render/sc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package render_test
import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/derailed/k9s/internal/render"
"github.com/stretchr/testify/assert"
)

func TestStorageClassRender(t *testing.T) {
Expand All @@ -14,5 +13,5 @@ func TestStorageClassRender(t *testing.T) {

assert.NoError(t, c.Render(load(t, "sc"), "", &r))
assert.Equal(t, "-/standard", r.ID)
assert.Equal(t, render.Fields{"standard (default)", "kubernetes.io/gce-pd"}, r.Fields[:2])
assert.Equal(t, render.Fields{"standard (default)", "kubernetes.io/gce-pd", "Delete", "Immediate", "true"}, r.Fields[:5])
}
3 changes: 2 additions & 1 deletion internal/render/testdata/sc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
},
"provisioner": "kubernetes.io/gce-pd",
"reclaimPolicy": "Delete",
"volumeBindingMode": "Immediate"
"volumeBindingMode": "Immediate",
"allowVolumeExpansion": true
}

0 comments on commit cbd0591

Please sign in to comment.