From fc9c4a95866b6d7db1b9b508c397bfd03bbd5e65 Mon Sep 17 00:00:00 2001 From: Seena Burns Date: Thu, 12 Aug 2021 09:03:17 -0700 Subject: [PATCH 1/4] Update go.sum with missing dependencies --- go.mod | 2 ++ go.sum | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/go.mod b/go.mod index 878db1a..54d34df 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/stripe/skycfg +go 1.16 + require ( github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.4.1 diff --git a/go.sum b/go.sum index 2c2c6db..927d325 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,6 @@ +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -18,6 +21,8 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= go.starlark.net v0.0.0-20201204201740-42d4f566359b h1:yHUzJ1WfcdR1oOafytJ6K1/ntYwnEIXICNVzHb+FzbA= go.starlark.net v0.0.0-20201204201740-42d4f566359b/go.mod h1:5YFcFnRptTN+41758c2bMPiqpGg4zBfYji1IQz8wNFk= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 h1:B6caxRw+hozq68X2MY7jEpZh/cr4/aHLv9xU8Kkadrw= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 11a58ce9264c943ff34588709be878efc03c8dc1 Mon Sep 17 00:00:00 2001 From: Seena Burns Date: Thu, 12 Aug 2021 09:04:02 -0700 Subject: [PATCH 2/4] Add self to contributors --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 02f64c9..bf12d83 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,5 +12,6 @@ Dmitry Ilyevsky # GM Cruise LLC Isaac Diamond John Millikin Matt Moriarity +Seena Burns # Please alphabetize new entries. From 424454d2d8e11a005530d998b9fd72d1675e3218 Mon Sep 17 00:00:00 2001 From: Seena Burns Date: Thu, 12 Aug 2021 09:06:35 -0700 Subject: [PATCH 3/4] Move assert impl to new assertmodule --- go/assertmodule/BUILD | 30 +++++++++++++++++++ .../go/skycfg => go/assertmodule}/assert.go | 0 .../skycfg => go/assertmodule}/assert_test.go | 0 .../go/skycfg => go/assertmodule}/fail.go | 0 internal/go/skycfg/BUILD | 3 -- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 go/assertmodule/BUILD rename {internal/go/skycfg => go/assertmodule}/assert.go (100%) rename {internal/go/skycfg => go/assertmodule}/assert_test.go (100%) rename {internal/go/skycfg => go/assertmodule}/fail.go (100%) diff --git a/go/assertmodule/BUILD b/go/assertmodule/BUILD new file mode 100644 index 0000000..c4b296e --- /dev/null +++ b/go/assertmodule/BUILD @@ -0,0 +1,30 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "assertmodule", + srcs = [ + "assert.go", + "fail.go", + ], + importpath = "github.com/stripe/skycfg/go/assertmodule", + visibility = ["//visibility:public"], + deps = [ + "@net_starlark_go//starlark", + "@net_starlark_go//starlarkstruct", + "@net_starlark_go//syntax", + ], +) + +go_test( + name = "assertmodule_test", + size = "small", + srcs = [ + "assert_test.go", + ], + embed = [":assertmodule"], + deps = [ + "@net_starlark_go//starlark", + "@net_starlark_go//starlarkstruct", + "@net_starlark_go//syntax", + ], +) diff --git a/internal/go/skycfg/assert.go b/go/assertmodule/assert.go similarity index 100% rename from internal/go/skycfg/assert.go rename to go/assertmodule/assert.go diff --git a/internal/go/skycfg/assert_test.go b/go/assertmodule/assert_test.go similarity index 100% rename from internal/go/skycfg/assert_test.go rename to go/assertmodule/assert_test.go diff --git a/internal/go/skycfg/fail.go b/go/assertmodule/fail.go similarity index 100% rename from internal/go/skycfg/fail.go rename to go/assertmodule/fail.go diff --git a/internal/go/skycfg/BUILD b/internal/go/skycfg/BUILD index 0b100d8..84c8d52 100644 --- a/internal/go/skycfg/BUILD +++ b/internal/go/skycfg/BUILD @@ -3,8 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "skycfg", srcs = [ - "assert.go", - "fail.go", "module.go", "proto_api.go", "proto_enum.go", @@ -34,7 +32,6 @@ go_test( name = "skycfg_test", size = "small", srcs = [ - "assert_test.go", "proto_test.go", "skycfg_test.go", ], From ee421cd6b35ce0e301bf95142dfe6b094db2c69f Mon Sep 17 00:00:00 2001 From: Seena Burns Date: Thu, 12 Aug 2021 09:09:00 -0700 Subject: [PATCH 4/4] Switch to starlarkstruct.Module, fix references --- BUILD.bazel | 1 + go/assertmodule/assert.go | 4 ++-- go/assertmodule/assert_test.go | 7 ++++--- go/assertmodule/fail.go | 2 +- skycfg.go | 5 +++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index e0ad4da..7e8fa6a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,6 +12,7 @@ go_library( importpath = "github.com/stripe/skycfg", visibility = ["//visibility:public"], deps = [ + "//go/assertmodule", "//go/hashmodule", "//go/protomodule", "//go/urlmodule", diff --git a/go/assertmodule/assert.go b/go/assertmodule/assert.go index 04d40e0..c621b62 100644 --- a/go/assertmodule/assert.go +++ b/go/assertmodule/assert.go @@ -14,7 +14,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package skycfg +package assertmodule import ( "fmt" @@ -89,7 +89,7 @@ type TestContext struct { Failures []error } -var _ starlark.HasAttrs = (*Module)(nil) +var _ starlark.HasAttrs = (*TestContext)(nil) var _ starlark.Value = (*TestContext)(nil) var _ starlark.Callable = (*TestContext)(nil) diff --git a/go/assertmodule/assert_test.go b/go/assertmodule/assert_test.go index 8ef76ab..dd771f8 100644 --- a/go/assertmodule/assert_test.go +++ b/go/assertmodule/assert_test.go @@ -14,7 +14,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package skycfg +package assertmodule import ( "fmt" @@ -22,6 +22,7 @@ import ( "testing" "go.starlark.net/starlark" + "go.starlark.net/starlarkstruct" "go.starlark.net/syntax" ) @@ -338,9 +339,9 @@ func evalAndReportResults(t *testing.T, cmd string, testCase assertTestCase) { assertModule := AssertModule() // set it up like it would be used, off a param - testCtx := &Module{ + testCtx := &starlarkstruct.Module{ Name: "skycfg_test_ctx", - Attrs: starlark.StringDict(map[string]starlark.Value{ + Members: starlark.StringDict(map[string]starlark.Value{ "assert": assertModule, }), } diff --git a/go/assertmodule/fail.go b/go/assertmodule/fail.go index 4911eff..1147550 100644 --- a/go/assertmodule/fail.go +++ b/go/assertmodule/fail.go @@ -1,4 +1,4 @@ -package skycfg +package assertmodule import ( "fmt" diff --git a/skycfg.go b/skycfg.go index 076ea09..e7974f9 100644 --- a/skycfg.go +++ b/skycfg.go @@ -34,6 +34,7 @@ import ( "go.starlark.net/starlarkstruct" "google.golang.org/protobuf/reflect/protoregistry" + "github.com/stripe/skycfg/go/assertmodule" "github.com/stripe/skycfg/go/hashmodule" "github.com/stripe/skycfg/go/protomodule" "github.com/stripe/skycfg/go/urlmodule" @@ -185,7 +186,7 @@ func WithProtoRegistry(r unstableProtoRegistry) LoadOption { // * url - utility package for encoding URL query string. func UnstablePredeclaredModules(r unstableProtoRegistry) starlark.StringDict { return starlark.StringDict{ - "fail": impl.Fail, + "fail": assertmodule.Fail, "hash": hashmodule.NewModule(), "json": starlarkjson.Module, "proto": UnstableProtoModule(r), @@ -443,7 +444,7 @@ func (t *Test) Run(ctx context.Context) (*TestResult, error) { } thread.SetLocal("context", ctx) - assertModule := impl.AssertModule() + assertModule := assertmodule.AssertModule() testCtx := &impl.Module{ Name: "skycfg_test_ctx", Attrs: starlark.StringDict(map[string]starlark.Value{