-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Initial support for configuring policies #4015
Conversation
We now allow receiving disabled policies in the AnalyzerInfo metadata, to allow such policies to be enabled and configured.
cbc4f70
to
7498136
Compare
pkg/engine/update.go
Outdated
analyzerInfo, err := analyzer.GetAnalyzerInfo() | ||
if err != nil { | ||
return err | ||
} | ||
config, err := plugin.ReconcilePolicyPackConfig(analyzerInfo.Policies, configFromAPI) | ||
if err != nil { | ||
return errors.Wrapf(err, "reconciling configuration for analyzer %q", analyzerInfo.Name) | ||
} |
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.
Note: An alternative to retrieving the metadata and reconciling the config here would be to just pass the config directly from the service (or from a --policy-pack-config
specified file) to the Policy Pack. However, then each language SDK for policies would have to handle reconciling its default values with the specified config. Looking ahead to implementing the SDK for Python, .NET, and Go, it seemed "better" to have a single implementation here for doing this reconciliation, rather than writing it N times for each language.
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.
Still parsing through, but thought I'd get this first batch out there!
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.
Just a few notes - but overall looks good to me. Not an expert on the design of the policy config feature though - or the specific interactions with the service APIs - so will leave detailed feedback to @ekrengel.
Instead of returning these as a single combined error, emit these as individual diagnostic messages. This allows these errors to be seen in the Pulumi Console. Also, make it so that all validation errors for all policy packs are returned. We should still consider adding a new diagnostic event for these, which would allow improved grouping and display, but that requires changes to both the CLI and service and can be done subsequently. Also, cleaned up some things and added more tests.
The way we're calling it, it's always going to be set, since we fill in the default enforcement level value from the policy metadata.
Older policy packs do not support config, so avoid sending schema for such policy packs so that the service can distinguish whether a policy pack is configurable or not. Also, avoid configuring policy packs that don't support config.
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.
👍
Apologies for the larger PR. It's broken up into more digestible commits.
This adds support for the
--policy-pack-config
flag and underlying implementation to apply configuration to policies. It also includes support for sending config schema to the service and using configuration from the service.The
pulumi/pulumi-policy
side of the change is here: pulumi/pulumi-policy#207Fixes pulumi/pulumi-policy#185
Fixes pulumi/pulumi-policy#186
Fixes pulumi/pulumi-policy#189
Fixes pulumi/pulumi-policy#190
Part of pulumi/pulumi-policy#187
Part of pulumi/pulumi-policy#188