cluster

package
v0.3.21-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

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)" @Param clusterName path string true "The name of the cluster" @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 /rest-api/v1/cluster/{clusterName} [post]

func Delete

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 @Param clusterName path string true "The name of the cluster" @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 /rest-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 @Param clusterName path string true "The name of the cluster" @Param format query string false "The format of the response. Either in json or yaml" @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 /rest-api/v1/cluster/{clusterName} [get]

func List

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 @Param summary query bool false "Whether to display summary or not. Default to false" @Param orderBy query string false "The order to list the cluster. Default to order by name" @Param descending query bool false "Whether to sort the list in descending order. Default to false" @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 /rest-api/v1/clusters [get]

func Update

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

@Summary Update 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)" @Param clusterName path string true "The name of the cluster" @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 /rest-api/v1/cluster/{clusterName} [put]

func UploadKubeConfig

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

@Summary Upload kubeConfig file for cluster @Description Uploads a KubeConfig file for cluster, with a maximum size of 2MB. @Tags cluster @Accept multipart/form-data @Produce plain @Param file formData file true "Upload file with field name 'file'" @Param name formData string true "cluster name" @Param displayName formData string true "cluster display name" @Param description formData string true "cluster description" @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 /rest-api/v1/cluster/config/file [post]

func ValidateKubeConfig

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 /rest-api/v1/cluster/config/validate [post]

Types

type ClusterPayload

type ClusterPayload struct {
	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 karpor-managed cluster

func (*ClusterPayload) Decode

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

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

type ValidatePayload

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

func (*ValidatePayload) Decode

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