Skip to content

Commit

Permalink
Merge pull request #199 from MadVikingGod/mvg/add-optional
Browse files Browse the repository at this point in the history
Add optional variant to requirement_level
  • Loading branch information
lquerel authored Jun 6, 2024
2 parents 9ab536f + 78ad26b commit 24965a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/weaver_resolved_schema/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl Catalog {
"recommended"
}
RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => "opt_in",
RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => "optional",
RequirementLevel::Recommended { .. } => "recommended",
RequirementLevel::ConditionallyRequired { .. } => "conditionally_required",
};
Expand Down
3 changes: 3 additions & 0 deletions crates/weaver_semconv/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ pub enum BasicRequirementLevelSpec {
Recommended,
/// An opt-in requirement level.
OptIn,
/// An optional requirement level.
Optional,
}

/// Implements a human readable display for BasicRequirementLevel.
Expand All @@ -482,6 +484,7 @@ impl Display for BasicRequirementLevelSpec {
BasicRequirementLevelSpec::Required => write!(f, "required"),
BasicRequirementLevelSpec::Recommended => write!(f, "recommended"),
BasicRequirementLevelSpec::OptIn => write!(f, "opt-in"),
BasicRequirementLevelSpec::Optional => write!(f, "optional"),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/weaver_semconv_gen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ impl<'a> AttributeView<'a> {
RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => {
Ok(write!(out, "`Opt-In`")?)
}
RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => {
Ok(write!(out, "`Optional`")?)
}
RequirementLevel::ConditionallyRequired { text } => {
if text.len() > BREAK_COUNT {
Ok(write!(
Expand Down Expand Up @@ -377,6 +380,7 @@ fn sort_ordinal_for_requirement(e: &RequirementLevel) -> i32 {
RequirementLevel::Recommended { .. } => 3,
RequirementLevel::Basic(BasicRequirementLevelSpec::Recommended) => 3,
RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => 4,
RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => todo!(),
}
}

Expand Down

0 comments on commit 24965a1

Please sign in to comment.