missing access (#438)

This commit is contained in:
Michael Quigley 2024-01-12 13:11:11 -05:00
parent 1e540f17eb
commit 63ef223ada
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 56 additions and 0 deletions

View File

@ -5,8 +5,10 @@ import (
"github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/table"
"github.com/openziti/zrok/drives/sync" "github.com/openziti/zrok/drives/sync"
"github.com/openziti/zrok/environment" "github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
"github.com/openziti/zrok/util" "github.com/openziti/zrok/util"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url" "net/url"
"os" "os"
@ -53,6 +55,18 @@ func (cmd *lsCommand) run(_ *cobra.Command, args []string) {
tui.Error("error loading root", err) 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) target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
if err != nil { if err != nil {
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err) tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)

View File

@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"github.com/openziti/zrok/drives/sync" "github.com/openziti/zrok/drives/sync"
"github.com/openziti/zrok/environment" "github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url" "net/url"
"os" "os"
@ -50,6 +52,18 @@ func (cmd *mdCommand) run(_ *cobra.Command, args []string) {
tui.Error("error loading root", err) 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) target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
if err != nil { if err != nil {
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err) tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)

View File

@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"github.com/openziti/zrok/drives/sync" "github.com/openziti/zrok/drives/sync"
"github.com/openziti/zrok/environment" "github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url" "net/url"
"os" "os"
@ -50,6 +52,18 @@ func (cmd *mvCommand) run(_ *cobra.Command, args []string) {
tui.Error("error loading root", err) 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) target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
if err != nil { if err != nil {
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err) tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)

View File

@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"github.com/openziti/zrok/drives/sync" "github.com/openziti/zrok/drives/sync"
"github.com/openziti/zrok/environment" "github.com/openziti/zrok/environment"
"github.com/openziti/zrok/sdk/golang/sdk"
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"net/url" "net/url"
"os" "os"
@ -50,6 +52,18 @@ func (cmd *rmCommand) run(_ *cobra.Command, args []string) {
tui.Error("error loading root", err) 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) target, err := sync.TargetForURL(targetUrl, root, cmd.basicAuth)
if err != nil { if err != nil {
tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err) tui.Error(fmt.Sprintf("error creating target for '%v'", targetUrl), err)