This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vitessio#7352 from tinyspeck/am_vtctld_listbackups
[vtctld] Migrate ListBackups as GetBackups in new vtctld server
- Loading branch information
1 parent
70fe751
commit 5dbea28
Showing
14 changed files
with
638 additions
and
140 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2021 The Vitess Authors. | ||
Licensed 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 command | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" | ||
) | ||
|
||
// GetBackups makes a GetBackups gRPC call to a vtctld. | ||
var GetBackups = &cobra.Command{ | ||
Use: "GetBackups keyspace shard", | ||
Args: cobra.ExactArgs(2), | ||
RunE: commandGetBackups, | ||
} | ||
|
||
func commandGetBackups(cmd *cobra.Command, args []string) error { | ||
keyspace := cmd.Flags().Arg(0) | ||
shard := cmd.Flags().Arg(1) | ||
|
||
resp, err := client.GetBackups(commandCtx, &vtctldatapb.GetBackupsRequest{ | ||
Keyspace: keyspace, | ||
Shard: shard, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
names := make([]string, len(resp.Backups)) | ||
for i, b := range resp.Backups { | ||
names[i] = b.Name | ||
} | ||
|
||
fmt.Printf("%s\n", strings.Join(names, "\n")) | ||
|
||
return nil | ||
} | ||
|
||
func init() { | ||
Root.AddCommand(GetBackups) | ||
} |
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,31 @@ | ||
/* | ||
Copyright 2021 The Vitess Authors. | ||
Licensed 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 mysqlctlproto | ||
|
||
import ( | ||
"vitess.io/vitess/go/vt/mysqlctl/backupstorage" | ||
|
||
mysqlctlpb "vitess.io/vitess/go/vt/proto/mysqlctl" | ||
) | ||
|
||
// BackupHandleToProto returns a BackupInfo proto from a BackupHandle. | ||
func BackupHandleToProto(bh backupstorage.BackupHandle) *mysqlctlpb.BackupInfo { | ||
return &mysqlctlpb.BackupInfo{ | ||
Name: bh.Name(), | ||
Directory: bh.Directory(), | ||
} | ||
} |
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,21 @@ | ||
/* | ||
Copyright 2021 The Vitess Authors. | ||
Licensed 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 mysqlctlproto provides utility functions for working with data | ||
structures in mysqlctl.proto. | ||
*/ | ||
package mysqlctlproto |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.