Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
velero-plugin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
velero-plugin
Commits
d975181e
Commit
d975181e
authored
Jan 13, 2020
by
haoshuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support use internal oss-endpoint
Signed-off-by: haoshuwei <haoshuwei24@gmail.com>
parent
20a8d2d1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
velero-plugin-for-alibabacloud/common.go
+32
-1
velero-plugin-for-alibabacloud/object_store.go
+1
-1
No files found.
velero-plugin-for-alibabacloud/common.go
View file @
d975181e
...
...
@@ -19,6 +19,9 @@ const (
kindKey
=
"kind"
persistentVolumeKey
=
"PersistentVolume"
persistentVolumeClaimKey
=
"PersistentVolumeClaim"
networkTypeConfigKey
=
"network"
networkTypeAccelerate
=
"accelerate"
networkTypeInternal
=
"internal"
)
// load environment vars from $ALIBABA_CLOUD_CREDENTIALS_FILE, if it exists
...
...
@@ -49,8 +52,36 @@ func getMetaData(resource string) (string, error) {
return
string
(
body
),
nil
}
// getOssEndpoint return oss endpoint in format "oss-%s.aliyuncs.com"
// getOssEndpoint:
// return oss public endpoint in format "oss-%s.aliyuncs.com"
// return oss accelerate endpoint in format "oss-accelerate.aliyuncs.com"
// return oss internal endpoint in format "oss-%s-internal.aliyuncs.com"
func
getOssEndpoint
(
config
map
[
string
]
string
)
string
{
if
networkType
:=
config
[
networkTypeConfigKey
];
networkType
!=
""
{
switch
networkType
{
case
networkTypeInternal
:
if
value
:=
config
[
regionConfigKey
];
value
!=
""
{
return
fmt
.
Sprintf
(
"oss-%s-internal.aliyuncs.com"
,
value
)
}
else
{
if
value
,
err
:=
getMetaData
(
metadataRegionKey
);
err
!=
nil
||
value
==
""
{
// set default region
return
"oss-cn-hangzhou-internal.aliyuncs.com"
}
}
case
networkTypeAccelerate
:
return
"oss-accelerate.aliyuncs.com"
default
:
if
value
:=
config
[
regionConfigKey
];
value
!=
""
{
return
fmt
.
Sprintf
(
"oss-%s.aliyuncs.com"
,
value
)
}
else
{
if
value
,
err
:=
getMetaData
(
metadataRegionKey
);
err
!=
nil
||
value
==
""
{
// set default region
return
"oss-cn-hangzhou.aliyuncs.com"
}
}
}
}
if
value
:=
config
[
regionConfigKey
];
value
==
""
{
if
value
,
err
:=
getMetaData
(
metadataRegionKey
);
err
!=
nil
||
value
==
""
{
// set default region
...
...
velero-plugin-for-alibabacloud/object_store.go
View file @
d975181e
...
...
@@ -85,7 +85,7 @@ func (o *ObjectStore) getBucket(bucket string) (ossBucket, error) {
// Init init oss client with os envs
func
(
o
*
ObjectStore
)
Init
(
config
map
[
string
]
string
)
error
{
if
err
:=
veleroplugin
.
ValidateObjectStoreConfigKeys
(
config
,
regionConfigKey
);
err
!=
nil
{
if
err
:=
veleroplugin
.
ValidateObjectStoreConfigKeys
(
config
,
regionConfigKey
,
networkTypeConfigKey
);
err
!=
nil
{
return
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment