Skip to content

Commit

Permalink
added ingresses-only flag
Browse files Browse the repository at this point in the history
  • Loading branch information
camperjett committed Sep 28, 2023
1 parent df5c050 commit b131dff
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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)
}
}
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit b131dff

Please sign in to comment.