go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/led/job/kitchen_support.go (about) 1 // Copyright 2020 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 job 16 17 import ( 18 "context" 19 20 "go.chromium.org/luci/common/errors" 21 swarmingpb "go.chromium.org/luci/swarming/proto/api_v2" 22 ) 23 24 // KitchenSupport is the object for an interface to support 'LegacyKitchen' job 25 // definitions. 26 // 27 // See 'infra/tools/led2' for the only real implementation of this. 28 // 29 // This is abstracted out because 'kitchen' and its libraries live in infra, not 30 // in luci-go. Once kitchen is deleted, this will go away as well. 31 type KitchenSupport interface { 32 FromSwarmingV2(ctx context.Context, in *swarmingpb.NewTaskRequest, out *Buildbucket) error 33 GenerateCommand(ctx context.Context, bb *Buildbucket) ([]string, error) 34 } 35 36 // NoKitchenSupport returns a null implementation of KitchenSupport which always 37 // returns errors if it ends up processing a kitchen job. 38 func NoKitchenSupport() KitchenSupport { 39 return nullKitchenSupport{} 40 } 41 42 type nullKitchenSupport struct{} 43 44 func (nullKitchenSupport) FromSwarmingV2(context.Context, *swarmingpb.NewTaskRequest, *Buildbucket) error { 45 return errors.New("kitchen job Definitions not supported by this binary") 46 } 47 48 func (nullKitchenSupport) GenerateCommand(context.Context, *Buildbucket) ([]string, error) { 49 return nil, errors.New("kitchen job Definitions not supported by this binary") 50 }