diff --git a/.bazelignore b/.bazelignore index ec27918fdc..960b544d36 100644 --- a/.bazelignore +++ b/.bazelignore @@ -5,6 +5,5 @@ terraform vendor .git .github -hack template pkg/app/web/node_modules \ No newline at end of file diff --git a/.bazelrc b/.bazelrc index 749e6eae69..afeff526df 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,7 +8,7 @@ test --test_output=errors --test_verbose_timeout_warnings --incompatible_strict_ build:stamping --stamp --workspace_status_command hack/print-workspace-status.sh # Enable go race detection -build --features=race +build --@io_bazel_rules_go//go/config:race # Output profiling to a file build --profile=/tmp/build.bazelprofile diff --git a/.bazelversion b/.bazelversion index a76ccff2a6..0b2eb36f50 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -3.7.1 +3.7.2 diff --git a/BUILD.bazel b/BUILD.bazel index 518f55b38c..c36f64466d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,7 +1,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:exclude docs -# gazelle:exclude hack # gazelle:exclude dockers # gazelle:exclude manifests # gazelle:exclude terraform @@ -9,8 +8,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:exclude vendor # gazelle:exclude pkg/app/web/node_modules # gazelle:exclude pkg/plugin/golinter/gofmt/testdata -# gazelle:exclude pkg/app/kapetool/cmd/godifflinter/pkg/linters/unusedparam/testdata -# gazelle:exclude pkg/app/kapetool/cmd/godifflinter/pkg/linters/ineffassign/testdata # gazelle:build_file_name BUILD.bazel # gazelle:prefix github.com/pipe-cd/pipe diff --git a/BUILD.bazel.tpl b/BUILD.bazel.tpl index 62e851c5bc..16676b8457 100644 --- a/BUILD.bazel.tpl +++ b/BUILD.bazel.tpl @@ -1,7 +1,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:exclude docs -# gazelle:exclude hack # gazelle:exclude dockers # gazelle:exclude manifests # gazelle:exclude terraform @@ -9,8 +8,6 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:exclude vendor # gazelle:exclude pkg/app/web/node_modules # gazelle:exclude pkg/plugin/golinter/gofmt/testdata -# gazelle:exclude pkg/app/kapetool/cmd/godifflinter/pkg/linters/unusedparam/testdata -# gazelle:exclude pkg/app/kapetool/cmd/godifflinter/pkg/linters/ineffassign/testdata # gazelle:build_file_name BUILD.bazel # gazelle:prefix github.com/pipe-cd/pipe diff --git a/WORKSPACE b/WORKSPACE index ee6d812bdd..9af32552f8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,10 +15,10 @@ load( ### Rules_go and gazelle http_archive( name = "io_bazel_rules_go", - sha256 = "207fad3e6689135c5d8713e5a17ba9d1290238f47b9ba545b63d9303406209c6", + sha256 = "7904dbecbaffd068651916dce77ff3437679f9d20e1a7956bff43826e7645fcc", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.7/rules_go-v0.24.7.tar.gz", - "https://github.com/bazelbuild/rules_go/releases/download/v0.24.7/rules_go-v0.24.7.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz", + "https://github.com/bazelbuild/rules_go/releases/download/v0.25.1/rules_go-v0.25.1.tar.gz", ], ) @@ -31,7 +31,7 @@ load( go_rules_dependencies() go_register_toolchains( - go_version = "1.14.10", + version = "1.15.6", ) load( @@ -43,10 +43,10 @@ go_embed_data_dependencies() http_archive( name = "bazel_gazelle", - sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c", + sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz", ], ) @@ -144,14 +144,6 @@ container_pull( tag = "0.0.1", ) -### Protoc-gen-validate -git_repository( - name = "com_github_envoyproxy_protoc_gen_validate", - commit = "9eff07ddfcb4001aa1aab280648153f46e1a8ddc", - remote = "https://github.com/envoyproxy/protoc-gen-validate.git", - shallow_since = "1560436592 +0000", -) - ### web http_archive( diff --git a/bazel/gomock.bzl b/bazel/gomock.bzl index d590ea0fac..dd675fb259 100644 --- a/bazel/gomock.bzl +++ b/bazel/gomock.bzl @@ -33,45 +33,64 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_context", "go_rule") -load("@io_bazel_rules_go//go/private:providers.bzl", "GoLibrary") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_context", "go_path", "go_rule") +load("@io_bazel_rules_go//go/private:providers.bzl", "GoLibrary", "GoPath") _MOCKGEN_TOOL = "@com_github_golang_mock//mockgen" _MOCKGEN_MODEL_LIB = "@com_github_golang_mock//mockgen/model:go_default_library" def _gomock_source_impl(ctx): - args = ["-source", ctx.file.source.path] - if ctx.attr.package != "": - args += ["-package", ctx.attr.package] - args += [",".join(ctx.attr.interfaces)] - - out = ctx.outputs.out - cmd = ctx.file.mockgen_tool go_ctx = go_context(ctx) - inputs = go_ctx.sdk.headers + go_ctx.sdk.srcs + go_ctx.sdk.tools + [ctx.file.source] + gopath = "$(pwd)/" + ctx.bin_dir.path + "/" + ctx.attr.gopath_dep[GoPath].gopath + + # passed in source needs to be in gopath to not trigger module mode + args = ["-source", gopath + "/src/" + ctx.attr.library[GoLibrary].importmap + "/"+ ctx.file.source.basename] + + args, needed_files = _handle_shared_args(ctx, args) + + if len(ctx.attr.aux_files) > 0: + aux_files = [] + for pkg, files in ctx.attr.aux_files.items(): + for f in files: + mapped_f = gopath + "/src/" + ctx.attr.library[GoLibrary].importmap + "/"+ f + aux_files.append("{0}={1}".format(pkg, mapped_f)) + args += ["-aux_files", ",".join(aux_files)] + + inputs = ( + ctx.attr.gopath_dep.files.to_list() + needed_files + + go_ctx.sdk.headers + go_ctx.sdk.srcs + go_ctx.sdk.tools + ) + [ctx.file.source] # We can use the go binary from the stdlib for most of the environment # variables, but our GOPATH is specific to the library target we were given. ctx.actions.run_shell( - outputs = [out], + outputs = [ctx.outputs.out], inputs = inputs, tools = [ - cmd, + ctx.file.mockgen_tool, go_ctx.go, ], command = """ source <($PWD/{godir}/go env) && export PATH=$GOROOT/bin:$PWD/{godir}:$PATH && + export GOPATH={gopath} && + mkdir -p .gocache && + export GOCACHE=$PWD/.gocache && {cmd} {args} > {out} """.format( godir = go_ctx.go.path[:-1 - len(go_ctx.go.basename)], - cmd = "$(pwd)/" + cmd.path, + gopath = gopath, + cmd = "$(pwd)/" + ctx.file.mockgen_tool.path, args = " ".join(args), - out = out.path, + out = ctx.outputs.out.path, + mnemonic = "GoMockSourceGen", ), + env = { + "GO111MODULE": "off", # explicitly relying on passed in go_path to not download modules while doing codegen + }, ) -_gomock_source = go_rule( +_gomock_source = rule( _gomock_source_impl, attrs = { "library": attr.label( @@ -88,10 +107,9 @@ _gomock_source = go_rule( doc = "The new Go file to emit the generated mocks into", mandatory = True, ), - "interfaces": attr.string_list( - allow_empty = False, - doc = "The names of the Go interfaces to generate mocks for. If not set, all of the interfaces in the library or source file will have mocks generated for them.", - mandatory = True, + "aux_files": attr.string_list_dict( + default = {}, + doc = "A map from packages to auxilliary Go source files to load for those packages.", ), "package": attr.string( doc = "The name of the package the generated mocks should be in. If not specified, uses mockgen's default.", @@ -99,15 +117,36 @@ _gomock_source = go_rule( "self_package": attr.string( doc = "The full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. This can happen if the mock's package is set to one of its inputs (usually the main one) and the output is stdio so mockgen cannot detect the final output package. Setting this flag will then tell mockgen which import to exclude.", ), + "imports": attr.string_dict( + doc = "Dictionary of name-path pairs of explicit imports to use.", + ), + "mock_names": attr.string_dict( + doc = "Dictionary of interface name to mock name pairs to change the output names of the mock objects. Mock names default to 'Mock' prepended to the name of the interface.", + default = {}, + ), + "copyright_file": attr.label( + doc = "Optional file containing copyright to prepend to the generated contents.", + allow_single_file = True, + mandatory = False, + ), + "gopath_dep": attr.label( + doc = "The go_path label to use to create the GOPATH for the given library. Will be set correctly by the gomock macro, so you don't need to set it.", + providers = [GoPath], + mandatory = False, + ), "mockgen_tool": attr.label( doc = "The mockgen tool to run", default = Label(_MOCKGEN_TOOL), allow_single_file = True, executable = True, - cfg = "host", + cfg = "exec", mandatory = False, ), + "_go_context_data": attr.label( + default = "@io_bazel_rules_go//:go_context_data", + ), }, + toolchains = ["@io_bazel_rules_go//go:toolchain"], ) def gomock(name, library, out, **kwargs): @@ -116,23 +155,28 @@ def gomock(name, library, out, **kwargs): mockgen_tool = kwargs["mockgen_tool"] if kwargs.get("source", None): + gopath_name = name + "_gomock_gopath" + go_path( + name = gopath_name, + deps = [library, mockgen_tool], + ) _gomock_source( name = name, library = library, + gopath_dep = gopath_name, out = out, - **kwargs - ) + **kwargs) else: _gomock_reflect( name = name, library = library, out = out, mockgen_tool = mockgen_tool, - **kwargs - ) + **kwargs) def _gomock_reflect(name, library, out, mockgen_tool, **kwargs): - interfaces = kwargs.get("interfaces", None) + interfaces = kwargs.pop("interfaces", None) + mockgen_model_lib = _MOCKGEN_MODEL_LIB if kwargs.get("mockgen_model_library", None): mockgen_model_lib = kwargs["mockgen_model_library"] @@ -143,7 +187,6 @@ def _gomock_reflect(name, library, out, mockgen_tool, **kwargs): name = prog_src, interfaces = interfaces, library = library, - package = kwargs.get("package", None), out = prog_src_out, mockgen_tool = mockgen_tool, ) @@ -157,17 +200,13 @@ def _gomock_reflect(name, library, out, mockgen_tool, **kwargs): name = name, interfaces = interfaces, library = library, - package = kwargs.get("package", None), out = out, prog_bin = prog_bin, mockgen_tool = mockgen_tool, - self_package = kwargs.get("self_package", None), - ) + **kwargs) def _gomock_prog_gen_impl(ctx): args = ["-prog_only"] - if ctx.attr.package != "": - args += ["-package", ctx.attr.package] args += [ctx.attr.library[GoLibrary].importpath] args += [",".join(ctx.attr.interfaces)] @@ -183,13 +222,14 @@ def _gomock_prog_gen_impl(ctx): args = " ".join(args), out = out.path, ), + mnemonic = "GoMockReflectProgOnlyGen" ) -_gomock_prog_gen = go_rule( +_gomock_prog_gen = rule( _gomock_prog_gen_impl, attrs = { "library": attr.label( - doc = "The target the Go library is at to look for the interfaces in. When this is set and source is not set, mockgen will use its reflect code to generate the mocks.", + doc = "The target the Go library is at to look for the interfaces in. When this is set and source is not set, mockgen will use its reflect code to generate the mocks. If source is set, its dependencies will be included in the GOPATH that mockgen will be run in.", providers = [GoLibrary], mandatory = True, ), @@ -202,34 +242,33 @@ _gomock_prog_gen = go_rule( doc = "The names of the Go interfaces to generate mocks for. If not set, all of the interfaces in the library or source file will have mocks generated for them.", mandatory = True, ), - "package": attr.string( - doc = "The name of the package the generated mocks should be in. If not specified, uses mockgen's default.", - ), "mockgen_tool": attr.label( doc = "The mockgen tool to run", default = Label(_MOCKGEN_TOOL), allow_single_file = True, executable = True, - cfg = "host", + cfg = "exec", mandatory = False, ), + "_go_context_data": attr.label( + default = "@io_bazel_rules_go//:go_context_data", + ), }, + toolchains = ["@io_bazel_rules_go//go:toolchain"], ) def _gomock_prog_exec_impl(ctx): args = ["-exec_only", ctx.file.prog_bin.path] - if ctx.attr.package != "": - args += ["-package", ctx.attr.package] - - if ctx.attr.self_package != "": - args += ["-self_package", ctx.attr.self_package] + args, needed_files = _handle_shared_args(ctx, args) + # annoyingly, the interfaces join has to go after the importpath so we can't + # share those. args += [ctx.attr.library[GoLibrary].importpath] args += [",".join(ctx.attr.interfaces)] ctx.actions.run_shell( outputs = [ctx.outputs.out], - inputs = [ctx.file.prog_bin], + inputs = [ctx.file.prog_bin] + needed_files, tools = [ctx.file.mockgen_tool], command = """{cmd} {args} > {out}""".format( cmd = "$(pwd)/" + ctx.file.mockgen_tool.path, @@ -240,9 +279,10 @@ def _gomock_prog_exec_impl(ctx): # GOCACHE is required starting in Go 1.12 "GOCACHE": "./.gocache", }, + mnemonic = "GoMockReflectExecOnlyGen", ) -_gomock_prog_exec = go_rule( +_gomock_prog_exec = rule( _gomock_prog_exec_impl, attrs = { "library": attr.label( @@ -265,11 +305,23 @@ _gomock_prog_exec = go_rule( "self_package": attr.string( doc = "The full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. This can happen if the mock's package is set to one of its inputs (usually the main one) and the output is stdio so mockgen cannot detect the final output package. Setting this flag will then tell mockgen which import to exclude.", ), + "imports": attr.string_dict( + doc = "Dictionary of name-path pairs of explicit imports to use.", + ), + "mock_names": attr.string_dict( + doc = "Dictionary of interfaceName-mockName pairs of explicit mock names to use. Mock names default to 'Mock'+ interfaceName suffix.", + default = {}, + ), + "copyright_file": attr.label( + doc = "Optional file containing copyright to prepend to the generated contents.", + allow_single_file = True, + mandatory = False, + ), "prog_bin": attr.label( doc = "The program binary generated by mockgen's -prog_only and compiled by bazel.", allow_single_file = True, executable = True, - cfg = "host", + cfg = "exec", mandatory = True, ), "mockgen_tool": attr.label( @@ -277,8 +329,31 @@ _gomock_prog_exec = go_rule( default = Label(_MOCKGEN_TOOL), allow_single_file = True, executable = True, - cfg = "host", + cfg = "exec", mandatory = False, + ), + "_go_context_data": attr.label( + default = "@io_bazel_rules_go//:go_context_data", ), }, + toolchains = ["@io_bazel_rules_go//go:toolchain"], ) + +def _handle_shared_args(ctx, args): + needed_files = [] + + if ctx.attr.package != "": + args += ["-package", ctx.attr.package] + if ctx.attr.self_package != "": + args += ["-self_package", ctx.attr.self_package] + if len(ctx.attr.imports) > 0: + imports = ",".join(["{0}={1}".format(name, pkg) for name, pkg in ctx.attr.imports.items()]) + args += ["-imports", imports] + if ctx.file.copyright_file != None: + args += ["-copyright_file", ctx.file.copyright_file.path] + needed_files.append(ctx.file.copyright_file) + if len(ctx.attr.mock_names) > 0: + mock_names = ",".join(["{0}={1}".format(name, pkg) for name, pkg in ctx.attr.mock_names.items()]) + args += ["-mock_names", mock_names] + + return args, needed_files diff --git a/go.mod b/go.mod index 7d34b4a09c..0b701c8151 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pipe-cd/pipe -go 1.14 +go 1.15 require ( cloud.google.com/go v0.65.0 @@ -12,7 +12,7 @@ require ( github.com/docker/distribution v2.7.1+incompatible github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect - github.com/envoyproxy/protoc-gen-validate v0.1.0 + github.com/envoyproxy/protoc-gen-validate v0.4.1 github.com/fsouza/fake-gcs-server v1.21.0 github.com/goccy/go-yaml v1.8.4 github.com/golang/mock v1.4.4 @@ -21,17 +21,19 @@ require ( github.com/google/go-github/v29 v29.0.3 github.com/google/uuid v1.1.1 github.com/hashicorp/golang-lru v0.5.1 + github.com/iancoleman/strcase v0.1.2 // indirect github.com/klauspost/compress v1.10.11 // indirect + github.com/lyft/protoc-gen-star v0.5.2 // indirect github.com/minio/minio-go/v7 v7.0.5 github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect github.com/prometheus/client_golang v1.6.0 github.com/prometheus/client_model v0.2.0 github.com/prometheus/common v0.9.1 - github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/robfig/cron/v3 v3.0.1 github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.5.1 + github.com/stretchr/testify v1.6.1 go.mongodb.org/mongo-driver v1.4.0 go.uber.org/atomic v1.7.0 go.uber.org/multierr v1.2.0 // indirect diff --git a/go.sum b/go.sum index b438e90a8b..1a41c7124c 100644 --- a/go.sum +++ b/go.sum @@ -110,6 +110,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.4.1 h1:7dLaJvASGRD7X49jSCSXXHwKPm0ZN9r9kJD+p+vS7dM= +github.com/envoyproxy/protoc-gen-validate v0.4.1/go.mod h1:E+IEazqdaWv3FrnGtZIu3b9fPFMK8AzeTTrk9SfVwWs= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses= @@ -275,6 +277,9 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= +github.com/iancoleman/strcase v0.1.2 h1:gnomlvw9tnV3ITTAxzKSgTF+8kFWcU/f+TgttpXGz1U= +github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -314,6 +319,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -323,6 +329,9 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU= +github.com/lyft/protoc-gen-star v0.5.2 h1:ICQPpOr4uO46eme1Y5Jj0fnJkc9/upQ9xxt0+2AmUDQ= +github.com/lyft/protoc-gen-star v0.5.2/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= @@ -373,6 +382,7 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -395,7 +405,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -416,6 +425,10 @@ github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a h1:pa8hGb/2 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/afero v1.3.3 h1:p5gZEKLYoL7wh8VrJesMaYeNxdEd1v3cb4irOk9zB54= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.3.4 h1:8q6vk3hthlpb2SouZcnBVKboxWQWMDNF38bwholZrJc= +github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= @@ -434,6 +447,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= @@ -468,6 +483,7 @@ golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaE golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -669,6 +685,7 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -799,6 +816,8 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/hack/BUILD.bazel b/hack/BUILD.bazel index 11e01465e2..aa849d3996 100644 --- a/hack/BUILD.bazel +++ b/hack/BUILD.bazel @@ -2,8 +2,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", - srcs = ["tools.go"], + srcs = ["tool.go"], importpath = "github.com/pipe-cd/pipe/hack", visibility = ["//visibility:public"], - deps = ["@io_k8s_code_generator//:go_default_library"], + deps = ["@com_github_envoyproxy_protoc_gen_validate//module:go_default_library"], ) diff --git a/hack/gen-go-strings/BUILD.bazel b/hack/gen-go-strings/BUILD.bazel new file mode 100644 index 0000000000..89374160c2 --- /dev/null +++ b/hack/gen-go-strings/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/pipe-cd/pipe/hack/gen-go-strings", + visibility = ["//visibility:private"], +) + +go_binary( + name = "gen-go-strings", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/hack/tool.go b/hack/tool.go new file mode 100644 index 0000000000..ffa1a4ea50 --- /dev/null +++ b/hack/tool.go @@ -0,0 +1,5 @@ +package hack + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/module" +) diff --git a/repositories.bzl b/repositories.bzl index 3a43bfdd97..f532956ace 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -286,8 +286,8 @@ def go_repositories(): go_repository( name = "com_github_envoyproxy_protoc_gen_validate", importpath = "github.com/envoyproxy/protoc-gen-validate", - sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", - version = "v0.1.0", + sum = "h1:7dLaJvASGRD7X49jSCSXXHwKPm0ZN9r9kJD+p+vS7dM=", + version = "v0.4.1", ) go_repository( name = "com_github_evanphx_json_patch", @@ -794,6 +794,12 @@ def go_repositories(): sum = "h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=", version = "v1.0.0", ) + go_repository( + name = "com_github_iancoleman_strcase", + importpath = "github.com/iancoleman/strcase", + sum = "h1:gnomlvw9tnV3ITTAxzKSgTF+8kFWcU/f+TgttpXGz1U=", + version = "v0.1.2", + ) go_repository( name = "com_github_ianlancetaylor_demangle", @@ -921,6 +927,13 @@ def go_repositories(): sum = "h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=", version = "v1.0.3", ) + go_repository( + name = "com_github_kr_fs", + importpath = "github.com/kr/fs", + sum = "h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=", + version = "v0.1.0", + ) + go_repository( name = "com_github_kr_logfmt", importpath = "github.com/kr/logfmt", @@ -958,6 +971,13 @@ def go_repositories(): sum = "h1:9MlwzLdW7QSDrhDjFlsEYmxpFyIoXmYRon3dt0io31k=", version = "v0.0.0-20181002194514-a7b3b318ed4e", ) + go_repository( + name = "com_github_lyft_protoc_gen_star", + importpath = "github.com/lyft/protoc-gen-star", + sum = "h1:ICQPpOr4uO46eme1Y5Jj0fnJkc9/upQ9xxt0+2AmUDQ=", + version = "v0.5.2", + ) + go_repository( name = "com_github_magiconair_properties", importpath = "github.com/magiconair/properties", @@ -1170,6 +1190,13 @@ def go_repositories(): sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", version = "v0.9.1", ) + go_repository( + name = "com_github_pkg_sftp", + importpath = "github.com/pkg/sftp", + sum = "h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=", + version = "v1.10.1", + ) + go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", @@ -1237,8 +1264,8 @@ def go_repositories(): go_repository( name = "com_github_robfig_cron_v3", importpath = "github.com/robfig/cron/v3", - sum = "h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E=", - version = "v3.0.0", + sum = "h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=", + version = "v3.0.1", ) go_repository( @@ -1364,8 +1391,8 @@ def go_repositories(): go_repository( name = "com_github_spf13_afero", importpath = "github.com/spf13/afero", - sum = "h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=", - version = "v1.2.2", + sum = "h1:8q6vk3hthlpb2SouZcnBVKboxWQWMDNF38bwholZrJc=", + version = "v1.3.4", ) go_repository( @@ -1415,8 +1442,8 @@ def go_repositories(): go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", - sum = "h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=", - version = "v1.5.1", + sum = "h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=", + version = "v1.6.1", ) go_repository( @@ -1639,6 +1666,12 @@ def go_repositories(): sum = "h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=", version = "v2.2.8", ) + go_repository( + name = "in_gopkg_yaml_v3", + importpath = "gopkg.in/yaml.v3", + sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=", + version = "v3.0.0-20200313102051-9f266ea9e77c", + ) go_repository( name = "io_etcd_go_bbolt",