go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/config_service/internal/ui/index.go (about) 1 // Copyright 2023 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 ui 16 17 import ( 18 "google.golang.org/protobuf/types/known/fieldmaskpb" 19 20 "go.chromium.org/luci/server/router" 21 "go.chromium.org/luci/server/templates" 22 23 configpb "go.chromium.org/luci/config_service/proto" 24 ) 25 26 var mask *fieldmaskpb.FieldMask 27 28 func init() { 29 var err error 30 mask, err = fieldmaskpb.New(&configpb.ConfigSet{}, 31 "name", "url", "revision", "last_import_attempt") 32 if err != nil { 33 panic(err) 34 } 35 } 36 37 func indexPage(c *router.Context) error { 38 ctx := c.Request.Context() 39 configSets, err := configsServer(ctx).ListConfigSets(ctx, &configpb.ListConfigSetsRequest{ 40 Fields: mask, 41 }) 42 if err != nil { 43 return err 44 } 45 templates.MustRender(ctx, c.Writer, "pages/index.html", map[string]any{ 46 "ConfigSets": configSets.GetConfigSets(), 47 }) 48 return nil 49 }