mirror of https://github.com/portainer/portainer
fix(more resources): fix porting and functionality [r8s-103] (#8)
Co-authored-by: testA113 <aliharriss1995@gmail.com> Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io> Co-authored-by: Ali <83188384+testA113@users.noreply.github.com>pull/7947/merge
parent
e6577ca269
commit
6d31f4876a
@ -1,16 +1,33 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sClusterRoleBinding struct {
|
||||
Name string `json:"name"`
|
||||
UID types.UID `json:"uid"`
|
||||
Namespace string `json:"namespace"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
Subjects []rbacv1.Subject `json:"subjects"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
IsSystem bool `json:"isSystem"`
|
||||
}
|
||||
|
||||
// K8sRoleBindingDeleteRequests slice of cluster role cluster bindings.
|
||||
K8sClusterRoleBindingDeleteRequests []string
|
||||
)
|
||||
|
||||
func (r K8sClusterRoleBindingDeleteRequests) Validate(request *http.Request) error {
|
||||
if len(r) == 0 {
|
||||
return errors.New("missing deletion request list in payload")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1,8 +1,28 @@
|
||||
package kubernetes
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
type K8sClusterRole struct {
|
||||
Name string `json:"name"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sClusterRole struct {
|
||||
Name string `json:"name"`
|
||||
UID types.UID `json:"uid"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
IsSystem bool `json:"isSystem"`
|
||||
}
|
||||
|
||||
K8sClusterRoleDeleteRequests []string
|
||||
)
|
||||
|
||||
func (r K8sClusterRoleDeleteRequests) Validate(request *http.Request) error {
|
||||
if len(r) == 0 {
|
||||
return errors.New("missing deletion request list in payload")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -1,17 +1,38 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sRoleBinding struct {
|
||||
Name string `json:"name"`
|
||||
UID types.UID `json:"uid"`
|
||||
Namespace string `json:"namespace"`
|
||||
RoleRef rbacv1.RoleRef `json:"roleRef"`
|
||||
Subjects []rbacv1.Subject `json:"subjects"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
IsSystem bool `json:"isSystem"`
|
||||
}
|
||||
|
||||
// K8sRoleBindingDeleteRequests is a mapping of namespace names to a slice of role bindings.
|
||||
K8sRoleBindingDeleteRequests map[string][]string
|
||||
)
|
||||
|
||||
func (r K8sRoleBindingDeleteRequests) 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
|
||||
}
|
||||
|
@ -1,9 +1,36 @@
|
||||
package kubernetes
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
type K8sRole struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sRole struct {
|
||||
Name string `json:"name"`
|
||||
UID types.UID `json:"uid"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
// isSystem is true if prefixed with "system:" or exists in the kube-system namespace
|
||||
// or is one of the portainer roles
|
||||
IsSystem bool `json:"isSystem"`
|
||||
}
|
||||
|
||||
// K8sRoleDeleteRequests is a mapping of namespace names to a slice of roles.
|
||||
K8sRoleDeleteRequests map[string][]string
|
||||
)
|
||||
|
||||
func (r K8sRoleDeleteRequests) 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
|
||||
}
|
||||
|
@ -1,9 +1,34 @@
|
||||
package kubernetes
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
type K8sServiceAccount struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
type (
|
||||
K8sServiceAccount struct {
|
||||
Name string `json:"name"`
|
||||
UID types.UID `json:"uid"`
|
||||
Namespace string `json:"namespace"`
|
||||
CreationDate time.Time `json:"creationDate"`
|
||||
IsSystem bool `json:"isSystem"`
|
||||
}
|
||||
|
||||
// K8sServiceAcountDeleteRequests is a mapping of namespace names to a slice of service account names.
|
||||
K8sServiceAccountDeleteRequests map[string][]string
|
||||
)
|
||||
|
||||
func (r K8sServiceAccountDeleteRequests) 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
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package errorlist
|
||||
|
||||
import "errors"
|
||||
|
||||
// Combine a slice of errors into a single error
|
||||
// to use this, generate errors by appending to errorList in a loop, then return combine(errorList)
|
||||
func Combine(errorList []error) error {
|
||||
if len(errorList) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
errorMsg := "Multiple errors occurred:"
|
||||
for _, err := range errorList {
|
||||
errorMsg += "\n" + err.Error()
|
||||
}
|
||||
|
||||
return errors.New(errorMsg)
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { Badge } from '@@/Badge';
|
||||
|
||||
export function SystemBadge() {
|
||||
return <Badge type="success">system</Badge>;
|
||||
return <Badge type="success">System</Badge>;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
|
||||
import { ClusterRole } from '../types';
|
||||
import { ClusterRoleRowData } from '../types';
|
||||
|
||||
export const columnHelper = createColumnHelper<ClusterRole>();
|
||||
export const columnHelper = createColumnHelper<ClusterRoleRowData>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
|
||||
import { Role } from '../types';
|
||||
import { RoleRowData } from '../types';
|
||||
|
||||
export const columnHelper = createColumnHelper<Role>();
|
||||
export const columnHelper = createColumnHelper<RoleRowData>();
|
||||
|
@ -1,10 +1,7 @@
|
||||
export type ServiceAccount = {
|
||||
name: string;
|
||||
namespace: string;
|
||||
resourceVersion: string;
|
||||
uid: string;
|
||||
namespace: string;
|
||||
creationDate: string;
|
||||
|
||||
isSystem: boolean;
|
||||
isUnused: boolean;
|
||||
};
|
||||
|
Loading…
Reference in new issue