Don't force debug to true in config file when set via flag
This commit is contained in:
		
							parent
							
								
									536038967a
								
							
						
					
					
						commit
						a8e907a0fc
					
				| 
						 | 
					@ -250,12 +250,17 @@ func ReadConfiguration(path string) (*Configuration, error) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var _config *Configuration
 | 
					var _config *Configuration
 | 
				
			||||||
 | 
					var _debugViaFlag bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Set the global configuration instance.
 | 
					// Set the global configuration instance.
 | 
				
			||||||
func Set(c *Configuration) {
 | 
					func Set(c *Configuration) {
 | 
				
			||||||
	_config = c
 | 
						_config = c
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func SetDebugViaFlag(d bool) {
 | 
				
			||||||
 | 
						_debugViaFlag = d
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Get the global configuration instance.
 | 
					// Get the global configuration instance.
 | 
				
			||||||
func Get() *Configuration {
 | 
					func Get() *Configuration {
 | 
				
			||||||
	return _config
 | 
						return _config
 | 
				
			||||||
| 
						 | 
					@ -383,7 +388,14 @@ func (c *Configuration) WriteToDisk() error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	defer f.Close()
 | 
						defer f.Close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	b, err := yaml.Marshal(&c)
 | 
						ccopy := *c
 | 
				
			||||||
 | 
						// If debugging is set with the flag, don't save that to the configuration file, otherwise
 | 
				
			||||||
 | 
						// you'll always end up in debug mode.
 | 
				
			||||||
 | 
						if _debugViaFlag {
 | 
				
			||||||
 | 
							ccopy.Debug = false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						b, err := yaml.Marshal(&ccopy)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										8
									
								
								wings.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								wings.go
									
									
									
									
									
								
							| 
						 | 
					@ -15,11 +15,14 @@ import (
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var configPath = "config.yml"
 | 
				
			||||||
 | 
					var debug = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Entrypoint for the Wings application. Configures the logger and checks any
 | 
					// Entrypoint for the Wings application. Configures the logger and checks any
 | 
				
			||||||
// flags that were passed through in the boot arguments.
 | 
					// flags that were passed through in the boot arguments.
 | 
				
			||||||
func main() {
 | 
					func main() {
 | 
				
			||||||
	var configPath = *flag.String("config", "config.yml", "set the location for the configuration file")
 | 
						flag.StringVar(&configPath, "config", "config.yml", "set the location for the configuration file")
 | 
				
			||||||
	var debug = *flag.Bool("debug", false, "pass in order to run wings in debug mode")
 | 
						flag.BoolVar(&debug, "debug", false, "pass in order to run wings in debug mode")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +52,7 @@ func main() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config.Set(c)
 | 
						config.Set(c)
 | 
				
			||||||
 | 
						config.SetDebugViaFlag(debug)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	zap.S().Infof("checking for pterodactyl system user \"%s\"", c.System.User)
 | 
						zap.S().Infof("checking for pterodactyl system user \"%s\"", c.System.User)
 | 
				
			||||||
	if su, err := c.EnsurePterodactylUser(); err != nil {
 | 
						if su, err := c.EnsurePterodactylUser(); err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user