...

Source file src/edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/common/result.go

Documentation: edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/policy/common

     1  // Copyright 2018 Palantir Technologies, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package common
    16  
    17  import (
    18  	"edge-infra.dev/pkg/f8n/devinfra/repo/owners/policybot/pull"
    19  )
    20  
    21  type EvaluationStatus int
    22  
    23  const (
    24  	StatusSkipped EvaluationStatus = iota // note: values used for ordering
    25  	StatusPending
    26  	StatusApproved
    27  	StatusDisapproved
    28  )
    29  
    30  func (s EvaluationStatus) String() string {
    31  	switch s {
    32  	case StatusSkipped:
    33  		return "skipped"
    34  	case StatusPending:
    35  		return "pending"
    36  	case StatusApproved:
    37  		return "approved"
    38  	case StatusDisapproved:
    39  		return "disapproved"
    40  	}
    41  	return "unknown"
    42  }
    43  
    44  type RequestMode string
    45  
    46  const (
    47  	RequestModeAllUsers    RequestMode = "all-users"
    48  	RequestModeRandomUsers RequestMode = "random-users"
    49  	RequestModeTeams       RequestMode = "teams"
    50  )
    51  
    52  type ReviewRequestRule struct {
    53  	Teams         []string
    54  	Users         []string
    55  	Organizations []string
    56  	Permissions   []pull.Permission
    57  	RequiredCount int
    58  
    59  	Mode RequestMode
    60  }
    61  
    62  type Result struct {
    63  	Name              string
    64  	Description       string
    65  	StatusDescription string
    66  	Status            EvaluationStatus
    67  	Error             error
    68  	PredicateResults  []*PredicateResult
    69  	Requires          Actors
    70  
    71  	ReviewRequestRule *ReviewRequestRule
    72  	AllowedCandidates []*Candidate
    73  
    74  	Children []*Result
    75  }
    76  

View as plain text