Skip to content

Conversation

@yaacov
Copy link
Member

@yaacov yaacov commented Aug 18, 2019

Add a plugins readme.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 18, 2019
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 18, 2019
@yaacov
Copy link
Member Author

yaacov commented Aug 18, 2019

@rhrazdil @mareklibra @vojtechszocs @suomiy @rawagner please review.

@yaacov
Copy link
Member Author

yaacov commented Aug 18, 2019

/test e2e-aws-console-olm

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 19, 2019
@yaacov yaacov force-pushed the plugins-readme branch 4 times, most recently from 5ad400d to 92d955c Compare August 19, 2019 07:31
@yaacov
Copy link
Member Author

yaacov commented Aug 19, 2019

/test e2e-aws-console-olm

2 similar comments
@yaacov
Copy link
Member Author

yaacov commented Aug 19, 2019

/test e2e-aws-console-olm

@yaacov
Copy link
Member Author

yaacov commented Aug 19, 2019

/test e2e-aws-console-olm

Copy link
Contributor

@pcbailey pcbailey left a comment

Choose a reason for hiding this comment

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

This is great, Kobi! Thanks for getting this started! =)

I just have some suggestions regarding word choice and a few grammatical and typographical fixes.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

'Plugins packages' -> 'Plugin packages'

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would work nicely as a bulleted list. You could put the naming convention note in parentheses next to the plugin entry file item.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please call them "plugin entry modules" since they are effectively ECMAscript modules.

Having package.json and OWNERS files is mandatory.

Every plugin should follow the recommended file structure:

  • src directory
  • integration-tests directory (if needed)
  • plugin entry module at src/plugin.ts
  • src/components for React components, src/models for k8s model definitions
  • unit tests co-located at /path/to/unit/__tests__/unit.spec.ts

In addition, every plugin should typically provide (at least) these two extensions:

  • ModelDefinition - add new k8s model definitions
  • FeatureFlag/Model (in future also FeatureFlag/Action) - add new feature flag

and use the newly added feature flags (possibly together with core Console flags) to gate its extensions.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming we're saying that unit tests are optional. I would word that like "Unit tests are encouraged, but optional. Unit tests should be placed in __tests__ directories as close as possible to the source code that they test. Integration tests should be placed in an integration-tests directory at the root level of the plugin directory."

Copy link
Contributor

Choose a reason for hiding this comment

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

Unit tests are highly encouraged. Testing is an important part of developing software.

Tests should be simple to read and consequently easy to maintain. If they're not, simplify them. Prefer smaller, focused test cases.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"Plugin directory name" -> "The plugin directory name"

Copy link
Contributor

Choose a reason for hiding this comment

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

Packages whose name starts with console- are expected to be maintained by core Console team, so they shouldn't have an OWNERS file.

Every (non-core) plugin package must have an OWNERS file. Its directory name should end with -plugin to denote its purpose.

Note: dev-console is the only exception to this rule, cc @christianvogt 😉

In addition, Console app itself is a plugin, see packages/console-app/src/plugin.tsx.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This applies to directories as well, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but I wouldn't mention it here, I think this is common knowledge (?)

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree with this style and it goes against other best practices. That being said this is not the right location to outline stylistic concerns. It's better managed through eslint enforcement or a separate styleguide.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"consolePlugin map, in the plugins package.json." -> "consolePlugin map in the plugin's package.json."

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"Test path is relative the plugin root" -> "The test path is relative to the plugin root"

You can delete the comma after "@console/internal-integration-tests".

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"OWNERS file define a list of maintainers, community plugins" -> "OWNERS file defines a list of maintainers. Community plugins".

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"responsible of reviewing" -> "responsible for reviewing"

"For more in depth information see [prow]" -> "For more in-depth information, see the [prow]"

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

"console or community teams, plugins" -> "console or community teams. Plugins"

You can delete the comma after "OWNERS file".

Copy link
Contributor

@vojtechszocs vojtechszocs left a comment

Choose a reason for hiding this comment

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

@yaacov Posted some initial comments for your consideration.

@pcbailey Many thanks for your comments!

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

@yaacov Can you please move this file to packages/console-plugin-sdk/README.md ?

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Many important things could be covered here:

  • plugins are static meaning their code gets bundled ("baked") into Console build output
    • plugins are not loaded dynamically at runtime, which in turn simplifies the architecture (no need to sandbox plugin execution or its interaction with Console app or Bridge server)
    • console-app dependencies control the set of plugins to include in Console build, this can be overridden via CONSOLE_PLUGINS env. variable
  • plugins have their code represented as Console monorepo packages
    • this increases the level of trust between Console app and its plugins
    • plugin code close to Console code avoids cross-repo PR maintenance issues
    • each plugin has an OWNERS file denoting its ownership (see here for details on reviewers and approvers)
  • plugins are declarative meaning they provide a list of extensions to be interpreted
    • each extension has a unique type and properties representing its parameters (data and/or callbacks)
    • (upcoming change) each extension has flags object to support gating by Console feature flags
  • Console demo plugin is used to demonstrate specific extensions
    • it should contain at least one instance of every extension type (sadly, this isn't the case yet)
    • it should be a "synthetic" (foo-bar, not-a-real-world) example acting as a starting point for further exploration

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Please call them "plugin entry modules" since they are effectively ECMAscript modules.

Having package.json and OWNERS files is mandatory.

Every plugin should follow the recommended file structure:

  • src directory
  • integration-tests directory (if needed)
  • plugin entry module at src/plugin.ts
  • src/components for React components, src/models for k8s model definitions
  • unit tests co-located at /path/to/unit/__tests__/unit.spec.ts

In addition, every plugin should typically provide (at least) these two extensions:

  • ModelDefinition - add new k8s model definitions
  • FeatureFlag/Model (in future also FeatureFlag/Action) - add new feature flag

and use the newly added feature flags (possibly together with core Console flags) to gate its extensions.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Unit tests are highly encouraged. Testing is an important part of developing software.

Tests should be simple to read and consequently easy to maintain. If they're not, simplify them. Prefer smaller, focused test cases.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Plugin Entry Module 😄

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use a dotted path notation, i.e. consolePlugin.entry value.

(These aren't variables from JSON file processing point of view.)

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

For better type checking and code completion, use a type parameter that represents the union of all the extension types consumed by the plugin.

// don't do this
const plugin: Plugin<any> = [ /* stuff */ ];
// do this
const plugin: Plugin<FooExtension | BarExtension> = [ /* stuff */ ];
// or better yet, this
type ConsumedExtensions = FooExtension | BarExtension;
const plugin: Plugin<ConsumedExtensions> = [ /* stuff */ ];

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, we should.

We can refer to console-demo-plugin but it isn't complete at the moment in terms of having at least one instance of each extension type. I'm planning to write a test for that.

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we simply state that Console plugins are 1st class citizens of Console monorepo and therefore reuse the same testing (Jest, Protractor, etc.) infrastructure and conventions?

PLUGINS.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

The OWNERS file should also include labels:

labels:
 - component/<plugin-name>

To add a new component labels, raise a PR here: https://github.com/openshift/release/blob/master/cluster/ci/config/prow/labels.yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks ! updated link

@openshift-ci-robot openshift-ci-robot added the component/sdk Related to console-plugin-sdk label Sep 10, 2019
@yaacov yaacov changed the title [WIP]Add a Plugins readme stub Add a Plugins readme stub Sep 10, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 10, 2019
@yaacov
Copy link
Member Author

yaacov commented Sep 10, 2019

@christianvogt @vojtechszocs @pcbailey Thanks for the reviews and helpful suggestions ❗

I removed the WIP, please re-review.

@yaacov
Copy link
Member Author

yaacov commented Sep 10, 2019

/test e2e-aws-console

Copy link
Contributor

Choose a reason for hiding this comment

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

"Plugins are static, their code gets bundled ("baked") into Console build output:"

"Plugins are static. Their code gets bundled ("baked") into the Console build output:"

Copy link
Contributor

Choose a reason for hiding this comment

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

"with Console app or Bridge"

"with the Console app or Bridge"

Copy link
Contributor

Choose a reason for hiding this comment

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

"Console-app dependencies control the set of plugins to include in Console build, this can be overridden via CONSOLE_PLUGINS env. variable."

"Console-app dependencies control the set of plugins to include in the Console build. This can be overridden using the CONSOLE_PLUGINS environment variable."

Should we provide an example of this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should.

PR #1926 documents this and provides examples for different scenarios, most notably:

  • development with specific plugins
  • development without any plugins

Copy link
Contributor

Choose a reason for hiding this comment

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

"between Console app"

"between the Console app"

Copy link
Contributor

Choose a reason for hiding this comment

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

"see here for details"

Is "here" supposed to be a link? If not, I'd say "see the OWNERS file section below for details" instead. Whenever I see something like "see here", I automatically assume the "here" is a link.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is "here" supposed to be a link?

It was, in my original comment 😃

Whenever I see something like "see here", I automatically assume the "here" is a link.

👍

A good documentation favors specific terms, like "OWNERS file section of the Prow approve plugin", instead of loose terms, like "here" or "this link".

Copy link
Contributor

Choose a reason for hiding this comment

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

"The OWNERS file define a list of maintainers, community"

"The OWNERS file defines a list of maintainers. Community"

Copy link
Contributor

Choose a reason for hiding this comment

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

"responsible of reviewing and approving pull requests for this plugin. For more in depth information see [prow]"

"responsible for reviewing and approving pull requests for this plugin. For more in-depth information, see the [prow]"

Copy link
Contributor

Choose a reason for hiding this comment

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

What do the labels do/represent?

Copy link
Contributor

Choose a reason for hiding this comment

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

@pcbailey These are GitHub PR labels representing components which are touched by the given change (PR).

For example, PR that touches shared code pkg and KubeVirt plugin pkg has labels component/shared and component/kubevirt.

In general, this is a Prow CI feature that allows PRs affected by OWNERS file(s) to be labeled.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

"Plugins can be owned by console or community teams, plugins maintained by the console team will not have an OWNERS file, and by convention use a directory named console-<some-name>."

"Plugins can be owned either by the Console team or community teams. Plugins maintained by the Console team will not have an OWNERS file and will use a directory named console-<some-name> by convention."

@yaacov yaacov force-pushed the plugins-readme branch 3 times, most recently from 7caab34 to bd5a472 Compare September 11, 2019 09:10
@openshift-bot
Copy link
Contributor

/retest

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

@spadgett
Copy link
Member

/hold
for #2817

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 23, 2019
@yaacov yaacov changed the base branch from master-4.3 to master September 24, 2019 05:49
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 24, 2019
@yaacov
Copy link
Member Author

yaacov commented Sep 24, 2019

changing back to master :-)
for #2817 ?

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 24, 2019
@yaacov
Copy link
Member Author

yaacov commented Sep 24, 2019

/test e2e-aws-console-olm

@yaacov
Copy link
Member Author

yaacov commented Sep 24, 2019

/test e2e-aws

4 similar comments
@yaacov
Copy link
Member Author

yaacov commented Sep 24, 2019

/test e2e-aws

@yaacov
Copy link
Member Author

yaacov commented Sep 24, 2019

/test e2e-aws

@yaacov
Copy link
Member Author

yaacov commented Sep 25, 2019

/test e2e-aws

@yaacov
Copy link
Member Author

yaacov commented Sep 25, 2019

/test e2e-aws

@yaacov
Copy link
Member Author

yaacov commented Sep 26, 2019

@spadgett is this still do-not-merge/hold ?

@vojtechszocs
Copy link
Contributor

@spadgett is this still do-not-merge/hold ?

@yaacov The master branch is now updated with 4.3 changes and open for new changes.

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 26, 2019
@vojtechszocs
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 26, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pcbailey, vojtechszocs, yaacov

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

@vojtechszocs
Copy link
Contributor

FYI the CONSOLE_PLUGINS env. var is described in PR #1926 - we can take examples from that.

@yaacov
Copy link
Member Author

yaacov commented Sep 26, 2019

@vojtechszocs a question about CONSOLE_PLUGINS

CONSOLE_PLUGINS can only remove plugins required by console-app (?), can we add a plugin that is currently not required by console-app ( e.g. the demo-plugin or some e2e-tests-plugin ) ?

The use case I have in mind is adding a testing plugin by only using CONSOLE_PLUGINS without adding it to the console-app require var ( cc @rhrazdil )

@vojtechszocs
Copy link
Contributor

CONSOLE_PLUGINS can only remove plugins required by console-app (?)

The plugins specified via the CONSOLE_PLUGINS env. variable don't have to be listed as dependencies in packages/console-app/package.json.

See resolvePluginPackages function in packages/console-plugin-sdk/src/codegen/plugin-resolver.ts - the pluginFilter parameter is not used with the CONSOLE_PLUGINS override.

can we add a plugin that is currently not required by console-app ( e.g. the demo-plugin or some e2e-tests-plugin )

Yes.

The use case I have in mind is adding a testing plugin by only using CONSOLE_PLUGINS without adding it to the console-app require var ( cc @rhrazdil )

Yes, this is a valid and supported use case 👍

@openshift-merge-robot openshift-merge-robot merged commit 3b657fe into openshift:master Sep 26, 2019
@spadgett spadgett added this to the v4.3 milestone Sep 26, 2019
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/sdk Related to console-plugin-sdk lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants