mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
feat(namespace): migrate create ns to react [EE-2226] (#10377)
This commit is contained in:
parent
31bcba96c6
commit
7218eb0892
83 changed files with 1869 additions and 358 deletions
|
@ -1,12 +1,36 @@
|
|||
package kubernetes
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
type K8sNamespaceDetails struct {
|
||||
Name string `json:"Name"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue