github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/pkg/api/server/register_swarm.go (about)

     1  package server
     2  
     3  import (
     4  	"errors"
     5  	"net/http"
     6  
     7  	"github.com/containers/libpod/pkg/api/handlers/utils"
     8  	"github.com/gorilla/mux"
     9  	"github.com/sirupsen/logrus"
    10  )
    11  
    12  func (s *APIServer) registerSwarmHandlers(r *mux.Router) error {
    13  	r.PathPrefix("/v{version:[0-9.]+}/configs/").HandlerFunc(noSwarm)
    14  	r.PathPrefix("/v{version:[0-9.]+}/nodes/").HandlerFunc(noSwarm)
    15  	r.PathPrefix("/v{version:[0-9.]+}/secrets/").HandlerFunc(noSwarm)
    16  	r.PathPrefix("/v{version:[0-9.]+}/services/").HandlerFunc(noSwarm)
    17  	r.PathPrefix("/v{version:[0-9.]+}/swarm/").HandlerFunc(noSwarm)
    18  	r.PathPrefix("/v{version:[0-9.]+}/tasks/").HandlerFunc(noSwarm)
    19  
    20  	// Added non version path to URI to support docker non versioned paths
    21  	r.PathPrefix("/configs/").HandlerFunc(noSwarm)
    22  	r.PathPrefix("/nodes/").HandlerFunc(noSwarm)
    23  	r.PathPrefix("/secrets/").HandlerFunc(noSwarm)
    24  	r.PathPrefix("/services/").HandlerFunc(noSwarm)
    25  	r.PathPrefix("/swarm/").HandlerFunc(noSwarm)
    26  	r.PathPrefix("/tasks/").HandlerFunc(noSwarm)
    27  	return nil
    28  }
    29  
    30  // noSwarm returns http.StatusServiceUnavailable rather than something like http.StatusInternalServerError,
    31  // this allows the client to decide if they still can talk to us
    32  func noSwarm(w http.ResponseWriter, r *http.Request) {
    33  	logrus.Errorf("%s is not a podman supported service", r.URL.String())
    34  	utils.Error(w, "node is not part of a swarm", http.StatusServiceUnavailable, errors.New("Podman does not support service: "+r.URL.String()))
    35  }