Skip to content

Commit

Permalink
update egctl mesh tenant command
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyingjie committed Apr 14, 2021
1 parent 345a687 commit d1246f2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
48 changes: 24 additions & 24 deletions cmd/client/command/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,41 +48,41 @@ const (
statusObjectURL = apiURL + "/status/objects/%s"
statusObjectsURL = apiURL + "/status/objects"

// MeshTenantPrefix is the mesh tenant prefix.
MeshTenantPrefix = apiURL + "/mesh/tenants"
// MeshTenantsURL is the mesh tenant prefix.
MeshTenantsURL = apiURL + "/mesh/tenants"

// MeshTenantPath is the mesh tenant path.
MeshTenantPath = apiURL + "/mesh/tenants/%s"
// MeshTenantURL is the mesh tenant path.
MeshTenantURL = apiURL + "/mesh/tenants/%s"

// MeshServicePrefix is mesh service prefix.
MeshServicePrefix = apiURL + "/mesh/services"
// MeshServicesURL is mesh service prefix.
MeshServicesURL = apiURL + "/mesh/services"

// MeshServicePath is the mesh service path.
MeshServicePath = apiURL + "/mesh/services/%s"
// MeshServiceURL is the mesh service path.
MeshServiceURL = apiURL + "/mesh/services/%s"

// MeshServiceCanaryPath is the mesh service canary path.
MeshServiceCanaryPath = apiURL + "/mesh/services/%s/canary"
// MeshServiceCanaryURL is the mesh service canary path.
MeshServiceCanaryURL = apiURL + "/mesh/services/%s/canary"

// MeshServiceResiliencePath is the mesh service resilience path.
MeshServiceResiliencePath = apiURL + "/mesh/services/%s/resilience"
// MeshServiceResilienceURL is the mesh service resilience path.
MeshServiceResilienceURL = apiURL + "/mesh/services/%s/resilience"

// MeshServiceLoadBalancePath is the mesh service load balance path.
MeshServiceLoadBalancePath = apiURL + "/mesh/services/%s/loadbalance"
// MeshServiceLoadBalanceURL is the mesh service load balance path.
MeshServiceLoadBalanceURL = apiURL + "/mesh/services/%s/loadbalance"

// MeshServiceOutputServerPath is the mesh service output server path.
MeshServiceOutputServerPath = apiURL + "/mesh/services/%s/outputserver"
// MeshServiceOutputServerURL is the mesh service output server path.
MeshServiceOutputServerURL = apiURL + "/mesh/services/%s/outputserver"

// MeshServiceTracingsPath is the mesh service tracings path.
MeshServiceTracingsPath = apiURL + "/mesh/services/%s/tracings"
// MeshServiceTracingsURL is the mesh service tracings path.
MeshServiceTracingsURL = apiURL + "/mesh/services/%s/tracings"

// MeshServiceMetricsPath is the mesh service metrics path.
MeshServiceMetricsPath = apiURL + "/mesh/services/%s/metrics"
// MeshServiceMetricsURL is the mesh service metrics path.
MeshServiceMetricsURL = apiURL + "/mesh/services/%s/metrics"

// MeshServiceInstancePrefix is the mesh service prefix.
MeshServiceInstancePrefix = apiURL + "/mesh/serviceinstances"
// MeshServiceInstancesURL is the mesh service prefix.
MeshServiceInstancesURL = apiURL + "/mesh/serviceinstances"

// MeshServiceInstancePath is the mesh service path.
MeshServiceInstancePath = apiURL + "/mesh/serviceinstances/%s/%s"
// MeshServiceInstanceURL is the mesh service path.
MeshServiceInstanceURL = apiURL + "/mesh/serviceinstances/%s/%s"
)

func makeURL(urlTemplate string, a ...interface{}) string {
Expand Down
10 changes: 5 additions & 5 deletions cmd/client/command/mesh_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func createServiceCmd() *cobra.Command {
Short: "Create an service from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServicePath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServicesURL), buff, cmd)
},
}

