cluster

package
v0.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create added in v0.2.8

Create returns an HTTP handler function that creates a cluster resource. It utilizes a ClusterManager to execute the logic.

@Summary      Create creates a cluster resource.
@Description  This endpoint creates a new cluster resource using the payload.
@Tags         cluster
@Accept       plain
@Accept       json
@Produce      json
@Param        request  body      ClusterPayload             true  "cluster to create (either plain text or JSON format)"
@Success      200      {object}  unstructured.Unstructured  "Unstructured object"
@Failure      400      {string}  string                     "Bad Request"
@Failure      401      {string}  string                     "Unauthorized"
@Failure      404      {string}  string                     "Not Found"
@Failure      405      {string}  string                     "Method Not Allowed"
@Failure      429      {string}  string                     "Too Many Requests"
@Failure      500      {string}  string                     "Internal Server Error"
@Router       /api/v1/cluster [post]

func Delete added in v0.2.8

Delete returns an HTTP handler function that deletes a cluster resource. It utilizes a ClusterManager to execute the logic.

@Summary      Delete removes a cluster resource by name.
@Description  This endpoint deletes the cluster resource by name.
@Tags         cluster
@Produce      json
@Success      200  {string}  string  "Operation status"
@Failure      400  {string}  string  "Bad Request"
@Failure      401  {string}  string  "Unauthorized"
@Failure      404  {string}  string  "Not Found"
@Failure      405  {string}  string  "Method Not Allowed"
@Failure      429  {string}  string  "Too Many Requests"
@Failure      500  {string}  string  "Internal Server Error"
@Router       /api/v1/cluster/{clusterName} [delete]

func Get

Get returns an HTTP handler function that reads a cluster detail. It utilizes a ClusterManager to execute the logic.

@Summary      Get returns a cluster resource by name.
@Description  This endpoint returns a cluster resource by name.
@Tags         cluster
@Produce      json
@Success      200  {object}  unstructured.Unstructured  "Unstructured object"
@Failure      400  {string}  string                     "Bad Request"
@Failure      401  {string}  string                     "Unauthorized"
@Failure      404  {string}  string                     "Not Found"
@Failure      405  {string}  string                     "Method Not Allowed"
@Failure      429  {string}  string                     "Too Many Requests"
@Failure      500  {string}  string                     "Internal Server Error"
@Router       /api/v1/cluster/{clusterName} [get]

func GetDetail

func GetDetail(clusterMgr *cluster.ClusterManager, c *server.CompletedConfig) http.HandlerFunc

GetDetail returns an HTTP handler function that returns details of a cluster. It utilizes a ClusterManager to execute the logic.

@Summary      GetDetail returns the details of a cluster by name.
@Description  This endpoint returns the details of a cluster by name.
@Tags         cluster
@Produce      json
@Success      200  {object}  cluster.ClusterDetail  "Cluster detail"
@Failure      400  {string}  string                 "Bad Request"
@Failure      401  {string}  string                 "Unauthorized"
@Failure      404  {string}  string                 "Not Found"
@Failure      405  {string}  string                 "Method Not Allowed"
@Failure      429  {string}  string                 "Too Many Requests"
@Failure      500  {string}  string                 "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}/detail [get]

func GetNamespace

func GetNamespace(clusterMgr *cluster.ClusterManager, c *server.CompletedConfig) http.HandlerFunc

GetNamespace returns an HTTP handler function that reads a namespace. It utilizes a ClusterManager to execute the logic.

@Summary      GetNamespace returns the namespace by name.
@Description  This endpoint returns the namespace by name.
@Tags         cluster
@Produce      json
@Success      200  {object}  v1.Namespace  "v1.Namespace"
@Failure      400  {string}  string        "Bad Request"
@Failure      401  {string}  string        "Unauthorized"
@Failure      404  {string}  string        "Not Found"
@Failure      405  {string}  string        "Method Not Allowed"
@Failure      429  {string}  string        "Too Many Requests"
@Failure      500  {string}  string        "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}/namespace/{namespaceName} [get]

func GetNamespaceTopology

func GetNamespaceTopology(clusterMgr *cluster.ClusterManager, c *server.CompletedConfig) http.HandlerFunc

GetNamespaceTopology returns an HTTP handler function that returns the topology of a namespace. It utilizes a ClusterManager to execute the logic.

@Summary      GetNamespaceTopology returns the topology of a namespace by name.
@Description  This endpoint returns the the topology of a namespace by name.
@Tags         cluster
@Produce      json
@Success      200  {object}  map[string]cluster.ClusterTopology  "map from string to cluster.ClusterTopology"
@Failure      400  {string}  string                              "Bad Request"
@Failure      401  {string}  string                              "Unauthorized"
@Failure      404  {string}  string                              "Not Found"
@Failure      405  {string}  string                              "Method Not Allowed"
@Failure      429  {string}  string                              "Too Many Requests"
@Failure      500  {string}  string                              "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}/namespace/{namespaceName}/topology [get]

func GetTopology

func GetTopology(clusterMgr *cluster.ClusterManager, c *server.CompletedConfig) http.HandlerFunc

GetTopology returns an HTTP handler function that returns a cluster topology. It utilizes a ClusterManager to execute the logic.

@Summary      GetTopology returns the topology of a cluster by name.
@Description  This endpoint returns the topology of a cluster by name.
@Tags         cluster
@Produce      json
@Success      200  {object}  map[string]cluster.ClusterTopology  "map from string to cluster.ClusterTopology"
@Failure      400  {string}  string                              "Bad Request"
@Failure      401  {string}  string                              "Unauthorized"
@Failure      404  {string}  string                              "Not Found"
@Failure      405  {string}  string                              "Method Not Allowed"
@Failure      429  {string}  string                              "Too Many Requests"
@Failure      500  {string}  string                              "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}/topology [get]

