src/server/auth/cmds/configure.go
func GetConfigCmd(noPortForwarding *bool) *cobra.Command {
	var format string
	getConfig := &cobra.Command{
		Short: "Retrieve Pachyderm's current auth configuration",
		Long:  "Retrieve Pachyderm's current auth configuration",
		Run: cmdutil.RunFixedArgs(0, func(args []string) error {
			c, err := client.NewOnUserMachine(true, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.GetConfiguration(c.Ctx(), &auth.GetConfigurationRequest{})
			if err != nil {
				return grpcutil.ScrubGRPC(err)
			}
			if resp.Configuration == nil {
				fmt.Println("no auth config set")
				return nil
			}
			output, err := json.MarshalIndent(resp.Configuration, "", "  ")
			if err != nil {
				return fmt.Errorf("could not marshal response:\n%v\ndue to: %v", resp.Configuration, err)
			}
			switch format {
			case "json":
				// already done
			case "yaml":
				output, err = yaml.JSONToYAML(output)
				if err != nil {
					return fmt.Errorf("could not convert json to yaml: %v", err)
				}
			default:
				return fmt.Errorf("invalid output format: %v", format)
			}
			fmt.Println(string(output))
			return nil
		}),
	}
	getConfig.Flags().StringVarP(&format, "output-format", "o", "json", "output "+
		"format (\"json\" or \"yaml\")")
	return cmdutil.CreateAlias(getConfig, "auth get-config")
}
func GetConfigCmd(noPortForwarding *bool) *cobra.Command {
	var format string
	getConfig := &cobra.Command{
		Short: "Retrieve Pachyderm's current auth configuration",
		Long:  "Retrieve Pachyderm's current auth configuration",
		Run: cmdutil.RunFixedArgs(0, func(args []string) error {
			c, err := client.NewOnUserMachine(true, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.GetConfiguration(c.Ctx(), &auth.GetConfigurationRequest{})
			if err != nil {
				return grpcutil.ScrubGRPC(err)
			}
			if resp.Configuration == nil {
				fmt.Println("no auth config set")
				return nil
			}
			output, err := json.MarshalIndent(resp.Configuration, "", "  ")
			if err != nil {
				return fmt.Errorf("could not marshal response:\n%v\ndue to: %v", resp.Configuration, err)
			}
			switch format {
			case "json":
				// already done
			case "yaml":
				output, err = yaml.JSONToYAML(output)
				if err != nil {
					return fmt.Errorf("could not convert json to yaml: %v", err)
				}
			default:
				return fmt.Errorf("invalid output format: %v", format)
			}
			fmt.Println(string(output))
			return nil
		}),
	}
	getConfig.Flags().StringVarP(&format, "output-format", "o", "json", "output "+
		"format (\"json\" or \"yaml\")")
	return cmdutil.CreateAlias(getConfig, "auth get-config")
}
func GetConfigCmd ( noPortForwarding * bool ) * cobra . Command { var format string getConfig := & cobra . Command { Short : " " , Long : " " , Run : cmdutil . RunFixedArgs ( 0 , func ( args [ ] string ) error { c , err := client . NewOnUserMachine ( true , ! * noPortForwarding , " " ) if err != nil { return fmt . Errorf ( " " , err ) } defer c . Close ( ) resp , err := c . GetConfiguration ( c . Ctx ( ) , & auth . GetConfigurationRequest { } ) if err != nil { return grpcutil . ScrubGRPC ( err ) } if resp . Configuration == nil { fmt . Println ( " " ) return nil } output , err := json . MarshalIndent ( resp . Configuration , " " , " " ) if err != nil { return fmt . Errorf ( " \n \n " , resp . Configuration , err ) } switch format { case " " : // already done case " " : output , err = yaml . JSONToYAML ( output ) if err != nil { return fmt . Errorf ( " " , err ) } default : return fmt . Errorf ( " " , format ) } fmt . Println ( string ( output ) ) return nil } ) , } getConfig . Flags ( ) . StringVarP ( & format , " " , " " , " " , " " + " \" \" \" \" " ) return cmdutil . CreateAlias ( getConfig , " " ) }
// GetConfigCmd returns a cobra command that lets the caller see the configured
// auth backends in Pachyderm
GetConfigCmd returns a cobra command that lets the caller see the configured auth backends in Pachyderm