go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/lucicfg/starlark/stdlib/internal/luci/rules/list_view_entry.star (about) 1 # Copyright 2019 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.list_view_entry(...) rule.""" 16 17 load("@stdlib//internal/lucicfg.star", "lucicfg") 18 load("@stdlib//internal/luci/common.star", "keys", "kinds", "view") 19 20 def _list_view_entry( 21 ctx, # @unused 22 builder = None, 23 *, 24 list_view = None): 25 """A builder entry in some luci.list_view(...). 26 27 Can be used to declare that a builder belongs to a list view outside of 28 the list view declaration. In particular useful in functions. For example: 29 30 luci.list_view(name = 'Try builders') 31 32 def try_builder(name, ...): 33 luci.builder(name = name, ...) 34 luci.list_view_entry(list_view = 'Try builders', builder = name) 35 36 Can also be used inline in luci.list_view(...) declarations, for consistency 37 with corresponding luci.console_view_entry(...) usage. `list_view` argument 38 can be omitted in this case: 39 40 luci.list_view( 41 name = 'Try builders', 42 entries = [ 43 luci.list_view_entry(builder = 'Win'), 44 ... 45 ], 46 ) 47 48 Args: 49 ctx: the implicit rule context, see lucicfg.rule(...). 50 builder: a builder to add, see luci.builder(...). Can also be a reference 51 to a builder defined in another project. See [Referring to builders in 52 other projects](#external-builders) for more details. 53 list_view: a list view to add the builder to. Can be omitted if 54 `list_view_entry` is used inline inside some luci.list_view(...) 55 declaration. 56 """ 57 return view.add_entry( 58 kind = kinds.LIST_VIEW_ENTRY, 59 view = keys.list_view(list_view) if list_view else None, 60 builder = builder, 61 ) 62 63 list_view_entry = lucicfg.rule(impl = _list_view_entry)