mirror of
https://github.com/containers/podman.git
synced 2025-08-24 10:04:57 +08:00
Merge pull request #26124 from Luap99/nilness
fix issues found by nilness
This commit is contained in:
@ -64,9 +64,6 @@ func prune(cmd *cobra.Command, args []string) error {
|
||||
if !force {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
fmt.Println("WARNING! This will remove all volumes not used by at least one container. The following volumes will be removed:")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listOptions.Filter, err = parse.FilterArgumentsIntoFilters(filter)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -901,25 +901,19 @@ func (c *Container) resolveWorkDir() error {
|
||||
if !c.config.CreateWorkingDir {
|
||||
// No need to create it (e.g., `--workdir=/foo`), so let's make sure
|
||||
// the path exists on the container.
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// If resolved Workdir path gets marked as a valid symlink,
|
||||
// return nil cause this is valid use-case.
|
||||
if c.isWorkDirSymlink(resolvedWorkdir) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("workdir %q does not exist on container %s", workdir, c.ID())
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
// If resolved Workdir path gets marked as a valid symlink,
|
||||
// return nil cause this is valid use-case.
|
||||
if c.isWorkDirSymlink(resolvedWorkdir) {
|
||||
return nil
|
||||
}
|
||||
// This might be a serious error (e.g., permission), so
|
||||
// we need to return the full error.
|
||||
return fmt.Errorf("detecting workdir %q on container %s: %w", workdir, c.ID(), err)
|
||||
return fmt.Errorf("workdir %q does not exist on container %s", workdir, c.ID())
|
||||
}
|
||||
return nil
|
||||
// This might be a serious error (e.g., permission), so
|
||||
// we need to return the full error.
|
||||
return fmt.Errorf("detecting workdir %q on container %s: %w", workdir, c.ID(), err)
|
||||
}
|
||||
if err := os.MkdirAll(resolvedWorkdir, 0755); err != nil {
|
||||
if os.IsExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("creating container %s workdir: %w", c.ID(), err)
|
||||
}
|
||||
|
||||
@ -1192,7 +1186,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
|
||||
return fmt.Errorf("exporting root file-system diff for %q: %w", c.ID(), err)
|
||||
}
|
||||
|
||||
addToTarFiles, err := crutils.CRCreateRootFsDiffTar(&rootFsChanges, c.state.Mountpoint, c.bundlePath())
|
||||
addToTarFiles, err = crutils.CRCreateRootFsDiffTar(&rootFsChanges, c.state.Mountpoint, c.bundlePath())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -90,11 +90,7 @@ func (r *Runtime) NewPod(ctx context.Context, p specgen.PodSpecGenerator, option
|
||||
break
|
||||
}
|
||||
}
|
||||
if addPodErr != nil {
|
||||
return nil, fmt.Errorf("adding pod to state: %w", addPodErr)
|
||||
}
|
||||
|
||||
return pod, nil
|
||||
return nil, fmt.Errorf("adding pod to state: %w", addPodErr)
|
||||
}
|
||||
|
||||
// AddInfra adds the created infra container to the pod state
|
||||
|
@ -785,7 +785,7 @@ func (ir *ImageEngine) Scp(ctx context.Context, src, dst string, opts entities.I
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if (report.LoadReport == nil && err == nil) && (report.Source != nil && report.Dest != nil) { // we need to execute the transfer
|
||||
if report.LoadReport == nil && (report.Source != nil && report.Dest != nil) { // we need to execute the transfer
|
||||
transferOpts := entities.ScpTransferOptions{}
|
||||
transferOpts.ParentFlags = report.ParentFlags
|
||||
_, err := Transfer(ctx, *report.Source, *report.Dest, transferOpts)
|
||||
|
@ -35,9 +35,6 @@ func GetLocalBlob(ctx context.Context, path string) (*types.BlobInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
blobs := img.LayerInfos()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(blobs) != 1 {
|
||||
return nil, errors.New("invalid disk image")
|
||||
}
|
||||
|
Reference in New Issue
Block a user