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
Bug 1797766: Resource Requirements" specDescriptor fields - CPU and Memory injects empty string YAML editor #5525
Conversation
@cyril-ui-developer: This pull request references Bugzilla bug 1797766, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
const [memory, setMemory] = React.useState<string>( | ||
_.get(obj.spec, `${path}.${type}.memory`, ''), | ||
); | ||
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a candidate for the typescript syntax instead? obj.spec?.path?.type?.cpu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a candidate for the typescript syntax instead?
obj.spec?.path?.type?.cpu
@benjaminapetersen path
and type
are string values to construct a valid path to the obj. Tried optional chaining in past here and got lint error. Trying it now seems to be happy. Investigating what was the issue in the past. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with using optional chaining here. I think it is because the path,
and type
are just string value, although I'm investigating it. When I console.log the value for optional chaining, I got undefined:
_.get(obj.spec, ${path}.${type}.cpu
) 33
obj.spec?.path?.type?.cpu undefined
@TheRealJon PTAL |
21eb4a3
to
fbe8b54
Compare
@spadgett Rebased. Thanks |
fbe8b54
to
7280d92
Compare
7280d92
to
9415612
Compare
@cyril-ui-developer: This pull request references Bugzilla bug 1797766, which is valid. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is untested, but I would think something like this would work:
const submit = (e) => {
e.preventDefault();
const newObj =
cpu || memory || storage
? _.set(_.cloneDeep(obj), `spec.${path}.${type}`, {
...(cpu && { cpu }),
...(memory && { memory }),
...(storage && { 'ephemeral-storage': storage }),
})
: obj;
return props.handlePromise(k8sUpdate(model, newObj), props.close);
};
@cyril-ui-developer: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
9415612
to
e336f49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is untested, but I would think something like this would work:
const submit = (e) => { e.preventDefault(); const newObj = cpu || memory || storage ? _.set(_.cloneDeep(obj), `spec.${path}.${type}`, { ...(cpu && { cpu }), ...(memory && { memory }), ...(storage && { 'ephemeral-storage': storage }), }) : obj; return props.handlePromise(k8sUpdate(model, newObj), props.close); };
@TheRealJon Looks cleaner! Works with small tweak.
PTAL. Thanks
const [memory, setMemory] = React.useState<string>( | ||
_.get(obj.spec, `${path}.${type}.memory`, ''), | ||
); | ||
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a candidate for the typescript syntax instead?
obj.spec?.path?.type?.cpu
@benjaminapetersen path
and type
are string values to construct a valid path to the obj. Tried optional chaining in past here and got lint error. Trying it now seems to be happy. Investigating what was the issue in the past. Thanks
const [memory, setMemory] = React.useState<string>( | ||
_.get(obj.spec, `${path}.${type}.memory`, ''), | ||
); | ||
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue with using optional chaining here. I think it is because the path,
and type
are just string value, although I'm investigating it. When I console.log the value for optional chaining, I got undefined:
_.get(obj.spec, ${path}.${type}.cpu
) 33
obj.spec?.path?.type?.cpu undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cyril-ui-developer, TheRealJon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@cyril-ui-developer: All pull requests linked via external trackers have merged: Bugzilla bug 1797766 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @TheRealJon
/cc @spadgett