@@ -401,7 +401,6 @@ func (n *NginxBinaryType) WriteConfig(config *proto.NginxConfig) (*sdk.ConfigApp
401
401
var configApply * sdk.ConfigApply
402
402
403
403
filesToUpdate , filesToDelete , allFilesHaveAnAction := generateActionMaps (config .DirectoryMap , n .config .AllowedDirectoriesMap )
404
-
405
404
if allFilesHaveAnAction {
406
405
configApply , err = n .writeConfigWithWithFileActions (config , details , filesToUpdate , filesToDelete )
407
406
} else {
@@ -486,7 +485,12 @@ func (n *NginxBinaryType) writeConfigWithNoFileActions(details *proto.NginxDetai
486
485
return configApply , nil
487
486
}
488
487
489
- func (n * NginxBinaryType ) writeConfigWithWithFileActions (config * proto.NginxConfig , details * proto.NginxDetails , filesToUpdate map [string ]proto.File_Action , filesToDelete map [string ]proto.File_Action ) (* sdk.ConfigApply , error ) {
488
+ func (n * NginxBinaryType ) writeConfigWithWithFileActions (
489
+ config * proto.NginxConfig ,
490
+ details * proto.NginxDetails ,
491
+ filesToUpdate map [string ]proto.File_Action ,
492
+ filesToDelete map [string ]proto.File_Action ,
493
+ ) (* sdk.ConfigApply , error ) {
490
494
confFiles , auxFiles , err := sdk .GetNginxConfigFiles (config )
491
495
if err != nil {
492
496
return nil , err
@@ -500,29 +504,34 @@ func (n *NginxBinaryType) writeConfigWithWithFileActions(config *proto.NginxConf
500
504
501
505
for _ , file := range confFiles {
502
506
rootDirectoryPath := filepath .Dir (details .ConfPath )
503
- if _ , found := filesToUpdate [ file .Name ]; ! found {
504
- log . Debugf ( "No action found for config file %s." , file . Name )
505
- continue
507
+ fileFullPath := file .Name
508
+ if ! filepath . IsAbs ( fileFullPath ) {
509
+ fileFullPath = filepath . Join ( rootDirectoryPath , fileFullPath )
506
510
}
507
-
508
- delete (filesToUpdate , file .Name )
509
-
510
- if err := n .env .WriteFile (configApply , file , rootDirectoryPath ); err != nil {
511
+ if _ , found := filesToUpdate [fileFullPath ]; ! found {
512
+ log .Warnf ("No action found for config file %s, assume update." ,
513
+ fileFullPath )
514
+ }
515
+ delete (filesToUpdate , fileFullPath )
516
+ if err = n .env .WriteFile (configApply , file , rootDirectoryPath ); err != nil {
511
517
log .Warnf ("configuration write failed: %s" , err )
512
518
return configApply , err
513
519
}
514
520
}
515
521
516
522
for _ , file := range auxFiles {
517
523
rootDirectoryPath := config .GetZaux ().GetRootDirectory ()
518
- if _ , found := filesToUpdate [file .Name ]; ! found {
519
- log .Debugf ("No action found for aux file %s." , file .Name )
524
+ fileFullPath := file .Name
525
+ if ! filepath .IsAbs (fileFullPath ) {
526
+ fileFullPath = filepath .Join (rootDirectoryPath , fileFullPath )
527
+ }
528
+ if _ , found := filesToUpdate [fileFullPath ]; ! found {
529
+ log .Debugf ("No action found for aux file %s." , fileFullPath )
520
530
continue
521
531
}
522
532
523
- delete (filesToUpdate , file .Name )
524
-
525
- if err := n .env .WriteFile (configApply , file , rootDirectoryPath ); err != nil {
533
+ delete (filesToUpdate , fileFullPath )
534
+ if err = n .env .WriteFile (configApply , file , rootDirectoryPath ); err != nil {
526
535
log .Warnf ("configuration write failed: %s" , err )
527
536
return configApply , err
528
537
}
@@ -617,7 +626,6 @@ func generateActionMaps(
617
626
filesToDelete [path ] = f .Action
618
627
continue
619
628
}
620
-
621
629
}
622
630
}
623
631
0 commit comments