forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove kyverno client v2beta1 (kyverno#10543)
* feat: remove kyverno client v2beta1 Signed-off-by: Charles-Edouard Brétéché <[email protected]> * codegen Signed-off-by: Charles-Edouard Brétéché <[email protected]> * fix tests Signed-off-by: Charles-Edouard Brétéché <[email protected]> --------- Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
ff88c4c
commit e900abf
Showing
53 changed files
with
84 additions
and
4,653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...verno/v2beta1/cleanup_policy_interface.go → api/kyverno/v2/cleanup_policy_interface.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package v2beta1 | ||
package v2 | ||
|
||
import ( | ||
"time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,7 @@ | ||
package v2 | ||
|
||
import ( | ||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
kyvernov2beta1 "github.com/kyverno/kyverno/api/kyverno/v2beta1" | ||
) | ||
|
||
// MatchResources is used to specify resource and admission review request data for | ||
// which a policy rule is applicable. | ||
type MatchResources struct { | ||
// Any allows specifying resources which will be ORed | ||
// +optional | ||
Any kyvernov1.ResourceFilters `json:"any,omitempty" yaml:"any,omitempty"` | ||
|
||
// All allows specifying resources which will be ANDed | ||
// +optional | ||
All kyvernov1.ResourceFilters `json:"all,omitempty" yaml:"all,omitempty"` | ||
} | ||
|
||
// GetKinds returns all kinds | ||
func (m *MatchResources) GetKinds() []string { | ||
var kinds []string | ||
for _, value := range m.All { | ||
kinds = append(kinds, value.ResourceDescription.Kinds...) | ||
} | ||
for _, value := range m.Any { | ||
kinds = append(kinds, value.ResourceDescription.Kinds...) | ||
} | ||
return kinds | ||
} | ||
|
||
// ValidateNoUserInfo verifies that no user info is used | ||
func (m *MatchResources) ValidateNoUserInfo(path *field.Path) (errs field.ErrorList) { | ||
anyPath := path.Child("any") | ||
for i, filter := range m.Any { | ||
errs = append(errs, filter.UserInfo.ValidateNoUserInfo(anyPath.Index(i))...) | ||
} | ||
allPath := path.Child("all") | ||
for i, filter := range m.All { | ||
errs = append(errs, filter.UserInfo.ValidateNoUserInfo(allPath.Index(i))...) | ||
} | ||
return errs | ||
} | ||
|
||
// ValidateResourceWithNoUserInfo implements programmatic validation and verifies that no user info is used | ||
func (m *MatchResources) ValidateResourceWithNoUserInfo(path *field.Path, namespaced bool, clusterResources sets.Set[string]) (errs field.ErrorList) { | ||
if len(m.Any) > 0 && len(m.All) > 0 { | ||
errs = append(errs, field.Invalid(path, m, "Can't specify any and all together")) | ||
} | ||
anyPath := path.Child("any") | ||
for i, filter := range m.Any { | ||
errs = append(errs, filter.UserInfo.ValidateNoUserInfo(anyPath.Index(i))...) | ||
errs = append(errs, filter.ResourceDescription.Validate(anyPath.Index(i), namespaced, clusterResources)...) | ||
} | ||
allPath := path.Child("all") | ||
for i, filter := range m.All { | ||
errs = append(errs, filter.UserInfo.ValidateNoUserInfo(allPath.Index(i))...) | ||
errs = append(errs, filter.ResourceDescription.Validate(allPath.Index(i), namespaced, clusterResources)...) | ||
} | ||
return errs | ||
} | ||
|
||
// Validate implements programmatic validation | ||
func (m *MatchResources) Validate(path *field.Path, namespaced bool, clusterResources sets.Set[string]) (errs field.ErrorList) { | ||
if len(m.Any) > 0 && len(m.All) > 0 { | ||
errs = append(errs, field.Invalid(path, m, "Can't specify any and all together")) | ||
} | ||
anyPath := path.Child("any") | ||
for i, filter := range m.Any { | ||
errs = append(errs, filter.UserInfo.Validate(anyPath.Index(i))...) | ||
errs = append(errs, filter.ResourceDescription.Validate(anyPath.Index(i), namespaced, clusterResources)...) | ||
} | ||
allPath := path.Child("all") | ||
for i, filter := range m.All { | ||
errs = append(errs, filter.UserInfo.Validate(allPath.Index(i))...) | ||
errs = append(errs, filter.ResourceDescription.Validate(allPath.Index(i), namespaced, clusterResources)...) | ||
} | ||
return errs | ||
} | ||
type MatchResources = kyvernov2beta1.MatchResources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.