Skip to content

Conversation

@rottencandy
Copy link
Contributor

Fixes:
https://issues.redhat.com/browse/ODC-6414

Description:
This is a follow up of #10331. Adds support for setting builder image environments defined by the ImportEnvironment extension to be loaded and shown in edit application form.

Unit test coverage report:

Test setup:

  • Create a node-js application from git import flow and use the run command field.
  • Open the edit form for the application.

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci openshift-ci bot added the component/dev-console Related to dev-console label Dec 1, 2021
@christoph-jerolimov
Copy link
Member

/retest
/assign

@christoph-jerolimov
Copy link
Member

/cc

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

(remove duplicate)

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

@rottencandy Found an issue: When editing the npm start command and saving the Deployment, the BuildConfig environment variables were added and not replaced:

image

Can you also add some unit tests for BuilderImageEnvironments? :)

@openshift-ci openshift-ci bot added component/core Related to console core functionality component/topology Related to topology labels Dec 6, 2021
@rottencandy
Copy link
Contributor Author

Fixed duplicating envs and added tests.

@rottencandy
Copy link
Contributor Author

/retest-required

@rottencandy
Copy link
Contributor Author

Propagating Docs & PX ack labels from epic ODC-6266

/label docs-approved
/label px-approved

@openshift-ci openshift-ci bot added docs-approved Signifies that Docs has signed off on this PR px-approved Signifies that Product Support has signed off on this PR labels Dec 8, 2021
@christoph-jerolimov
Copy link
Member

/retest

Comment on lines 206 to 209
Copy link
Member

Choose a reason for hiding this comment

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

As discussed in slack (only as info for other reviews) that the merge here doesn't allow the user to unset the "Start command" at the moment. It is automatically restored from the collapsed environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to hide envs from build config section, and to not pick emptied fields.

Copy link
Member

@christoph-jerolimov christoph-jerolimov Dec 9, 2021

Choose a reason for hiding this comment

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

I personally would use the customEnvs first and then override it with user envs, but that's a big IMHO and I wouldn't add this comment if I didn't find the "not saving" issue above. :)

@openshift-ci openshift-ci bot added the component/sdk Related to console-plugin-sdk label Dec 9, 2021
@rottencandy rottencandy force-pushed the feat/import-env-edit branch 2 times, most recently from f9460a5 to bd7feea Compare December 9, 2021 14:13
Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

Small bug found when saving a Deployment without npm start command.

Comment on lines 185 to 192
Copy link
Member

Choose a reason for hiding this comment

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

When editing a Deployment with a BuildConfig environment variable (A=a) and no npm start command (no NPM_RUN) it was not possible to to save the edit form. It shows "Cannot convert undefined or null to object"

This happens when building the buildEnvs because imageEnv is undefined.

I think this would help but any solution is fine for me! :)

Suggested change
const customBuildEnvs = imageEnv
const customEnvs = imageEnv
? Object.keys(imageEnv)
.filter((k) => !!imageEnv[k])
.map((k) => ({ name: k, value: imageEnv[k] }))
: [];
const buildEnvs = env.filter(
(buildEnv) => !Object.keys(imageEnv).some((envKey) => buildEnv.name === envKey),
);
const imageEnvKeys = imageEnv ? Object.keys(imageEnv) : [];
const customEnvs = imageEnvKeys
.filter((k) => !!imageEnv[k])
.map((k) => ({ name: k, value: imageEnv[k] }));
const buildEnvs = env.filter(
(buildEnv) => !imageEnvKeys.some((envKey) => buildEnv.name === envKey),
);

Or could we simplify this by extracting buildEnvs with an imageEnvKeys?.includes(buildEnv.name) instead of .some? Not 100% sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I forgot it could be undefined. Updated.

Copy link
Member

Choose a reason for hiding this comment

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

Not necessary change or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was testing this but did not revert : p

Comment on lines 206 to 209
Copy link
Member

@christoph-jerolimov christoph-jerolimov Dec 9, 2021

Choose a reason for hiding this comment

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

I personally would use the customEnvs first and then override it with user envs, but that's a big IMHO and I wouldn't add this comment if I didn't find the "not saving" issue above. :)

Comment on lines 114 to 115
Copy link
Member

Choose a reason for hiding this comment

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

Nit. Can we also check that it only exists once? Wdyt?

(Again, only add this comment because you need to touch the PR anyway because saving doesn't work when start command is not defined.)

Suggested change
cy.get(`input[data-test="pairs-list-name"][value="${envKey}"]`).should('exist');
cy.get(`input[data-test="pairs-list-value"][value="${envVal}"]`).should('exist');
cy.get(`input[data-test="pairs-list-name"][value="${envKey}"]`).should('have.length', 1)
cy.get(`input[data-test="pairs-list-value"][value="${envVal}"]`).should('have.length', 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@christoph-jerolimov
Copy link
Member

/retest

1 similar comment
@christoph-jerolimov
Copy link
Member

/retest

@christoph-jerolimov
Copy link
Member

Tested this locally and on a cluster created with cluster bot. Tested many cases with and without, changing and deleting the npm "Start command". Works fine. 👍

/approve
/lgtm
/label qe-approved

@openshift-ci openshift-ci bot added qe-approved Signifies that QE has signed off on this PR lgtm Indicates that a PR is ready to be merged. labels Dec 10, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 10, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerolimov, rottencandy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2021
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 10, 2021

@rottencandy: all tests passed!

Full PR test history. Your PR dashboard.

Details

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.

@openshift-merge-robot openshift-merge-robot merged commit b850b61 into openshift:master Dec 10, 2021
@rottencandy rottencandy deleted the feat/import-env-edit branch April 21, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console component/sdk Related to console-plugin-sdk component/topology Related to topology docs-approved Signifies that Docs has signed off on this PR lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants