From 1c729695423fc70e4f8409d03c0f7d7ce4edafe9 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Wed, 17 May 2023 15:06:32 +0800 Subject: [PATCH] use sts cred from env --- ci/ossutil/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/ossutil/main.go b/ci/ossutil/main.go index 221924df..794b7aab 100644 --- a/ci/ossutil/main.go +++ b/ci/ossutil/main.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "log" + "os" "path" "time" @@ -52,7 +53,12 @@ func (p *ossCredentialsProvider) GetCredentials() oss.Credentials { } func NewClient(endpoint string) (*oss.Client, error) { - cred, err := credentials.NewCredential(nil) + cred, err := credentials.NewCredential(&credentials.Config{ + Type: tea.String("sts"), + AccessKeyId: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")), + AccessKeySecret: tea.String(os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")), + SecurityToken: tea.String(os.Getenv("ALIBABA_CLOUD_SECURITY_TOKEN")), + }) if err != nil { return nil, err }