go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/lucicfg/starlark/stdlib/internal/luci/rules/logdog.star (about)

     1  # Copyright 2018 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  """Defines luci.logdog(...) rule."""
    16  
    17  load("@stdlib//internal/graph.star", "graph")
    18  load("@stdlib//internal/lucicfg.star", "lucicfg")
    19  load("@stdlib//internal/validate.star", "validate")
    20  load("@stdlib//internal/luci/common.star", "keys")
    21  
    22  def _logdog(
    23          ctx,  # @unused
    24          *,
    25          gs_bucket = None,
    26          cloud_logging_project = None):
    27      """Defines configuration of the LogDog service for this project.
    28  
    29      Usually required for any non-trivial project.
    30  
    31      Args:
    32        ctx: the implicit rule context, see lucicfg.rule(...).
    33        gs_bucket: base Google Storage archival path, archive logs will be written
    34          to this bucket/path.
    35        cloud_logging_project: the name of the Cloud project to export logs.
    36      """
    37      key = keys.logdog()
    38  
    39      graph.add_node(key, props = {
    40          "cloud_logging_project": validate.string(
    41              "cloud_logging_project",
    42              cloud_logging_project,
    43              required = False,
    44          ),
    45          "gs_bucket": validate.string(
    46              "gs_bucket",
    47              gs_bucket,
    48              required = False,
    49          ),
    50      })
    51      graph.add_edge(keys.project(), key)
    52      return graph.keyset(key)
    53  
    54  logdog = lucicfg.rule(impl = _logdog)