()
| 31 | ) |
| 32 | |
| 33 | func RegisterDomainCommand() *cobra.Command { |
| 34 | Domain := &cobra.Command{ |
| 35 | Use: "domain", |
| 36 | Short: "domain operation commands", |
| 37 | Run: func(cmd *cobra.Command, args []string) { |
| 38 | fmt.Printf("please run with 'list | create | update | delete | example | additional-resource'.\n") |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | var listOutput string |
| 43 | list := &cobra.Command{ |
| 44 | Use: "list [name]", |
| 45 | Short: "list domain info", |
| 46 | Example: "deepflow-ctl domain list deepflow-domain", |
| 47 | Run: func(cmd *cobra.Command, args []string) { |
| 48 | listDomain(cmd, args, listOutput) |
| 49 | }, |
| 50 | } |
| 51 | list.Flags().StringVarP(&listOutput, "output", "o", "", "output format") |
| 52 | |
| 53 | var createFilename string |
| 54 | create := &cobra.Command{ |
| 55 | Use: "create", |
| 56 | Short: "create domain", |
| 57 | Example: "deepflow-ctl domain create -f -", |
| 58 | Run: func(cmd *cobra.Command, args []string) { |
| 59 | createDomain(cmd, args, createFilename) |
| 60 | }, |
| 61 | } |
| 62 | create.Flags().StringVarP(&createFilename, "filename", "f", "", "create domain from file or stdin") |
| 63 | create.MarkFlagRequired("filename") |
| 64 | |
| 65 | var updateFilename string |
| 66 | update := &cobra.Command{ |
| 67 | Use: "update", |
| 68 | Short: "update domain", |
| 69 | Example: "deepflow-ctl domain update deepflow-domain -f k8s.yaml", |
| 70 | Run: func(cmd *cobra.Command, args []string) { |
| 71 | updateDomain(cmd, args, updateFilename) |
| 72 | }, |
| 73 | } |
| 74 | update.Flags().StringVarP(&updateFilename, "filename", "f", "", "update domain from file or stdin") |
| 75 | update.MarkFlagRequired("filename") |
| 76 | |
| 77 | delete := &cobra.Command{ |
| 78 | Use: "delete [name]", |
| 79 | Short: "delete domain", |
| 80 | Example: "deepflow-ctl domain delete deepflow-domain", |
| 81 | Run: func(cmd *cobra.Command, args []string) { |
| 82 | deleteDomain(cmd, args) |
| 83 | }, |
| 84 | } |
| 85 | |
| 86 | exampleCmd := &cobra.Command{ |
| 87 | Use: "example domain_type", |
| 88 | Short: "example domain create yaml", |
| 89 | Long: "supported types: " + strings.Trim(fmt.Sprint(common.DomainTypes), "[]"), |
| 90 | Example: "deepflow-ctl domain example agent_sync \nsupport example type: aliyun | aws | baidu_bce | filereader | agent_sync | \nhuawei | kubernetes | qingcloud | tencent | volcengine", |
no test coverage detected