Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ This above command will:

### `print` command

| Flag | Default Value | Required | Description |
| -------------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| namespace | | No | If present, the namespace scope for the invocation |
| all-namespaces | False | No | If present, list the requested object(s) across all namespaces. Namespace in the current context is ignored even if specified with --namespace |
| output | yaml | No | The output format, either yaml or json |
| input_file | | No | Path to the manifest file. When set, the tool will read ingresses from the file instead of reading from the cluster. Supported files are yaml and json |
| Flag | Default Value | Required | Description |
| -------------- | ----------------------- | -------- | ------------------------------------------------------------ |
| namespace | | No | If present, the namespace scope for the invocation |
| all-namespaces | False | No | If present, list the requested object(s) across all namespaces. Namespace in the current context is ignored even if specified with --namespace |
| output | yaml | No | The output format, either yaml or json |
| input_file | | No | Path to the manifest file. When set, the tool will read ingresses from the file instead of reading from the cluster. Supported files are yaml and json |
| providers | all supported providers | No | Comma-separated list of providers. If present, the tool will try to convert only resources related to the specified providers. Otherwise it will default to all the supported providers |
| kubeconfig | | No | The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file. |

## Conversion of Ingress resources to Gateway API

Expand Down
4 changes: 0 additions & 4 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,3 @@ func getNamespaceInCurrentContext() (string, error) {

return currentNamespace, err
}

func init() {
rootCmd.AddCommand(newPrintCommand())
}
26 changes: 23 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,32 @@ import (
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "ingress2gateway",
Short: "Convert Ingress manifests to Gateway API manifests",
// kubeconfig indicates kubeconfig file location.
var kubeconfig string

func newRootCmd() *cobra.Command {
rootCmd := &cobra.Command{
Use: "ingress2gateway",
Short: "Convert Ingress manifests to Gateway API manifests",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
getKubeconfig()
},
}

rootCmd.PersistentFlags().StringVar(&kubeconfig, "kubeconfig", "",
`The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.`)
return rootCmd
}

func getKubeconfig() {
if kubeconfig != "" {
os.Setenv("KUBECONFIG", kubeconfig)
}
}

func Execute() {
rootCmd := newRootCmd()
rootCmd.AddCommand(newPrintCommand())
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
Expand Down