diff options
| author | Rain Li <blacktear23@gmail.com> | 2021-08-30 15:52:54 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-30 15:52:54 +0800 |
| commit | e5f9ff983d7153ec9c3966d896c69c3901a873fc (patch) | |
| tree | b64f53d9fa36fc2c2c796e9c8385f7be1407fc6f /weed/shell/command_remote_configure.go | |
| parent | c1dc5ab4ac90589fd5c4eaf75f7f2d4e870ae91d (diff) | |
| parent | 44d0ac95f6a068203edc4568660a720c6f5cdf8b (diff) | |
| download | seaweedfs-e5f9ff983d7153ec9c3966d896c69c3901a873fc.tar.xz seaweedfs-e5f9ff983d7153ec9c3966d896c69c3901a873fc.zip | |
Merge branch 'master' into filerstore-tikv
Diffstat (limited to 'weed/shell/command_remote_configure.go')
| -rw-r--r-- | weed/shell/command_remote_configure.go | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/weed/shell/command_remote_configure.go b/weed/shell/command_remote_configure.go index 56f0e321e..b6c4af178 100644 --- a/weed/shell/command_remote_configure.go +++ b/weed/shell/command_remote_configure.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" + "github.com/chrislusf/seaweedfs/weed/pb/remote_pb" "github.com/chrislusf/seaweedfs/weed/util" "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" @@ -35,6 +36,9 @@ func (c *commandRemoteConfigure) Help() string { remote.configure -name=cloud1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy remote.configure -name=cloud2 -type=gcs -gcs.appCredentialsFile=~/service-account-file.json remote.configure -name=cloud3 -type=azure -azure.account_name=xxx -azure.account_key=yyy + remote.configure -name=cloud4 -type=aliyun -aliyun.access_key=xxx -aliyun.secret_key=yyy -aliyun.endpoint=oss-cn-shenzhen.aliyuncs.com -aliyun.region=cn-sehnzhen + remote.configure -name=cloud5 -type=tencent -tencent.secret_id=xxx -tencent.secret_key=yyy -tencent.endpoint=cos.ap-guangzhou.myqcloud.com + remote.configure -name=cloud6 -type=wasabi -wasabi.access_key=xxx -wasabi.secret_key=yyy -wasabi.endpoint=s3.us-west-1.wasabisys.com -wasabi.region=us-west-1 # delete one configuration remote.configure -delete -name=cloud1 @@ -48,13 +52,13 @@ var ( func (c *commandRemoteConfigure) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { - conf := &filer_pb.RemoteConf{} + conf := &remote_pb.RemoteConf{} remoteConfigureCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) isDelete := remoteConfigureCommand.Bool("delete", false, "delete one remote storage by its name") remoteConfigureCommand.StringVar(&conf.Name, "name", "", "a short name to identify the remote storage") - remoteConfigureCommand.StringVar(&conf.Type, "type", "s3", "[s3|gcs|azure|b2|aliyun|tencent] storage type") + remoteConfigureCommand.StringVar(&conf.Type, "type", "s3", "[s3|gcs|azure|b2|aliyun|tencent|baidu|wasabi|hdfs] storage type") remoteConfigureCommand.StringVar(&conf.S3AccessKey, "s3.access_key", "", "s3 access key") remoteConfigureCommand.StringVar(&conf.S3SecretKey, "s3.secret_key", "", "s3 secret key") @@ -86,10 +90,32 @@ func (c *commandRemoteConfigure) Do(args []string, commandEnv *CommandEnv, write remoteConfigureCommand.StringVar(&conf.BaiduEndpoint, "baidu.endpoint", "", "Baidu endpoint") remoteConfigureCommand.StringVar(&conf.BaiduRegion, "baidu.region", "", "Baidu region") + remoteConfigureCommand.StringVar(&conf.WasabiAccessKey, "wasabi.access_key", "", "Wasabi access key") + remoteConfigureCommand.StringVar(&conf.WasabiSecretKey, "wasabi.secret_key", "", "Wasabi secret key") + remoteConfigureCommand.StringVar(&conf.WasabiEndpoint, "wasabi.endpoint", "", "Wasabi endpoint, see https://wasabi.com/wp-content/themes/wasabi/docs/API_Guide/index.html#t=topics%2Fapidiff-intro.htm") + remoteConfigureCommand.StringVar(&conf.WasabiRegion, "wasabi.region", "", "Wasabi region") + + var namenodes arrayFlags + remoteConfigureCommand.Var(&namenodes, "hdfs.namenodes", "hdfs name node and port, example: namenode1:8020,namenode2:8020") + remoteConfigureCommand.StringVar(&conf.HdfsUsername, "hdfs.username", "", "hdfs user name") + remoteConfigureCommand.StringVar(&conf.HdfsServicePrincipalName, "hdfs.servicePrincipalName", "", `Kerberos service principal name for the namenode + +Example: hdfs/namenode.hadoop.docker +Namenode running as service 'hdfs' with FQDN 'namenode.hadoop.docker'. +`) + remoteConfigureCommand.StringVar(&conf.HdfsDataTransferProtection, "hdfs.dataTransferProtection", "", "[authentication|integrity|privacy] Kerberos data transfer protection") + + if err = remoteConfigureCommand.Parse(args); err != nil { return nil } + if conf.Type != "s3" { + // clear out the default values + conf.S3Region = "" + conf.S3ForcePathStyle = false + } + if conf.Name == "" { return c.listExistingRemoteStorages(commandEnv, writer) } @@ -116,7 +142,7 @@ func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandE if !strings.HasSuffix(entry.Name, filer.REMOTE_STORAGE_CONF_SUFFIX) { return nil } - conf := &filer_pb.RemoteConf{} + conf := &remote_pb.RemoteConf{} if err := proto.Unmarshal(entry.Content, conf); err != nil { return fmt.Errorf("unmarshal %s/%s: %v", filer.DirectoryEtcRemote, entry.Name, err) @@ -162,7 +188,7 @@ func (c *commandRemoteConfigure) deleteRemoteStorage(commandEnv *CommandEnv, wri } -func (c *commandRemoteConfigure) saveRemoteStorage(commandEnv *CommandEnv, writer io.Writer, conf *filer_pb.RemoteConf) error { +func (c *commandRemoteConfigure) saveRemoteStorage(commandEnv *CommandEnv, writer io.Writer, conf *remote_pb.RemoteConf) error { data, err := proto.Marshal(conf) if err != nil { @@ -178,3 +204,14 @@ func (c *commandRemoteConfigure) saveRemoteStorage(commandEnv *CommandEnv, write return nil } + +type arrayFlags []string + +func (i *arrayFlags) String() string { + return "my string representation" +} + +func (i *arrayFlags) Set(value string) error { + *i = append(*i, value) + return nil +} |
