mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 18:15:48 +00:00
Set Version to Group/Version for /apis/* URLs
Signed-off-by: Joshua Snider <jsnider@mtu.edu>
This commit is contained in:
parent
0a7f3e091b
commit
23149738df
1 changed files with 27 additions and 11 deletions
|
@ -81,7 +81,7 @@ func NewAPIPath(path string) (*APIPath, error) {
|
|||
return &APIPath{
|
||||
Root: paths[0],
|
||||
Group: paths[1],
|
||||
Version: paths[2],
|
||||
Version: paths[1] + "/" + paths[2],
|
||||
ResourceType: paths[3],
|
||||
}, nil
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func NewAPIPath(path string) (*APIPath, error) {
|
|||
return &APIPath{
|
||||
Root: paths[0],
|
||||
Group: paths[1],
|
||||
Version: paths[2],
|
||||
Version: paths[1] + "/" + paths[2],
|
||||
ResourceType: paths[3],
|
||||
Name: paths[4],
|
||||
}, nil
|
||||
|
@ -102,7 +102,7 @@ func NewAPIPath(path string) (*APIPath, error) {
|
|||
return &APIPath{
|
||||
Root: paths[0],
|
||||
Group: paths[1],
|
||||
Version: paths[2],
|
||||
Version: paths[1] + "/" + paths[2],
|
||||
Namespace: paths[4],
|
||||
ResourceType: paths[5],
|
||||
}, nil
|
||||
|
@ -113,7 +113,7 @@ func NewAPIPath(path string) (*APIPath, error) {
|
|||
return &APIPath{
|
||||
Root: paths[0],
|
||||
Group: paths[1],
|
||||
Version: paths[2],
|
||||
Version: paths[1] + "/" + paths[2],
|
||||
Namespace: paths[4],
|
||||
ResourceType: paths[5],
|
||||
Name: paths[6],
|
||||
|
@ -125,17 +125,33 @@ func NewAPIPath(path string) (*APIPath, error) {
|
|||
|
||||
func (a *APIPath) String() string {
|
||||
var paths []string
|
||||
if a.Namespace != "" {
|
||||
if a.Name == "" {
|
||||
paths = []string{a.Root, a.Group, a.Version, "namespaces", a.Namespace, a.ResourceType}
|
||||
if a.Root == "apis" {
|
||||
if a.Namespace != "" {
|
||||
if a.Name == "" {
|
||||
paths = []string{a.Root, a.Version, "namespaces", a.Namespace, a.ResourceType}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Version, "namespaces", a.Namespace, a.ResourceType, a.Name}
|
||||
}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Group, a.Version, "namespaces", a.Namespace, a.ResourceType, a.Name}
|
||||
if a.Name != "" {
|
||||
paths = []string{a.Root, a.Version, a.ResourceType, a.Name}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Version, a.ResourceType}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if a.Name != "" {
|
||||
paths = []string{a.Root, a.Group, a.Version, a.ResourceType, a.Name}
|
||||
if a.Namespace != "" {
|
||||
if a.Name == "" {
|
||||
paths = []string{a.Root, a.Group, "namespaces", a.Namespace, a.ResourceType}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Group, "namespaces", a.Namespace, a.ResourceType, a.Name}
|
||||
}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Group, a.Version, a.ResourceType}
|
||||
if a.Name != "" {
|
||||
paths = []string{a.Root, a.Group, a.ResourceType, a.Name}
|
||||
} else {
|
||||
paths = []string{a.Root, a.Group, a.ResourceType}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue