-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpk: list virtual cluster on cloud login
Now rpk cloud login will display a list of virtual clusters and clusters when you succesfully logged in. Then you can pick one of them and rpk will create a profile with the selection. If there is just one cluster, it will select that cluster by default and create a profile.
- Loading branch information
Showing
7 changed files
with
213 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2023 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
package cloudapi | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/httpapi" | ||
) | ||
|
||
const ( | ||
virtualClusterPath = "/api/v1/virtual-clusters" | ||
ClusterStateReady = "ready" | ||
) | ||
|
||
type ( | ||
VirtualClusterSpec struct { | ||
ServerlessRegionID string `json:"serverlessRegionId"` | ||
} | ||
VirtualClusterStatus struct { | ||
Created struct { | ||
VirtualRedpandaDetails struct { | ||
AdminAPIURL string `json:"adminApiUrl"` | ||
SeedAddresses []string `json:"seedAddresses"` | ||
} `json:"virtualRedpandaDetails"` | ||
Metadata struct { | ||
Source string `json:"source"` | ||
ReportedAt string `json:"reportedAt"` | ||
} `json:"metadata"` | ||
} `json:"created"` | ||
} | ||
|
||
VirtualCluster struct { | ||
NameID | ||
NamespaceUUID string `json:"namespaceUuid"` | ||
CreatedAt time.Time `json:"createdAt"` | ||
State string `json:"state"` | ||
|
||
Spec VirtualClusterSpec `json:"spec"` | ||
Status VirtualClusterStatus `json:"status"` | ||
} | ||
// VirtualClusters is a set of Redpanda virtual clusters. | ||
VirtualClusters []VirtualCluster | ||
) | ||
|
||
func (cl *Client) VirtualClusters(ctx context.Context) (VirtualClusters, error) { | ||
var cs []VirtualCluster | ||
err := cl.cl.Get(ctx, virtualClusterPath, nil, &cs) | ||
return cs, err | ||
} | ||
|
||
func (cl *Client) VirtualCluster(ctx context.Context, vClusterID string) (VirtualCluster, error) { | ||
path := httpapi.Pathfmt(virtualClusterPath+"/%s", vClusterID) | ||
var vc VirtualCluster | ||
err := cl.cl.Get(ctx, path, nil, &vc) | ||
return vc, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters