@@ -16,97 +16,26 @@ limitations under the License.
16
16
17
17
package common
18
18
19
- const (
20
- // FilesystemOverheadVar provides a constant to capture our env variable "FILESYSTEM_OVERHEAD"
21
- FilesystemOverheadVar = "FILESYSTEM_OVERHEAD"
22
- // OwnerUID provides the UID of the owner entity (either PVC or DV)
23
- OwnerUID = "OWNER_UID"
24
-
25
- // ImporterContainerName provides a constant to use as a name for importer Container
26
- ImporterContainerName = "importer"
27
- // UploaderContainerName provides a constant to use as a name for uploader Container
28
- UploaderContainerName = "uploader"
29
- // UploaderPortName provides a constant to use as a port name for uploader Service
30
- UploaderPortName = "uploader"
31
- // UploaderPort provides a constant to use as a port for uploader Service
32
- UploaderPort = 80
33
- // ImporterPodImageNameVar is a name of variable with the image name for the importer Pod
34
- ImporterPodImageNameVar = "IMPORTER_IMAGE"
35
- // UploaderPodImageNameVar is a name of variable with the image name for the uploader Pod
36
- UploaderPodImageNameVar = "UPLOADER_IMAGE"
37
- // ImporterCertDir is where the configmap containing certs will be mounted
38
- ImporterCertDir = "/certs"
39
- // ImporterProxyCertDir is where the configmap containing proxy certs will be mounted
40
- ImporterProxyCertDir = "/proxycerts/"
41
-
42
- // ImporterSource provides a constant to capture our env variable "IMPORTER_SOURCE"
43
- ImporterSource = "IMPORTER_SOURCE"
44
- // ImporterContentType provides a constant to capture our env variable "IMPORTER_CONTENTTYPE"
45
- ImporterContentType = "IMPORTER_CONTENTTYPE"
46
- // ImporterEndpoint provides a constant to capture our env variable "IMPORTER_ENDPOINT"
47
- ImporterEndpoint = "IMPORTER_ENDPOINT"
48
- // ImporterAccessKeyID provides a constant to capture our env variable "IMPORTER_ACCES_KEY_ID"
49
- ImporterAccessKeyID = "IMPORTER_ACCESS_KEY_ID"
50
- // ImporterSecretKey provides a constant to capture our env variable "IMPORTER_SECRET_KEY"
51
- ImporterSecretKey = "IMPORTER_SECRET_KEY"
52
- // ImporterImageSize provides a constant to capture our env variable "IMPORTER_IMAGE_SIZE"
53
- ImporterImageSize = "IMPORTER_IMAGE_SIZE"
54
- // ImporterCertDirVar provides a constant to capture our env variable "IMPORTER_CERT_DIR"
55
- ImporterCertDirVar = "IMPORTER_CERT_DIR"
56
- // InsecureTLSVar provides a constant to capture our env variable "INSECURE_TLS"
57
- InsecureTLSVar = "INSECURE_TLS"
58
- // ImporterDiskID provides a constant to capture our env variable "IMPORTER_DISK_ID"
59
- ImporterDiskID = "IMPORTER_DISK_ID"
60
- // ImporterUUID provides a constant to capture our env variable "IMPORTER_UUID"
61
- ImporterUUID = "IMPORTER_UUID"
62
- // ImporterReadyFile provides a constant to capture our env variable "IMPORTER_READY_FILE"
63
- ImporterReadyFile = "IMPORTER_READY_FILE"
64
- // ImporterDoneFile provides a constant to capture our env variable "IMPORTER_DONE_FILE"
65
- ImporterDoneFile = "IMPORTER_DONE_FILE"
66
- // ImporterBackingFile provides a constant to capture our env variable "IMPORTER_BACKING_FILE"
67
- ImporterBackingFile = "IMPORTER_BACKING_FILE"
68
- // ImporterThumbprint provides a constant to capture our env variable "IMPORTER_THUMBPRINT"
69
- ImporterThumbprint = "IMPORTER_THUMBPRINT"
70
- // ImportProxyHTTP provides a constant to capture our env variable "http_proxy"
71
- ImportProxyHTTP = "http_proxy"
72
- // ImportProxyHTTPS provides a constant to capture our env variable "https_proxy"
73
- ImportProxyHTTPS = "https_proxy"
74
- // ImportProxyNoProxy provides a constant to capture our env variable "no_proxy"
75
- ImportProxyNoProxy = "no_proxy"
76
- // ImporterProxyCertDirVar provides a constant to capture our env variable "IMPORTER_PROXY_CERT_DIR"
77
- ImporterProxyCertDirVar = "IMPORTER_PROXY_CERT_DIR"
78
- // ImporterExtraHeader provides a constant to include extra HTTP headers, as the prefix to a format string
79
- ImporterExtraHeader = "IMPORTER_EXTRA_HEADER_"
80
- // ImporterSecretExtraHeadersDir is where the secrets containing extra HTTP headers will be mounted
81
- ImporterSecretExtraHeadersDir = "/extraheaders"
82
-
83
- // ImporterDestinationAuthConfigDir is a mount directory for auth Secret.
84
- ImporterDestinationAuthConfigDir = "/dvcr-auth"
85
- // ImporterDestinationAuthConfigVar is an environment variable with auth config file for Importer Pod.
86
- ImporterDestinationAuthConfigVar = "IMPORTER_DESTINATION_AUTH_CONFIG"
87
- // ImporterDestinationAuthConfigFile is a path to auth config file in mount directory.
88
- ImporterDestinationAuthConfigFile = "/dvcr-auth/.dockerconfigjson"
89
- // DestinationInsecureTLSVar is an environment variable for Importer Pod that defines whether DVCR is insecure.
90
- DestinationInsecureTLSVar = "DESTINATION_INSECURE_TLS"
91
- ImporterSHA256Sum = "IMPORTER_SHA256SUM"
92
- ImporterMD5Sum = "IMPORTER_MD5SUM"
93
- ImporterAuthConfigVar = "IMPORTER_AUTH_CONFIG"
94
- ImporterAuthConfigDir = "/dvcr-src-auth"
95
- ImporterAuthConfigFile = "/dvcr-src-auth/.dockerconfigjson"
96
- ImporterDestinationEndpoint = "IMPORTER_DESTINATION_ENDPOINT"
97
-
98
- UploaderDestinationEndpoint = "UPLOADER_DESTINATION_ENDPOINT"
99
- UploaderDestinationAuthConfigVar = "UPLOADER_DESTINATION_AUTH_CONFIG"
100
- UploaderExtraHeader = "UPLOADER_EXTRA_HEADER_"
101
- UploaderDestinationAuthConfigDir = "/dvcr-auth"
102
- UploaderDestinationAuthConfigFile = "/dvcr-auth/.dockerconfigjson"
103
- UploaderSecretExtraHeadersDir = "/extraheaders"
104
-
105
- DockerRegistrySchemePrefix = "docker://"
106
-
107
- VmBlockDeviceAttachedLimit = 16
19
+ import (
20
+ "errors"
21
+ "strings"
22
+ )
108
23
109
- CmpLesser = - 1
110
- CmpEqual = 0
111
- CmpGreater = 1
24
+ var (
25
+ // ErrUnknownValue is a variable of type `error` that represents an error message indicating an unknown value.
26
+ ErrUnknownValue = errors .New ("unknown value" )
27
+ // ErrUnknownType is a variable of type `error` that represents an error message indicating an unknown type.
28
+ ErrUnknownType = errors .New ("unknown type" )
112
29
)
30
+
31
+ // ErrQuotaExceeded checked is the error is of exceeded quota
32
+ func ErrQuotaExceeded (err error ) bool {
33
+ return strings .Contains (err .Error (), "exceeded quota:" )
34
+ }
35
+
36
+ func BoolFloat64 (b bool ) float64 {
37
+ if b {
38
+ return 1
39
+ }
40
+ return 0
41
+ }
0 commit comments