Skip to content

Commit

Permalink
fix(service list): Use status.URL instead of status.Address in column
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Jul 9, 2019
1 parent f0a1667 commit 5b10a2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/kn/commands/service/human_readable_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func ServiceListHandlers(h hprinters.PrintHandler) {
kServiceColumnDefinitions := []metav1beta1.TableColumnDefinition{
{Name: "Name", Type: "string", Description: "Name of the Knative service."},
{Name: "Address", Type: "string", Description: "Address of the Knative service."},
{Name: "Url", Type: "string", Description: "URL of the Knative service."},
//{Name: "LastCreatedRevision", Type: "string", Description: "Name of last revision created."},
//{Name: "LastReadyRevision", Type: "string", Description: "Name of last ready revision."},
{Name: "Generation", Type: "integer", Description: "Sequence number of 'Generation' of the service that was last processed by the controller."},
Expand Down Expand Up @@ -57,7 +57,7 @@ func printKServiceList(kServiceList *servingv1alpha1.ServiceList, options hprint
// printKService populates the knative service table rows
func printKService(kService *servingv1alpha1.Service, options hprinters.PrintOptions) ([]metav1beta1.TableRow, error) {
name := kService.Name
url := kService.Status.RouteStatusFields.Address.URL
url := kService.Status.URL
//lastCreatedRevision := kService.Status.LatestCreatedRevisionName
//lastReadyRevision := kService.Status.LatestReadyRevisionName
generation := kService.Status.ObservedGeneration
Expand Down
13 changes: 6 additions & 7 deletions pkg/kn/commands/service/service_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"testing"

"github.com/knative/pkg/apis"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
duckv1beta1 "github.com/knative/pkg/apis/duck/v1beta1"
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
"gotest.tools/assert"
Expand Down Expand Up @@ -64,8 +63,8 @@ func TestListEmpty(t *testing.T) {
}

func TestServiceListDefaultOutput(t *testing.T) {
service1 := createMockServiceWithParams("foo", "foo.default.example.com", 1)
service2 := createMockServiceWithParams("bar", "bar.default.example.com", 2)
service1 := createMockServiceWithParams("foo", "http://foo.default.example.com", 1)
service2 := createMockServiceWithParams("bar", "http://bar.default.example.com", 2)
serviceList := &v1alpha1.ServiceList{Items: []v1alpha1.Service{*service1, *service2}}
action, output, err := fakeServiceList([]string{"service", "list"}, serviceList)
if err != nil {
Expand All @@ -76,13 +75,13 @@ func TestServiceListDefaultOutput(t *testing.T) {
} else if !action.Matches("list", "services") {
t.Errorf("Bad action %v", action)
}
assert.Check(t, util.ContainsAll(output[0], "NAME", "ADDRESS", "GENERATION", "AGE", "CONDITIONS", "READY", "REASON"))
assert.Check(t, util.ContainsAll(output[0], "NAME", "URL", "GENERATION", "AGE", "CONDITIONS", "READY", "REASON"))
assert.Check(t, util.ContainsAll(output[1], "foo", "foo.default.example.com", "1"))
assert.Check(t, util.ContainsAll(output[2], "bar", "bar.default.example.com", "2"))
}

func createMockServiceWithParams(name, domain string, generation int64) *v1alpha1.Service {
url, _ := apis.ParseURL(domain)
func createMockServiceWithParams(name, urlS string, generation int64) *v1alpha1.Service {
url, _ := apis.ParseURL(urlS)
service := &v1alpha1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
Expand All @@ -99,7 +98,7 @@ func createMockServiceWithParams(name, domain string, generation int64) *v1alpha
Status: duckv1beta1.Status{
ObservedGeneration: generation},
RouteStatusFields: v1alpha1.RouteStatusFields{
Address: &duckv1alpha1.Addressable{Addressable: duckv1beta1.Addressable{URL: url}},
URL: url,
},
},
}
Expand Down

0 comments on commit 5b10a2d

Please sign in to comment.