11package main
22
33import (
4+ "fmt"
45 "io/ioutil"
56 "log"
67 "os"
78 "os/exec"
89)
910
1011const (
11- registryBinary = "/bin/registry"
12- registryConfig = "/etc/docker/registry/config.yml"
12+ registryBinary = "/bin/registry"
13+ registryConfig = "/etc/docker/registry/config.yml"
14+ minioHostEnvVar = "DEIS_MINIO_SERVICE_HOST"
15+ minioPortEnvVar = "DEIS_MINIO_SERVICE_PORT"
1316)
1417
1518func main () {
1619 log .Println ("INFO: Starting registry..." )
1720 storageType := getenv ("REGISTRY_STORAGE" , "filesystem" )
1821 if storageType == "gcs" {
22+ log .Println ("INFO: using google cloud storage as the backend" )
1923 if _ , err := os .Stat ("/var/run/secrets/deis/registry/creds/key.json" ); err != nil {
2024 log .Fatal ("Service account not given" )
2125 }
@@ -25,7 +29,8 @@ func main() {
2529 } else {
2630 os .Setenv ("REGISTRY_STORAGE_GCS_BUCKET" , string (bucket ))
2731 }
28- } else if storageType == "generic" {
32+ } else if storageType == "s3" {
33+ log .Println ("INFO: using s3 as the backend" )
2934 if accesskey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/accesskey" ); err != nil {
3035 log .Fatal (err )
3136 } else {
@@ -50,6 +55,7 @@ func main() {
5055 os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , string (bucket ))
5156 }
5257 } else if storageType == "azure" {
58+ log .Println ("INFO: using azure as the backend" )
5359 if accountname , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/accountname" ); err != nil {
5460 log .Fatal (err )
5561 } else {
@@ -68,6 +74,29 @@ func main() {
6874 os .Setenv ("REGISTRY_STORAGE_AZURE_CONTAINER" , string (container ))
6975 }
7076
77+ } else if storageType == "minio" {
78+ log .Println ("INFO: using minio as the backend" )
79+ mHost := os .Getenv (minioHostEnvVar )
80+ mPort := os .Getenv (minioPortEnvVar )
81+ os .Setenv ("REGISTRY_STORAGE" , "s3" )
82+ os .Setenv ("REGISTRY_STORAGE_S3_BACKEND" , "minio" )
83+ os .Setenv ("REGISTRY_STORAGE_S3_REGIONENDPOINT" , fmt .Sprintf ("http://%s:%s" , mHost , mPort ))
84+
85+ if accesskey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/access-key-id" ); err != nil {
86+ log .Fatal (err )
87+ } else {
88+ os .Setenv ("REGISTRY_STORAGE_S3_ACCESSKEY" , string (accesskey ))
89+ }
90+
91+ if secretkey , err := ioutil .ReadFile ("/var/run/secrets/deis/registry/creds/access-secret-key" ); err != nil {
92+ log .Fatal (err )
93+ } else {
94+ os .Setenv ("REGISTRY_STORAGE_S3_SECRETKEY" , string (secretkey ))
95+ }
96+
97+ os .Setenv ("REGISTRY_STORAGE_S3_REGION" , "us-east-1" )
98+ os .Setenv ("REGISTRY_STORAGE_S3_BUCKET" , "registry" )
99+
71100 }
72101
73102 cmd := exec .Command (registryBinary , registryConfig )
0 commit comments