From e66295ba6f35c1f63c61c0966e48c665f0a10955 Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Fri, 11 Aug 2023 12:07:46 -0700 Subject: [PATCH] add initial bazel config --- .gitignore | 5 ++++ BUILD.bazel | 18 ++++++++++++++ WORKSPACE | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ deps.bzl | 31 ++++++++++++++++++++++++ go.mod | 6 +++++ 5 files changed, 128 insertions(+) create mode 100644 BUILD.bazel create mode 100644 WORKSPACE create mode 100644 deps.bzl diff --git a/.gitignore b/.gitignore index 17ce4ed9ea..7d88ea51c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ +bazel-out +bazel-bin +bazel-controller-cdktf +bazel-testlogs + !gen/*/jsii/*.tgz diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000000..230530efdc --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,18 @@ +# load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +# gazelle:prefix github.com/sourcegraph/controller-cdktf +# gazelle:build_file_name BUILD.bazel +load("@bazel_gazelle//:def.bzl", "gazelle") + +gazelle(name = "gazelle") + +gazelle( + name = "gazelle-update-repos", + args = [ + "-from_file=go.mod", + "-to_macro=deps.bzl%go_dependencies", + "-prune", + "-build_file_proto_mode=disable_global", + ], + command = "update-repos", +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000000..e7d2546111 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,68 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "bazel_skylib", + sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + ], +) + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +http_archive( + name = "aspect_bazel_lib", + sha256 = "2518c757715d4f5fc7cc7e0a68742dd1155eaafc78fb9196b8a18e13a738cea2", + strip_prefix = "bazel-lib-1.28.0", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.28.0/bazel-lib-v1.28.0.tar.gz", +) + +http_archive( + name = "io_bazel_rules_go", + sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip", + ], +) + +http_archive( + name = "bazel_gazelle", + sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz", + ], +) + +http_archive( + name = "com_google_protobuf", + sha256 = "6aff9834fd7c540875e1836967c8d14c6897e3785a2efac629f69860fb7834ff", + strip_prefix = "protobuf-3.15.0", + urls = [ + "https://github.com/protocolbuffers/protobuf/archive/v3.15.0.tar.gz", + ], +) + +# Go toolchain setup +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("//:deps.bzl", "go_dependencies") + +# gazelle:repository_macro deps.bzl%go_dependencies +go_dependencies() + +go_rules_dependencies() + +go_register_toolchains( + version = "1.20.3", +) + +gazelle_dependencies() + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() diff --git a/deps.bzl b/deps.bzl new file mode 100644 index 0000000000..a99e597dd7 --- /dev/null +++ b/deps.bzl @@ -0,0 +1,31 @@ +load("@bazel_gazelle//:deps.bzl", "go_repository") + +"Bazel go dependencies" + +def go_dependencies(): + """The go dependencies in this macro are auto-updated by gazelle + To update run, + bazel run //:gazelle-update-repos + """ + pass + go_repository( + name = "com_github_aws_constructs_go_constructs_v10", + build_file_proto_mode = "disable_global", + importpath = "github.com/aws/constructs-go/constructs/v10", + sum = "h1:XW89VuKlwwzgU77Nyzj30SPn2SFtDYkzfF+QN84b5bQ=", + version = "v10.2.69", + ) + go_repository( + name = "com_github_aws_jsii_runtime_go", + build_file_proto_mode = "disable_global", + importpath = "github.com/aws/jsii-runtime-go", + sum = "h1:C8BMeDgDz4IcDvgKFPMDt2OUGsTiANVu/YZGtwUoJqE=", + version = "v1.87.0", + ) + go_repository( + name = "com_github_hashicorp_terraform_cdk_go_cdktf", + build_file_proto_mode = "disable_global", + importpath = "github.com/hashicorp/terraform-cdk-go/cdktf", + sum = "h1:rpgeX9zQ9jhHoBc/qKEoVOAP/iVhwPN463UyhZKTwy0=", + version = "v0.16.3", + ) diff --git a/go.mod b/go.mod index 91579dce12..bf6ba6a12b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,9 @@ module github.com/sourcegraph/controller-cdktf go 1.20 + +require ( + github.com/aws/jsii-runtime-go v1.87.0 + github.com/hashicorp/terraform-cdk-go/cdktf v0.16.3 + github.com/aws/constructs-go/constructs/v10 v10.2.69 +)