yunikorn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-yunikorn-k8shim] TaoYang526 commented on a change in pull request #81: [YUNIKORN-28] Support validating yunikorn-configs before admitting it
Date Wed, 11 Mar 2020 01:30:09 GMT
TaoYang526 commented on a change in pull request #81: [YUNIKORN-28] Support validating yunikorn-configs
before admitting it
URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/81#discussion_r390700267
 
 

 ##########
 File path: pkg/plugin/admissioncontrollers/webhook/admission_controller.go
 ##########
 @@ -167,6 +169,53 @@ func updateLabels(pod *v1.Pod, patch []patchOperation) []patchOperation
{
 	return patch
 }
 
+func (c *admissionController) validateConf(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionResponse
{
+	req := ar.Request
+	log.Logger.Info("AdmissionReview",
+		zap.Any("Kind", req.Kind),
+		zap.String("Namespace", req.Namespace),
+		zap.String("UID", string(req.UID)),
+		zap.String("Operation", string(req.Operation)),
+		zap.Any("UserInfo", req.UserInfo))
+
+	if req.Kind.Kind == "ConfigMap" {
+		var configmap v1.ConfigMap
+		if err := json.Unmarshal(req.Object.Raw, &configmap); err != nil {
+			return &v1beta1.AdmissionResponse{
+				Result: &metav1.Status{
+					Message: err.Error(),
+				},
+			}
+		}
+		// validate new/updated config map
+		if err := c.validateConfigMap(&configmap); err != nil {
+			return &v1beta1.AdmissionResponse{
+				Result: &metav1.Status{
+					Message: err.Error(),
 
 Review comment:
   Make sense.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org


Mime
View raw message