예제 #1
0
파일: cmd.go 프로젝트: sammath/pachyderm
func PachctlCmd(pfsdAddress string, ppsdAddress string) (*cobra.Command, error) {
	rootCmd := &cobra.Command{
		Use: os.Args[0],
		Long: `Access the Pachyderm API.

Envronment variables:
  PFS_ADDRESS=0.0.0.0:650, the PFS server to connect to.
  PPS_ADDRESS=0.0.0.0:651, the PPS server to connect to.
`,
	}
	pfsCmds := pfscmds.Cmds(pfsdAddress)
	for _, cmd := range pfsCmds {
		rootCmd.AddCommand(cmd)
	}
	ppsCmds, err := ppscmds.Cmds(ppsdAddress)
	if err != nil {
		return nil, err
	}
	for _, cmd := range ppsCmds {
		rootCmd.AddCommand(cmd)
	}

	deployCmds := deploycmds.Cmds()
	for _, cmd := range deployCmds {
		rootCmd.AddCommand(cmd)
	}
	version := &cobra.Command{
		Use:   "version",
		Short: "Return version information.",
		Long:  "Return version information.",
		Run: pkgcobra.RunFixedArgs(0, func(args []string) error {
			pfsdVersionClient, err := getVersionAPIClient(pfsdAddress)
			if err != nil {
				return err
			}
			pfsdVersion, err := pfsdVersionClient.GetVersion(context.Background(), &google_protobuf.Empty{})
			if err != nil {
				return err
			}
			ppsdVersionClient, err := getVersionAPIClient(pfsdAddress)
			if err != nil {
				return err
			}
			ppsdVersion, err := ppsdVersionClient.GetVersion(context.Background(), &google_protobuf.Empty{})
			if err != nil {
				return err
			}
			writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
			printVerisonHeader(writer)
			printVersion(writer, "pachctl", pachyderm.Version)
			printVersion(writer, "pfsd", pfsdVersion)
			printVersion(writer, "ppsd", ppsdVersion)
			return writer.Flush()
		}),
	}
	rootCmd.AddCommand(version)
	return rootCmd, nil
}
예제 #2
0
func do(appEnvObj interface{}) error {
	appEnv := appEnvObj.(*appEnv)
	rootCmd := &cobra.Command{
		Use: "pach",
		Long: `Access the Pachyderm API.

Envronment variables:
  PFS_ADDRESS=0.0.0.0:650, the PFS server to connect to.
  PPS_ADDRESS=0.0.0.0:651, the PPS server to connect to.
  KUBERNETES_ADDRESS=http://localhost:8080, the Kubernetes endpoint to connect to.
  KUBERNETES_USERNAME=admin
  KUBERNETES_PASSWORD
  PROVIDER, which provider to use for cluster creation (currently only supports GCE).
  GCE_PROJECT
  GCE_ZONE`,
	}
	pfsCmds, err := pfscmds.Cmds(getPfsdAddress(appEnv))
	if err != nil {
		return err
	}
	for _, cmd := range pfsCmds {
		rootCmd.AddCommand(cmd)
	}
	ppsCmds, err := ppscmds.Cmds(getPpsdAddress(appEnv))
	if err != nil {
		return err
	}
	for _, cmd := range ppsCmds {
		rootCmd.AddCommand(cmd)
	}

	deployCmds, err := deploycmds.Cmds(
		appEnv.KubernetesAddress,
		appEnv.KubernetesUsername,
		appEnv.KubernetesAddress,
		appEnv.Provider,
		appEnv.GCEProject,
		appEnv.GCEZone,
	)
	if err != nil {
		return err
	}
	for _, cmd := range deployCmds {
		rootCmd.AddCommand(cmd)
	}

	return rootCmd.Execute()
}
예제 #3
0
func do(appEnvObj interface{}) error {
	appEnv := appEnvObj.(*appEnv)
	rootCmd := &cobra.Command{
		Use: os.Args[0],
		Long: `Access the Pachyderm API.

Envronment variables:
  PFS_ADDRESS=0.0.0.0:650, the PFS server to connect to.
  PPS_ADDRESS=0.0.0.0:651, the PPS server to connect to.
  KUBERNETES_ADDRESS=http://localhost:8080, the Kubernetes endpoint to connect to.
  KUBERNETES_USERNAME=admin
  KUBERNETES_PASSWORD
  PROVIDER, which provider to use for cluster creation (currently only supports GCE).
  GCE_PROJECT
  GCE_ZONE`,
	}
	pfsdAddress := getPfsdAddress(appEnv)
	ppsdAddress := getPpsdAddress(appEnv)
	pfsCmds, err := pfscmds.Cmds(pfsdAddress)
	if err != nil {
		return err
	}
	for _, cmd := range pfsCmds {
		rootCmd.AddCommand(cmd)
	}
	ppsCmds, err := ppscmds.Cmds(ppsdAddress)
	if err != nil {
		return err
	}
	for _, cmd := range ppsCmds {
		rootCmd.AddCommand(cmd)
	}

	deployCmds, err := deploycmds.Cmds(
		appEnv.KubernetesAddress,
		appEnv.KubernetesUsername,
		appEnv.KubernetesAddress,
		appEnv.Provider,
		appEnv.GCEProject,
		appEnv.GCEZone,
	)
	if err != nil {
		return err
	}
	for _, cmd := range deployCmds {
		rootCmd.AddCommand(cmd)
	}
	version := &cobra.Command{
		Use:   "version",
		Short: "Return version information.",
		Long:  "Return version information.",
		Run: pkgcobra.RunFixedArgs(0, func(args []string) error {
			pfsdVersionClient, err := getVersionAPIClient(pfsdAddress)
			if err != nil {
				return err
			}
			pfsdVersion, err := pfsdVersionClient.GetVersion(context.Background(), &google_protobuf.Empty{})
			if err != nil {
				return err
			}
			ppsdVersionClient, err := getVersionAPIClient(pfsdAddress)
			if err != nil {
				return err
			}
			ppsdVersion, err := ppsdVersionClient.GetVersion(context.Background(), &google_protobuf.Empty{})
			if err != nil {
				return err
			}
			writer := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
			printVerisonHeader(writer)
			printVersion(writer, "pachctl", pachyderm.Version)
			printVersion(writer, "pfsd", pfsdVersion)
			printVersion(writer, "ppsd", ppsdVersion)
			return writer.Flush()
		}),
	}
	rootCmd.AddCommand(version)

	return rootCmd.Execute()
}