diff --git a/tools/pd-ctl/pdctl/command/config_command.go b/tools/pd-ctl/pdctl/command/config_command.go index 4efaae3fa13..a8e5af73638 100644 --- a/tools/pd-ctl/pdctl/command/config_command.go +++ b/tools/pd-ctl/pdctl/command/config_command.go @@ -17,6 +17,7 @@ package command import ( "bytes" "encoding/json" + "fmt" "net/http" "net/url" "os" @@ -33,19 +34,20 @@ import ( ) const ( - configPrefix = "pd/api/v1/config" - schedulePrefix = "pd/api/v1/config/schedule" - replicatePrefix = "pd/api/v1/config/replicate" - labelPropertyPrefix = "pd/api/v1/config/label-property" - clusterVersionPrefix = "pd/api/v1/config/cluster-version" - rulesPrefix = "pd/api/v1/config/rules" - rulesBatchPrefix = "pd/api/v1/config/rules/batch" - rulePrefix = "pd/api/v1/config/rule" - ruleGroupPrefix = "pd/api/v1/config/rule_group" - ruleGroupsPrefix = "pd/api/v1/config/rule_groups" - replicationModePrefix = "pd/api/v1/config/replication-mode" - ruleBundlePrefix = "pd/api/v1/config/placement-rule" - pdServerPrefix = "pd/api/v1/config/pd-server" + configPrefix = "pd/api/v1/config" + schedulePrefix = "pd/api/v1/config/schedule" + replicatePrefix = "pd/api/v1/config/replicate" + labelPropertyPrefix = "pd/api/v1/config/label-property" + clusterVersionPrefix = "pd/api/v1/config/cluster-version" + rulesPrefix = "pd/api/v1/config/rules" + rulesBatchPrefix = "pd/api/v1/config/rules/batch" + rulePrefix = "pd/api/v1/config/rule" + ruleGroupPrefix = "pd/api/v1/config/rule_group" + ruleGroupsPrefix = "pd/api/v1/config/rule_groups" + replicationModePrefix = "pd/api/v1/config/replication-mode" + ruleBundlePrefix = "pd/api/v1/config/placement-rule" + pdServerPrefix = "pd/api/v1/config/pd-server" + serviceMiddlewareConfigPrefix = "pd/api/v1/service-middleware/config" // flagFromAPIServer has no influence for pd mode, but it is useful for us to debug in api mode. flagFromAPIServer = "from_api_server" ) @@ -77,6 +79,7 @@ func NewShowConfigCommand() *cobra.Command { sc.AddCommand(NewShowClusterVersionCommand()) sc.AddCommand(newShowReplicationModeCommand()) sc.AddCommand(NewShowServerConfigCommand()) + sc.AddCommand(NewShowServiceMiddlewareConfigCommand()) sc.Flags().Bool(flagFromAPIServer, false, "read data from api server rather than micro service") return sc } @@ -151,6 +154,16 @@ func NewShowServerConfigCommand() *cobra.Command { } } +// NewShowReplicationConfigCommand return a show all subcommand of show subcommand +func NewShowServiceMiddlewareConfigCommand() *cobra.Command { + sc := &cobra.Command{ + Use: "service-middleware", + Short: "show service middleware config of PD", + Run: showServiceMiddlewareConfigCommandFunc, + } + return sc +} + // NewSetConfigCommand return a set subcommand of configCmd func NewSetConfigCommand() *cobra.Command { sc := &cobra.Command{ @@ -161,6 +174,7 @@ func NewSetConfigCommand() *cobra.Command { sc.AddCommand(NewSetLabelPropertyCommand()) sc.AddCommand(NewSetClusterVersionCommand()) sc.AddCommand(newSetReplicationModeCommand()) + sc.AddCommand(newSetServiceMiddlewareCommand()) return sc } @@ -192,6 +206,14 @@ func newSetReplicationModeCommand() *cobra.Command { } } +func newSetServiceMiddlewareCommand() *cobra.Command { + return &cobra.Command{ + Use: "service-middleware [ |