Expand All @@ -50,7 +50,7 @@ func updateServiceCmd() *cobra.Command {
Short: "Update an service from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServicePath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceURL, name), buff, cmd)
},
}

Expand All @@ -73,7 +73,7 @@ func deleteServiceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServicePath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceURL, args[0]), nil, cmd)
},
}

Expand All @@ -94,7 +94,7 @@ func getServiceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServicePath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceURL, args[0]), nil, cmd)
},
}

Expand All @@ -107,7 +107,7 @@ func listServicesCmd() *cobra.Command {
Short: "List all services",
Example: "egctl mesh service list",
Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServicePrefix), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServicesURL), nil, cmd)
},
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/client/command/mesh_service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func deleteServiceInstanceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceInstancePath, args[0], args[1]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceInstanceURL, args[0], args[1]), nil, cmd)
},
}

Expand All @@ -54,7 +54,7 @@ func getServiceInstanceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceInstancePath, args[0], args[1]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceInstanceURL, args[0], args[1]), nil, cmd)
},
}

Expand All @@ -67,7 +67,7 @@ func listServiceInstancesCmd() *cobra.Command {
Short: "List all service instances",
Example: "egctl mesh service instance list",
Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceInstancePrefix), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceInstancesURL), nil, cmd)
},
}

Expand Down
48 changes: 24 additions & 24 deletions cmd/client/command/mesh_service_observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func createServiceCanaryCmd() *cobra.Command {
Short: "Create an service canary from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceCanaryPath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceCanaryURL), buff, cmd)
},
}

Expand All @@ -43,7 +43,7 @@ func updateServiceCanaryCmd() *cobra.Command {
Short: "Update an service canary from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceCanaryPath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceCanaryURL, name), buff, cmd)
},
}

Expand All @@ -66,7 +66,7 @@ func deleteServiceCanaryCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceCanaryPath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceCanaryURL, args[0]), nil, cmd)
},
}

Expand All @@ -87,7 +87,7 @@ func getServiceCanaryCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceCanaryPath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceCanaryURL, args[0]), nil, cmd)
},
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func createServiceResilienceCmd() *cobra.Command {
Short: "Create an service resilience from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceResiliencePath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceResilienceURL), buff, cmd)
},
}

Expand All @@ -131,7 +131,7 @@ func updateServiceResilienceCmd() *cobra.Command {
Short: "Update an service resilience from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceResiliencePath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceResilienceURL, name), buff, cmd)
},
}

Expand All @@ -154,7 +154,7 @@ func deleteServiceResilienceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceResiliencePath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceResilienceURL, args[0]), nil, cmd)
},
}

Expand All @@ -175,7 +175,7 @@ func getServiceResilienceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceResiliencePath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceResilienceURL, args[0]), nil, cmd)
},
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func createServiceLoadbalanceCmd() *cobra.Command {
Short: "Create an service loadbalance from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceLoadBalancePath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceLoadBalanceURL), buff, cmd)
},
}

Expand All @@ -219,7 +219,7 @@ func updateServiceLoadbalanceCmd() *cobra.Command {
Short: "Update an service loadbalance from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceLoadBalancePath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceLoadBalanceURL, name), buff, cmd)
},
}

Expand All @@ -242,7 +242,7 @@ func deleteServiceLoadbalanceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceLoadBalancePath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceLoadBalanceURL, args[0]), nil, cmd)
},
}

Expand All @@ -263,7 +263,7 @@ func getServiceLoadbalanceCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceLoadBalancePath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceLoadBalanceURL, args[0]), nil, cmd)
},
}

Expand Down Expand Up @@ -291,7 +291,7 @@ func createServiceOutputserverCmd() *cobra.Command {
Short: "Create an service outputserver from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceOutputServerPath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceOutputServerURL), buff, cmd)
},
}

