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 be8c051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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
4 changes: 0 additions & 4 deletions pkg/i2gw/providers/kong/resource_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
)

var count int

// converter implements the i2gw.CustomResourceReader interface.
type resourceReader struct {
conf *i2gw.ProviderConf
Expand Down Expand Up @@ -90,8 +88,6 @@ func (r *resourceReader) readResourcesFromFile(filename string) (*storage, error
// -----------------------------------------------------------------------------

func (r *resourceReader) readTCPIngressesFromCluster(ctx context.Context) ([]kongv1beta1.TCPIngress, error) {
count++
fmt.Println(count)
tcpIngressList := &unstructured.UnstructuredList{}
tcpIngressList.SetGroupVersionKind(tcpIngressGVK)

Expand Down

0 comments on commit be8c051

Please sign in to comment.