go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/buildbucket/appengine/model/project.go (about)

     1  // Copyright 2022 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 model
    16  
    17  import (
    18  	"context"
    19  
    20  	"go.chromium.org/luci/gae/service/datastore"
    21  
    22  	pb "go.chromium.org/luci/buildbucket/proto"
    23  )
    24  
    25  const (
    26  	// ProjectKind is a project entity's kind in the datastore.
    27  	ProjectKind = "Project"
    28  )
    29  
    30  // Project is the parent entity of buckets in the datastore.
    31  // Entities of this kind may not exist in the datastore if they don't have
    32  // global_config.
    33  type Project struct {
    34  	_kind string `gae:"$kind,Project"`
    35  	ID    string `gae:"$id"`
    36  
    37  	// CommonConfig is the share config among all buckets and builders in this
    38  	// project.
    39  	CommonConfig *pb.BuildbucketCfg_CommonConfig `gae:"common_config"`
    40  }
    41  
    42  // ProjectKey returns a datastore key of a project.
    43  func ProjectKey(ctx context.Context, project string) *datastore.Key {
    44  	return datastore.KeyForObj(ctx, &Project{ID: project})
    45  }