2019-03-12 16:52:23 +00:00
|
|
|
/*
|
|
|
|
Copyright 2019 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package general
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2019-06-09 22:49:59 +00:00
|
|
|
|
2019-03-12 16:52:23 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
|
|
|
|
|
|
|
"k8s.io/ingress-nginx/cmd/plugin/kubectl"
|
|
|
|
"k8s.io/ingress-nginx/cmd/plugin/request"
|
|
|
|
"k8s.io/ingress-nginx/cmd/plugin/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CreateCommand creates and returns this cobra subcommand
|
|
|
|
func CreateCommand(flags *genericclioptions.ConfigFlags) *cobra.Command {
|
2023-05-01 11:32:18 +00:00
|
|
|
var pod, deployment, selector, container *string
|
2019-03-12 16:52:23 +00:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "general",
|
|
|
|
Short: "Inspect the other dynamic ingress-nginx information",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2023-05-01 11:32:18 +00:00
|
|
|
util.PrintError(general(flags, *pod, *deployment, *selector, *container))
|
2019-03-12 16:52:23 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
pod = util.AddPodFlag(cmd)
|
|
|
|
deployment = util.AddDeploymentFlag(cmd)
|
2020-02-15 04:19:05 +00:00
|
|
|
selector = util.AddSelectorFlag(cmd)
|
2023-05-01 11:32:18 +00:00
|
|
|
container = util.AddContainerFlag(cmd)
|
2019-03-12 16:52:23 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2023-08-31 07:36:48 +00:00
|
|
|
func general(flags *genericclioptions.ConfigFlags, podName, deployment, selector, container string) error {
|
2020-02-15 04:19:05 +00:00
|
|
|
pod, err := request.ChoosePod(flags, podName, deployment, selector)
|
2019-03-12 16:52:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-05-01 11:32:18 +00:00
|
|
|
out, err := kubectl.PodExecString(flags, &pod, container, []string{"/dbg", "general"})
|
2019-03-12 16:52:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Print(out)
|
|
|
|
return nil
|
|
|
|
}
|