mirror of
https://github.com/openziti/zrok.git
synced 2025-01-22 22:09:03 +01:00
zrok http backend -> zrok share public (#106)
This commit is contained in:
parent
b54876fcb6
commit
3f35888ad3
@ -16,6 +16,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&panicInstead, "panic", "p", false, "Panic instead of showing pretty errors")
|
||||
zrokdir.AddZrokApiEndpointFlag(&apiEndpoint, rootCmd.PersistentFlags())
|
||||
rootCmd.AddCommand(httpCmd)
|
||||
rootCmd.AddCommand(shareCmd)
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
@ -36,6 +37,11 @@ var httpCmd = &cobra.Command{
|
||||
Short: "HTTP endpoint operations",
|
||||
}
|
||||
|
||||
var shareCmd = &cobra.Command{
|
||||
Use: "share",
|
||||
Short: "Share resources",
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
panic(err)
|
||||
|
@ -25,30 +25,30 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
httpCmd.AddCommand(newHttpBackendCommand().cmd)
|
||||
shareCmd.AddCommand(newHttpBackendCommand().cmd)
|
||||
}
|
||||
|
||||
type httpBackendCommand struct {
|
||||
type sharePublicCommand struct {
|
||||
quiet bool
|
||||
basicAuth []string
|
||||
cmd *cobra.Command
|
||||
}
|
||||
|
||||
func newHttpBackendCommand() *httpBackendCommand {
|
||||
func newHttpBackendCommand() *sharePublicCommand {
|
||||
cmd := &cobra.Command{
|
||||
Use: "backend <targetEndpoint>",
|
||||
Use: "public <targetEndpoint>",
|
||||
Aliases: []string{"be"},
|
||||
Short: "Create an HTTP binding",
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
command := &httpBackendCommand{cmd: cmd}
|
||||
command := &sharePublicCommand{cmd: cmd}
|
||||
cmd.Flags().BoolVarP(&command.quiet, "quiet", "q", false, "Disable TUI 'chrome' for quiet operation")
|
||||
cmd.Flags().StringArrayVar(&command.basicAuth, "basic-auth", []string{}, "Basic authentication users (<username:password>,...")
|
||||
cmd.Run = command.run
|
||||
return command
|
||||
}
|
||||
|
||||
func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
||||
func (self *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
||||
targetEndpoint, err := url.Parse(args[0])
|
||||
if err != nil {
|
||||
if !panicInstead {
|
||||
@ -225,7 +225,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *httpBackendCommand) destroy(id string, cfg *backend.Config, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {
|
||||
func (self *sharePublicCommand) destroy(id string, cfg *backend.Config, zrok *rest_client_zrok.Zrok, auth runtime.ClientAuthInfoWriter) {
|
||||
logrus.Debugf("shutting down '%v'", cfg.Service)
|
||||
req := service.NewUnshareParams()
|
||||
req.Body = &rest_model_zrok.UnshareRequest{
|
Loading…
Reference in New Issue
Block a user