mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(ingress): ingresses datatable with add/edit ingresses EE-2615 (#7672)
This commit is contained in:
parent
393d1fc91d
commit
ef1d648c07
68 changed files with 4938 additions and 61 deletions
17
api/database/models/configmaps_and_secrets.go
Normal file
17
api/database/models/configmaps_and_secrets.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package models
|
||||
|
||||
type (
|
||||
K8sConfigMapOrSecret struct {
|
||||
UID string `json:"UID"`
|
||||
Name string `json:"Name"`
|
||||
Namespace string `json:"Namespace"`
|
||||
CreationDate string `json:"CreationDate"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
Data map[string]string `json:"Data"`
|
||||
Applications []string `json:"Applications"`
|
||||
IsSecret bool `json:"IsSecret"`
|
||||
|
||||
// SecretType will be an empty string for config maps.
|
||||
SecretType string `json:"SecretType"`
|
||||
}
|
||||
)
|
77
api/database/models/ingress.go
Normal file
77
api/database/models/ingress.go
Normal file
|
@ -0,0 +1,77 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sIngressController struct {
|
||||
Name string `json:"Name"`
|
||||
ClassName string `json:"ClassName"`
|
||||
Type string `json:"Type"`
|
||||
Availability bool `json:"Availability"`
|
||||
New bool `json:"New"`
|
||||
}
|
||||
|
||||
K8sIngressControllers []K8sIngressController
|
||||
|
||||
K8sIngressInfo struct {
|
||||
Name string `json:"Name"`
|
||||
UID string `json:"UID"`
|
||||
Type string `json:"Type"`
|
||||
Namespace string `json:"Namespace"`
|
||||
ClassName string `json:"ClassName"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
Hosts []string `json:"Hosts"`
|
||||
Paths []K8sIngressPath `json:"Paths"`
|
||||
TLS []K8sIngressTLS `json:"TLS"`
|
||||
}
|
||||
|
||||
K8sIngressTLS struct {
|
||||
Hosts []string `json:"Hosts"`
|
||||
SecretName string `json:"SecretName"`
|
||||
}
|
||||
|
||||
K8sIngressPath struct {
|
||||
IngressName string `json:"IngressName"`
|
||||
Host string `json:"Host"`
|
||||
ServiceName string `json:"ServiceName"`
|
||||
Port int `json:"Port"`
|
||||
Path string `json:"Path"`
|
||||
PathType string `json:"PathType"`
|
||||
}
|
||||
|
||||
// K8sIngressDeleteRequests is a mapping of namespace names to a slice of
|
||||
// ingress names.
|
||||
K8sIngressDeleteRequests map[string][]string
|
||||
)
|
||||
|
||||
func (r K8sIngressControllers) Validate(request *http.Request) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r K8sIngressInfo) Validate(request *http.Request) error {
|
||||
if r.Name == "" {
|
||||
return errors.New("missing ingress name from the request payload")
|
||||
}
|
||||
if r.Namespace == "" {
|
||||
return errors.New("missing ingress Namespace from the request payload")
|
||||
}
|
||||
if r.ClassName == "" {
|
||||
return errors.New("missing ingress ClassName from the request payload")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r K8sIngressDeleteRequests) Validate(request *http.Request) error {
|
||||
if len(r) == 0 {
|
||||
return errors.New("missing deletion request list in payload")
|
||||
}
|
||||
for ns := range r {
|
||||
if len(ns) == 0 {
|
||||
return errors.New("deletion given with empty namespace")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
12
api/database/models/namespaces.go
Normal file
12
api/database/models/namespaces.go
Normal file
|
@ -0,0 +1,12 @@
|
|||
package models
|
||||
|
||||
import "net/http"
|
||||
|
||||
type K8sNamespaceInfo struct {
|
||||
Name string `json:"Name"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
}
|
||||
|
||||
func (r *K8sNamespaceInfo) Validate(request *http.Request) error {
|
||||
return nil
|
||||
}
|
64
api/database/models/services.go
Normal file
64
api/database/models/services.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sServiceInfo struct {
|
||||
Name string `json:"Name"`
|
||||
UID string `json:"UID"`
|
||||
Type string `json:"Type"`
|
||||
Namespace string `json:"Namespace"`
|
||||
Annotations map[string]string `json:"Annotations"`
|
||||
CreationTimestamp string `json:"CreationTimestamp"`
|
||||
Labels map[string]string `json:"Labels"`
|
||||
AllocateLoadBalancerNodePorts *bool `json:"AllocateLoadBalancerNodePorts,omitempty"`
|
||||
Ports []K8sServicePort `json:"Ports"`
|
||||
Selector map[string]string `json:"Selector"`
|
||||
IngressStatus []K8sServiceIngress `json:"IngressStatus"`
|
||||
}
|
||||
|
||||
K8sServicePort struct {
|
||||
Name string `json:"Name"`
|
||||
NodePort int `json:"NodePort"`
|
||||
Port int `json:"Port"`
|
||||
Protocol string `json:"Protocol"`
|
||||
TargetPort int `json:"TargetPort"`
|
||||
}
|
||||
|
||||
K8sServiceIngress struct {
|
||||
IP string `json:"IP"`
|
||||
Host string `json:"Host"`
|
||||
}
|
||||
|
||||
// K8sServiceDeleteRequests is a mapping of namespace names to a slice of
|
||||
// service names.
|
||||
K8sServiceDeleteRequests map[string][]string
|
||||
)
|
||||
|
||||
func (s *K8sServiceInfo) Validate(request *http.Request) error {
|
||||
if s.Name == "" {
|
||||
return errors.New("missing service name from the request payload")
|
||||
}
|
||||
if s.Namespace == "" {
|
||||
return errors.New("missing service namespace from the request payload")
|
||||
}
|
||||
if s.Ports == nil {
|
||||
return errors.New("missing service ports from the request payload")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r K8sServiceDeleteRequests) Validate(request *http.Request) error {
|
||||
if len(r) == 0 {
|
||||
return errors.New("missing deletion request list in payload")
|
||||
}
|
||||
for ns := range r {
|
||||
if len(ns) == 0 {
|
||||
return errors.New("deletion given with empty namespace")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue