mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 23:02:52 +01:00
missing access (#438)
This commit is contained in:
parent
1e540f17eb
commit
63ef223ada
@ -5,8 +5,10 @@ import (
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/openziti/zrok/drives/sync"
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/openziti/zrok/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -53,6 +55,18 @@ func (cmd *lsCommand) run(_ *cobra.Command, args []string) {
|
||||
tui.Error("error loading root", err)
|
||||
}
|
||||
|
||||
if targetUrl.Scheme == "zrok" {
|
||||
access, err := sdk.CreateAccess(root, &sdk.AccessRequest{ShareToken: targetUrl.Host})
|
||||
if err != nil {
|
||||
tui.Error("error creating access", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sdk.DeleteAccess(root, access); err != nil {
|
||||
logrus.Warningf("error freeing access: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
|
||||
if err != nil {
|
||||
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/openziti/zrok/drives/sync"
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -50,6 +52,18 @@ func (cmd *mdCommand) run(_ *cobra.Command, args []string) {
|
||||
tui.Error("error loading root", err)
|
||||
}
|
||||
|
||||
if targetUrl.Scheme == "zrok" {
|
||||
access, err := sdk.CreateAccess(root, &sdk.AccessRequest{ShareToken: targetUrl.Host})
|
||||
if err != nil {
|
||||
tui.Error("error creating access", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sdk.DeleteAccess(root, access); err != nil {
|
||||
logrus.Warningf("error freeing access: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
|
||||
if err != nil {
|
||||
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/openziti/zrok/drives/sync"
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -50,6 +52,18 @@ func (cmd *mvCommand) run(_ *cobra.Command, args []string) {
|
||||
tui.Error("error loading root", err)
|
||||
}
|
||||
|
||||
if targetUrl.Scheme == "zrok" {
|
||||
access, err := sdk.CreateAccess(root, &sdk.AccessRequest{ShareToken: targetUrl.Host})
|
||||
if err != nil {
|
||||
tui.Error("error creating access", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sdk.DeleteAccess(root, access); err != nil {
|
||||
logrus.Warningf("error freeing access: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
|
||||
if err != nil {
|
||||
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)
|
||||
|
@ -4,7 +4,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/openziti/zrok/drives/sync"
|
||||
"github.com/openziti/zrok/environment"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
"github.com/openziti/zrok/tui"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -50,6 +52,18 @@ func (cmd *rmCommand) run(_ *cobra.Command, args []string) {
|
||||
tui.Error("error loading root", err)
|
||||
}
|
||||
|
||||
if targetUrl.Scheme == "zrok" {
|
||||
access, err := sdk.CreateAccess(root, &sdk.AccessRequest{ShareToken: targetUrl.Host})
|
||||
if err != nil {
|
||||
tui.Error("error creating access", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := sdk.DeleteAccess(root, access); err != nil {
|
||||
logrus.Warningf("error freeing access: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
|
||||
if err != nil {
|
||||
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)
|
||||
|
Loading…
Reference in New Issue
Block a user