diff --git a/cmd/print.go b/cmd/print.go index 3da5740b..ca8d2ea8 100644 --- a/cmd/print.go +++ b/cmd/print.go @@ -57,6 +57,9 @@ type PrintRunner struct { // providers indicates which providers are used to execute convert action. providers []string + + // ingressesOnly indicates whether only the converted Ingresses should be printed. + ingressesOnly bool } // PrintGatewaysAndHTTPRoutes performs necessary steps to digest and print @@ -76,8 +79,11 @@ func (pr *PrintRunner) PrintGatewaysAndHTTPRoutes(cmd *cobra.Command, _ []string if err != nil { return err } - - pr.outputResult(httpRoutes, gateways) + if pr.ingressesOnly { + pr.outputResult(httpRoutes, nil) + } else { + pr.outputResult(httpRoutes, gateways) + } return nil } @@ -92,10 +98,12 @@ func (pr *PrintRunner) outputResult(httpRoutes []gatewayv1beta1.HTTPRoute, gatew return } - for i := range gateways { - err := pr.resourcePrinter.PrintObj(&gateways[i], os.Stdout) - if err != nil { - fmt.Printf("# Error printing %s HTTPRoute: %v\n", gateways[i].Name, err) + if pr.ingressesOnly == false { + for i := range gateways { + err := pr.resourcePrinter.PrintObj(&gateways[i], os.Stdout) + if err != nil { + fmt.Printf("# Error printing %s HTTPRoute: %v\n", gateways[i].Name, err) + } } } @@ -182,6 +190,7 @@ if specified with --namespace.`) cmd.Flags().StringSliceVar(&pr.providers, "providers", i2gw.GetSupportedProviders(), fmt.Sprintf("If present, the tool will try to convert only resources related to the specified providers, supported values are %v", i2gw.GetSupportedProviders())) + cmd.Flags().BoolVar(&pr.ingressesOnly, "ingresses-only", false, "If present, the tool will only print the converted Ingresses.") cmd.MarkFlagsMutuallyExclusive("namespace", "all-namespaces") return cmd }