"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "internal/backend/remote-state/oss/backend.go" between
terraform-1.0.2.tar.gz and terraform-1.0.3.tar.gz

About: Terraform is a tool for building, changing, and versioning a datacenter infrastructure (written in Go).

backend.go  (terraform-1.0.2):backend.go  (terraform-1.0.3)
skipping to change at line 322 skipping to change at line 322
if roleArn != "" { if roleArn != "" {
subAccessKeyId, subAccessKeySecret, subSecurityToken, err := getA ssumeRoleAK(accessKey, secretKey, securityToken, region, roleArn, sessionName, p olicy, sessionExpiration) subAccessKeyId, subAccessKeySecret, subSecurityToken, err := getA ssumeRoleAK(accessKey, secretKey, securityToken, region, roleArn, sessionName, p olicy, sessionExpiration)
if err != nil { if err != nil {
return err return err
} }
accessKey, secretKey, securityToken = subAccessKeyId, subAccessKe ySecret, subSecurityToken accessKey, secretKey, securityToken = subAccessKeyId, subAccessKe ySecret, subSecurityToken
} }
if endpoint == "" { if endpoint == "" {
endpointItem, _ := b.getOSSEndpointByRegion(accessKey, secretKey, endpointsResponse, _ := b.getOSSEndpointByRegion(accessKey, secre
securityToken, region) tKey, securityToken, region)
if endpointItem != nil && len(endpointItem.Endpoint) > 0 { for _, endpointItem := range endpointsResponse.Endpoints.Endpoint
if len(endpointItem.Protocols.Protocols) > 0 { {
// HTTP or HTTPS if endpointItem.Type == "openAPI" {
schma = strings.ToLower(endpointItem.Protocols.Pr endpoint = endpointItem.Endpoint
otocols[0]) break
for _, p := range endpointItem.Protocols.Protocol
s {
if strings.ToLower(p) == "https" {
schma = strings.ToLower(p)
break
}
}
} }
endpoint = endpointItem.Endpoint }
} else { if endpoint == "" {
endpoint = fmt.Sprintf("oss-%s.aliyuncs.com", region) endpoint = fmt.Sprintf("oss-%s.aliyuncs.com", region)
} }
} }
if !strings.HasPrefix(endpoint, "http") { if !strings.HasPrefix(endpoint, "http") {
endpoint = fmt.Sprintf("%s://%s", schma, endpoint) endpoint = fmt.Sprintf("%s://%s", schma, endpoint)
} }
log.Printf("[DEBUG] Instantiate OSS client using endpoint: %#v", endpoint ) log.Printf("[DEBUG] Instantiate OSS client using endpoint: %#v", endpoint )
var options []oss.ClientOption var options []oss.ClientOption
if securityToken != "" { if securityToken != "" {
options = append(options, oss.SecurityToken(securityToken)) options = append(options, oss.SecurityToken(securityToken))
skipping to change at line 370 skipping to change at line 364
} }
b.otsEndpoint = otsEndpoint b.otsEndpoint = otsEndpoint
parts := strings.Split(strings.TrimPrefix(strings.TrimPrefix(otsE ndpoint, "https://"), "http://"), ".") parts := strings.Split(strings.TrimPrefix(strings.TrimPrefix(otsE ndpoint, "https://"), "http://"), ".")
b.otsClient = tablestore.NewClientWithConfig(otsEndpoint, parts[0 ], accessKey, secretKey, securityToken, tablestore.NewDefaultTableStoreConfig()) b.otsClient = tablestore.NewClientWithConfig(otsEndpoint, parts[0 ], accessKey, secretKey, securityToken, tablestore.NewDefaultTableStoreConfig())
} }
b.otsTable = d.Get("tablestore_table").(string) b.otsTable = d.Get("tablestore_table").(string)
return err return err
} }
func (b *Backend) getOSSEndpointByRegion(access_key, secret_key, security_token, func (b *Backend) getOSSEndpointByRegion(access_key, secret_key, security_token,
region string) (*location.DescribeEndpointResponse, error) { region string) (*location.DescribeEndpointsResponse, error) {
args := location.CreateDescribeEndpointRequest() args := location.CreateDescribeEndpointsRequest()
args.ServiceCode = "oss" args.ServiceCode = "oss"
args.Id = region args.Id = region
args.Domain = "location-readonly.aliyuncs.com" args.Domain = "location-readonly.aliyuncs.com"
locationClient, err := location.NewClientWithOptions(region, getSdkConfig (), credentials.NewStsTokenCredential(access_key, secret_key, security_token)) locationClient, err := location.NewClientWithOptions(region, getSdkConfig (), credentials.NewStsTokenCredential(access_key, secret_key, security_token))
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to initialize the location client: %#v", err) return nil, fmt.Errorf("Unable to initialize the location client: %#v", err)
} }
locationClient.AppendUserAgent(TerraformUA, TerraformVersion) locationClient.AppendUserAgent(TerraformUA, TerraformVersion)
endpointsResponse, err := locationClient.DescribeEndpoint(args) endpointsResponse, err := locationClient.DescribeEndpoints(args)
if err != nil { if err != nil {
return nil, fmt.Errorf("Describe oss endpoint using region: %#v g ot an error: %#v.", region, err) return nil, fmt.Errorf("Describe oss endpoint using region: %#v g ot an error: %#v.", region, err)
} }
return endpointsResponse, nil return endpointsResponse, nil
} }
func getAssumeRoleAK(accessKey, secretKey, stsToken, region, roleArn, sessionNam e, policy string, sessionExpiration int) (string, string, string, error) { func getAssumeRoleAK(accessKey, secretKey, stsToken, region, roleArn, sessionNam e, policy string, sessionExpiration int) (string, string, string, error) {
request := sts.CreateAssumeRoleRequest() request := sts.CreateAssumeRoleRequest()
request.RoleArn = roleArn request.RoleArn = roleArn
request.RoleSessionName = sessionName request.RoleSessionName = sessionName
 End of changes. 4 change blocks. 
20 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)