diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-08-08 18:55:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-08 18:55:53 -0700 |
| commit | 52fcce81c64348dccf706e52161cf3fcf71e1df8 (patch) | |
| tree | eff9e3a111e227de7803c4ab5bd03ea79897bb57 /weed/shell/command_remote_configure.go | |
| parent | 4370a4db634f2268526911842a804d9dee97aadc (diff) | |
| parent | 882a93dacd2ca8549af50b80a8a98a861fdee0ed (diff) | |
| download | seaweedfs-52fcce81c64348dccf706e52161cf3fcf71e1df8.tar.xz seaweedfs-52fcce81c64348dccf706e52161cf3fcf71e1df8.zip | |
Merge pull request #2241 from chrislusf/add_remote_storage
WIP: remote storage
Diffstat (limited to 'weed/shell/command_remote_configure.go')
| -rw-r--r-- | weed/shell/command_remote_configure.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/weed/shell/command_remote_configure.go b/weed/shell/command_remote_configure.go index 567143ce1..7a9ad1f65 100644 --- a/weed/shell/command_remote_configure.go +++ b/weed/shell/command_remote_configure.go @@ -7,9 +7,11 @@ import ( "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/util" + "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" "io" "regexp" + "strings" ) func init() { @@ -84,6 +86,9 @@ func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandE fmt.Fprintf(writer, "skipping %s\n", entry.Name) return nil } + if !strings.HasSuffix(entry.Name, filer.REMOTE_STORAGE_CONF_SUFFIX) { + return nil + } conf := &filer_pb.RemoteConf{} if err := proto.Unmarshal(entry.Content, conf); err != nil { @@ -92,9 +97,15 @@ func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandE conf.S3SecretKey = "" - fmt.Fprintf(writer, "%+v\n", conf) + m := jsonpb.Marshaler{ + EmitDefaults: false, + Indent: " ", + } + + err := m.Marshal(writer, conf) + fmt.Fprintln(writer) - return nil + return err }) } @@ -105,7 +116,7 @@ func (c *commandRemoteConfigure) deleteRemoteStorage(commandEnv *CommandEnv, wri request := &filer_pb.DeleteEntryRequest{ Directory: filer.DirectoryEtcRemote, - Name: storageName, + Name: storageName + filer.REMOTE_STORAGE_CONF_SUFFIX, IgnoreRecursiveError: false, IsDeleteData: true, IsRecursive: true, @@ -132,7 +143,7 @@ func (c *commandRemoteConfigure) saveRemoteStorage(commandEnv *CommandEnv, write } if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { - return filer.SaveInsideFiler(client, filer.DirectoryEtcRemote, conf.Name, data) + return filer.SaveInsideFiler(client, filer.DirectoryEtcRemote, conf.Name+filer.REMOTE_STORAGE_CONF_SUFFIX, data) }); err != nil && err != filer_pb.ErrNotFound { return err } |
