You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/api/http/models/kubernetes/namespaces.go

37 lines
846 B

package kubernetes
import (
"fmt"
"net/http"
"k8s.io/apimachinery/pkg/api/resource"
)
type K8sNamespaceDetails struct {
Name string `json:"Name"`
Annotations map[string]string `json:"Annotations"`
ResourceQuota *K8sResourceQuota `json:"ResourceQuota"`
}
type K8sResourceQuota struct {
Enabled bool `json:"enabled"`
Memory string `json:"memory"`
CPU string `json:"cpu"`
}
func (r *K8sNamespaceDetails) Validate(request *http.Request) error {
if r.ResourceQuota != nil && r.ResourceQuota.Enabled {
_, err := resource.ParseQuantity(r.ResourceQuota.Memory)
if err != nil {
return fmt.Errorf("error parsing memory quota value: %w", err)
}
_, err = resource.ParseQuantity(r.ResourceQuota.CPU)
if err != nil {
return fmt.Errorf("error parsing cpu quota value: %w", err)
}
}
return nil
}