go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/luci_notify/config/builder.go (about)

     1  // Copyright 2017 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  	buildbucketpb "go.chromium.org/luci/buildbucket/proto"
    21  	"go.chromium.org/luci/gae/service/datastore"
    22  
    23  	notifypb "go.chromium.org/luci/luci_notify/api/config"
    24  )
    25  
    26  // Builder represents the state of the last build seen from a particular
    27  // builder in order to implement certain notification triggers (i.e. on change).
    28  type Builder struct {
    29  	// ProjectKey is a datastore key to this Builder's project. Note that this key
    30  	// is a parent key, effectively making the Builder a child of a specific project.
    31  	ProjectKey *datastore.Key `gae:"$parent"`
    32  
    33  	// ID is the builder's canonical ID (e.g. <bucket>/<name>).
    34  	ID string `gae:"$id"`
    35  
    36  	// Repository is the repository this builder is tracking and the repository that
    37  	// Revision is valid for.
    38  	Repository string
    39  
    40  	// Notifications is Notifications proto message, containing Notification messages
    41  	// associated with this builder. Each notification contains information about who
    42  	// to notify, and different settings on how to notify them.
    43  	Notifications notifypb.Notifications
    44  
    45  	// Status is current status of the builder.
    46  	// It is updated every time a new build has a new status and either
    47  	//   1) the new build has a newer revision than StatusRevision, or
    48  	//   2) the new build's revision == StatusRevision, but it has a newer
    49  	//      creation time.
    50  	Status buildbucketpb.Status
    51  
    52  	// BuildTime is computed as the creation time of the most recent build encountered.
    53  	// It can be used to decide whether Status and this Builder should be updated.
    54  	BuildTime time.Time
    55  
    56  	// Revision is the revision of the codebase that's associated with the most
    57  	// recent build encountered. It can be used to decide whether Status should be
    58  	// updated.
    59  	Revision string
    60  
    61  	// GitilesCommits are the gitiles commits checked out by the most recent build
    62  	// encountered that had a non-empty checkout. It can also be used to compute a
    63  	// blamelist.
    64  	GitilesCommits *notifypb.GitilesCommits `gae:",legacy"`
    65  
    66  	// Extra and unrecognized fields will be loaded without issue but not saved.
    67  	_ datastore.PropertyMap `gae:"-,extra"`
    68  }