ops-itop / itop-extensions

my extensions of itop
29 stars 12 forks source link

管理专用annotation导致整个ingress无法更新 #106

Closed annProg closed 5 years ago

annProg commented 5 years ago

描述

当一个ingress的annotation包含adminonly的规则时,非管理员无法添加或更新其他任何规则

问题

DeploymentIngress 中的以下代码,未检测是否是变更项目,应只检查变更的项目

// 检查ingressannotations格式
$validate = $this->Get('ingressannotations_list');
foreach($validate as $val) {
    $value = $val->Get('value');
    $pattern = $val->Get('k8singressannotations_validate');
    if(!$value) {
        $value = $val->Get('k8singressannotations_default_value');
        $val->Set('value', $value);
    }
    if($pattern && !preg_match($pattern, $value)) {
        $this->m_aCheckIssues[] = Dict::Format("Class:lnkK8sIngressAnnotationsToDeployment/Error:ValueNotValid", $pattern);
    }

    if($val->Get('adminonly') == "yes" && !UserRights::IsAdministrator()) {
        $this->m_aCheckIssues[] = Dict::Format("Class:lnkK8sIngressAnnotationsToDeployment/Error:AdminOnly", $val->Get('k8singressannotations_name'));
    }
}
parent::DoCheckToWrite();
}