AdditionalSupport for SubPath volume mounts
Add support for inspecting Mounts which include SubPaths. Handle SubPaths for kubernetes image volumes. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
		
							parent
							
								
									c0e24c6b60
								
							
						
					
					
						commit
						6346a11b09
					
				| 
						 | 
				
			
			@ -258,6 +258,7 @@ func (c *Container) GetMounts(namedVolumes []*ContainerNamedVolume, imageVolumes
 | 
			
		|||
		mountStruct.Type = "volume"
 | 
			
		||||
		mountStruct.Destination = volume.Dest
 | 
			
		||||
		mountStruct.Name = volume.Name
 | 
			
		||||
		mountStruct.SubPath = volume.SubPath
 | 
			
		||||
 | 
			
		||||
		// For src and driver, we need to look up the named
 | 
			
		||||
		// volume.
 | 
			
		||||
| 
						 | 
				
			
			@ -284,6 +285,7 @@ func (c *Container) GetMounts(namedVolumes []*ContainerNamedVolume, imageVolumes
 | 
			
		|||
		mountStruct.Destination = volume.Dest
 | 
			
		||||
		mountStruct.Source = volume.Source
 | 
			
		||||
		mountStruct.RW = volume.ReadWrite
 | 
			
		||||
		mountStruct.SubPath = volume.SubPath
 | 
			
		||||
 | 
			
		||||
		inspectMounts = append(inspectMounts, mountStruct)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -285,6 +285,9 @@ type InspectMount struct {
 | 
			
		|||
	// Mount propagation for the mount. Can be empty if not specified, but
 | 
			
		||||
	// is always printed - no omitempty.
 | 
			
		||||
	Propagation string `json:"Propagation"`
 | 
			
		||||
	// SubPath object from the volume. Specified as a path within
 | 
			
		||||
	// the source volume to be mounted at the Destination.
 | 
			
		||||
	SubPath string `json:"SubPath,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InspectContainerState provides a detailed record of a container's current
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -575,7 +575,7 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
 | 
			
		|||
				Destination: volume.MountPath,
 | 
			
		||||
				ReadWrite:   false,
 | 
			
		||||
				Source:      volumeSource.Source,
 | 
			
		||||
				SubPath:     "",
 | 
			
		||||
				SubPath:     volume.SubPath,
 | 
			
		||||
			}
 | 
			
		||||
			s.ImageVolumes = append(s.ImageVolumes, &imageVolume)
 | 
			
		||||
		default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -148,6 +148,14 @@ load helpers
 | 
			
		|||
    run_podman run --rm --mount "${mountopts},readwrite=true" $iname \
 | 
			
		||||
               touch /image-mount/readwrite
 | 
			
		||||
 | 
			
		||||
    tmpctr="c-$(safename)"
 | 
			
		||||
    subpathopts="type=image,src=$iname,dst=/image-mount,subpath=/etc"
 | 
			
		||||
    run_podman run --name $tmpctr --mount "${subpathopts}" $iname \
 | 
			
		||||
               ls /image-mount/shadow
 | 
			
		||||
    run_podman inspect $tmpctr --format '{{ (index .Mounts 0).SubPath }}'
 | 
			
		||||
    assert "$output" == "/etc" "SubPath contains /etc"
 | 
			
		||||
    run_podman rm $tmpctr
 | 
			
		||||
 | 
			
		||||
    # The rest of the tests below are meaningless under remote
 | 
			
		||||
    if is_remote; then
 | 
			
		||||
        run_podman rmi $iname
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue