Skip to content
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

feat!: add organization support #499

Merged
merged 1 commit into from
Nov 7, 2024
Merged

feat!: add organization support #499

merged 1 commit into from
Nov 7, 2024

Conversation

maxrake
Copy link
Contributor

@maxrake maxrake commented Nov 7, 2024

This change adds support for organizations. It does so by adding an optional --org argument to the phylum-ci entry point. That argument will take precedence over any value found in the Phylum settings file. The argument and all the logic and documentation around it allow for no org to be specified. This is intentional since there will have to be a transition period where some users may not be using orgs just yet.

When an org is specified, it is required that a group also be specified. However, it is still possible to specify a group without an org and even no group at all. The log output was updated to make it more clear which project/org/group combo is in use.

Additional changes made include:

  • Update the custom ci Phylum analysis extension
    • Add --org option and use it when calling PhylumApi::analyze
  • Account for change in phylum project status json output
    • Change repository_url to repositoryUrl
    • Fixes subtle bug where existing repo_url entries were overwritten
  • Update documentation
  • Refactor and format throughout
    • Create _cmd_extender helper function to add common CLI options
      • This also helps to keep the McCabe complexity score low for QA
    • Use the parent OSError exception instead of more specific one
      • This may help prevent unhandled exceptions on Windows

BREAKING CHANGE: Phylum CLI installs before v7.1.4-rc1 are no longer supported. That release is the first one providing support for analysis with organizations via extensions.

Testing

The changes in this PR are available for testing with the maxrake/phylum-ci:orgs Docker image found on Docker Hub.

The changes were tested explicitly for each of the following scenarios:

  • org specified in settings.yaml file only
  • org specified with --org option only
  • different orgs specified in settings.yaml file and --org option
  • non-existent org specified
  • org specified without a group
  • org/group pair that does not already exist
  • org/group pair that does already exist
  • group specified without an org
  • project/org/group combos that do not already exist
  • project/org/group combos that do already exist

TODO

A separate PR in the phylum-analyze-pr-action repository will be created to update the documentation there. That PR won't be merged until after the changes from this PR have been approved, merged, and a release created from it.

This change adds support for organizations. It does so by adding an
optional `--org` argument to the `phylum-ci` entry point. That argument
will take precedence over any value found in the Phylum settings file.
The argument and all the logic and documentation around it allow for no
org to be specified. This is intentional since there will have to be a
transition period where some users may not be using orgs just yet.

When an org is specified, it is required that a group also be specified.
However, it is still possible to specify a group without an org and even
no group at all. The log output was updated to make it more clear which
project/org/group combo is in use.

Additional changes made include:

* Update the custom `ci` Phylum analysis extension
  * Add `--org` option and use it when calling `PhylumApi::analyze`
* Account for change in `phylum project status` json output
  * Change `repository_url` to `repositoryUrl`
  * Fixes subtle bug where existing `repo_url` entries were overwritten
* Update documentation
  * Add example usage
  * Link to https://docs.phylum.io/knowledge_base/phylum_project_files
  * Link to https://docs.phylum.io/knowledge_base/api-keys in more spots
* Refactor and format throughout
  * Create `_cmd_extender` helper function to add common CLI options
    * This also helps to keep the McCabe complexity score low for QA
  * Use the parent `OSError` exception instead of more specific one
    * This may help prevent unhandled exceptions on Windows

BREAKING CHANGE: Phylum CLI installs before v7.1.4-rc1 are no longer
supported. That release is the first one providing support for analysis
with organizations via extensions.
@maxrake maxrake self-assigned this Nov 7, 2024
@maxrake maxrake requested a review from a team as a code owner November 7, 2024 19:11
@maxrake maxrake requested a review from cd-work November 7, 2024 19:11
maxrake added a commit to phylum-dev/phylum-analyze-pr-action that referenced this pull request Nov 7, 2024
This PR updates the documentation for the GitHub Action to
match the examples provided in phylum-dev/phylum-ci#499.
@maxrake maxrake merged commit 1ad0ea7 into main Nov 7, 2024
23 checks passed
@maxrake maxrake deleted the orgs branch November 7, 2024 20:07
maxrake added a commit to phylum-dev/phylum-analyze-pr-action that referenced this pull request Nov 7, 2024
This PR updates the documentation for the GitHub Action to
match the examples provided in phylum-dev/phylum-ci#499.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants