Skip to content

Commit

Permalink
Improve Ingress info message for default path (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed Jan 31, 2019
1 parent 0e5116e commit f0fa441
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pkg/await/extensions_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,18 @@ func expectedIngressPath(host, path, serviceName string) string {
}

// It is valid for a user not to specify either a host or path [1]. In this case, any traffic not
// matching another rule is routed to the specified Service for this rule. Print <default> to make
// this expectation clear to users.
// matching another rule is routed to the specified Service for this rule. Print
// `"" (default path)` to make this expectation clear to users.
//
// [1] https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#httpingresspath-v1beta1-extensions
if rulePath == "" {
rulePath = "<default>"
rulePath = `"" (default path)`
} else {
rulePath = fmt.Sprintf("%q", rulePath)
}

// [host][path] -> serviceName
return fmt.Sprintf("%q -> %q", rulePath, serviceName)
return fmt.Sprintf("%s -> %q", rulePath, serviceName)
}

func (iia *ingressInitAwaiter) processEndpointEvent(event watch.Event, settledCh chan<- struct{}) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/await/extensions_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func initializedIngressUnspecifiedPath(namespace, name, targetService string) *u
return obj
}

func Test_fqIngressPath(t *testing.T) {
func Test_expectedIngressPath(t *testing.T) {
type args struct {
host string
path string
Expand All @@ -348,7 +348,7 @@ func Test_fqIngressPath(t *testing.T) {
{name: "host + path", args: args{host: "foo", path: "/bar", serviceName: "baz"}, want: `"foo/bar" -> "baz"`},
{name: "host only", args: args{host: "foo", serviceName: "baz"}, want: `"foo" -> "baz"`},
{name: "path only", args: args{path: "/bar", serviceName: "baz"}, want: `"/bar" -> "baz"`},
{name: "empty", args: args{serviceName: "baz"}, want: `"<default>" -> "baz"`},
{name: "empty", args: args{serviceName: "baz"}, want: `"" (default path) -> "baz"`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit f0fa441

Please sign in to comment.