@@ -29,31 +29,36 @@ func main() {
2929 log .Fatal (err )
3030 } else {
3131 os .Setenv ("REGISTRY_STORAGE_GCS_BUCKET" , string (bucket ))
32+ os .Setenv ("BUCKET_NAME" , string (bucket ))
3233 }
3334 } else if storageType == "s3" {
3435 log .Println ("INFO: using s3 as the backend" )
3536 if accesskey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/accesskey" ); err != nil {
3637 log .Fatal (err )
3738 } else {
3839 os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
40+ os .Setenv ("AWS_ACCESS_KEY_ID" , string (accesskey ))
3941 }
4042
4143 if secretkey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/secretkey" ); err != nil {
4244 log .Fatal (err )
4345 } else {
4446 os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
47+ os .Setenv ("AWS_SECRET_ACCESS_KEY" , string (secretkey ))
4548 }
4649
4750 if region , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/region" ); err != nil {
4851 log .Fatal (err )
4952 } else {
5053 os .Setenv ("REGISTRY_STORAGE_S3_REGION" , string (region ))
54+ os .Setenv ("AWS_REGION" , string (region ))
5155 }
5256
5357 if bucket , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/registry-bucket" ); err != nil {
5458 log .Fatal (err )
5559 } else {
5660 os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string (bucket ))
61+ os .Setenv ("BUCKET_NAME" , string (bucket ))
5762 }
5863 } else if storageType == "azure" {
5964 log .Println ("INFO: using azure as the backend" )
@@ -73,6 +78,7 @@ func main() {
7378 log .Fatal (err )
7479 } else {
7580 os .Setenv ("REGISTRY_STORAGE_AZURE_CONTAINER" , string (container ))
81+ os .Setenv ("BUCKET_NAME" , string (container ))
7682 }
7783
7884 } else if storageType == "minio" {
@@ -82,21 +88,29 @@ func main() {
8288 os .Setenv ("REGISTRY_STORAGE" , "s3" )
8389 os .Setenv ("REGISTRY_STORAGE_S3_BACKEND" , "minio" )
8490 os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s:%s" , mHost , mPort ))
91+ // NOTE(bacongobbler): custom envvars used in /bin/create-bucket
92+ os .Setenv ("S3_HOST" , mHost )
93+ os .Setenv ("S3_PORT" , mPort )
94+ os .Setenv ("S3_USE_SIGV4" , "true" )
8595
8696 if accesskey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/accesskey" ); err != nil {
8797 log .Fatal (err )
8898 } else {
8999 os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
100+ os .Setenv ("AWS_ACCESS_KEY_ID" , string (accesskey ))
90101 }
91102
92103 if secretkey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/secretkey" ); err != nil {
93104 log .Fatal (err )
94105 } else {
95106 os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
107+ os .Setenv ("AWS_SECRET_ACCESS_KEY" , string (secretkey ))
96108 }
97109
98110 os .Setenv ("REGISTRY_STORAGE_S3_REGION" , "us-east-1" )
111+ os .Setenv ("AWS_REGION" , "us-east-1" )
99112 os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , "registry" )
113+ os .Setenv ("BUCKET_NAME" , "registry" )
100114
101115 } else if storageType == "swift" {
102116 log .Println ("INFO: using swift as the backend" )
@@ -138,11 +152,19 @@ func main() {
138152
139153 }
140154
141- cmd := exec .Command (registryBinary , command , registryConfig )
155+ // run /bin/create-bucket
156+ cmd := exec .Command ("/bin/create-bucket" )
142157 cmd .Stdout = os .Stdout
143158 cmd .Stderr = os .Stderr
144159 if err := cmd .Run (); err != nil {
145- log .Fatal ("Error starting the registry" , err )
160+ log .Fatal ("Error creating the registry bucket: " , err )
161+ }
162+
163+ cmd = exec .Command (registryBinary , command , registryConfig )
164+ cmd .Stdout = os .Stdout
165+ cmd .Stderr = os .Stderr
166+ if err := cmd .Run (); err != nil {
167+ log .Fatal ("Error starting the registry: " , err )
146168 }
147169 log .Println ("INFO: registry started." )
148170}
0 commit comments