Documentation
¶
Overview ¶
Package zuul exposes useful commands for Zuul deployers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateAuthTokenCmd = &cobra.Command{ Use: "create-auth-token", Short: "Create a time-limited authentication token scoped to a tenant", Long: `This command is a proxy for the "zuul-admin create-auth-token" command run on a scheduler pod. The command will output a JWT that can be passed to the zuul-client CLI or used with cURL to perform administrative actions on a specified tenant.`, Run: func(cmd *cobra.Command, args []string) { tenant, _ := cmd.Flags().GetString("tenant") user, _ := cmd.Flags().GetString("user") expiry, _ := cmd.Flags().GetInt32("expires-in") namespace, _ := cmd.Flags().GetString("namespace") kubeConfig, kubeClientSet := utils.GetKubernetesClientSet() podslist, _ := kubeClientSet.CoreV1().Pods(namespace).List(context.TODO(), metav1.ListOptions{}) var zuulSchedulerContainer *v1.Pod = nil prefix := "zuul-scheduler" for _, container := range podslist.Items { if strings.HasPrefix(container.Name, prefix) { zuulSchedulerContainer = &container break } } if zuulSchedulerContainer == nil { fmt.Println("No Zuul scheduler pod running in the given namespace") os.Exit(1) } zuulAdminArgs := []string{ "zuul-admin", "create-auth-token", "--auth-config", "zuul_client", "--tenant", tenant, "--user", user, "--expires-in", strconv.Itoa(int(expiry)), } buffer := &bytes.Buffer{} errorBuffer := &bytes.Buffer{} request := kubeClientSet.CoreV1().RESTClient().Post().Resource("pods").Namespace(namespace).Name(zuulSchedulerContainer.Name).SubResource("exec").VersionedParams(&v1.PodExecOptions{ Container: "zuul-scheduler", Command: zuulAdminArgs, Stdin: false, Stdout: true, Stderr: true, }, scheme.ParameterCodec) exec, _ := remotecommand.NewSPDYExecutor(kubeConfig, "POST", request.URL()) err := exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdout: buffer, Stderr: errorBuffer, }) if err != nil { fmt.Println(errorBuffer) fmt.Println(err) os.Exit(1) } fmt.Print(buffer) }, }
View Source
var ZuulCmd = &cobra.Command{ Use: "zuul", Short: "Commands related to the administration of Zuul deployment with SF Operator", Long: `The following commands simplify administrative tasks on a Zuul cluster deployed with SF Operator.`, Run: func(cmd *cobra.Command, args []string) { cmd.Help() os.Exit(0) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.