mirror of
https://github.com/containers/podman.git
synced 2025-05-17 06:59:07 +08:00

The new golangci-lint version 1.60.1 has problems with typecheck when linting remote files. We have certain pakcages that should never be inlcuded in remote but the typecheck tries to compile all of them but this never works and it seems to ignore the exclude files we gave it. To fix this the proper way is to mark all packages we only use locally with !remote tags. This is a bit ugly but more correct. I also moved the DecodeChanges() code around as it is called from the client so the handles package which should only be remote doesn't really fit anyway. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
121 lines
3.8 KiB
Go
121 lines
3.8 KiB
Go
//go:build !remote
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/containers/common/pkg/completion"
|
|
"github.com/containers/podman/v5/cmd/podman/validate"
|
|
"github.com/containers/podman/v5/internal/domain/entities"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
removeStorageLayerDescription = `Remove an unmanaged layer in local storage, potentially corrupting it.`
|
|
removeStorageLayerCmd = &cobra.Command{
|
|
Use: "remove-storage-layer [options]",
|
|
Args: validate.NoArgs,
|
|
Short: "Remove an unmanaged layer",
|
|
Long: removeStorageLayerDescription,
|
|
RunE: removeStorageLayer,
|
|
ValidArgsFunction: completion.AutocompleteNone,
|
|
Example: `podman testing remove-storage-layer`,
|
|
}
|
|
|
|
removeStorageLayerOpts entities.RemoveStorageLayerOptions
|
|
|
|
removeLayerDescription = `Remove a layer in local storage, potentially corrupting it.`
|
|
removeLayerCmd = &cobra.Command{
|
|
Use: "remove-layer [options]",
|
|
Args: validate.NoArgs,
|
|
Short: "Remove a layer",
|
|
Long: removeLayerDescription,
|
|
RunE: removeLayer,
|
|
ValidArgsFunction: completion.AutocompleteNone,
|
|
Example: `podman testing remove-layer`,
|
|
}
|
|
|
|
removeLayerOpts entities.RemoveLayerOptions
|
|
|
|
removeImageDescription = `Remove an image in local storage, potentially corrupting it.`
|
|
removeImageCmd = &cobra.Command{
|
|
Use: "remove-image [options]",
|
|
Args: validate.NoArgs,
|
|
Short: "Remove an image",
|
|
Long: removeImageDescription,
|
|
RunE: removeImage,
|
|
ValidArgsFunction: completion.AutocompleteNone,
|
|
Example: `podman testing remove-image`,
|
|
}
|
|
|
|
removeImageOpts entities.RemoveImageOptions
|
|
|
|
removeContainerDescription = `Remove a container in local storage, potentially corrupting it.`
|
|
removeContainerCmd = &cobra.Command{
|
|
Use: "remove-container [options]",
|
|
Args: validate.NoArgs,
|
|
Short: "Remove an container",
|
|
Long: removeContainerDescription,
|
|
RunE: removeContainer,
|
|
ValidArgsFunction: completion.AutocompleteNone,
|
|
Example: `podman testing remove-container`,
|
|
}
|
|
|
|
removeContainerOpts entities.RemoveContainerOptions
|
|
)
|
|
|
|
func init() {
|
|
mainCmd.AddCommand(removeStorageLayerCmd)
|
|
flags := removeStorageLayerCmd.Flags()
|
|
flags.StringVarP(&removeStorageLayerOpts.ID, "layer", "i", "", "ID of the layer to remove")
|
|
|
|
mainCmd.AddCommand(removeLayerCmd)
|
|
flags = removeLayerCmd.Flags()
|
|
flags.StringVarP(&removeLayerOpts.ID, "layer", "i", "", "ID of the layer to remove")
|
|
|
|
mainCmd.AddCommand(removeImageCmd)
|
|
flags = removeImageCmd.Flags()
|
|
flags.StringVarP(&removeImageOpts.ID, "image", "i", "", "ID of the image to remove")
|
|
|
|
mainCmd.AddCommand(removeContainerCmd)
|
|
flags = removeContainerCmd.Flags()
|
|
flags.StringVarP(&removeContainerOpts.ID, "container", "i", "", "ID of the container to remove")
|
|
}
|
|
|
|
func removeStorageLayer(cmd *cobra.Command, args []string) error {
|
|
results, err := testingEngine.RemoveStorageLayer(mainContext, removeStorageLayerOpts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(results.ID)
|
|
return nil
|
|
}
|
|
|
|
func removeLayer(cmd *cobra.Command, args []string) error {
|
|
results, err := testingEngine.RemoveLayer(mainContext, removeLayerOpts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(results.ID)
|
|
return nil
|
|
}
|
|
|
|
func removeImage(cmd *cobra.Command, args []string) error {
|
|
results, err := testingEngine.RemoveImage(mainContext, removeImageOpts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(results.ID)
|
|
return nil
|
|
}
|
|
|
|
func removeContainer(cmd *cobra.Command, args []string) error {
|
|
results, err := testingEngine.RemoveContainer(mainContext, removeContainerOpts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(results.ID)
|
|
return nil
|
|
}
|