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 ...@@ -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_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID>
ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET> 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 ## Install velero and velero-plugin for alibabacloud
......
...@@ -30,7 +30,8 @@ metadata: ...@@ -30,7 +30,8 @@ metadata:
name: default name: default
namespace: velero namespace: velero
spec: spec:
config: {} config:
region: <REGION>
objectStorage: objectStorage:
bucket: <BUCKET> bucket: <BUCKET>
prefix: "" prefix: ""
......
ALIBABA_CLOUD_ACCESS_KEY_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID> ALIBABA_CLOUD_ACCESS_KEY_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID>
ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET> ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET>
ALIBABA_CLOUD_OSS_ENDPOINT=<ALIBABA_CLOUD_OSS_ENDPOINT>
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
const ( const (
metadataURL = "http://100.100.100.200/latest/meta-data/" metadataURL = "http://100.100.100.200/latest/meta-data/"
metadataRegionKey = "region" metadataRegionKey = "region-id"
metadataZoneKey = "zone-id" metadataZoneKey = "zone-id"
regionConfigKey = "region" regionConfigKey = "region"
minReqVolSizeBytes = 21474836480 minReqVolSizeBytes = 21474836480
...@@ -52,7 +52,7 @@ func getMetaData(resource string) (string, error) { ...@@ -52,7 +52,7 @@ func getMetaData(resource string) (string, error) {
// getOssEndpoint return oss endpoint in format "oss-%s.aliyuncs.com" // getOssEndpoint return oss endpoint in format "oss-%s.aliyuncs.com"
func getOssEndpoint(config map[string]string) string { func getOssEndpoint(config map[string]string) string {
if value := config[regionConfigKey]; value == "" { if value := config[regionConfigKey]; value == "" {
if value, err := getMetaData(metadataRegionKey); err != nil { if value, err := getMetaData(metadataRegionKey); err != nil || value == "" {
// set default region // set default region
return "oss-cn-hangzhou.aliyuncs.com" return "oss-cn-hangzhou.aliyuncs.com"
} else { } else {
...@@ -66,7 +66,7 @@ func getOssEndpoint(config map[string]string) string { ...@@ -66,7 +66,7 @@ func getOssEndpoint(config map[string]string) string {
// getEcsRegionID return ecs region id // getEcsRegionID return ecs region id
func getEcsRegionID(config map[string]string) string { func getEcsRegionID(config map[string]string) string {
if value := config[regionConfigKey]; value == "" { if value := config[regionConfigKey]; value == "" {
if value, err := getMetaData(metadataRegionKey); err != nil { if value, err := getMetaData(metadataRegionKey); err != nil || value == "" {
// set default region // set default region
return "cn-hangzhou" return "cn-hangzhou"
} else { } 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