Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vtctld] Migrate ListBackups as GetBackups in new vtctld server #7352

Merged
merged 5 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions go/cmd/vtctldclient/internal/command/backups.go
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)
}
31 changes: 31 additions & 0 deletions go/vt/mysqlctl/mysqlctlproto/backup.go
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(),
}
}
21 changes: 21 additions & 0 deletions go/vt/mysqlctl/mysqlctlproto/doc.go
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
97 changes: 74 additions & 23 deletions go/vt/proto/mysqlctl/mysqlctl.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading