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
Sync data between Create Operand YAML and Form #3894
Sync data between Create Operand YAML and Form #3894
Conversation
fd7f449
to
771a446
Compare
/retest |
771a446
to
7137373
Compare
@benjaminapetersen @spadgett This is ready for review. |
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.
/approve
/lgtm
Nice work on this. It would be good to switch to optional chaining while changing the code, but since this was in existing code, I don't want to hold up the PR.
], | ||
.map((field) => { | ||
const capabilities = field.capabilities || []; | ||
const openAPIProperties = _.get(openAPI, 'properties.spec.properties'); |
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.
const openAPIProperties = _.get(openAPI, 'properties.spec.properties'); | |
const openAPIProperties = openAPI?.properties?.spec?.properties; |
|
||
const [formValues, setFormValues] = React.useState<FormValues>({ | ||
'metadata.name': 'example', | ||
'metadata.labels': [], | ||
'metadata.name': _.get(sample, 'metadata.name', 'example'), |
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.
'metadata.name': _.get(sample, 'metadata.name', 'example'), | |
'metadata.name': sample?.metadata?.name || 'example', |
'metadata.name': 'example', | ||
'metadata.labels': [], | ||
'metadata.name': _.get(sample, 'metadata.name', 'example'), | ||
'metadata.labels': SelectorInput.arrayify(_.get(sample, 'metadata.labels')) || [], |
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.
'metadata.labels': SelectorInput.arrayify(_.get(sample, 'metadata.labels')) || [], | |
'metadata.labels': SelectorInput.arrayify(sample?.metadata?.labels) || [], |
}, | ||
spec: _.reduce( | ||
specValues, | ||
(spec, value, path) => _.set(spec, path, value), | ||
_.get(props.sample, 'spec', {}), | ||
_.get(sample, 'spec', {}), |
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.
_.get(sample, 'spec', {}), | |
sample?.spec || {}, |
name: formValues['metadata.name'], | ||
labels: SelectorInput.objectify( | ||
formValues['metadata.labels'], | ||
) as ObjectMetadata['labels'], | ||
annotations: _.get(props.sample, 'metadata.annotations', {}), | ||
annotations: _.get(sample, 'metadata.annotations', {}), |
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.
annotations: _.get(sample, 'metadata.annotations', {}), | |
annotations: sample?.metadata?.annotations || {}, |
icon={_.get(props.clusterServiceVersion, 'spec.icon[0]')} | ||
provider={_.get(props.clusterServiceVersion, 'spec.provider')} | ||
displayName={providedAPI.displayName} | ||
icon={_.get(clusterServiceVersion, 'spec.icon[0]')} |
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.
icon={_.get(clusterServiceVersion, 'spec.icon[0]')} | |
icon={clusterServiceVersion?.spec?.icon?.[0]} |
provider={_.get(props.clusterServiceVersion, 'spec.provider')} | ||
displayName={providedAPI.displayName} | ||
icon={_.get(clusterServiceVersion, 'spec.icon[0]')} | ||
provider={_.get(clusterServiceVersion, 'spec.provider')} |
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.
provider={_.get(clusterServiceVersion, 'spec.provider')} | |
provider={clusterServiceVersion?.spec?.provider} |
operandModel, | ||
}) => { | ||
const { data: csv } = clusterServiceVersion; | ||
const csvAnnotations = _.get(csv, 'metadata.annotations', {}); |
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.
const csvAnnotations = _.get(csv, 'metadata.annotations', {}); | |
const csvAnnotations = csv?.metadata?.annotations || {}; |
|
||
const defaultSample = React.useMemo<K8sResourceKind>( | ||
() => | ||
JSON.parse(_.get(csvAnnotations, annotationKey, '[]')).find( |
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.
JSON.parse(_.get(csvAnnotations, annotationKey, '[]')).find( | |
JSON.parse(csvAnnotations?.[annotationKey] || '[]').find( |
@spadgett I did consider converting to optional chaining in a lot of those places. Decided against it to keep my changes to a minimum. Clearly worked out in my favor with the size of this PR 😆 |
/retest Please review the full test history for this PR and help us cut down flakes. |
6 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/lgtm cancel Runtime error in crud scenario
|
7137373
to
5114672
Compare
95db8cb
to
3dd119f
Compare
/hold cancel |
@spadgett It looks like the olm test was the problem. Looking at https://github.com/openshift/console/blob/006516745042a2d99f65f70ca9eded19a0600f9a/frontend/packages/operator-lifecycle-manager/integration-tests/scenarios/descriptors.scenario.ts#L348-L350p A new operand is created at the beginning of that test scenario but is not cleaned up until after all of the test cases run. We check the list and details pages, then move on to the operand creation form, where we try to create a new operand using the form. This step was failing because it is trying to create a duplicate operand. Not sure why or how we weren't failing on this before now. |
@@ -314,98 +335,114 @@ export const CreateOperandForm: React.FC<CreateOperandFormProps> = (props) => { | |||
}; | |||
|
|||
const [formValues, setFormValues] = React.useState<FormValues>({ | |||
'metadata.name': 'example', | |||
'metadata.labels': [], | |||
'metadata.name': _.get(sample, 'metadata.name', 'example'), |
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 line is what was causing the integration test failure. Previously, metadata.name
was not synced from the YAML view and just defaulted to 'example', so when the integration tests created a new operand using the form, it didn't conflict with the existing one. Now that data is synced, the metadata.name
field from the YAML view is carried over to the form view and conflicts with the existing resource.
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.
@benjaminapetersen @spadgett I guess an easier solution to this failure would be to add a step to change the operand name before we create it via the form. But... since deleting and recreating it seems to work just fine (and adds a little bit more coverage), we might as well just leave it. Any objections or thoughts?
/retest |
/hold nevermind, CI is broken. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: benjaminapetersen, spadgett, 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 |
/retest |
5 similar comments
/retest |
/retest |
/retest |
/retest |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
Sync data between yaml and form editors in the create operand workflow. Also fix visual issue where field group names overlap left blue border. It appears that the implementation of the blue border on patternfly accordions changed at some point and our css to override those styles was no longer working as expected.
Also update olm descriptor integration tests to delete the test operand between testing list/details views and creation form. There was previously no cleanup between these tests, which was causing a failure when attempting to create a new operand during the latter steps.