mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-22 19:43:51 -05:00
disable aws params for dolt_sync command run via sql and minor credentialing change
This commit is contained in:
@@ -142,6 +142,11 @@ func (fact AWSFactory) newChunkStore(ctx context.Context, nbf *types.NomsBinForm
|
||||
}
|
||||
|
||||
sess := session.Must(session.NewSessionWithOptions(opts))
|
||||
_, err = sess.Config.Credentials.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
q := nbs.NewUnlimitedMemQuotaProvider()
|
||||
return nbs.NewAWSStore(ctx, nbf.VersionString(), parts[0], dbName, parts[1], s3.New(sess), dynamodb.New(sess), defaultMemTableSize, q)
|
||||
}
|
||||
@@ -188,6 +193,11 @@ func awsConfigFromParams(params map[string]interface{}) (session.Options, error)
|
||||
opts.Profile = val.(string)
|
||||
}
|
||||
|
||||
filePath, ok := params[AWSCredsFileParam]
|
||||
if ok && len(filePath.(string)) != 0 && awsCredsSource == RoleCS {
|
||||
awsCredsSource = FileCS
|
||||
}
|
||||
|
||||
switch awsCredsSource {
|
||||
case EnvCS:
|
||||
awsConfig = awsConfig.WithCredentials(credentials.NewEnvCredentials())
|
||||
|
||||
@@ -84,6 +84,13 @@ func DoDoltBackup(ctx *sql.Context, args []string) (int, error) {
|
||||
return statusErr, err
|
||||
}
|
||||
|
||||
invalidParams := []string{dbfactory.AWSCredsFileParam, dbfactory.AWSCredsProfile, dbfactory.AWSCredsTypeParam, dbfactory.AWSRegionParam}
|
||||
for _, param := range invalidParams {
|
||||
if apr.Contains(param) {
|
||||
return statusErr, fmt.Errorf("parameter '%s' is not supported when running this command via SQL", param)
|
||||
}
|
||||
}
|
||||
|
||||
sess := dsess.DSessFromSess(ctx.Session)
|
||||
dbData, ok := sess.GetDbData(ctx, dbName)
|
||||
if !ok {
|
||||
@@ -122,6 +129,18 @@ func DoDoltBackup(ctx *sql.Context, args []string) (int, error) {
|
||||
return statusErr, err
|
||||
}
|
||||
|
||||
credsFile, _ := sess.GetSessionVariable(ctx, dsess.AwsCredsFileKey)
|
||||
credsFileStr, isStr := credsFile.(string)
|
||||
if isStr && len(credsFileStr) > 0 {
|
||||
params[dbfactory.AWSCredsFileParam] = credsFileStr
|
||||
}
|
||||
|
||||
credsProfile, err := sess.GetSessionVariable(ctx, dsess.AwsCredsProfileKey)
|
||||
profStr, isStr := credsProfile.(string)
|
||||
if isStr && len(profStr) > 0 {
|
||||
params[dbfactory.AWSCredsProfile] = profStr
|
||||
}
|
||||
|
||||
b = env.NewRemote("__temp__", backupUrl, params, nil)
|
||||
|
||||
case apr.Arg(0) == cli.SyncBackupId:
|
||||
|
||||
Reference in New Issue
Block a user