Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Fix missing package-level vars in GCP policy editor #132068

Merged
merged 5 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we populate packagePolicy.vars?.[varName]?.value with the default value here instead of displaying the default value, I think if the user do not change the value it will not be saved no? (not tested locally)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed up fede140 which should address this. We now create the vars[varName] object entry on packagePolicy and set the default value if necessary, and the values/vars persist as expected.

image


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