diff --git a/pkg/cmd/flags/config.go b/pkg/cmd/flags/config.go index 7d37af6a..c12c5795 100644 --- a/pkg/cmd/flags/config.go +++ b/pkg/cmd/flags/config.go @@ -40,12 +40,12 @@ type Registry struct { } type Pull struct { - ID int `name:"github pull request ID" flag:"gh-pull-id" desc:"set the GitHub pull request ID" validate:"required_if=Reporter github-pr-review" flagset:"Reporting" json:"gh-pull-id"` + ID int `name:"github pull request ID" flag:"gh-pull-id" desc:"set the GitHub pull request ID" flagset:"Reporting" json:"gh-pull-id"` } type GitHub struct { - Owner string `name:"github owner" flag:"gh-owner" desc:"set the GitHub owner name (org|user)" validate:"required_if=Reporter github-pr-review" flagset:"Reporting" json:"gh-owner"` - Repo string `name:"github repository" flag:"gh-repo" desc:"set the GitHub repository name" validate:"required_if=Reporter github-pr-review" flagset:"Reporting" json:"gh-repo"` + Owner string `name:"github owner" flag:"gh-owner" desc:"set the GitHub owner name (org|user)" flagset:"Reporting" json:"gh-owner"` + Repo string `name:"github repository" flag:"gh-repo" desc:"set the GitHub repository name" flagset:"Reporting" json:"gh-repo"` Pull } diff --git a/pkg/validate/reporter.go b/pkg/validate/reporter.go deleted file mode 100644 index 232c14ff..00000000 --- a/pkg/validate/reporter.go +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// -// Copyright © 2023 The listen.dev team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package validate - -import ( - "fmt" - "reflect" - - "github.com/XANi/goneric" - "github.com/go-playground/validator/v10" -) - -var availableReporters = []string{} - -func RegisterAvailableReporter(name string) { - availableReporters = append(availableReporters, name) -} - -func isReporterAvailable(fl validator.FieldLevel) bool { - field := fl.Field() - - if field.Kind() == reflect.String { - return goneric.SliceIn(availableReporters, field.String()) - } - - panic(fmt.Sprintf("bad field type: %T", field.Interface())) -} diff --git a/pkg/validate/validate.go b/pkg/validate/validate.go index 5758953d..3d860f19 100644 --- a/pkg/validate/validate.go +++ b/pkg/validate/validate.go @@ -60,9 +60,6 @@ func init() { if err := Singleton.RegisterValidation("version_constraint", isVersionConstraint); err != nil { panic(err) } - if err := Singleton.RegisterValidation("reporter", isReporterAvailable); err != nil { - panic(err) - } Singleton.RegisterAlias("shasum", "len=40") Singleton.RegisterAlias("mandatory", "required")