mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 08:56:05 +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>
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
//go:build !remote
 | 
						|
 | 
						|
package compat
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"net/http"
 | 
						|
 | 
						|
	"github.com/containers/podman/v5/libpod"
 | 
						|
	"github.com/containers/podman/v5/libpod/define"
 | 
						|
	"github.com/containers/podman/v5/pkg/api/handlers/utils"
 | 
						|
	api "github.com/containers/podman/v5/pkg/api/types"
 | 
						|
)
 | 
						|
 | 
						|
func Changes(w http.ResponseWriter, r *http.Request) {
 | 
						|
	decoder := utils.GetDecoder(r)
 | 
						|
	runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
 | 
						|
 | 
						|
	query := struct {
 | 
						|
		Parent   string `schema:"parent"`
 | 
						|
		DiffType string `schema:"diffType"`
 | 
						|
	}{}
 | 
						|
	if err := decoder.Decode(&query, r.URL.Query()); err != nil {
 | 
						|
		utils.Error(w, http.StatusBadRequest, fmt.Errorf("failed to parse parameters for %s: %w", r.URL.String(), err))
 | 
						|
		return
 | 
						|
	}
 | 
						|
	var diffType define.DiffType
 | 
						|
	switch query.DiffType {
 | 
						|
	case "", "all":
 | 
						|
		diffType = define.DiffAll
 | 
						|
	case "container":
 | 
						|
		diffType = define.DiffContainer
 | 
						|
	case "image":
 | 
						|
		diffType = define.DiffImage
 | 
						|
	default:
 | 
						|
		utils.Error(w, http.StatusBadRequest, fmt.Errorf("invalid diffType value %q", query.DiffType))
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	id := utils.GetName(r)
 | 
						|
	changes, err := runtime.GetDiff(query.Parent, id, diffType)
 | 
						|
	if err != nil {
 | 
						|
		utils.InternalServerError(w, err)
 | 
						|
		return
 | 
						|
	}
 | 
						|
	utils.WriteJSON(w, 200, changes)
 | 
						|
}
 |