Documentation
¶
Overview ¶
Package zuulclient exposes function for use zuul-client
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ZuulClientCmd = &cobra.Command{ Use: "zuul-client", Short: "Run zuul-client command", Long: `Run zuul-client command on the corresponding pod ./tools/sfconfig zuul-client [flags] [OPTIONS] flags: [-n|--namespace <name>] - executes comand in the corresponding namespace (default: "sf") OPTIONS: zuul-client [OPTIONS] - all zuul-client available options Examples: ./sfconfig zuul-client - print sfconfig zuul-client subcommand options ./sfconfig zuul-client -h - prints zuul-client options ./sfconfig zuul-client [-n|--namespace <name>] [OPTIONS] executes comand in the corresponding namespace (default: "sf") `, Aliases: []string{"zc"}, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Help() os.Exit(0) } zuulClientArgs := xORNameSpace(args) cmd.DisableFlagParsing = false cmd.ParseFlags(args) cmd.DisableFlagParsing = true namespace, _ := cmd.Flags().GetString("namespace") kubeConfig, kubeClientSet := utils.GetKubernetesClientSet() podslist, _ := kubeClientSet.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{}) var zuulwebcontainer *v1.Pod = nil zuulwebprefix := "zuul-web" for _, container := range podslist.Items { if strings.HasPrefix(container.Name, zuulwebprefix) { zuulwebcontainer = &container break } } if zuulwebcontainer == nil { fmt.Println("Container with the prefix " + zuulwebprefix + " not found in namespace " + namespace) os.Exit(1) } zuulClientBaseArgs := []string{ "zuul-client", "--use-config", "webclient", } zuulClientArgs = append(zuulClientBaseArgs, zuulClientArgs...) buf := &bytes.Buffer{} errBuf := &bytes.Buffer{} request := kubeClientSet.CoreV1().RESTClient().Post().Resource("pods").Namespace(namespace).Name(zuulwebcontainer.Name).SubResource("exec").VersionedParams(&v1.PodExecOptions{ Container: "zuul-web", Command: zuulClientArgs, Stdin: false, Stdout: true, Stderr: true, }, scheme.ParameterCodec) exec, _ := remotecommand.NewSPDYExecutor(kubeConfig, "POST", request.URL()) err := exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdout: buf, Stderr: errBuf, }) if err != nil { fmt.Println(errBuf) fmt.Println(err) os.Exit(1) } fmt.Print(buf) }, }
ZuulClientCmd operator ZuulClientCmd represents the zuul-client command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.