Unverified Commit 2650f1a7 by Shuwei Hao Committed by GitHub

Merge pull request #26 from haoshuwei/hotfix_get_oss_endpoint

get correct oss endpoint
parents d193f2b9 07153c9b
......@@ -92,10 +92,9 @@ For more information, see [the AlibabaCloud documentation on RAM users guides][1
```
ALIBABA_CLOUD_ACCESS_KEY_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID>
ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET>
ALIBABA_CLOUD_OSS_ENDPOINT=<ALIBABA_CLOUD_OSS_ENDPOINT>
```
where the access key id and secret are the values get from the step 3 and the oss endpoint is the value oss-$REGION.aliyuncs.com.
where the access key id and secret are the values get from the step 3.
## Install velero and velero-plugin for alibabacloud
......
......@@ -30,7 +30,8 @@ metadata:
name: default
namespace: velero
spec:
config: {}
config:
region: <REGION>
objectStorage:
bucket: <BUCKET>
prefix: ""
......
ALIBABA_CLOUD_ACCESS_KEY_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID>
ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET>
ALIBABA_CLOUD_OSS_ENDPOINT=<ALIBABA_CLOUD_OSS_ENDPOINT>
......@@ -11,7 +11,7 @@ import (
const (
metadataURL = "http://100.100.100.200/latest/meta-data/"
metadataRegionKey = "region"
metadataRegionKey = "region-id"
metadataZoneKey = "zone-id"
regionConfigKey = "region"
minReqVolSizeBytes = 21474836480
......@@ -52,7 +52,7 @@ func getMetaData(resource string) (string, error) {
// getOssEndpoint return oss endpoint in format "oss-%s.aliyuncs.com"
func getOssEndpoint(config map[string]string) string {
if value := config[regionConfigKey]; value == "" {
if value, err := getMetaData(metadataRegionKey); err != nil {
if value, err := getMetaData(metadataRegionKey); err != nil || value == "" {
// set default region
return "oss-cn-hangzhou.aliyuncs.com"
} else {
......@@ -66,7 +66,7 @@ func getOssEndpoint(config map[string]string) string {
// getEcsRegionID return ecs region id
func getEcsRegionID(config map[string]string) string {
if value := config[regionConfigKey]; value == "" {
if value, err := getMetaData(metadataRegionKey); err != nil {
if value, err := getMetaData(metadataRegionKey); err != nil || value == "" {
// set default region
return "cn-hangzhou"
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment