Instance-namespace utility endpoints.

This commit is contained in:
2025-10-14 21:04:40 +00:00
parent 8d19fbd549
commit 393306de12
3 changed files with 24 additions and 11 deletions

View File

@@ -26,7 +26,7 @@ var operationGetCmd = &cobra.Command{
return err return err
} }
resp, err := apiClient.Get(fmt.Sprintf("/api/v1/operations/%s?instance=%s", args[0], inst)) resp, err := apiClient.Get(fmt.Sprintf("/api/v1/instances/%s/operations/%s", inst, args[0]))
if err != nil { if err != nil {
return err return err
} }
@@ -43,7 +43,12 @@ var operationListCmd = &cobra.Command{
Use: "list", Use: "list",
Short: "List operations", Short: "List operations",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
resp, err := apiClient.Get("/api/v1/operations") inst, err := getInstanceName()
if err != nil {
return err
}
resp, err := apiClient.Get(fmt.Sprintf("/api/v1/instances/%s/operations", inst))
if err != nil { if err != nil {
return err return err
} }
@@ -90,7 +95,7 @@ func streamOperationOutput(opID string) error {
} }
// Connect to SSE stream // Connect to SSE stream
url := fmt.Sprintf("%s/api/v1/operations/%s/stream?instance=%s", baseURL, opID, inst) url := fmt.Sprintf("%s/api/v1/instances/%s/operations/%s/stream", baseURL, inst, opID)
client := sse.NewClient(url) client := sse.NewClient(url)
events := make(chan *sse.Event) events := make(chan *sse.Event)
@@ -105,7 +110,7 @@ func streamOperationOutput(opID string) error {
ticker := time.NewTicker(500 * time.Millisecond) ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()
for range ticker.C { for range ticker.C {
resp, err := apiClient.Get(fmt.Sprintf("/api/v1/operations/%s?instance=%s", opID, inst)) resp, err := apiClient.Get(fmt.Sprintf("/api/v1/instances/%s/operations/%s", inst, opID))
if err == nil { if err == nil {
status := resp.GetString("status") status := resp.GetString("status")
if status == "completed" || status == "failed" { if status == "completed" || status == "failed" {

View File

@@ -72,7 +72,12 @@ var nodeIPCmd = &cobra.Command{
Use: "node-ip", Use: "node-ip",
Short: "Get control plane IP", Short: "Get control plane IP",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
resp, err := apiClient.Get("/api/v1/utilities/controlplane/ip") inst, err := getInstanceName()
if err != nil {
return err
}
resp, err := apiClient.Get(fmt.Sprintf("/api/v1/instances/%s/utilities/controlplane/ip", inst))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -24,13 +24,16 @@ var versionCmd = &cobra.Command{
// If connected to daemon, show cluster versions // If connected to daemon, show cluster versions
if apiClient != nil { if apiClient != nil {
resp, err := apiClient.Get("/api/v1/utilities/version") inst, err := getInstanceName()
if err == nil { if err == nil {
if k8s, ok := resp.Data["kubernetes"].(string); ok { resp, err := apiClient.Get(fmt.Sprintf("/api/v1/instances/%s/utilities/version", inst))
fmt.Printf("Kubernetes: %s\n", k8s) if err == nil {
} if k8s, ok := resp.Data["kubernetes"].(string); ok {
if talos, ok := resp.Data["talos"].(string); ok && talos != "" { fmt.Printf("Kubernetes: %s\n", k8s)
fmt.Printf("Talos: %s\n", talos) }
if talos, ok := resp.Data["talos"].(string); ok && talos != "" {
fmt.Printf("Talos: %s\n", talos)
}
} }
} }
} }