staging/apiserver: correct KubeConfigFile type in authorization types

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>
This commit is contained in:
Nabarun Pal 2023-09-27 17:48:38 +05:30
parent fe6d64d080
commit 2bf2c4f3a4
No known key found for this signature in database
GPG Key ID: E71158161DF2A2CB
4 changed files with 15 additions and 15 deletions

View File

@ -169,7 +169,7 @@ func (o *BuiltInAuthorizationOptions) buildAuthorizationConfiguration() (*authzc
FailurePolicy: authzconfig.FailurePolicyNoOpinion, FailurePolicy: authzconfig.FailurePolicyNoOpinion,
SubjectAccessReviewVersion: o.WebhookVersion, SubjectAccessReviewVersion: o.WebhookVersion,
ConnectionInfo: authzconfig.WebhookConnectionInfo{ ConnectionInfo: authzconfig.WebhookConnectionInfo{
Type: authzconfig.AuthorizationWebhookConnectionInfoTypeKubeConfig, Type: authzconfig.AuthorizationWebhookConnectionInfoTypeKubeConfigFile,
KubeConfigFile: &o.WebhookConfigFile, KubeConfigFile: &o.WebhookConfigFile,
}, },
}, },

View File

@ -215,7 +215,7 @@ const (
TypeWebhook AuthorizerType = "Webhook" TypeWebhook AuthorizerType = "Webhook"
FailurePolicyNoOpinion string = "NoOpinion" FailurePolicyNoOpinion string = "NoOpinion"
FailurePolicyDeny string = "Deny" FailurePolicyDeny string = "Deny"
AuthorizationWebhookConnectionInfoTypeKubeConfig string = "KubeConfigFile" AuthorizationWebhookConnectionInfoTypeKubeConfigFile string = "KubeConfigFile"
AuthorizationWebhookConnectionInfoTypeInCluster string = "InClusterConfig" AuthorizationWebhookConnectionInfoTypeInCluster string = "InClusterConfig"
) )
@ -294,7 +294,7 @@ type WebhookConfiguration struct {
type WebhookConnectionInfo struct { type WebhookConnectionInfo struct {
// Controls how the webhook should communicate with the server. // Controls how the webhook should communicate with the server.
// Valid values: // Valid values:
// - KubeConfig: use the file specified in kubeConfigFile to locate the // - KubeConfigFile: use the file specified in kubeConfigFile to locate the
// server. // server.
// - InClusterConfig: use the in-cluster configuration to call the // - InClusterConfig: use the in-cluster configuration to call the
// SubjectAccessReview API hosted by kube-apiserver. This mode is not // SubjectAccessReview API hosted by kube-apiserver. This mode is not

View File

@ -285,7 +285,7 @@ const (
TypeWebhook AuthorizerType = "Webhook" TypeWebhook AuthorizerType = "Webhook"
FailurePolicyNoOpinion string = "NoOpinion" FailurePolicyNoOpinion string = "NoOpinion"
FailurePolicyDeny string = "Deny" FailurePolicyDeny string = "Deny"
AuthorizationWebhookConnectionInfoTypeKubeConfig string = "KubeConfigFile" AuthorizationWebhookConnectionInfoTypeKubeConfigFile string = "KubeConfigFile"
AuthorizationWebhookConnectionInfoTypeInCluster string = "InClusterConfig" AuthorizationWebhookConnectionInfoTypeInCluster string = "InClusterConfig"
) )
@ -365,7 +365,7 @@ type WebhookConfiguration struct {
type WebhookConnectionInfo struct { type WebhookConnectionInfo struct {
// Controls how the webhook should communicate with the server. // Controls how the webhook should communicate with the server.
// Valid values: // Valid values:
// - KubeConfig: use the file specified in kubeConfigFile to locate the // - KubeConfigFile: use the file specified in kubeConfigFile to locate the
// server. // server.
// - InClusterConfig: use the in-cluster configuration to call the // - InClusterConfig: use the in-cluster configuration to call the
// SubjectAccessReview API hosted by kube-apiserver. This mode is not // SubjectAccessReview API hosted by kube-apiserver. This mode is not

View File

@ -319,7 +319,7 @@ func ValidateWebhookConfiguration(fldPath *field.Path, c *api.WebhookConfigurati
if c.ConnectionInfo.KubeConfigFile != nil { if c.ConnectionInfo.KubeConfigFile != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("connectionInfo", "kubeConfigFile"), *c.ConnectionInfo.KubeConfigFile, "can only be set when type=KubeConfigFile")) allErrs = append(allErrs, field.Invalid(fldPath.Child("connectionInfo", "kubeConfigFile"), *c.ConnectionInfo.KubeConfigFile, "can only be set when type=KubeConfigFile"))
} }
case api.AuthorizationWebhookConnectionInfoTypeKubeConfig: case api.AuthorizationWebhookConnectionInfoTypeKubeConfigFile:
if c.ConnectionInfo.KubeConfigFile == nil || *c.ConnectionInfo.KubeConfigFile == "" { if c.ConnectionInfo.KubeConfigFile == nil || *c.ConnectionInfo.KubeConfigFile == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("connectionInfo", "kubeConfigFile"), "")) allErrs = append(allErrs, field.Required(fldPath.Child("connectionInfo", "kubeConfigFile"), ""))
} else if !filepath.IsAbs(*c.ConnectionInfo.KubeConfigFile) { } else if !filepath.IsAbs(*c.ConnectionInfo.KubeConfigFile) {
@ -330,7 +330,7 @@ func ValidateWebhookConfiguration(fldPath *field.Path, c *api.WebhookConfigurati
allErrs = append(allErrs, field.Invalid(fldPath.Child("connectionInfo", "kubeConfigFile"), *c.ConnectionInfo.KubeConfigFile, "must be a regular file")) allErrs = append(allErrs, field.Invalid(fldPath.Child("connectionInfo", "kubeConfigFile"), *c.ConnectionInfo.KubeConfigFile, "must be a regular file"))
} }
default: default:
allErrs = append(allErrs, field.NotSupported(fldPath.Child("connectionInfo", "type"), c.ConnectionInfo, []string{"InClusterConfig", "KubeConfigFile"})) allErrs = append(allErrs, field.NotSupported(fldPath.Child("connectionInfo", "type"), c.ConnectionInfo, []string{api.AuthorizationWebhookConnectionInfoTypeInCluster, api.AuthorizationWebhookConnectionInfoTypeKubeConfigFile}))
} }
// TODO: Remove this check and ensure that correct validations below for MatchConditions are added // TODO: Remove this check and ensure that correct validations below for MatchConditions are added