-
Notifications
You must be signed in to change notification settings - Fork 567
/
util.go
106 lines (93 loc) · 3.83 KB
/
util.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
97
98
99
100
101
102
103
104
105
106
package integrationtests
import (
"os"
"testing"
"github.com/pachyderm/pachyderm/v2/src/internal/require"
)
// The Load.*Parameters functions in this file are where we get the credentials
// for running object client tests. These are sourced from your environment
// variables. You can provide these yourself, or Pachyderm employees may use the
// variables defined in the password manager under the secure note "Pachyderm CI
// Object Storage Credentials". These should all be scoped to the smallest set
// of permissions necessary, which is just object create/read/delete within a
// specific bucket.
// LoadAmazonParameters loads the test parameters for S3 object storage:
//
// id - the key id credential
// secret - the key secret credential
// bucket - the S3 bucket to issue requests towards
// region - the S3 region that the bucket is in
func LoadAmazonParameters(t *testing.T) (string, string, string, string) {
id := os.Getenv("AMAZON_CLIENT_ID")
secret := os.Getenv("AMAZON_CLIENT_SECRET")
bucket := os.Getenv("AMAZON_CLIENT_BUCKET")
region := os.Getenv("AMAZON_CLIENT_REGION")
require.NotEqual(t, "", id)
require.NotEqual(t, "", secret)
require.NotEqual(t, "", bucket)
require.NotEqual(t, "", region)
return id, secret, bucket, region
}
// LoadECSParameters loads the test parameters for ECS object storage
// (credentials can be requested for a new account from portal.ecstestdrive.com):
//
// id - the key id credential
// secret - the key secret credential
// bucket - the ECS bucket to issue requests towards
// region - a dummy region - some clients require this but it is unused with 'endpoint'
// endpoint - the S3-compatible server to send requests to
func LoadECSParameters(t *testing.T) (string, string, string, string, string) {
id := os.Getenv("ECS_CLIENT_ID")
secret := os.Getenv("ECS_CLIENT_SECRET")
bucket := os.Getenv("ECS_CLIENT_BUCKET")
endpoint := os.Getenv("ECS_CLIENT_CUSTOM_ENDPOINT")
require.NotEqual(t, "", id)
require.NotEqual(t, "", secret)
require.NotEqual(t, "", bucket)
require.NotEqual(t, "", endpoint)
return id, secret, bucket, "dummy-region", endpoint
}
// LoadGoogleParameters loads the test parameters for GCS object storage:
//
// bucket - the GCS bucket to issue requests towards
// creds - the JSON GCP credentials to use
func LoadGoogleParameters(t *testing.T) (string, string) {
bucket := os.Getenv("GOOGLE_CLIENT_BUCKET")
creds := os.Getenv("GOOGLE_CLIENT_CREDS")
require.NotEqual(t, "", bucket)
require.NotEqual(t, "", creds)
return bucket, creds
}
// LoadGoogleHMACParameters loads the test parameters for GCS object storage,
// specifically for use with S3-compatible clients:
//
// id - the key id credential
// secret - the key secret credential
// bucket - the GCS bucket to issue requests towards
// region - the GCS region that the bucket is in
// endpoint - the S3-compatible server to send requests to
func LoadGoogleHMACParameters(t *testing.T) (string, string, string, string, string) {
id := os.Getenv("GOOGLE_CLIENT_HMAC_ID")
secret := os.Getenv("GOOGLE_CLIENT_HMAC_SECRET")
bucket := os.Getenv("GOOGLE_CLIENT_BUCKET")
region := os.Getenv("GOOGLE_CLIENT_REGION")
require.NotEqual(t, "", id)
require.NotEqual(t, "", secret)
require.NotEqual(t, "", bucket)
require.NotEqual(t, "", region)
return id, secret, bucket, region, "storage.googleapis.com"
}
// LoadMicrosoftParameters loads the test parameters for Azure blob storage:
//
// id - the key id credential
// secret - the key secret credential
// container - the Azure blob container to issue requests towards
func LoadMicrosoftParameters(t *testing.T) (string, string, string) {
id := os.Getenv("MICROSOFT_CLIENT_ID")
secret := os.Getenv("MICROSOFT_CLIENT_SECRET")
container := os.Getenv("MICROSOFT_CLIENT_CONTAINER")
require.NotEqual(t, "", id)
require.NotEqual(t, "", secret)
require.NotEqual(t, "", container)
return id, secret, container
}