go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/cv/internal/usertext/common.go (about) 1 // Copyright 2021 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 usertext 16 17 import ( 18 "strings" 19 "text/template" 20 ) 21 22 // tmplFuncs are commonly used constants, usable via Go templates. 23 var tmplFuncs = template.FuncMap{ 24 "CQ_OR_CV": func() string { return "CQ" }, 25 "CONTACT_YOUR_INFRA": func() string { 26 // TODO(tandrii): ideally, CV or even LUCI would provide project-specific 27 // URL from a config. 28 return "Please contact your EngProd or infrastructure team" 29 }, 30 } 31 32 func tmplMust(text string) *template.Template { 33 text = strings.TrimSpace(text) 34 return template.Must(template.New("").Funcs(tmplFuncs).Parse(text)) 35 }