forked from redhat-developer/odo
/
url.go
43 lines (34 loc) · 1.43 KB
/
url.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package url
import (
"fmt"
ktemplates "k8s.io/kubernetes/pkg/kubectl/util/templates"
odoutil "github.com/openshift/odo/pkg/odo/util"
"github.com/spf13/cobra"
)
// RecommendedCommandName is the recommended url command name
const RecommendedCommandName = "url"
var (
urlShortDesc = `Expose component to the outside world`
urlLongDesc = ktemplates.LongDesc(`Expose component to the outside world.
The URLs that are generated using this command, can be used to access the deployed components from outside the cluster.`)
)
// NewCmdURL returns the top-level url command
func NewCmdURL(name, fullName string) *cobra.Command {
urlCreateCmd := NewCmdURLCreate(createRecommendedCommandName, odoutil.GetFullName(fullName, createRecommendedCommandName))
urlDeleteCmd := NewCmdURLDelete(deleteRecommendedCommandName, odoutil.GetFullName(fullName, deleteRecommendedCommandName))
urlListCmd := NewCmdURLList(listRecommendedCommandName, odoutil.GetFullName(fullName, listRecommendedCommandName))
urlCmd := &cobra.Command{
Use: name,
Short: urlShortDesc,
Long: urlLongDesc,
Example: fmt.Sprintf("%s\n\n%s\n\n%s",
urlCreateCmd.Example,
urlDeleteCmd.Example,
urlListCmd.Example),
}
// Add a defined annotation in order to appear in the help menu
urlCmd.Annotations = map[string]string{"command": "main"}
urlCmd.SetUsageTemplate(odoutil.CmdUsageTemplate)
urlCmd.AddCommand(urlCreateCmd, urlDeleteCmd, urlListCmd)
return urlCmd
}