[GitHub] lburgazzoli commented on issue #257: chore: add all sorts of linters and pre-commit hook

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] lburgazzoli commented on issue #257: chore: add all sorts of linters and pre-commit hook

GitBox
lburgazzoli commented on issue #257: chore: add all sorts of linters and pre-commit hook
URL: https://github.com/apache/camel-k/pull/257#issuecomment-444525197
 
 
   @zregvart digget into it a little more, I think you can replace the method with something like:
   
   ```go
   
   // NewKamelCommand --
   func NewKamelCommand(ctx context.Context) (*cobra.Command, error) {
    options := RootCmdOptions{
    Context: ctx,
    }
    var cmd = cobra.Command{
    Use:                    "kamel",
    Short:                  "Kamel is a awesome client tool for running Apache Camel integrations natively on Kubernetes",
    Long:                   kamelCommandLongDescription,
    BashCompletionFunction: bashCompletionFunction,
    PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
    if options.Namespace == "" {
    current, err := kubernetes.GetClientCurrentNamespace(options.KubeConfig)
    if err != nil {
    return errors.Wrap(err, "cannot get current namespace")
    }
    err = cmd.Flag("namespace").Value.Set(current)
    if err != nil {
    return err
    }
    }
   
    // Let's use a fast refresh period when running with the CLI
    k8sclient.ResetCacheEvery(2 * time.Second)
   
    // Initialize the Kubernetes client to allow using the operator-sdk
    return kubernetes.InitKubeClient(options.KubeConfig)
    },
    }
   
    cmd.PersistentFlags().StringVar(&options.KubeConfig, "config", "", "Path to the config file to use for CLI requests")
    cmd.PersistentFlags().StringVarP(&options.Namespace, "namespace", "n", "", "Namespace to use for all operations")
   
    cmd.AddCommand(newCmdCompletion(&cmd))
    cmd.AddCommand(newCmdVersion())
    cmd.AddCommand(newCmdRun(&options))
    cmd.AddCommand(newCmdGet(&options))
    cmd.AddCommand(newCmdDelete(&options))
    cmd.AddCommand(newCmdInstall(&options))
    cmd.AddCommand(newCmdLog(&options))
    cmd.AddCommand(newCmdContext(&options))
   
    return &cmd, nil
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services