@@ -660,8 +660,8 @@ func resolveEnvironment(serviceConfig *types.ServiceConfig, workingDir string, l
660660 return nil
661661}
662662
663- func resolveVolumePath ( volume types. ServiceVolumeConfig , workingDir string , lookupEnv template.Mapping ) types. ServiceVolumeConfig {
664- filePath := expandUser (volume . Source , lookupEnv )
663+ func resolveMaybeUnixPath ( path string , workingDir string , lookupEnv template.Mapping ) string {
664+ filePath := expandUser (path , lookupEnv )
665665 // Check if source is an absolute path (either Unix or Windows), to
666666 // handle a Windows client with a Unix daemon or vice-versa.
667667 //
@@ -671,10 +671,21 @@ func resolveVolumePath(volume types.ServiceVolumeConfig, workingDir string, look
671671 if ! paths .IsAbs (filePath ) && ! isAbs (filePath ) {
672672 filePath = absPath (workingDir , filePath )
673673 }
674- volume .Source = filePath
674+ return filePath
675+ }
676+
677+ func resolveVolumePath (volume types.ServiceVolumeConfig , workingDir string , lookupEnv template.Mapping ) types.ServiceVolumeConfig {
678+ volume .Source = resolveMaybeUnixPath (volume .Source , workingDir , lookupEnv )
675679 return volume
676680}
677681
682+ func resolveSecretsPath (secret types.SecretConfig , workingDir string , lookupEnv template.Mapping ) types.SecretConfig {
683+ if ! secret .External .External && secret .File != "" {
684+ secret .File = resolveMaybeUnixPath (secret .File , workingDir , lookupEnv )
685+ }
686+ return secret
687+ }
688+
678689// TODO: make this more robust
679690func expandUser (path string , lookupEnv template.Mapping ) string {
680691 if strings .HasPrefix (path , "~" ) {
@@ -782,11 +793,14 @@ func LoadSecrets(source map[string]interface{}, details types.ConfigDetails, res
782793 return secrets , err
783794 }
784795 for name , secret := range secrets {
785- obj , err := loadFileObjectConfig (name , "secret" , types .FileObjectConfig (secret ), details , resolvePaths )
796+ obj , err := loadFileObjectConfig (name , "secret" , types .FileObjectConfig (secret ), details , false )
786797 if err != nil {
787798 return nil , err
788799 }
789800 secretConfig := types .SecretConfig (obj )
801+ if resolvePaths {
802+ secretConfig = resolveSecretsPath (secretConfig , details .WorkingDir , details .LookupEnv )
803+ }
790804 secrets [name ] = secretConfig
791805 }
792806 return secrets , nil
0 commit comments