mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
commit
0465cd7d04
@ -58,7 +58,7 @@ func (s *APIEnablementOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
// But in the advanced (and usually not recommended) case of delegated apiservers there can be more.
|
||||
// Validate will filter out the known groups of each registry.
|
||||
// If anything is left over after that, an error is returned.
|
||||
func (s *APIEnablementOptions) Validate(registries ...GroupRegisty) []error {
|
||||
func (s *APIEnablementOptions) Validate(registries ...GroupRegistry) []error {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
@ -98,7 +98,7 @@ func (s *APIEnablementOptions) ApplyTo(c *server.Config, defaultResourceConfig *
|
||||
return err
|
||||
}
|
||||
|
||||
func unknownGroups(groups []string, registry GroupRegisty) []string {
|
||||
func unknownGroups(groups []string, registry GroupRegistry) []string {
|
||||
unknownGroups := []string{}
|
||||
for _, group := range groups {
|
||||
if !registry.IsGroupRegistered(group) {
|
||||
@ -108,8 +108,8 @@ func unknownGroups(groups []string, registry GroupRegisty) []string {
|
||||
return unknownGroups
|
||||
}
|
||||
|
||||
// GroupRegisty provides a method to check whether given group is registered.
|
||||
type GroupRegisty interface {
|
||||
// GroupRegistry provides a method to check whether given group is registered.
|
||||
type GroupRegistry interface {
|
||||
// IsRegistered returns true if given group is registered.
|
||||
IsGroupRegistered(group string) bool
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ import (
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
)
|
||||
|
||||
type fakeGroupRegisty struct{}
|
||||
type fakeGroupRegistry struct{}
|
||||
|
||||
func (f fakeGroupRegisty) IsGroupRegistered(group string) bool {
|
||||
func (f fakeGroupRegistry) IsGroupRegistered(group string) bool {
|
||||
return group == "apiregistration.k8s.io"
|
||||
}
|
||||
|
||||
@ -67,11 +67,11 @@ func TestAPIEnablementOptionsValidate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
testGroupRegisty := fakeGroupRegisty{}
|
||||
testGroupRegistry := fakeGroupRegistry{}
|
||||
|
||||
for _, testcase := range testCases {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
errs := testcase.testOptions.Validate(testGroupRegisty)
|
||||
errs := testcase.testOptions.Validate(testGroupRegistry)
|
||||
if len(testcase.expectErr) != 0 && !strings.Contains(utilerrors.NewAggregate(errs).Error(), testcase.expectErr) {
|
||||
t.Errorf("got err: %v, expected err: %s", errs, testcase.expectErr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user