feat: add env to skip installation #357

This commit is contained in:
Jacky 2024-05-06 21:45:16 +08:00
parent cb0fb47e1c
commit 13c4eb04a3
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
5 changed files with 22 additions and 1 deletions

View file

@ -20,6 +20,7 @@ type Server struct {
GithubProxy string `json:"github_proxy" binding:"omitempty,url"`
CertRenewalInterval int `json:"cert_renewal_interval" binding:"min=7,max=21"`
RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
SkipInstallation bool `json:"skip_installation"`
}
func (s *Server) GetCADir() string {

View file

@ -25,6 +25,7 @@ func TestSetup(t *testing.T) {
_ = os.Setenv("NGINX_UI_SERVER_HTTP_HOST", "127.0.0.1")
_ = os.Setenv("NGINX_UI_SERVER_CERT_RENEWAL_INTERVAL", "14")
_ = os.Setenv("NGINX_UI_SERVER_RECURSIVE_NAMESERVERS", "8.8.8.8")
_ = os.Setenv("NGINX_UI_SERVER_SKIP_INSTALLATION", "true")
_ = os.Setenv("NGINX_UI_NGINX_ACCESS_LOG_PATH", "/tmp/nginx/access.log")
_ = os.Setenv("NGINX_UI_NGINX_ERROR_LOG_PATH", "/tmp/nginx/error.log")
@ -67,6 +68,7 @@ func TestSetup(t *testing.T) {
assert.Equal(t, "127.0.0.1", ServerSettings.HttpHost)
assert.Equal(t, 14, ServerSettings.CertRenewalInterval)
assert.Equal(t, []string{"8.8.8.8"}, ServerSettings.RecursiveNameservers)
assert.Equal(t, true, ServerSettings.SkipInstallation)
assert.Equal(t, "/tmp/nginx/access.log", NginxSettings.AccessLogPath)
assert.Equal(t, "/tmp/nginx/error.log", NginxSettings.ErrorLogPath)

8
settings/user.go Normal file
View file

@ -0,0 +1,8 @@
package settings
type PredefinedUser struct {
User string `json:"user"`
Password string `json:"password"`
}
var PredefinedUserSettings = &PredefinedUser{}