Expand All @@ -307,7 +307,7 @@ func updateServiceOutputserverCmd() *cobra.Command {
Short: "Update an service outputserver from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceOutputServerPath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceOutputServerURL, name), buff, cmd)
},
}

Expand All @@ -330,7 +330,7 @@ func deleteServiceOutputserverCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceOutputServerPath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceOutputServerURL, args[0]), nil, cmd)
},
}

Expand All @@ -351,7 +351,7 @@ func getServiceOutputserverCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceOutputServerPath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceOutputServerURL, args[0]), nil, cmd)
},
}

Expand Down Expand Up @@ -379,7 +379,7 @@ func createServiceTracingCmd() *cobra.Command {
Short: "Create an service tracings from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceTracingsPath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceTracingsURL), buff, cmd)
},
}

Expand All @@ -395,7 +395,7 @@ func updateServiceTracingCmd() *cobra.Command {
Short: "Update an service tracings from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceTracingsPath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceTracingsURL, name), buff, cmd)
},
}

Expand All @@ -418,7 +418,7 @@ func deleteServiceTracingCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceTracingsPath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceTracingsURL, args[0]), nil, cmd)
},
}

Expand All @@ -439,7 +439,7 @@ func getServiceTracingCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceTracingsPath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceTracingsURL, args[0]), nil, cmd)
},
}

Expand Down Expand Up @@ -467,7 +467,7 @@ func createServiceMetricCmd() *cobra.Command {
Short: "Create an service metrics from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceMetricsPath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshServiceMetricsURL), buff, cmd)
},
}

Expand All @@ -483,7 +483,7 @@ func updateServiceMetricCmd() *cobra.Command {
Short: "Update an service metrics from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceMetricsPath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshServiceMetricsURL, name), buff, cmd)
},
}

Expand All @@ -506,7 +506,7 @@ func deleteServiceMetricCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshServiceMetricsPath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshServiceMetricsURL, args[0]), nil, cmd)
},
}

Expand All @@ -527,7 +527,7 @@ func getServiceMetricCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshServiceMetricsPath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshServiceMetricsURL, args[0]), nil, cmd)
},
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/client/command/mesh_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func createTenantCmd() *cobra.Command {
Short: "Create an tenant from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, _ := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPost, makeURL(MeshTenantPath), buff, cmd)
handleRequest(http.MethodPost, makeURL(MeshTenantsURL), buff, cmd)
},
}

Expand All @@ -42,7 +42,7 @@ func updateTenantCmd() *cobra.Command {
Short: "Update an tenant from a yaml file or stdin",
Run: func(cmd *cobra.Command, args []string) {
buff, name := readFromFileOrStdin(specFile, cmd)
handleRequest(http.MethodPut, makeURL(MeshTenantPath, name), buff, cmd)
handleRequest(http.MethodPut, makeURL(MeshTenantURL, name), buff, cmd)
},
}

Expand All @@ -65,7 +65,7 @@ func deleteTenantCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodDelete, makeURL(MeshTenantPath, args[0]), nil, cmd)
handleRequest(http.MethodDelete, makeURL(MeshTenantURL, args[0]), nil, cmd)
},
}

Expand All @@ -86,7 +86,7 @@ func getTenantCmd() *cobra.Command {
},

Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshTenantPath, args[0]), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshTenantURL, args[0]), nil, cmd)
},
}

Expand All @@ -99,7 +99,7 @@ func listTenantsCmd() *cobra.Command {
Short: "List all tenants",
Example: "egctl mesh tenant list",
Run: func(cmd *cobra.Command, args []string) {
handleRequest(http.MethodGet, makeURL(MeshTenantPrefix), nil, cmd)
handleRequest(http.MethodGet, makeURL(MeshTenantsURL), nil, cmd)
},
}

Expand Down

0 comments on commit d1246f2

Please sign in to comment.