Merge pull request #6506 from dolthub/macneale4/drop-aws-args

Drop the aws flags from the `dolt_remote()`  and `dolt_clone()` procedures
This commit is contained in:
Neil Macneale IV
2023-08-16 12:21:54 -07:00
committed by GitHub
4 changed files with 10 additions and 42 deletions
-4
View File
@@ -169,10 +169,6 @@ func CreateResetArgParser() *argparser.ArgParser {
func CreateRemoteArgParser() *argparser.ArgParser {
ap := argparser.NewArgParserWithVariableArgs("remote")
ap.SupportsString(dbfactory.AWSRegionParam, "", "region", "")
ap.SupportsValidatedString(dbfactory.AWSCredsTypeParam, "", "creds-type", "", argparser.ValidatorFromStrList(dbfactory.AWSCredsTypeParam, dbfactory.AWSCredTypes))
ap.SupportsString(dbfactory.AWSCredsFileParam, "", "file", "AWS credentials file")
ap.SupportsString(dbfactory.AWSCredsProfile, "", "profile", "AWS profile to use")
return ap
}
+6 -3
View File
@@ -86,10 +86,13 @@ func (cmd RemoteCmd) Docs() *cli.CommandDocumentation {
func (cmd RemoteCmd) ArgParser() *argparser.ArgParser {
ap := cli.CreateRemoteArgParser()
ap.ArgListHelp = append(ap.ArgListHelp, [2]string{"region", "cloud provider region associated with this remote."})
ap.ArgListHelp = append(ap.ArgListHelp, [2]string{"creds-type", "credential type. Valid options are role, env, and file. See the help section for additional details."})
ap.ArgListHelp = append(ap.ArgListHelp, [2]string{"profile", "AWS profile to use."})
ap.SupportsFlag(cli.VerboseFlag, "v", "When printing the list of remotes adds additional details.")
ap.SupportsString(dbfactory.AWSRegionParam, "", "region", "Cloud provider region associated with this remote.")
ap.SupportsValidatedString(dbfactory.AWSCredsTypeParam, "", "creds-type", "Credential type. Valid options are role, env, and file. See the help section for additional details.", argparser.ValidatorFromStrList(dbfactory.AWSCredsTypeParam, dbfactory.AWSCredTypes))
ap.SupportsString(dbfactory.AWSCredsFileParam, "", "file", "AWS credentials file")
ap.SupportsString(dbfactory.AWSCredsProfile, "", "profile", "AWS profile to use")
ap.SupportsString(dbfactory.OSSCredsFileParam, "", "file", "OSS credentials file")
ap.SupportsString(dbfactory.OSSCredsProfile, "", "profile", "OSS profile to use")
return ap
@@ -44,17 +44,12 @@ func doltClone(ctx *sql.Context, args ...string) (sql.RowIter, error) {
}
sess := dsess.DSessFromSess(ctx.Session)
scheme, remoteUrl, err := env.GetAbsRemoteUrl(sess.Provider().FileSystem(), emptyConfig(), urlStr)
_, remoteUrl, err := env.GetAbsRemoteUrl(sess.Provider().FileSystem(), emptyConfig(), urlStr)
if err != nil {
return nil, errhand.BuildDError("error: '%s' is not valid.", urlStr).Build()
}
params, err := remoteParams(apr, scheme, remoteUrl)
if err != nil {
return nil, err
}
err = sess.Provider().CloneDatabaseFromRemote(ctx, dir, branch, remoteName, remoteUrl, params)
err = sess.Provider().CloneDatabaseFromRemote(ctx, dir, branch, remoteName, remoteUrl, map[string]string{})
if err != nil {
return nil, err
}
@@ -21,9 +21,7 @@ import (
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/cmd/dolt/cli"
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
"github.com/dolthub/dolt/go/libraries/doltcore/branch_control"
"github.com/dolthub/dolt/go/libraries/doltcore/dbfactory"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env"
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
@@ -99,16 +97,12 @@ func addRemote(_ *sql.Context, dbName string, dbd env.DbData, apr *argparser.Arg
return err
}
scheme, absRemoteUrl, err := env.GetAbsRemoteUrl(dbFs, &config.MapConfig{}, remoteUrl)
_, absRemoteUrl, err := env.GetAbsRemoteUrl(dbFs, &config.MapConfig{}, remoteUrl)
if err != nil {
return err
}
params, err := remoteParams(apr, scheme, absRemoteUrl)
if err != nil {
return err
}
r := env.NewRemote(remoteName, absRemoteUrl, params)
r := env.NewRemote(remoteName, absRemoteUrl, map[string]string{})
return dbd.Rsw.AddRemote(r)
}
@@ -149,23 +143,3 @@ func removeRemote(ctx *sql.Context, dbd env.DbData, apr *argparser.ArgParseResul
return dbd.Rsw.RemoveRemote(ctx, remote.Name)
}
func remoteParams(apr *argparser.ArgParseResults, scheme, remoteUrl string) (map[string]string, errhand.VerboseError) {
params := map[string]string{}
var err error
switch scheme {
case dbfactory.AWSScheme:
err = cli.AddAWSParams(remoteUrl, apr, params)
case dbfactory.OSSScheme:
err = cli.AddOSSParams(remoteUrl, apr, params)
default:
err = cli.VerifyNoAwsParams(apr)
}
if err != nil {
return nil, errhand.VerboseErrorFromError(err)
}
return params, nil
}