Skip to content

Commit

Permalink
Fix missing package-level vars in GCP policy editor
Browse files Browse the repository at this point in the history
Display package-level variables even if they aren't defined on the
existing package policy during an upgrade, honoring default values for
all variables if they exist.

Fixes #131251
  • Loading branch information
kpollich committed May 11, 2022
1 parent 327df57 commit 132f547
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const validatePackagePolicy = (
description: null,
namespace: null,
inputs: {},
vars: {},
};
const namespaceValidation = isValidNamespace(packagePolicy.namespace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ export const StepDefinePackagePolicy: React.FunctionComponent<{

{/* Required vars */}
{requiredVars.map((varDef) => {
const { name: varName, type: varType } = varDef;
if (!packagePolicy.vars || !packagePolicy.vars[varName]) return null;
const value = packagePolicy.vars[varName].value;
const { name: varName, type: varType, default: defaultValue } = varDef;
const value = packagePolicy.vars?.[varName]?.value ?? defaultValue;

return (
<EuiFlexItem key={varName}>
<PackagePolicyInputVarField
Expand Down

0 comments on commit 132f547

Please sign in to comment.