Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Ingress info message for default path #388

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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