Skip to content
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

mantle/platform/aliyun: modify the API to use HTTPS by default #3845

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
14 changes: 6 additions & 8 deletions mantle/platform/api/aliyun/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"github.com/coreos/pkg/capnslog"
"github.com/coreos/pkg/multierror"

"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
Expand Down Expand Up @@ -88,7 +90,10 @@ func New(opts *Options) (*API, error) {
opts.Region = profile.Region
}

ecs, err := ecs.NewClientWithAccessKey(opts.Region, opts.AccessKeyID, opts.SecretKey)
config := sdk.NewConfig()
config.Scheme = "HTTPS"
credential := credentials.NewAccessKeyCredential(opts.AccessKeyID, opts.SecretKey)
ecs, err := ecs.NewClientWithOptions(opts.Region, config, credential)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -207,7 +212,6 @@ func (a *API) ImportImage(format, bucket, object, image_size, device, name, desc
request := ecs.CreateImportImageRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
aaradhak marked this conversation as resolved.
Show resolved Hide resolved
request.DiskDeviceMapping = &[]ecs.ImportImageDiskDeviceMapping{
{
Format: format,
Expand Down Expand Up @@ -297,7 +301,6 @@ func (a *API) GetImages(name string) (*ecs.DescribeImagesResponse, error) {
request := ecs.CreateDescribeImagesRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
request.ImageName = name
return a.ecs.DescribeImages(request)
}
Expand All @@ -307,7 +310,6 @@ func (a *API) GetImagesByID(id string, region string) (*ecs.DescribeImagesRespon
request := ecs.CreateDescribeImagesRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
request.ImageId = id
request.RegionId = region
return a.ecs.DescribeImages(request)
Expand All @@ -318,7 +320,6 @@ func (a *API) DeleteImage(id string, force bool) error {
request := ecs.CreateDeleteImageRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
request.ImageId = id
request.Force = requests.NewBoolean(force)

Expand Down Expand Up @@ -350,7 +351,6 @@ func (a *API) DeleteSnapshot(id string, force bool) error {
request := ecs.CreateDeleteSnapshotRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
request.SnapshotId = id
request.Force = requests.NewBoolean(force)
_, err := a.ecs.DeleteSnapshot(request)
Expand Down Expand Up @@ -430,7 +430,6 @@ func (a *API) ListRegions() ([]string, error) {
request := ecs.CreateDescribeRegionsRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"

response, err := a.ecs.DescribeRegions(request)
if err != nil {
Expand Down Expand Up @@ -468,7 +467,6 @@ func (a *API) ChangeVisibility(region string, id string, public bool) error {
request := ecs.CreateModifyImageSharePermissionRequest()
request.SetConnectTimeout(defaultConnectTimeout)
request.SetReadTimeout(defaultReadTimeout)
request.Scheme = "https"
request.ImageId = id
request.RegionId = region
request.IsPublic = requests.NewBoolean(public)
Expand Down
Loading