go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/luci_notify/config/tree_closer.go (about) 1 // Copyright 2020 The LUCI Authors. 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 config 16 17 import ( 18 "time" 19 20 "go.chromium.org/luci/gae/service/datastore" 21 22 notifypb "go.chromium.org/luci/luci_notify/api/config" 23 ) 24 25 type TreeCloserStatus string 26 27 const ( 28 Open TreeCloserStatus = "Open" 29 Closed TreeCloserStatus = "Closed" 30 ) 31 32 // TreeCloser represents a tree closing rule from the config, along with its 33 // current state. 34 type TreeCloser struct { 35 // BuilderKey is a datastore key to this TreeCloser's parent builder. 36 BuilderKey *datastore.Key `gae:"$parent"` 37 38 // TreeStatusHost is the host that this rule opens/closes. This is 39 // duplicated from notifypb.TreeCloser, so that we can use it as the ID 40 // for datastore. The combination of tree status host and builder is 41 // guaranteed to be unique. 42 TreeStatusHost string `gae:"$id"` 43 44 // TreeCloser is the underlying TreeCloser proto from the current 45 // version of the config. 46 TreeCloser notifypb.TreeCloser 47 48 // Status is the current status of this rule. If any TreeCloser for a 49 // given tree-status host has a status of 'Closed', the tree will be 50 // closed. 51 Status TreeCloserStatus 52 53 // Timestamp stores the finish time of the build which caused us to set 54 // the current status. This is used to decide which template to use 55 // when setting the tree status message. 56 Timestamp time.Time 57 58 // Message contains the status message to use if this TreeCloser is the 59 // one that updates the status of the tree. Only valid if Status is 60 // Closed. 61 Message string 62 }