Documentation
¶
Overview ¶
Package lint detects breaking changes between two versions of pbflags proto definitions.
Index ¶
- Constants
- func BuildDescriptors(protoDir string) ([]byte, error)
- func BuildDescriptorsFromRef(protoDir, gitRef string) ([]byte, error)
- func ExtractScopesFromDescriptors(descriptorData []byte) ([]ScopeInfo, []FeatureScopeInfo, error)
- func HasProtoChanges(baseRef, protoDir string) (bool, error)
- type FeatureScopeInfo
- type ScopeInfo
- type Violation
Constants ¶
const ( RuleTypeChanged = "type_changed" RuleLayerChanged = "layer_changed" )
Rule names.
const ( RuleScopeDimChanged = "scope_dimension_changed" RuleScopeRemoved = "scope_removed" RuleFeatureScopeRemoved = "feature_scope_removed" RuleCondScopeCompat = "condition_scope_compat" )
Rule names for scope-related violations.
Variables ¶
This section is empty.
Functions ¶
func BuildDescriptors ¶
BuildDescriptors builds a FileDescriptorSet from the proto files in protoDir (working tree). Returns the serialized bytes.
func BuildDescriptorsFromRef ¶
BuildDescriptorsFromRef builds a FileDescriptorSet from the proto files at the given git ref. Extracts the proto directory from the ref into a temp directory, then runs buf build.
func ExtractScopesFromDescriptors ¶ added in v0.17.0
func ExtractScopesFromDescriptors(descriptorData []byte) ([]ScopeInfo, []FeatureScopeInfo, error)
ExtractScopesFromDescriptors builds ScopeInfo and FeatureScopeInfo from raw descriptors using contextutil's discovery functions and evaluator's FlagDef parsing.
func HasProtoChanges ¶
HasProtoChanges returns true if any .proto files in protoDir differ between the given git ref and the working tree.
Types ¶
type FeatureScopeInfo ¶ added in v0.17.0
FeatureScopeInfo holds a feature's scope declarations for comparison.
type ScopeInfo ¶ added in v0.17.0
type ScopeInfo struct {
Name string
Dimensions []string // additional dimensions beyond globally required
}
ScopeInfo holds a scope's name and dimensions for comparison.
type Violation ¶
type Violation struct {
FlagID string // e.g., "notifications/1"
Rule string // machine-readable rule name
Message string // human-readable description
Guidance string // suggested fix
}
Violation represents a breaking change detected between two versions of flag definitions.
func Check ¶
Check compares base and current flag definitions and returns any breaking change violations. This is a pure function with no I/O.
func CheckConditionScopeCompat ¶ added in v0.17.0
func CheckConditionScopeCompat( contextMsg protoreflect.MessageDescriptor, scopes []ScopeInfo, features []FeatureScopeInfo, flagDefs []evaluator.FlagDef, conditionDims map[string][]string, ) []Violation
CheckConditionScopeCompat checks that every CEL dimension referenced by a feature's conditions is available in every scope the feature declares. This uses the condition ASTs and scope definitions from the current descriptors.
func CheckScopes ¶ added in v0.17.0
func CheckScopes(baseScopes, currentScopes []ScopeInfo, baseFeatures, currentFeatures []FeatureScopeInfo) []Violation
CheckScopes compares scope definitions between base and current descriptors. Returns breaking-change violations for:
- Scope dimension set changes
- Scope removals (removes generated *Features type)
- Feature scope removals (removes generated accessor method)