mirror of
https://github.com/Quiq/docker-registry-ui.git
synced 2025-07-18 16:21:24 +00:00
Merge pull request #13 from Area128/master
Allow reading password from file so that docker secrets can be used
This commit is contained in:
commit
7525e87c1a
@ -12,8 +12,11 @@ verify_tls: true
|
||||
# They need to have a full access to the registry.
|
||||
# If token authentication service is enabled, it will be auto-discovered and those credentials
|
||||
# will be used to obtain access tokens.
|
||||
# When the registry_password_file entry is used, the password can be passed as a docker secret
|
||||
# and read from file. This overides the registry_password entry.
|
||||
registry_username: user
|
||||
registry_password: pass
|
||||
# registry_password_file: /run/secrets/registry_password_file
|
||||
|
||||
# Event listener token.
|
||||
# The same one should be configured on Docker registry as Authorization Bearer token.
|
||||
|
12
main.go
12
main.go
@ -26,6 +26,7 @@ type configData struct {
|
||||
VerifyTLS bool `yaml:"verify_tls"`
|
||||
Username string `yaml:"registry_username"`
|
||||
Password string `yaml:"registry_password"`
|
||||
PasswordFile string `yaml:"registry_password_file"`
|
||||
EventListenerToken string `yaml:"event_listener_token"`
|
||||
EventRetentionDays int `yaml:"event_retention_days"`
|
||||
EventDatabaseDriver string `yaml:"event_database_driver"`
|
||||
@ -86,6 +87,17 @@ func main() {
|
||||
a.config.BasePath = a.config.BasePath[0 : len(a.config.BasePath)-1]
|
||||
}
|
||||
}
|
||||
// Read password from file.
|
||||
if a.config.PasswordFile != "" {
|
||||
if _, err := os.Stat(a.config.PasswordFile); os.IsNotExist(err) {
|
||||
panic(err)
|
||||
}
|
||||
passwordBytes, err := ioutil.ReadFile(a.config.PasswordFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
a.config.Password = string(passwordBytes[:])
|
||||
}
|
||||
|
||||
// Init registry API client.
|
||||
a.client = registry.NewClient(a.config.RegistryURL, a.config.VerifyTLS, a.config.Username, a.config.Password)
|
||||
|
Loading…
Reference in New Issue
Block a user