service/vendor/github.com/aliyun/credentials-go/credentials/instance_provider.go

29 lines
533 B
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package credentials
import (
"os"
"github.com/alibabacloud-go/tea/tea"
)
type instanceCredentialsProvider struct{}
var providerInstance = new(instanceCredentialsProvider)
func newInstanceCredentialsProvider() Provider {
return &instanceCredentialsProvider{}
}
func (p *instanceCredentialsProvider) resolve() (*Config, error) {
roleName, ok := os.LookupEnv(ENVEcsMetadata)
if !ok {
return nil, nil
}
config := &Config{
Type: tea.String("ecs_ram_role"),
RoleName: tea.String(roleName),
}
return config, nil
}