From 79113bd304eb9c8e14a4771011f4d3709eedc1be Mon Sep 17 00:00:00 2001 From: vilmibm Date: Wed, 8 Feb 2023 18:30:04 -0800 Subject: [PATCH] start writing up structs for rules API payloads --- pkg/cmd/ruleset/rules.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pkg/cmd/ruleset/rules.go diff --git a/pkg/cmd/ruleset/rules.go b/pkg/cmd/ruleset/rules.go new file mode 100644 index 000000000..b3405d839 --- /dev/null +++ b/pkg/cmd/ruleset/rules.go @@ -0,0 +1,39 @@ +package ruleset + +type RuleType string +type Enforcement string +type MatchingOperator string + +const ( + RuleTypeCommitAuthorEmailPattern RuleType = "commit_author_email_pattern" + RuleTypePullRequest RuleType = "pull_request" + // TODO others + + EnforcementEnabled Enforcement = "enabled" + EnforcementDisabled Enforcement = "disabled" + + MatchingOperatorStartsWith MatchingOperator = "starts_with" + MatchingOperatorEndsWith MatchingOperator = "ends_with" + MatchingOperatorContains MatchingOperator = "contains" + MatchingOperatorRegex MatchingOperator = "regex" +) + +type ConfigurationPullRequest struct { + DissmissStaleReviewsOnPush bool + RequireCodeOwnerReview bool + RequestLastPushApproval bool + RequiredApprovingReviewCount int +} + +type BranchNamePattern struct { + Name string + Negate bool + Operator MatchingOperator +} + +type Rule struct { + ID string + Type RuleType + Enforcement Enforcement + Configuration interface{} +}