src/server/auth/cmds/configure.go
func SetConfigCmd(noPortForwarding *bool) *cobra.Command {
	var file string
	setConfig := &cobra.Command{
		Short: "Set Pachyderm's current auth configuration",
		Long:  "Set 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()
			var configBytes []byte
			if file == "-" {
				var err error
				configBytes, err = ioutil.ReadAll(os.Stdin)
				if err != nil {
					return fmt.Errorf("could not read config from stdin: %v", err)
				}
			} else if file != "" {
				var err error
				configBytes, err = ioutil.ReadFile(file)
				if err != nil {
					return fmt.Errorf("could not read config from %q: %v", file, err)
				}
			} else {
				return errors.New("must set input file (use \"-\" to read from stdin)")
			}

			// Try to parse config as YAML (JSON is a subset of YAML)
			var config auth.AuthConfig
			if err := yaml.Unmarshal(configBytes, &config); err != nil {
				return fmt.Errorf("could not parse config: %v", err)
			}
			// TODO(msteffen): try to handle empty config?
			_, err = c.SetConfiguration(c.Ctx(), &auth.SetConfigurationRequest{
				Configuration: &config,
			})
			return grpcutil.ScrubGRPC(err)
		}),
	}
	setConfig.Flags().StringVarP(&file, "file", "f", "-", "input file (to use "+
		"as the new config")
	return cmdutil.CreateAlias(setConfig, "auth set-config")
}
func SetConfigCmd(noPortForwarding *bool) *cobra.Command {
	var file string
	setConfig := &cobra.Command{
		Short: "Set Pachyderm's current auth configuration",
		Long:  "Set 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()
			var configBytes []byte
			if file == "-" {
				var err error
				configBytes, err = ioutil.ReadAll(os.Stdin)
				if err != nil {
					return fmt.Errorf("could not read config from stdin: %v", err)
				}
			} else if file != "" {
				var err error
				configBytes, err = ioutil.ReadFile(file)
				if err != nil {
					return fmt.Errorf("could not read config from %q: %v", file, err)
				}
			} else {
				return errors.New("must set input file (use \"-\" to read from stdin)")
			}

			// Try to parse config as YAML (JSON is a subset of YAML)
			var config auth.AuthConfig
			if err := yaml.Unmarshal(configBytes, &config); err != nil {
				return fmt.Errorf("could not parse config: %v", err)
			}
			// TODO(msteffen): try to handle empty config?
			_, err = c.SetConfiguration(c.Ctx(), &auth.SetConfigurationRequest{
				Configuration: &config,
			})
			return grpcutil.ScrubGRPC(err)
		}),
	}
	setConfig.Flags().StringVarP(&file, "file", "f", "-", "input file (to use "+
		"as the new config")
	return cmdutil.CreateAlias(setConfig, "auth set-config")
}
func SetConfigCmd ( noPortForwarding * bool ) * cobra . Command { var file string setConfig := & 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 ( ) var configBytes [ ] byte if file == " " { var err error configBytes , err = ioutil . ReadAll ( os . Stdin ) if err != nil { return fmt . Errorf ( " " , err ) } } else if file != " " { var err error configBytes , err = ioutil . ReadFile ( file ) if err != nil { return fmt . Errorf ( " " , file , err ) } } else { return errors . New ( " \" \" " ) } // Try to parse config as YAML (JSON is a subset of YAML) var config auth . AuthConfig if err := yaml . Unmarshal ( configBytes , & config ) ; err != nil { return fmt . Errorf ( " " , err ) } // TODO(msteffen): try to handle empty config? _ , err = c . SetConfiguration ( c . Ctx ( ) , & auth . SetConfigurationRequest { Configuration : & config , } ) return grpcutil . ScrubGRPC ( err ) } ) , } setConfig . Flags ( ) . StringVarP ( & file , " " , " " , " " , " " + " " ) return cmdutil . CreateAlias ( setConfig , " " ) }
// SetConfigCmd returns a cobra command that lets the caller configure auth
// backends in Pachyderm
SetConfigCmd returns a cobra command that lets the caller configure auth backends in Pachyderm