-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the list/describe commands (#93)
* wip * wip * fix the unit tests for backup as well * do CDC as well * typo
- Loading branch information
Showing
15 changed files
with
244 additions
and
74 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
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,69 @@ | ||
// Licensed to Yugabyte, Inc. under one or more contributor license | ||
// agreements. See the NOTICE file distributed with this work for | ||
// additional information regarding copyright ownership. Yugabyte | ||
// licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cluster | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client" | ||
"github.com/yugabyte/ybm-cli/internal/formatter" | ||
) | ||
|
||
var describeClusterCmd = &cobra.Command{ | ||
Use: "describe", | ||
Short: "Describe a cluster in YugabyteDB Managed", | ||
Long: "Describe a cluster in YugabyteDB Managed", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
authApi, err := ybmAuthClient.NewAuthApiClient() | ||
if err != nil { | ||
logrus.Fatalf("could not initiate api client: %s", err.Error()) | ||
} | ||
authApi.GetInfo("", "") | ||
clusterListRequest := authApi.ListClusters() | ||
clusterName, _ := cmd.Flags().GetString("cluster-name") | ||
clusterListRequest = clusterListRequest.Name(clusterName) | ||
|
||
resp, r, err := clusterListRequest.Execute() | ||
|
||
if err != nil { | ||
logrus.Debugf("Full HTTP response: %v", r) | ||
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err)) | ||
} | ||
|
||
if len(resp.GetData()) > 0 && viper.GetString("output") == "table" { | ||
fullClusterContext := *formatter.NewFullClusterContext() | ||
fullClusterContext.Output = os.Stdout | ||
fullClusterContext.Format = formatter.NewFullClusterFormat(viper.GetString("output")) | ||
fullClusterContext.SetFullCluster(*authApi, resp.GetData()[0]) | ||
fullClusterContext.Write() | ||
return | ||
} | ||
clustersCtx := formatter.Context{ | ||
Output: os.Stdout, | ||
Format: formatter.NewClusterFormat(viper.GetString("output")), | ||
} | ||
formatter.ClusterWrite(clustersCtx, resp.GetData()) | ||
}, | ||
} | ||
|
||
func init() { | ||
ClusterCmd.AddCommand(describeClusterCmd) | ||
describeClusterCmd.Flags().String("cluster-name", "", "[REQUIRED] The name of the cluster to get details.") | ||
describeClusterCmd.MarkFlagRequired("cluster-name") | ||
} |
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,62 @@ | ||
// Licensed to Yugabyte, Inc. under one or more contributor license | ||
// agreements. See the NOTICE file distributed with this work for | ||
// additional information regarding copyright ownership. Yugabyte | ||
// licenses this file to you under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package cluster | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client" | ||
"github.com/yugabyte/ybm-cli/internal/formatter" | ||
) | ||
|
||
var listClusterCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "List clusters in YugabyteDB Managed", | ||
Long: "List clusters in YugabyteDB Managed", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
authApi, err := ybmAuthClient.NewAuthApiClient() | ||
if err != nil { | ||
logrus.Fatalf("could not initiate api client: %s", err.Error()) | ||
} | ||
authApi.GetInfo("", "") | ||
clusterListRequest := authApi.ListClusters() | ||
// if user filters by name, add it to the request | ||
clusterName, _ := cmd.Flags().GetString("cluster-name") | ||
if clusterName != "" { | ||
clusterListRequest = clusterListRequest.Name(clusterName) | ||
} | ||
|
||
resp, r, err := clusterListRequest.Execute() | ||
|
||
if err != nil { | ||
logrus.Debugf("Full HTTP response: %v", r) | ||
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err)) | ||
} | ||
|
||
clustersCtx := formatter.Context{ | ||
Output: os.Stdout, | ||
Format: formatter.NewClusterFormat(viper.GetString("output")), | ||
} | ||
formatter.ClusterWrite(clustersCtx, resp.GetData()) | ||
}, | ||
} | ||
|
||
func init() { | ||
ClusterCmd.AddCommand(listClusterCmd) | ||
} |
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
Oops, something went wrong.