github.com/henvic/wedeploycli@v1.7.6-0.20200319005353-3630f582f284/command/domain/add/add.go (about) 1 package add 2 3 import ( 4 "context" 5 6 "github.com/henvic/wedeploycli/cmdflagsfromhost" 7 "github.com/henvic/wedeploycli/command/domain/internal/commands" 8 "github.com/henvic/wedeploycli/command/internal/we" 9 "github.com/henvic/wedeploycli/services" 10 "github.com/spf13/cobra" 11 ) 12 13 // Cmd for adding a domain 14 var Cmd = &cobra.Command{ 15 Use: "add", 16 Aliases: []string{"set"}, 17 Short: "Add custom domain to a given service", 18 Example: " lcp domain add example.com", 19 PreRunE: preRun, 20 RunE: run, 21 } 22 23 var setupHost = cmdflagsfromhost.SetupHost{ 24 Pattern: cmdflagsfromhost.FullHostPattern, 25 26 Requires: cmdflagsfromhost.Requires{ 27 Auth: true, 28 Project: true, 29 Service: true, 30 }, 31 32 PromptMissingService: true, 33 } 34 35 func init() { 36 setupHost.Init(Cmd) 37 } 38 39 func preRun(cmd *cobra.Command, args []string) error { 40 return setupHost.Process(context.Background(), we.Context()) 41 } 42 43 func run(cmd *cobra.Command, args []string) error { 44 var c = commands.Command{ 45 SetupHost: setupHost, 46 ServicesClient: services.New(we.Context()), 47 } 48 49 return c.Add(context.Background(), args) 50 }