-
Notifications
You must be signed in to change notification settings - Fork 19
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
Infrastructure to support backward-compatibility check #257
Conversation
# Conflicts: # crates/weaver_forge/src/config.rs # crates/weaver_forge/src/extensions/case.rs # crates/weaver_forge/src/lib.rs
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.
Overall LGTM. A couple nits - Predominately I think next time the Git-Url / path reference code should be a separate PR form the policy engine changing code.
THink you can close a few open issues for this one :)
Self::create_parent_dirs(&valid_entry_path, archive_filename)?; | ||
// Unpack returns an Unpacked type containing the file descriptor to the | ||
// unpacked file. The file descriptor is ignored as we don't have any use for it. | ||
_ = entry |
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.
Nit for rust - Maybe we should open a FR - that #[must_use]
for Result
where you ?
away a ()
doesn't cause a warning, and then you can map_error(..)
and something like .ignore_result()?
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.
I'm not 100% sure, but I think a templated #[must_use]
function returning a Result<T, Error>
with T=()
doesn't emit a warning.
I like the idea of the .ignore_result()?
if we can specify a parameter &str
representing the justification.
GitRepo { | ||
/// URL of the Git repository | ||
url: String, | ||
/// Tag of the Git repository (NOT YET SUPPORTED) |
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.
This should be tag, branch or commit
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.
Renamed refspec
and updated the comment.
// Add the standard semconv policies | ||
// Note: `add_policy` the package name, we ignore it here as we don't need it | ||
_ = engine | ||
.add_policy("defaults/rego/semconv.rego", SEMCONV_REGO) |
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.
Should this only be added for a particular phase of the engine? Aren't these symbols meaningless in before_resolution
or are they meant to be applied there too?
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.
IMO, some of the rules/functions definitions could be used in any phases.
src/util.rs
Outdated
@@ -119,9 +102,19 @@ pub(crate) fn check_policy_stage<T: Serialize>( | |||
policy_stage: PolicyStage, | |||
policy_file: &str, | |||
input: &T, | |||
data: &[T], |
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.
Nit: If you want data to actually be generic, you need to use a different type. Right now input AND the array of data must be the same type.
At a minimum, you should have:
fn check_policy_stage<T: Serialize, U:Serialize>(
policy_engine: &mut Engine,
policy_stage: PolicyStage,
policy_file: &str,
input: &T,
data: &[U],
However, if you want data to not be monomorphic, you'd need to use an HList (likely k-list) or tuple-type structure to preserve the original types.
I don't think this is what you want at all. For now, at least, I'd use a different generic for data. In the future, you may want to use a different type to encapsulate serialization more generically.
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.
Nice catch. I made the changes.
Yes, creating two PRs was part of the initial intentions, but it got lost in the heat of the moment. |
Description
This PR implements the infrastructure to support backward-compatibility testing and, more generally, policies applied to multi-version registries.
The following command checks the current registry (main branch in the official repo) with a baseline registry (here, the archive v1.26.0) against a package of rules (policies) defined in the file
compatibility_check.rego
:The following screenshot is the output of this command if we artificially remove the file
registry/deprecated/container.yaml
from the main branch.Changes
<local-path>
(e.g. $HOME/otel-registry)<git-url>
(e.g. https://github.com/open-telemetry/semantic-conventions.git)<git-url>[<sub-folder>]
(e.g. https://github.com/open-telemetry/semantic-conventions.git[model])<git-archive-url>
(e.g. https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v1.26.0.zip)<git-archive-url>[<sub-folder>]
(e.g. https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v1.26.0.zip[model])<git-url>@<tag>
<git-url>@<tag>[<sub-folder>]
RegistryPath
(merge the two existing implementations defined in theweaver
andweaver_semconv
crates).--baseline-registry
in addition to--registry
(both will support the same syntax for the registry path). The--registry-git-sub-dir
will be marked as deprecated.Cache
with the more general concept ofRegistryRepo
supporting all the variants ofRegistryPath
.--baseline-registry
with the policy engine. In particular, we must decide how to expose the two registries in Rego.