go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/resultdb/pbutil/invocation_processing.go (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 package pbutil 16 17 import ( 18 "go.chromium.org/luci/common/errors" 19 20 pb "go.chromium.org/luci/resultdb/proto/v1" 21 ) 22 23 // ValidateBigQueryExport returns a non-nil error if bqExport is determined to 24 // be invalid. 25 func ValidateBigQueryExport(bqExport *pb.BigQueryExport) error { 26 switch { 27 case bqExport.Project == "": 28 return errors.Annotate(unspecified(), "project").Err() 29 case bqExport.Dataset == "": 30 return errors.Annotate(unspecified(), "dataset").Err() 31 case bqExport.Table == "": 32 return errors.Annotate(unspecified(), "table").Err() 33 } 34 35 switch resultType := bqExport.ResultType.(type) { 36 case *pb.BigQueryExport_TestResults_: 37 return errors.Annotate(ValidateTestResultPredicate(resultType.TestResults.GetPredicate()), "test_results: predicate").Err() 38 case *pb.BigQueryExport_TextArtifacts_: 39 return errors.Annotate(ValidateArtifactPredicate(resultType.TextArtifacts.GetPredicate()), "artifacts: predicate").Err() 40 case nil: 41 return errors.Annotate(unspecified(), "result_type").Err() 42 default: 43 panic("impossible") 44 } 45 }