Skip to content

enhancement: enable credentials for source bucket in current account #15

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
43 changes: 20 additions & 23 deletions dth/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,26 @@ func getCredentials(ctx context.Context, param string, inCurrentAccount bool, sm
noSignRequest: false,
}

// No need to do anything if inCurrentAccount is true
if !inCurrentAccount {
if param == "" {
// no credential is required.
cred.noSignRequest = true
} else {
credStr := sm.GetSecret(ctx, &param)
if credStr != nil {
credMap := make(map[string]string)
err := json.Unmarshal([]byte(*credStr), &credMap)
if err != nil {
log.Printf("Warning - Unable to parse the credentials string, please make sure the it is a valid json format. - %s\n", err.Error())
} else {
cred.accessKey = credMap["access_key_id"]
cred.secretKey = credMap["secret_access_key"]
}
// log.Println(*credStr)
// log.Println(credMap)
} else {
log.Printf("Credential parameter %s ignored, use default configuration\n", param)
}
}
}
if param == "" {
// no credential is required if not in current account
cred.noSignRequest = !inCurrentAccount
} else {
credStr := sm.GetSecret(ctx, &param)
if credStr != nil {
credMap := make(map[string]string)
err := json.Unmarshal([]byte(*credStr), &credMap)
if err != nil {
log.Printf("Warning - Unable to parse the credentials string, please make sure the it is a valid json format. - %s\n", err.Error())
} else {
cred.accessKey = credMap["access_key_id"]
cred.secretKey = credMap["secret_access_key"]
}
// log.Println(*credStr)
// log.Println(credMap)
} else {
log.Printf("Credential parameter %s ignored, use default configuration\n", param)
}
}
return cred
}

Expand Down