Skip to content

Consolidate Gatekeeper and Rego packages#69

Merged
jpreese merged 13 commits intomainfrom
rule-naming
Sep 9, 2020
Merged

Consolidate Gatekeeper and Rego packages#69
jpreese merged 13 commits intomainfrom
rule-naming

Conversation

@jpreese
Copy link
Collaborator

@jpreese jpreese commented Aug 31, 2020

This spawned from reading through our current docs and shoring up anything that was out of date. Working through a couple of inconsistencies, it just felt better to try to continue to make more sense out of our packages.

The goal was more or less to have a no-op when it comes to changes in outputs (i.e. generated policies, docs) and focus more on the refactoring effort to make review easier.

The only notable set of changes comes from adding the hyphen to each policy which results from removing the newline when printing the source (see chomping). This makes the output less opinionated.

This should provide a more consistent experience when parsing data from each of the policies. Each command can then take the extracted data, and manipulate/use it in a way that makes sense for the command.

Freebies

  • Library folder no longer matters. The rego files are loaded and the dependencies are built out based on the name of the package(s) that the rego file imports.

  • The loaded rego files are now be compiled during the create step. This makes sure that the entire set of rego policies are actually valid before running create. Previously, no validation was performed.

  • Since all rego is pre-loaded, this allows for package consumers to use the methods on the Rego type without error checking. e.g. rego.Libraries()

Overall this should give more cohesion to the rego package and keep the CLI concerns separate from the package. e.g. The create command no longer needs to figure out the library directory, or call GetKinds/GetName--It's all a part of the loaded rego type.

NOTE
Since the docs/policies/etc are left mostly unchanged and this is more of a refactoring effort--it may be better to view the structure/code on GitHub rather than trying to make sense of the diffs.

@jpreese jpreese changed the title Consolidate Gatekeeper and Rego packages [DRAFT] Consolidate Gatekeeper and Rego packages Aug 31, 2020
@jpreese jpreese force-pushed the rule-naming branch 3 times, most recently from 183ac28 to d589ff1 Compare September 1, 2020 19:23
@jpreese jpreese changed the title [DRAFT] Consolidate Gatekeeper and Rego packages Consolidate Gatekeeper and Rego packages Sep 1, 2020
@jpreese jpreese requested a review from jalseth September 1, 2020 19:40
Copy link
Collaborator

@jalseth jalseth left a comment

Choose a reason for hiding this comment

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

Looks great to me! Sorry for the delay in getting to the review.

@jpreese jpreese merged commit 94a9a0d into main Sep 9, 2020
@jalseth jalseth deleted the rule-naming branch November 19, 2020 23:28
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