Skip to content
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
7 changes: 7 additions & 0 deletions pkg/cmd/cli/cmd/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ $ %[1]s expose service nginx
// Create a route and specify your own label and route name
$ %[1]s expose service nginx -l name=myroute --name=fromdowntown

// Create a route and specify a hostname
$ %[1]s expose service nginx --hostname=www.example.com

// Expose a deployment configuration as a service and use the specified port
$ %[1]s expose dc ruby-hello-world --port=8080 --generator=services/v1`
)
Expand All @@ -42,6 +45,7 @@ func NewCmdExpose(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.C
err = kcmd.RunExpose(f.Factory, out, cmd, args)
cmdutil.CheckErr(err)
}
cmd.Flags().String("hostname", "", "Set a hostname for the new route")
return cmd
}

Expand All @@ -50,6 +54,9 @@ func NewCmdExpose(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.C
// to be exposed as routes.
func validate(cmd *cobra.Command, f *clientcmd.Factory, args []string) error {
if cmdutil.GetFlagString(cmd, "generator") != "route/v1" {
if len(cmdutil.GetFlagString(cmd, "hostname")) > 0 {
return fmt.Errorf("cannot use --hostname without generating a route")
}
return nil
}
namespace, err := f.DefaultNamespace()
Expand Down
2 changes: 2 additions & 0 deletions pkg/route/generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func (RouteGenerator) ParamNames() []kubectl.GeneratorParam {
{"labels", false},
{"default-name", true},
{"name", false},
{"hostname", false},
}
}

Expand Down Expand Up @@ -50,6 +51,7 @@ func (RouteGenerator) Generate(params map[string]string) (runtime.Object, error)
Name: name,
Labels: labels,
},
Host: params["hostname"],
ServiceName: params["default-name"],
}, nil
}
Expand Down