Skip to content

Commit

Permalink
Comment out unused function for verifying public keys in shoot admission
Browse files Browse the repository at this point in the history
  • Loading branch information
rrhubenov committed Oct 21, 2024
1 parent 80d3449 commit 31b25f8
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions pkg/admission/validator/lakom/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/gardener/gardener-extension-shoot-lakom-service/pkg/apis/lakom"
"github.com/gardener/gardener-extension-shoot-lakom-service/pkg/constants"
"github.com/gardener/gardener-extension-shoot-lakom-service/pkg/lakom/utils"

extensionswebhook "github.com/gardener/gardener/extensions/pkg/webhook"
"github.com/gardener/gardener/pkg/apis/core"
Expand Down Expand Up @@ -53,29 +52,29 @@ func (s *shoot) validateScopeType(fldPath *field.Path, scopeType lakom.ScopeType
}

// TODO: This check exists in the validation of the lakom config as well. It can be extracted as a util function
func (s *shoot) validateCosignPublicKeys(fldPath *field.Path, cosignPublicKeys []lakom.Key) field.ErrorList {
errList := field.ErrorList{}

usedNames := map[string]any{}
for idx, k := range cosignPublicKeys {
if k.Name == "" {
errList = append(errList, field.Required(fldPath.Index(idx), "key name should no be empty"))
}

if _, ok := usedNames[k.Name]; ok {
errList = append(errList, field.Duplicate(fldPath.Index(idx), k.Name))
}
usedNames[k.Name] = nil

if keys, err := utils.GetCosignPublicKeys([]byte(k.Key)); err != nil {
errList = append(errList, field.Invalid(fldPath.Index(idx), k.Key, "key could not be parsed"))
} else if len(keys) != 1 {
errList = append(errList, field.Invalid(fldPath.Index(idx), k.Key, "expected exactly one key for the given name"))
}
}

return errList
}
// func (s *shoot) validateCosignPublicKeys(fldPath *field.Path, cosignPublicKeys []lakom.Key) field.ErrorList {
// errList := field.ErrorList{}

// usedNames := map[string]any{}
// for idx, k := range cosignPublicKeys {
// if k.Name == "" {
// errList = append(errList, field.Required(fldPath.Index(idx), "key name should no be empty"))
// }

// if _, ok := usedNames[k.Name]; ok {
// errList = append(errList, field.Duplicate(fldPath.Index(idx), k.Name))
// }
// usedNames[k.Name] = nil

// if keys, err := utils.GetCosignPublicKeys([]byte(k.Key)); err != nil {
// errList = append(errList, field.Invalid(fldPath.Index(idx), k.Key, "key could not be parsed"))
// } else if len(keys) != 1 {
// errList = append(errList, field.Invalid(fldPath.Index(idx), k.Key, "expected exactly one key for the given name"))
// }
// }

// return errList
// }

// Validate validates the given shoot object
func (s *shoot) Validate(_ context.Context, new, _ client.Object) error {
Expand Down

0 comments on commit 31b25f8

Please sign in to comment.