From da1adb8199f2d78b2079d85b77fbaf4594e0a16f Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 20 Aug 2024 19:52:50 +0000 Subject: [PATCH] v0.1.1 misc fixes --- cli.go | 12 ++++++++++++ detection/detection_test.go | 2 ++ detection/languages.go | 2 +- lcl/bootstrap.go | 10 +--------- lcl/lcl.go | 3 --- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cli.go b/cli.go index e95e1d4..a07aca5 100644 --- a/cli.go +++ b/cli.go @@ -6,6 +6,7 @@ import ( "fmt" "net/url" "os" + "os/exec" "runtime" "strings" "time" @@ -17,6 +18,7 @@ import ( "github.com/anchordotdev/cli/models" "github.com/anchordotdev/cli/stacktrace" + "github.com/anchordotdev/cli/truststore" "github.com/anchordotdev/cli/ui" ) @@ -172,6 +174,16 @@ func isReportable(err error) bool { return false } + var terr truststore.Error + if errors.As(err, &terr) { + return false + } + + eerr := new(exec.ExitError) + if errors.As(err, &eerr) { + return false + } + switch err { case context.Canceled: return false diff --git a/detection/detection_test.go b/detection/detection_test.go index a0bb1d4..5806485 100644 --- a/detection/detection_test.go +++ b/detection/detection_test.go @@ -39,6 +39,8 @@ func TestDefaultDetectors(t *testing.T) { fakeFS := fstest.MapFS{ "Gemfile": &fstest.MapFile{Data: []byte(""), Mode: 0644}, "Gemfile.lock": &fstest.MapFile{Data: []byte(""), Mode: 0644}, + "Pipfile": &fstest.MapFile{Data: []byte(""), Mode: 0644}, + "Pipfile.lock": &fstest.MapFile{Data: []byte(""), Mode: 0644}, "package.json": &fstest.MapFile{Data: []byte(""), Mode: 0644}, "requirements.txt": &fstest.MapFile{Data: []byte(""), Mode: 0644}, "main.go": &fstest.MapFile{Data: []byte(""), Mode: 0644}, diff --git a/detection/languages.go b/detection/languages.go index 9687ab1..15d8a24 100644 --- a/detection/languages.go +++ b/detection/languages.go @@ -28,7 +28,7 @@ var ( Python = &FileDetector{ Title: "Python", - Paths: []string{"requirements.txt"}, + Paths: []string{"Pipfile", "Pipfile.lock", "requirements.txt"}, FollowUpDetectors: []Detector{Django, Flask}, AnchorCategory: anchorcli.CategoryPython, } diff --git a/lcl/bootstrap.go b/lcl/bootstrap.go index 948656a..f6f3b66 100644 --- a/lcl/bootstrap.go +++ b/lcl/bootstrap.go @@ -32,8 +32,7 @@ var CmdBootstrap = cli.NewCmd[Bootstrap](CmdLcl, "bootstrap", func(cmd *cobra.Co var loopbackAddrs = []string{"127.0.0.1", "::1"} type Bootstrap struct { - anc *api.Session - orgSlug, realmSlug string + anc *api.Session auditInfo *truststore.AuditInfo } @@ -168,10 +167,6 @@ func (c Bootstrap) perform(ctx context.Context, drv *ui.Driver) error { } func (c Bootstrap) personalOrgAPID(ctx context.Context) (string, error) { - if c.orgSlug != "" { - return c.orgSlug, nil - } - userInfo, err := c.anc.UserInfo(ctx) if err != nil { return "", err @@ -180,9 +175,6 @@ func (c Bootstrap) personalOrgAPID(ctx context.Context) (string, error) { } func (c Bootstrap) localhostRealmAPID() (string, error) { - if c.realmSlug != "" { - return c.realmSlug, nil // TODO: is this used? - } return "localhost", nil } diff --git a/lcl/lcl.go b/lcl/lcl.go index 74233fe..8f7aea1 100644 --- a/lcl/lcl.go +++ b/lcl/lcl.go @@ -148,9 +148,6 @@ func (c *Command) systemConfig(ctx context.Context, drv *ui.Driver) error { cmdBootstrap := &Bootstrap{ anc: c.anc, - orgSlug: orgSlug, - realmSlug: realmSlug, - auditInfo: auditInfo, }