Merge remote-tracking branch 'origin/master' into fix/1784-managed-repository-materialization
This commit is contained in:
@@ -76,6 +76,16 @@ function normalizeAdmissionPolicySpec(value) {
|
||||
if (Object.prototype.hasOwnProperty.call(spec, "matchConstraints")) {
|
||||
const matchConstraints = { ...record(spec.matchConstraints) };
|
||||
if (!Object.prototype.hasOwnProperty.call(matchConstraints, "matchPolicy")) matchConstraints.matchPolicy = "Equivalent";
|
||||
for (const selector of ["namespaceSelector", "objectSelector"]) {
|
||||
if (isEmptyRecord(matchConstraints[selector])) delete matchConstraints[selector];
|
||||
}
|
||||
if (Array.isArray(matchConstraints.resourceRules)) {
|
||||
matchConstraints.resourceRules = matchConstraints.resourceRules.map((value) => {
|
||||
const rule = { ...record(value) };
|
||||
if (rule.scope === "*") delete rule.scope;
|
||||
return rule;
|
||||
});
|
||||
}
|
||||
spec.matchConstraints = matchConstraints;
|
||||
}
|
||||
return spec;
|
||||
@@ -91,6 +101,10 @@ function normalizeAdmissionBindingSpec(value) {
|
||||
return spec;
|
||||
}
|
||||
|
||||
function isEmptyRecord(value) {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
||||
}
|
||||
|
||||
function evaluatePacAdmissionState(inputValue) {
|
||||
const input = record(inputValue);
|
||||
const policy = record(input.policy);
|
||||
|
||||
Reference in New Issue
Block a user