forked from NVIDIA/aistore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
96 lines (83 loc) · 1.69 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Package apc: API messages and constants
/*
* Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
*/
package apc
import (
"github.com/artashesbalabekyan/aistore/cmn/cos"
)
// Backend Provider enum
const (
AIS = "ais"
AWS = "aws"
Azure = "azure"
GCP = "gcp"
HDFS = "hdfs"
HTTP = "ht"
AllProviders = "ais, aws (s3://), gcp (gs://), azure (az://), hdfs://, ht://" // NOTE: must include all
NsUUIDPrefix = '@' // BEWARE: used by on-disk layout
NsNamePrefix = '#' // BEWARE: used by on-disk layout
BckProviderSeparator = "://"
BckObjnameSeparator = "/"
// scheme://
DefaultScheme = "https"
GSScheme = "gs"
S3Scheme = "s3"
AZScheme = "az"
AISScheme = "ais"
)
var Providers = cos.NewStrSet(AIS, GCP, AWS, Azure, HDFS, HTTP)
func IsProvider(p string) bool { return Providers.Contains(p) }
func IsCloudProvider(p string) bool {
return p == AWS || p == GCP || p == Azure
}
func IsRemoteProvider(p string) bool {
return IsCloudProvider(p) || p == HDFS || p == HTTP
}
func ToScheme(p string) string {
switch p {
case AWS:
return S3Scheme
case Azure:
return AZScheme
case GCP:
return GSScheme
default:
return p
}
}
func NormalizeProvider(p string) string {
if IsProvider(p) {
return p
}
switch p {
case "":
return AIS // NOTE: ais is the default provider
case S3Scheme:
return AWS
case AZScheme:
return Azure
case GSScheme:
return GCP
default:
return ""
}
}
func DisplayProvider(p string) string {
switch p {
case AIS:
return "AIS"
case AWS, S3Scheme:
return "AWS"
case Azure, AZScheme:
return "Azure"
case GCP, GSScheme:
return "GCP"
case HDFS:
return "HDFS"
case HTTP:
return "HTTP(S)"
default:
return p
}
}