...

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

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

     1  // Copyright 2021 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 predicate
    16  
    17  type Predicates struct {
    18  	ChangedFiles     *ChangedFiles     `yaml:"changed_files,omitempty"`
    19  	OnlyChangedFiles *OnlyChangedFiles `yaml:"only_changed_files,omitempty"`
    20  
    21  	HasAuthorIn             *HasAuthorIn             `yaml:"has_author_in,omitempty"`
    22  	HasContributorIn        *HasContributorIn        `yaml:"has_contributor_in,omitempty"`
    23  	OnlyHasContributorsIn   *OnlyHasContributorsIn   `yaml:"only_has_contributors_in,omitempty"`
    24  	AuthorIsOnlyContributor *AuthorIsOnlyContributor `yaml:"author_is_only_contributor,omitempty"`
    25  
    26  	TargetsBranch *TargetsBranch `yaml:"targets_branch,omitempty"`
    27  	FromBranch    *FromBranch    `yaml:"from_branch,omitempty"`
    28  
    29  	ModifiedLines *ModifiedLines `yaml:"modified_lines,omitempty"`
    30  
    31  	HasSuccessfulStatus *HasSuccessfulStatus `yaml:"has_successful_status,omitempty"`
    32  
    33  	HasLabels *HasLabels `yaml:"has_labels,omitempty"`
    34  
    35  	Repository *Repository `yaml:"repository,omitempty"`
    36  	Title      *Title      `yaml:"title,omitempty"`
    37  
    38  	HasValidSignatures       *HasValidSignatures       `yaml:"has_valid_signatures,omitempty"`
    39  	HasValidSignaturesBy     *HasValidSignaturesBy     `yaml:"has_valid_signatures_by,omitempty"`
    40  	HasValidSignaturesByKeys *HasValidSignaturesByKeys `yaml:"has_valid_signatures_by_keys,omitempty"`
    41  }
    42  
    43  func (p *Predicates) Predicates() []Predicate {
    44  	var ps []Predicate
    45  
    46  	if p.ChangedFiles != nil {
    47  		ps = append(ps, Predicate(p.ChangedFiles))
    48  	}
    49  	if p.OnlyChangedFiles != nil {
    50  		ps = append(ps, Predicate(p.OnlyChangedFiles))
    51  	}
    52  
    53  	if p.HasAuthorIn != nil {
    54  		ps = append(ps, Predicate(p.HasAuthorIn))
    55  	}
    56  	if p.HasContributorIn != nil {
    57  		ps = append(ps, Predicate(p.HasContributorIn))
    58  	}
    59  	if p.OnlyHasContributorsIn != nil {
    60  		ps = append(ps, Predicate(p.OnlyHasContributorsIn))
    61  	}
    62  	if p.AuthorIsOnlyContributor != nil {
    63  		ps = append(ps, Predicate(p.AuthorIsOnlyContributor))
    64  	}
    65  
    66  	if p.TargetsBranch != nil {
    67  		ps = append(ps, Predicate(p.TargetsBranch))
    68  	}
    69  	if p.FromBranch != nil {
    70  		ps = append(ps, Predicate(p.FromBranch))
    71  	}
    72  
    73  	if p.ModifiedLines != nil {
    74  		ps = append(ps, Predicate(p.ModifiedLines))
    75  	}
    76  
    77  	if p.HasSuccessfulStatus != nil {
    78  		ps = append(ps, Predicate(p.HasSuccessfulStatus))
    79  	}
    80  
    81  	if p.HasLabels != nil {
    82  		ps = append(ps, Predicate(p.HasLabels))
    83  	}
    84  
    85  	if p.Repository != nil {
    86  		ps = append(ps, Predicate(p.Repository))
    87  	}
    88  
    89  	if p.Title != nil {
    90  		ps = append(ps, Predicate(p.Title))
    91  	}
    92  
    93  	if p.HasValidSignatures != nil {
    94  		ps = append(ps, Predicate(p.HasValidSignatures))
    95  	}
    96  
    97  	if p.HasValidSignaturesBy != nil {
    98  		ps = append(ps, Predicate(p.HasValidSignaturesBy))
    99  	}
   100  
   101  	if p.HasValidSignaturesByKeys != nil {
   102  		ps = append(ps, Predicate(p.HasValidSignaturesByKeys))
   103  	}
   104  
   105  	return ps
   106  }
   107  

View as plain text