Skip to content

Commit

Permalink
validate openapi exclusivity
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorLieberman committed Jun 13, 2024
1 parent bb5b431 commit 230e6cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd
import (
"fmt"
"os"
"slices"
"strings"

"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
Expand Down Expand Up @@ -237,6 +238,13 @@ func newPrintCommand() *cobra.Command {
Use: "print",
Short: "Prints Gateway API objects generated from ingress and provider-specific resources.",
RunE: pr.PrintGatewayAPIObjects,
PreRunE: func(cmd *cobra.Command, args []string) error {
openAPIExist := slices.Contains(pr.providers, "openapi3")
if openAPIExist && len(pr.providers) != 1 {
return fmt.Errorf("openapi3 must be the only provider when specified")
}
return nil
},
}

cmd.Flags().StringVarP(&pr.outputFormat, "output", "o", "yaml",
Expand Down

0 comments on commit 230e6cd

Please sign in to comment.