Add a --write and --diff flag; require --write to be set before making any changes, for safety
This commit is contained in:
@@ -76,7 +76,7 @@ type NginxTemplateData struct {
|
||||
ListenPort string
|
||||
}
|
||||
|
||||
func generateNginx(yamlFile string) {
|
||||
func generateNginx(yamlFile string, wantDiff bool, allowWrite bool, useColor bool) {
|
||||
config := loadConfig(yamlFile)
|
||||
|
||||
// Extract port from first listen address
|
||||
@@ -123,7 +123,7 @@ func generateNginx(yamlFile string) {
|
||||
}
|
||||
|
||||
// Write file with status
|
||||
err = writeFileWithStatus(outputPath, buf.Bytes())
|
||||
err = writeFileWithStatus(outputPath, buf.Bytes(), wantDiff, allowWrite, useColor)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write nginx config file %s: %v\n", outputPath, err)
|
||||
continue
|
||||
|
Reference in New Issue
Block a user