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
Add container source form in event source add flow #5061
Add container source form in event source add flow #5061
Conversation
/kind feature |
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.
@karthikjeeyar this is looking good, thanks for doing this! Approved by UX
We will likely have some copy updates for help text, but UX won't be proposing til all PRs for Feature Freeze are merged.
Thanks Serena, we will have tech debt item to align with UX updates post FF. |
ab79371
to
b078d63
Compare
containers: [ | ||
{ | ||
image: '', | ||
name: '', | ||
args: [{ name: '' }], | ||
env: [], | ||
}, | ||
], |
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.
can we have
template: {
spec: {
containers: [
{
image: '',
name: '',
args: [{ name: '' }],
env: [],
},
]
}
}
then we can pass it as is to getEventSourcesDepResource
and avoid util getContainerSourceResource
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.
We cannot avoid the util function as MulticolumnField value return an array objects
ie: args: [ {name: 'x'} ]
which is needs transformation in that util function to make it array of strings. eg: `args: ['x'].
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts
Show resolved
Hide resolved
frontend/packages/knative-plugin/src/utils/create-eventsources-utils.ts
Outdated
Show resolved
Hide resolved
bfe0748
to
dae951f
Compare
Thanks @karthikjeeyar Verified locally , works as expected /approve /assign @sahil143 |
frontend/packages/knative-plugin/src/components/add/event-sources/ContainerSourceSection.tsx
Show resolved
Hide resolved
import { getSuggestedName } from '@console/dev-console/src/utils/imagestream-utils'; | ||
|
||
const ContainerSourceSection: React.FC = () => { | ||
const envPath = 'data.containersource.containers[0].env'; |
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.
If there is a case one of the values prop is undefined then please use optional chaining to get env values in a const something like envValues
.
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.
I use this envPath
in setFieldValue function below, so it will not work if i use optional chaining path in Formik and moreover the values has a default env values as initialValues which will be always present.
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.
Based on your previous comment, if we are destructuring then we no longer need this Path variable.
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.
Yes agreed! After destructuring, this is not needed. this was just a suggestion in case some values are optional.
const envPath = 'data.containersource.containers[0].env'; | ||
const { values, setFieldValue } = useFormikContext<FormikValues>(); | ||
|
||
const initialEnvValues = !_.isEmpty(values[envPath]) |
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 initialEnvValues = !_.isEmpty(values[envPath]) | |
const initialEnvValues = !_.isEmpty(envValues) |
const { values, setFieldValue } = useFormikContext<FormikValues>(); | ||
|
||
const initialEnvValues = !_.isEmpty(values[envPath]) | ||
? _.map(values[envPath], (env) => _.values(env)) |
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.
same as above
frontend/packages/knative-plugin/src/components/add/event-sources/ContainerSourceSection.tsx
Outdated
Show resolved
Hide resolved
dae951f
to
a822a22
Compare
then: yup.object().shape({ | ||
containersource: yup.object().shape({ | ||
containers: yup.array().of( | ||
yup.object({ |
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.
I think here also it should be yup.object().shape({image: yup.string().required('Required')})
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.
You can either use yup.object().shape({x: y})
or directly pass the shape in the object's constructor yup.object({x:y})
. Both does exactly the same thing.
Refer: https://github.com/jquense/yup#object
Usually, i do object().shape if there is nested object, for plain one level object i pass the shape inside the object(shape)
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.
Okay. Got it. Thanks
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: divyanshiGupta, invincibleJai, karthikjeeyar, serenamarie125 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 |
Fixes:- https://issues.redhat.com/browse/ODC-3532
Analysis / Root cause:
Container source option is missing in event source creation flow.
Solution Description:
Added container source option in event source creation flow
doc: https://github.com/knative/docs/tree/master/docs/eventing/samples/container-source
screenshot:
Form structure:
Unit test converage:
containerSourceSection:
containersource validations:
Browser conformance:
cc: @serenamarie125 @christianvogt