mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
f4406bbefc
* cleanup phase 1 * linter fixes phase 2 * linter fixes * linter fixes
106 lines
3 KiB
Go
106 lines
3 KiB
Go
package webhookconfig
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/golang/glog"
|
|
"github.com/nirmata/kyverno/pkg/config"
|
|
admregapi "k8s.io/api/admissionregistration/v1beta1"
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
func (wrc *WebhookRegistrationClient) contructPolicyValidatingWebhookConfig(caData []byte) *admregapi.ValidatingWebhookConfiguration {
|
|
|
|
return &admregapi.ValidatingWebhookConfiguration{
|
|
ObjectMeta: v1.ObjectMeta{
|
|
Name: config.PolicyValidatingWebhookConfigurationName,
|
|
OwnerReferences: []v1.OwnerReference{
|
|
wrc.constructOwner(),
|
|
},
|
|
},
|
|
Webhooks: []admregapi.Webhook{
|
|
generateWebhook(
|
|
config.PolicyValidatingWebhookName,
|
|
config.PolicyValidatingWebhookServicePath,
|
|
caData,
|
|
true,
|
|
wrc.timeoutSeconds,
|
|
"clusterpolicies/*",
|
|
"kyverno.io",
|
|
"v1",
|
|
[]admregapi.OperationType{admregapi.Create, admregapi.Update},
|
|
),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wrc *WebhookRegistrationClient) contructDebugPolicyValidatingWebhookConfig(caData []byte) *admregapi.ValidatingWebhookConfiguration {
|
|
url := fmt.Sprintf("https://%s%s", wrc.serverIP, config.PolicyValidatingWebhookServicePath)
|
|
glog.V(4).Infof("Debug PolicyValidatingWebhookConfig is registered with url %s\n", url)
|
|
|
|
return &admregapi.ValidatingWebhookConfiguration{
|
|
ObjectMeta: v1.ObjectMeta{
|
|
Name: config.PolicyValidatingWebhookConfigurationDebugName,
|
|
},
|
|
Webhooks: []admregapi.Webhook{
|
|
generateDebugWebhook(
|
|
config.PolicyValidatingWebhookName,
|
|
url,
|
|
caData,
|
|
true,
|
|
wrc.timeoutSeconds,
|
|
"clusterpolicies/*",
|
|
"kyverno.io",
|
|
"v1",
|
|
[]admregapi.OperationType{admregapi.Create, admregapi.Update},
|
|
),
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wrc *WebhookRegistrationClient) contructPolicyMutatingWebhookConfig(caData []byte) *admregapi.MutatingWebhookConfiguration {
|
|
return &admregapi.MutatingWebhookConfiguration{
|
|
ObjectMeta: v1.ObjectMeta{
|
|
Name: config.PolicyMutatingWebhookConfigurationName,
|
|
OwnerReferences: []v1.OwnerReference{
|
|
wrc.constructOwner(),
|
|
},
|
|
},
|
|
Webhooks: []admregapi.Webhook{
|
|
generateWebhook(
|
|
config.PolicyMutatingWebhookName,
|
|
config.PolicyMutatingWebhookServicePath,
|
|
caData,
|
|
true,
|
|
wrc.timeoutSeconds,
|
|
"clusterpolicies/*",
|
|
"kyverno.io",
|
|
"v1",
|
|
[]admregapi.OperationType{admregapi.Create, admregapi.Update},
|
|
),
|
|
},
|
|
}
|
|
}
|
|
func (wrc *WebhookRegistrationClient) contructDebugPolicyMutatingWebhookConfig(caData []byte) *admregapi.MutatingWebhookConfiguration {
|
|
url := fmt.Sprintf("https://%s%s", wrc.serverIP, config.PolicyMutatingWebhookServicePath)
|
|
glog.V(4).Infof("Debug PolicyMutatingWebhookConfig is registered with url %s\n", url)
|
|
|
|
return &admregapi.MutatingWebhookConfiguration{
|
|
ObjectMeta: v1.ObjectMeta{
|
|
Name: config.PolicyMutatingWebhookConfigurationDebugName,
|
|
},
|
|
Webhooks: []admregapi.Webhook{
|
|
generateDebugWebhook(
|
|
config.PolicyMutatingWebhookName,
|
|
url,
|
|
caData,
|
|
true,
|
|
wrc.timeoutSeconds,
|
|
"clusterpolicies/*",
|
|
"kyverno.io",
|
|
"v1",
|
|
[]admregapi.OperationType{admregapi.Create, admregapi.Update},
|
|
),
|
|
},
|
|
}
|
|
}
|