| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package cmd
- import (
- "os"
- "github.com/porter-dev/porter/cli/cmd/api"
- "github.com/porter-dev/porter/cli/cmd/connect"
- "github.com/spf13/cobra"
- )
- var (
- kubeconfigPath string
- print *bool
- contexts *[]string
- )
- var connectCmd = &cobra.Command{
- Use: "connect",
- Short: "Commands that connect to external clusters and providers",
- }
- var connectKubeconfigCmd = &cobra.Command{
- Use: "kubeconfig",
- Short: "Uses the local kubeconfig to connect to a cluster",
- Run: func(cmd *cobra.Command, args []string) {
- err := checkLoginAndRun(args, runConnect)
- if err != nil {
- os.Exit(1)
- }
- },
- }
- func init() {
- rootCmd.AddCommand(connectCmd)
- connectCmd.AddCommand(connectKubeconfigCmd)
- connectCmd.PersistentFlags().StringVar(
- &host,
- "host",
- getHost(),
- "host url of Porter instance",
- )
- projectID = *connectCmd.PersistentFlags().UintP(
- "project-id",
- "p",
- getProjectID(),
- "project id to use",
- )
- connectKubeconfigCmd.PersistentFlags().StringVarP(
- &kubeconfigPath,
- "kubeconfig",
- "k",
- "",
- "path to kubeconfig",
- )
- contexts = connectKubeconfigCmd.PersistentFlags().StringArray(
- "contexts",
- nil,
- "the list of contexts to connect (defaults to the current context)",
- )
- }
- func runConnect(_ *api.AuthCheckResponse, client *api.Client, _ []string) error {
- return connect.Kubeconfig(
- client,
- kubeconfigPath,
- *contexts,
- getProjectID(),
- )
- }
|