sqlboiler: remove
We do not use any SQL anymore in this repository, so we do not need sqlboiler.
Test Plan: Refactor, covered by CI.
X-Origin-Diff: phab/D677
GitOrigin-RevId: 1ed24f3d57774be14e6611582f691e73b1106ea9
diff --git a/build/fietsje/BUILD.bazel b/build/fietsje/BUILD.bazel
index 70b6639..cf75cca 100644
--- a/build/fietsje/BUILD.bazel
+++ b/build/fietsje/BUILD.bazel
@@ -9,7 +9,6 @@
"deps_delve.go",
"deps_gvisor.go",
"deps_kubernetes.go",
- "deps_sqlboiler.go",
"main.go",
"planner.go",
"render.go",
diff --git a/build/fietsje/deps_cilium.go b/build/fietsje/deps_cilium.go
index d4d9e19..0a1252b 100644
--- a/build/fietsje/deps_cilium.go
+++ b/build/fietsje/deps_cilium.go
@@ -52,6 +52,7 @@
"github.com/kr/text",
"github.com/hashicorp/go-cleanhttp",
"github.com/hashicorp/serf",
+ "github.com/joho/godotenv",
"github.com/envoyproxy/protoc-gen-validate",
"github.com/hashicorp/go-rootcerts",
"github.com/armon/go-metrics",
diff --git a/build/fietsje/deps_kubernetes.go b/build/fietsje/deps_kubernetes.go
index be7355d..3626f68 100644
--- a/build/fietsje/deps_kubernetes.go
+++ b/build/fietsje/deps_kubernetes.go
@@ -111,12 +111,14 @@
"github.com/grpc-ecosystem/go-grpc-middleware",
"github.com/grpc-ecosystem/go-grpc-prometheus",
"github.com/grpc-ecosystem/grpc-gateway",
+ "github.com/hashicorp/hcl",
"github.com/hpcloud/tail",
"github.com/jonboulle/clockwork",
"github.com/karrick/godirwalk",
"github.com/liggitt/tabwriter",
"github.com/lithammer/dedent",
"github.com/mailru/easyjson",
+ "github.com/magiconair/properties",
"github.com/mattn/go-colorable",
"github.com/mattn/go-isatty",
"github.com/mattn/go-runewidth",
@@ -139,7 +141,11 @@
"github.com/russross/blackfriday",
"github.com/soheilhy/cmux",
"github.com/spf13/afero",
+ "github.com/spf13/cast",
+ "github.com/spf13/jwalterweatherman",
+ "github.com/spf13/cobra",
"github.com/spf13/pflag",
+ "github.com/spf13/viper",
"github.com/stretchr/testify",
"github.com/tmc/grpc-websocket-proxy",
"github.com/vishvananda/netlink",
diff --git a/build/fietsje/deps_sqlboiler.go b/build/fietsje/deps_sqlboiler.go
deleted file mode 100644
index dd0cb22..0000000
--- a/build/fietsje/deps_sqlboiler.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2020 The Monogon Project Authors.
-//
-// SPDX-License-Identifier: Apache-2.0
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package main
-
-func depsSQLBoiler(p *planner) {
- p.collect(
- "github.com/volatiletech/sqlboiler/v4", "v4.1.1",
- ).use(
- "github.com/denisenkom/go-mssqldb",
- "github.com/ericlagergren/decimal",
- "github.com/friendsofgo/errors",
- "github.com/go-sql-driver/mysql",
- "github.com/golang-sql/civil",
- "github.com/hashicorp/hcl",
- "github.com/lib/pq",
- "github.com/magiconair/properties",
- "github.com/spf13/cast",
- "github.com/spf13/cobra",
- "github.com/spf13/jwalterweatherman",
- "github.com/spf13/viper",
- "github.com/subosito/gotenv",
- "github.com/volatiletech/inflect",
- "github.com/volatiletech/null/v8",
- "github.com/volatiletech/randomize",
- "github.com/volatiletech/strmangle",
- "gopkg.in/ini.v1",
- )
- // required by //build/sqlboiler autogeneration
- p.collect(
- "github.com/glerchundi/sqlboiler-crdb/v4", "d540ee52783ebbbfe010acc5d91a9043d88de3fd",
- ).use(
- "github.com/gofrs/uuid",
- )
- p.collect(
- "github.com/rubenv/sql-migrate", "ae26b214fa431c314a5a9b986d5c90fb1719c68d",
- ).use(
- "github.com/armon/go-radix",
- "github.com/mattn/go-sqlite3",
- "github.com/mitchellh/cli",
- "github.com/posener/complete",
- "github.com/joho/godotenv",
- "gopkg.in/gorp.v1",
- )
-}
diff --git a/build/fietsje/main.go b/build/fietsje/main.go
index 5da9b49..f9671a3 100644
--- a/build/fietsje/main.go
+++ b/build/fietsje/main.go
@@ -66,7 +66,6 @@
depsContainerd(p)
depsGVisor(p)
depsCilium(p)
- depsSQLBoiler(p)
// our own deps, common
p.collectOverride("go.uber.org/zap", "v1.15.0")
diff --git a/build/sqlboiler/BUILD b/build/sqlboiler/BUILD
deleted file mode 100644
index e9ec548..0000000
--- a/build/sqlboiler/BUILD
+++ /dev/null
@@ -1,4 +0,0 @@
-exports_files([
- "dbconfig.yml",
- "sqlboiler.toml",
-])
diff --git a/build/sqlboiler/README.md b/build/sqlboiler/README.md
deleted file mode 100644
index bb61463..0000000
--- a/build/sqlboiler/README.md
+++ /dev/null
@@ -1,59 +0,0 @@
-##SQLboiler
-
-This rule allows to generate sqlboiler models and ORM code for golang from a stack of SQL migrations.
-
-It uses `sql-migrate`, `sqlboiler` and `sqlboiker-crdb`.
-
-###How to use
-
-Create a package and create a `0_initial.sql` file with the following template:
-
-```
--- +migrate Up
-
-Your initial SQL goes here
-
--- +migrate Down
-
-```
-
-Then create a `BUILD` file with the following rules:
-
-```
-load("//build/sqlboiler:sqlboiler.bzl", "go_sqlboiler_library", "sqlboiler")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-# gazelle:ignore .
-
-sqlboiler(
- name = "sqlboiler",
- srcs = glob(["*.sql"]),
- tables = [
- <your table names>
- ],
-)
-
-go_sqlboiler_library(
- name = "sqlboiler_lib",
- importpath = "git.monogon.dev/source/nexantic.git/<target>",
- sqlboiler = ":sqlboiler",
-)
-
-go_library(
- name = "go_default_library",
- embed = [":sqlboiler_lib"],
- importpath = "git.monogon.dev/source/nexantic.git/<target>",
- visibility = ["//visibility:public"],
-)
-
-```
-
-Replace `target` with your intended importpath and add all created tables to the `tables` argument of the sqlboiler rule.
-
-Running the tasks will apply the migrations to a temporary database using `sql-migrate` and generate sqlboiler code from it.
-The code will be importable from the specified `importpath`.
-
-When making changes to the schema please generate new migrations using the `<n>_<description>.sql` pattern for file names.
-The migrations will automatically be applied and the models updated.
-
-Make sure to also update the `tables` argument when creating new tables in migrations.
diff --git a/build/sqlboiler/dbconfig.yml b/build/sqlboiler/dbconfig.yml
deleted file mode 100644
index 8a2d3b4..0000000
--- a/build/sqlboiler/dbconfig.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-development:
- dialect: postgres
- datasource: dbname=_dbname_ sslmode=disable port=26257 user=root
- dir: migrations
- table: migrations
diff --git a/build/sqlboiler/sqlboiler.bzl b/build/sqlboiler/sqlboiler.bzl
deleted file mode 100644
index bfb4bf9..0000000
--- a/build/sqlboiler/sqlboiler.bzl
+++ /dev/null
@@ -1,163 +0,0 @@
-# Copyright 2020 The Monogon Project Authors.
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@bazel_gazelle//:deps.bzl", "go_repository")
-load(
- "@io_bazel_rules_go//go/private:rules/rule.bzl",
- "go_rule",
-)
-load(
- "@io_bazel_rules_go//go:def.bzl",
- "GoLibrary",
- "go_context",
-)
-
-# Default files generated by the sqlboiler + cockroach module
-SQLBOILER_FILES = [
- "boil_main_test.go",
- "boil_queries.go",
- "boil_queries_test.go",
- "boil_suites_test.go",
- "boil_table_names.go",
- "boil_types.go",
- "crdb_main_test.go",
- "crdb_suites_test.go",
- "crdb_upsert.go",
-]
-
-def _sqlboiler_impl(ctx):
- """Generate sqlboiler models from sql-migrate migrations"""
-
- filesn = []
- filesn += SQLBOILER_FILES
-
- for table in ctx.attr.tables:
- filesn += [
- "{}.go".format(table),
- "{}_test.go".format(table),
- ]
-
- outs = []
- for file in filesn:
- outs += [ctx.actions.declare_file(file)]
-
- # run_shell does not so set -euo pipefail
- command = "set -euo pipefail\n"
-
- # Create random db name
- command += "TMP_DB=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 12 | head -n 1 ; echo)\n"
- command += "echo DB name: $TMP_DB\n"
-
- # Create DB and template configs
- command += "/usr/bin/psql --host localhost --port 26257 --user root -c \"CREATE DATABASE $TMP_DB;\"\n"
-
- command += "ln -s \"{}\" . \n".format(ctx.file.migrate_config.path)
- command += "sed -i \"s/_dbname_/$TMP_DB/g\" \"{}\" \n".format(ctx.file.migrate_config.basename)
-
- command += "ln -s {} . \n".format(ctx.file.boiler_config.path)
- command += "sed -i \"s/_dbname_/$TMP_DB/g\" \"{}\" \n".format(ctx.file.boiler_config.basename)
-
- # Copy in all sql files
- command += "mkdir migrations\n"
- for f in ctx.files.srcs:
- command += "cp \"{}\" migrations/\n".format(f.path)
-
- # Copy in adapter
- command += "cp \"{}\" sqlboiler-crdb\n".format(ctx.file.adapter.path)
-
- # Apply sql-migrate
- command += "{} up --config \"{}\" \n".format(ctx.file.migrate.path, ctx.file.migrate_config.basename)
-
- # Run sqlboiler
- command += "{} --output \"{}\" --config \"{}\" --wipe crdb \n".format(
- ctx.file.boiler.path,
- outs[0].dirname,
- ctx.file.boiler_config.basename,
- )
-
- ctx.actions.run_shell(
- inputs = ctx.files.srcs + [
- ctx.file.migrate_config,
- ctx.file.boiler,
- ctx.file.adapter,
- ctx.file.migrate,
- ctx.file.boiler_config,
- ],
- outputs = outs,
- command = command,
- )
-
- return [DefaultInfo(files = depset(outs))]
-
-sqlboiler = rule(
- implementation = _sqlboiler_impl,
- attrs = {
- "srcs": attr.label_list(mandatory = True, allow_files = [".sql"]),
- "tables": attr.string_list(default = []),
- "migrate_config": attr.label(allow_single_file = True, default = Label("//build/sqlboiler:dbconfig.yml")),
- "boiler_config": attr.label(allow_single_file = True, default = Label("//build/sqlboiler:sqlboiler.toml")),
- "boiler": attr.label(allow_single_file = True, default = Label("@com_github_volatiletech_sqlboiler_v4//:v4")),
- "adapter": attr.label(allow_single_file = True, default = Label("@com_github_glerchundi_sqlboiler_crdb_v4//:v4")),
- "migrate": attr.label(allow_single_file = True, default = Label("@com_github_rubenv_sql_migrate//sql-migrate:sql-migrate")),
- },
-)
-
-def _sqlboiler_go_impl(ctx):
- go = go_context(ctx)
-
- source_files = []
-
- # Don't include test files as they cannot be processed by go_library
- for file in ctx.attr.sqlboiler.files.to_list():
- if not "test" in file.path:
- source_files += [file]
-
- library = go.new_library(
- go,
- srcs = source_files,
- )
- source = go.library_to_source(go, ctx.attr, library, False)
- providers = [library, source]
- output_groups = {
- "go_generated_srcs": source_files,
- }
-
- return providers + [OutputGroupInfo(**output_groups)]
-
-go_sqlboiler_library = go_rule(
- _sqlboiler_go_impl,
- attrs = {
- "sqlboiler": attr.label(providers = [DefaultInfo]),
- "importpath": attr.string(),
- "deps": attr.label_list(
- providers = [GoLibrary],
- default = [
- Label("@com_github_friendsofgo_errors//:go_default_library"),
- Label("@com_github_lib_pq//:go_default_library"),
- Label("@com_github_pkg_errors//:go_default_library"),
- Label("@com_github_spf13_viper//:go_default_library"),
- Label("@com_github_volatiletech_strmangle//:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//boil:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//drivers:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//queries:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//queries/qm:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//types:go_default_library"),
- Label("@com_github_volatiletech_sqlboiler_v4//queries/qmhelper:go_default_library"),
- Label("@com_github_volatiletech_null_v8//:go_default_library"),
- ],
- ),
- },
-)
diff --git a/build/sqlboiler/sqlboiler.toml b/build/sqlboiler/sqlboiler.toml
deleted file mode 100644
index 551ce5e..0000000
--- a/build/sqlboiler/sqlboiler.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[crdb]
- dbname = "_dbname_"
- host = "localhost"
- port = 26257
- user = "root"
- pass = ""
- sslmode = "disable"
- schema = "public"
- blacklist = ["migrations"]