@@ -18,147 +18,32 @@ const (
1818
1919func main () {
2020 log .Println ("INFO: Starting registry..." )
21- storageType := getenv ("REGISTRY_STORAGE" , "filesystem" )
22- if storageType == "gcs" {
23- log .Println ("INFO: using google cloud storage as the backend" )
24- if _ , err := os .Stat ("/var/run/secrets/drycc/registry/creds/key.json" ); err != nil {
25- log .Fatal ("Service account not given" )
26- }
27- os .Setenv ("REGISTRY_STORAGE_GCS_KEYFILE" , "/var/run/secrets/drycc/registry/creds/key.json" )
28- if bucket , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/registry-bucket" ); err != nil {
29- log .Fatal (err )
30- } else {
31- os .Setenv ("REGISTRY_STORAGE_GCS_BUCKET" , string (bucket ))
32- os .Setenv ("BUCKET_NAME" , string (bucket ))
33- }
34- } else if storageType == "s3" {
35- log .Println ("INFO: using s3 as the backend" )
36- if accesskey , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/accesskey" ); err != nil {
37- log .Fatal (err )
38- } else {
39- os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
40- if len (accesskey ) != 0 {
41- os .Setenv ("AWS_ACCESS_KEY_ID" , string (accesskey ))
42- }
43- }
44-
45- if secretkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/secretkey" ); err != nil {
46- log .Fatal (err )
47- } else {
48- os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
49- if len (secretkey ) != 0 {
50- os .Setenv ("AWS_SECRET_ACCESS_KEY" , string (secretkey ))
51- }
52- }
53-
54- if region , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/region" ); err != nil {
55- log .Fatal (err )
56- } else {
57- os .Setenv ("REGISTRY_STORAGE_S3_REGION" , string (region ))
58- os .Setenv ("AWS_REGION" , string (region ))
59- }
60-
61- if bucket , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/registry-bucket" ); err != nil {
62- log .Fatal (err )
63- } else {
64- os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string (bucket ))
65- os .Setenv ("BUCKET_NAME" , string (bucket ))
66- }
67- } else if storageType == "azure" {
68- log .Println ("INFO: using azure as the backend" )
69- if accountname , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/accountname" ); err != nil {
70- log .Fatal (err )
71- } else {
72- os .Setenv ("REGISTRY_STORAGE_AZURE_ACCOUNTNAME" , string (accountname ))
73- }
74-
75- if accountkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/accountkey" ); err != nil {
76- log .Fatal (err )
77- } else {
78- os .Setenv ("REGISTRY_STORAGE_AZURE_ACCOUNTKEY" , string (accountkey ))
79- }
80-
81- if container , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/registry-container" ); err != nil {
82- log .Fatal (err )
83- } else {
84- os .Setenv ("REGISTRY_STORAGE_AZURE_CONTAINER" , string (container ))
85- os .Setenv ("BUCKET_NAME" , string (container ))
86- }
87-
88- } else if storageType == "minio" {
89- log .Println ("INFO: using minio as the backend" )
90- mHost := os .Getenv (minioHostEnvVar )
91- mPort := os .Getenv (minioPortEnvVar )
92- os .Setenv ("REGISTRY_STORAGE" , "s3" )
93- os .Setenv ("REGISTRY_STORAGE_S3_BACKEND" , "minio" )
94- os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s:%s" , mHost , mPort ))
95- // NOTE(bacongobbler): custom envvars used in /bin/create-bucket
96- os .Setenv ("S3_HOST" , mHost )
97- os .Setenv ("S3_PORT" , mPort )
98- os .Setenv ("S3_USE_SIGV4" , "true" )
99-
100- if accesskey , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/accesskey" ); err != nil {
101- log .Fatal (err )
102- } else {
103- os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
104- os .Setenv ("AWS_ACCESS_KEY_ID" , string (accesskey ))
105- }
106-
107- if secretkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/secretkey" ); err != nil {
108- log .Fatal (err )
109- } else {
110- os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
111- os .Setenv ("AWS_SECRET_ACCESS_KEY" , string (secretkey ))
112- }
113-
114- os .Setenv ("REGISTRY_STORAGE_S3_REGION" , "us-east-1" )
115- os .Setenv ("AWS_REGION" , "us-east-1" )
116- os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , "registry" )
117- os .Setenv ("BUCKET_NAME" , "registry" )
118-
119- } else if storageType == "swift" {
120- log .Println ("INFO: using swift as the backend" )
121- if authurl , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/authurl" ); err != nil {
122- log .Fatal (err )
123- } else {
124- os .Setenv ("REGISTRY_STORAGE_SWIFT_AUTHURL" , string (authurl ))
125- }
126-
127- if username , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/username" ); err != nil {
128- log .Fatal (err )
129- } else {
130- os .Setenv ("REGISTRY_STORAGE_SWIFT_USERNAME" , string (username ))
131- }
132-
133- if password , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/password" ); err != nil {
134- log .Fatal (err )
135- } else {
136- os .Setenv ("REGISTRY_STORAGE_SWIFT_PASSWORD" , string (password ))
137- }
138-
139- if container , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/registry-container" ); err != nil {
140- log .Fatal (err )
141- } else {
142- os .Setenv ("REGISTRY_STORAGE_SWIFT_CONTAINER" , string (container ))
143- os .Setenv ("BUCKET_NAME" , string (container ))
144- }
145-
146- if authVersion , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/authversion" ); err != nil {
147- log .Fatal (err )
148- } else {
149- os .Setenv ("REGISTRY_STORAGE_SWIFT_AUTHVERSION" , string (authVersion ))
150- }
151-
152- if tenant , err := ioutil .ReadFile ("/var/run/secrets/drycc/registry/creds/tenant" ); err != nil {
153- log .Fatal (err )
154- } else {
155- os .Setenv ("REGISTRY_STORAGE_SWIFT_TENANT" , string (tenant ))
156- }
21+ mHost := os .Getenv (minioHostEnvVar )
22+ mPort := os .Getenv (minioPortEnvVar )
23+ os .Setenv ("REGISTRY_STORAGE" , "s3" )
24+ os .Setenv ("REGISTRY_STORAGE_S3_BACKEND" , "minio" )
25+ os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s:%s" , mHost , mPort ))
26+
27+ if accesskey , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore/creds/accesskey" ); err != nil {
28+ log .Fatal (err )
29+ } else {
30+ os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
31+ }
15732
33+ if secretkey , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore/creds/secretkey" ); err != nil {
34+ log .Fatal (err )
35+ } else {
36+ os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
37+ }
38+ if bucket , err := ioutil .ReadFile ("/var/run/secrets/drycc/objectstore/creds/registry-bucket" ); err != nil {
39+ log .Fatal (err )
40+ } else {
41+ os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string (bucket ))
15842 }
43+ os .Setenv ("REGISTRY_STORAGE_S3_REGION" , "us-east-1" )
15944
160- // run /bin/create-bucket
161- cmd := exec .Command ("/bin/create-bucket " )
45+ // run /bin/create_bucket
46+ cmd := exec .Command ("/bin/create_bucket " )
16247 cmd .Stdout = os .Stdout
16348 cmd .Stderr = os .Stderr
16449 if err := cmd .Run (); err != nil {
0 commit comments