func GetYAML

GetYAML returns an HTTP handler function that returns a cluster YAML. It utilizes a ClusterManager to execute the logic.

@Summary      GetYAML returns a cluster YAML by name.
@Description  This endpoint returns a cluster YAML by name.
@Tags         cluster
@Produce      json
@Success      200  {array}   byte    "Byte array"
@Failure      400  {string}  string  "Bad Request"
@Failure      401  {string}  string  "Unauthorized"
@Failure      404  {string}  string  "Not Found"
@Failure      405  {string}  string  "Method Not Allowed"
@Failure      429  {string}  string  "Too Many Requests"
@Failure      500  {string}  string  "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}/yaml [get]

func List added in v0.2.9

List returns an HTTP handler function that lists all cluster resources. It utilizes a ClusterManager to execute the logic.

@Summary      List lists all cluster resources.
@Description  This endpoint lists all cluster resources.
@Tags         cluster
@Produce      json
@Success      200  {array}   unstructured.Unstructured  "List of cluster objects"
@Failure      400  {string}  string                     "Bad Request"
@Failure      401  {string}  string                     "Unauthorized"
@Failure      404  {string}  string                     "Not Found"
@Failure      405  {string}  string                     "Method Not Allowed"
@Failure      429  {string}  string                     "Too Many Requests"
@Failure      500  {string}  string                     "Internal Server Error"
@Router       /api/v1/cluster [get]

func UpdateKubeConfig added in v0.2.6

func UpdateKubeConfig(w http.ResponseWriter, r *http.Request)

@Summary Upload kubeConfig file for cluster @Description Uploads a KubeConfig file for cluster, with a maximum size of 2MB, and the valid file extension is "", ".yaml", ".yml", ".json", ".kubeconfig", ".kubeconf". @Tags cluster @Accept multipart/form-data @Produce plain @Param file formData file true "Upload file with field name 'file'" @Success 200 {object} UploadData "Returns the content of the uploaded KubeConfig file." @Failure 400 {string} string "The uploaded file is too large or the request is invalid." @Failure 500 {string} string "Internal server error." @Router /api/v1/cluster/config/file [post]

func UpdateMetadata added in v0.2.8

func UpdateMetadata(clusterMgr *cluster.ClusterManager, c *server.CompletedConfig) http.HandlerFunc

Create returns an HTTP handler function that updates a cluster resource. It utilizes a ClusterManager to execute the logic.

@Summary      UpdateMetadata updates the cluster metadata by name.
@Description  This endpoint updates the display name and description of an existing cluster resource.
@Tags         cluster
@Accept       plain
@Accept       json
@Produce      json
@Param        request  body      ClusterPayload             true  "cluster to update (either plain text or JSON format)"
@Success      200      {object}  unstructured.Unstructured  "Unstructured object"
@Failure      400      {string}  string                     "Bad Request"
@Failure      401      {string}  string                     "Unauthorized"
@Failure      404      {string}  string                     "Not Found"
@Failure      405      {string}  string                     "Method Not Allowed"
@Failure      429      {string}  string                     "Too Many Requests"
@Failure      500      {string}  string                     "Internal Server Error"
@Router       /api/v1/cluster/{clusterName}  [put]

func ValidateKubeConfig added in v0.2.8

func ValidateKubeConfig(clusterMgr *cluster.ClusterManager) http.HandlerFunc

ValidateKubeConfig returns an HTTP handler function to validate a KubeConfig.

@Summary      Validate KubeConfig
@Description  Validates the provided KubeConfig using cluster manager methods.
@Tags         cluster
@Accept       plain
@Accept       json
@Produce      json
@Param        request  body      ValidatePayload  true  "KubeConfig payload to validate"
@Success      200      {string}  string           "Verification passed server version"
@Failure      400      {object}  string           "Bad Request"
@Failure      401      {object}  string           "Unauthorized"
@Failure      429      {object}  string           "Too Many Requests"
@Failure      404      {object}  string           "Not Found"
@Failure      500      {object}  string           "Internal Server Error"
@Router       /api/v1/cluster/config/validate [post]

Types

type ClusterPayload added in v0.2.8

type ClusterPayload struct {
	ClusterName        string `json:"name"`        // ClusterName is the name of cluster to be created
	ClusterDisplayName string `json:"displayName"` // ClusterDisplayName is the display name of cluster to be created
	ClusterDescription string `json:"description"` // ClusterDescription is the description of cluster to be created
	ClusterKubeConfig  string `json:"kubeconfig"`  // ClusterKubeConfig is the kubeconfig of cluster to be created
}

ClusterPayload represents the structure for cluster request data. It includes the name, display name, description and kubeconfig of a karbour-managed cluster

func (*ClusterPayload) Decode added in v0.2.8

func (payload *ClusterPayload) Decode(r *http.Request) error

decode detects the correct decoder for use on an HTTP request and marshals into a given interface.

type UploadData added in v0.2.6

type UploadData struct {
	FileName string `json:"fileName"`
	FileSize int    `json:"fileSize"`
	Content  string `json:"content"`
}

type ValidatePayload added in v0.2.8

type ValidatePayload struct {
	KubeConfig string `json:"kubeConfig"`
}

func (*ValidatePayload) Decode added in v0.2.8

func (payload *ValidatePayload) Decode(r *http.Request) error

decode detects the correct decoder for use on an HTTP request and marshals into a given interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL