go: re-do the entire thing
This is a mega-change, but attempting to split this up further is
probably not worth the effort.
Summary:
1. Bump up bazel, rules_go, and others.
2. Switch to new go target naming (bye bye go_default_library)
3. Move go deps to go.mod/go.sum, use make gazelle generate from that
4. Bump up Python deps a bit
And also whatever was required to actually get things to work - loads of
small useless changes.
Tested to work on NixOS and Ubuntu 20.04:
$ bazel build //...
$ bazel test //...
Change-Id: I8364bdaa1406b9ae4d0385a6b607f3e7989f98a9
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1583
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/hswaw/capacifier/BUILD.bazel b/hswaw/capacifier/BUILD.bazel
index 752064d..45d56f9 100644
--- a/hswaw/capacifier/BUILD.bazel
+++ b/hswaw/capacifier/BUILD.bazel
@@ -2,20 +2,20 @@
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_layer", "container_push")
go_library(
- name = "go_default_library",
+ name = "capacifier_lib",
srcs = ["capacifier.go"],
importpath = "code.hackerspace.pl/hscloud/hswaw/capacifier",
visibility = ["//visibility:private"],
deps = [
- "//go/mirko:go_default_library",
- "@com_github_golang_glog//:go_default_library",
- "@in_gopkg_ldap_v3//:go_default_library",
+ "//go/mirko",
+ "@com_github_go_ldap_ldap_v3//:ldap",
+ "@com_github_golang_glog//:glog",
],
)
go_binary(
name = "capacifier",
- embed = [":go_default_library"],
+ embed = [":capacifier_lib"],
visibility = ["//visibility:public"],
)
diff --git a/hswaw/capacifier/capacifier.go b/hswaw/capacifier/capacifier.go
index 34c62a1..0fcefd8 100644
--- a/hswaw/capacifier/capacifier.go
+++ b/hswaw/capacifier/capacifier.go
@@ -9,8 +9,8 @@
"strings"
"sync"
+ ldap "github.com/go-ldap/ldap/v3"
"github.com/golang/glog"
- ldap "gopkg.in/ldap.v3"
"code.hackerspace.pl/hscloud/go/mirko"
)
diff --git a/hswaw/cebulacamp/landing/BUILD.bazel b/hswaw/cebulacamp/landing/BUILD.bazel
index e2f09e0..607790f 100644
--- a/hswaw/cebulacamp/landing/BUILD.bazel
+++ b/hswaw/cebulacamp/landing/BUILD.bazel
@@ -4,7 +4,12 @@
go_embed_data(
name = "static",
- srcs = ["index.html", "style/main.css", "cebula2020.jpeg", "hotel-orle.jpg"],
+ srcs = [
+ "cebula2020.jpeg",
+ "hotel-orle.jpg",
+ "index.html",
+ "style/main.css",
+ ],
package = "static",
)
@@ -17,17 +22,17 @@
)
container_image(
- name="latest",
- base="@prodimage-bionic//image",
- files = ["//hswaw/cebulacamp/landing/backend:backend"],
+ name = "latest",
+ base = "@prodimage-bionic//image",
directory = "/hscloud/hswaw/cebulacamp/landing",
entrypoint = ["/hscloud/hswaw/cebulacamp/landing/backend"],
+ files = ["//hswaw/cebulacamp/landing/backend"],
)
container_push(
name = "push",
- image = ":latest",
format = "Docker",
+ image = ":latest",
registry = "registry.k0.hswaw.net",
repository = "q3k/cebulacamp-landing",
tag = "{BUILD_TIMESTAMP}-{STABLE_GIT_COMMIT}",
diff --git a/hswaw/cebulacamp/landing/backend/BUILD.bazel b/hswaw/cebulacamp/landing/backend/BUILD.bazel
index 8840951..c69721e 100644
--- a/hswaw/cebulacamp/landing/backend/BUILD.bazel
+++ b/hswaw/cebulacamp/landing/backend/BUILD.bazel
@@ -1,24 +1,18 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "backend_lib",
srcs = ["main.go"],
importpath = "code.hackerspace.pl/hscloud/hswaw/cebulacamp/landing/backend",
visibility = ["//visibility:private"],
deps = [
- "@com_github_golang_glog//:go_default_library",
- "//hswaw/cebulacamp/landing:static_go", # keep
+ "//hswaw/cebulacamp/landing:static_go", # keep
+ "@com_github_golang_glog//:glog",
],
)
go_binary(
name = "backend",
- embed = [":go_default_library"],
+ embed = [":backend_lib"],
visibility = ["//visibility:public"],
)
-
-go_test(
- name = "go_default_test",
- srcs = ["main_test.go"],
- embed = [":go_default_library"],
-)
diff --git a/hswaw/laserproxy/BUILD.bazel b/hswaw/laserproxy/BUILD.bazel
index ca8bfb1..0d3c711 100644
--- a/hswaw/laserproxy/BUILD.bazel
+++ b/hswaw/laserproxy/BUILD.bazel
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "laserproxy_lib",
srcs = [
"locker.go",
"main.go",
@@ -10,14 +10,14 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/laserproxy",
visibility = ["//visibility:private"],
deps = [
- "//go/mirko:go_default_library",
- "//hswaw/laserproxy/tpl:go_default_library",
- "@com_github_golang_glog//:go_default_library",
+ "//go/mirko",
+ "//hswaw/laserproxy/tpl",
+ "@com_github_golang_glog//:glog",
],
)
go_binary(
name = "laserproxy",
- embed = [":go_default_library"],
+ embed = [":laserproxy_lib"],
visibility = ["//visibility:public"],
)
diff --git a/hswaw/laserproxy/tpl/BUILD.bazel b/hswaw/laserproxy/tpl/BUILD.bazel
index 10e3740..efddf19 100644
--- a/hswaw/laserproxy/tpl/BUILD.bazel
+++ b/hswaw/laserproxy/tpl/BUILD.bazel
@@ -9,7 +9,7 @@
)
go_library(
- name = "go_default_library",
+ name = "tpl",
srcs = [
":tpl_bindata", # keep
],
diff --git a/hswaw/leasifier/BUILD.bazel b/hswaw/leasifier/BUILD.bazel
index 1873ad8..0aec03c 100644
--- a/hswaw/leasifier/BUILD.bazel
+++ b/hswaw/leasifier/BUILD.bazel
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "leasifier_lib",
srcs = [
"main.go",
"statusz.go",
@@ -9,15 +9,15 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/leasifier",
visibility = ["//visibility:private"],
deps = [
- "//go/mirko:go_default_library",
- "//go/statusz:go_default_library",
- "//hswaw/proto:go_default_library",
- "@com_github_golang_glog//:go_default_library",
+ "//go/mirko",
+ "//go/statusz",
+ "//hswaw/proto",
+ "@com_github_golang_glog//:glog",
],
)
go_binary(
name = "leasifier",
- embed = [":go_default_library"],
+ embed = [":leasifier_lib"],
visibility = ["//visibility:public"],
)
diff --git a/hswaw/lib/flask_spaceauth/BUILD b/hswaw/lib/flask_spaceauth/BUILD
index 4c29872..719c302 100644
--- a/hswaw/lib/flask_spaceauth/BUILD
+++ b/hswaw/lib/flask_spaceauth/BUILD
@@ -8,5 +8,5 @@
requirement("flask"),
requirement("werkzeug"),
requirement("itsdangerous"),
- ]
+ ],
)
diff --git a/hswaw/lib/flask_spaceauth/spaceauth/BUILD b/hswaw/lib/flask_spaceauth/spaceauth/BUILD
index ee3d670..1745342 100644
--- a/hswaw/lib/flask_spaceauth/spaceauth/BUILD
+++ b/hswaw/lib/flask_spaceauth/spaceauth/BUILD
@@ -10,6 +10,6 @@
deps = [
requirement("blinker"),
requirement("flask_login"),
- requirement("flask_oauthlib"),
+ requirement("oauthlib"),
],
)
diff --git a/hswaw/lib/flask_spaceauth/spaceauth/__init__.py b/hswaw/lib/flask_spaceauth/spaceauth/__init__.py
index 6452307..89f1487 100644
--- a/hswaw/lib/flask_spaceauth/spaceauth/__init__.py
+++ b/hswaw/lib/flask_spaceauth/spaceauth/__init__.py
@@ -1,5 +1,5 @@
from flask import Blueprint, request, url_for, session, redirect, abort, flash
-from flask_oauthlib.client import OAuth, OAuthException
+from authlib.integrations.flask_client import OAuth, OAuthError
from flask_login import LoginManager, login_user, logout_user, current_user, login_required, UserMixin
from .caps import cap_required
@@ -36,7 +36,7 @@
super(SpaceAuth, self).init_app(app)
app.register_blueprint(self.blueprint, url_prefix=url_prefix)
- @app.errorhandler(OAuthException)
+ @app.errorhandler(OAuthError)
def errorhandler(err):
flash('OAuth error occured', 'error')
return redirect('/')
@@ -57,7 +57,7 @@
def callback_view_handler(self):
resp = self.remote.authorized_response()
if resp is None:
- raise OAuthException(
+ raise OAuthError(
'Access denied', type=request.args.get('error'))
# TODO encrypt token...?
diff --git a/hswaw/oodviewer/BUILD.bazel b/hswaw/oodviewer/BUILD.bazel
index 607780d..769051c 100644
--- a/hswaw/oodviewer/BUILD.bazel
+++ b/hswaw/oodviewer/BUILD.bazel
@@ -2,7 +2,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "oodviewer_lib",
srcs = [
"app.go",
"main.go",
@@ -11,24 +11,24 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/oodviewer",
visibility = ["//visibility:private"],
deps = [
- "//hswaw/oodviewer/templates:go_default_library",
- "@com_github_golang_glog//:go_default_library",
- "@com_github_lib_pq//:go_default_library",
+ "//hswaw/oodviewer/templates",
+ "@com_github_golang_glog//:glog",
+ "@com_github_lib_pq//:pq",
],
)
go_binary(
name = "oodviewer",
- embed = [":go_default_library"],
+ embed = [":oodviewer_lib"],
visibility = ["//visibility:public"],
)
container_layer(
name = "layer_bin",
+ directory = "/hswaw/",
files = [
":oodviewer",
],
- directory = "/hswaw/",
)
container_image(
@@ -41,8 +41,8 @@
container_push(
name = "push",
- image = ":runtime",
format = "Docker",
+ image = ":runtime",
registry = "registry.k0.hswaw.net",
repository = "q3k/oodviewer",
tag = "{BUILD_TIMESTAMP}-{STABLE_GIT_COMMIT}",
diff --git a/hswaw/oodviewer/templates/BUILD.bazel b/hswaw/oodviewer/templates/BUILD.bazel
index be98820..f902c0e 100644
--- a/hswaw/oodviewer/templates/BUILD.bazel
+++ b/hswaw/oodviewer/templates/BUILD.bazel
@@ -4,17 +4,17 @@
go_embed_data(
name = "templates_data",
srcs = glob(["*.html"]),
- package = "templates",
flatten = True,
+ package = "templates",
)
go_library(
- name = "go_default_library",
+ name = "templates",
srcs = [
":templates_data", # keep
],
+ importpath = "code.hackerspace.pl/hscloud/hswaw/oodviewer/templates", # keep
visibility = [
"//hswaw/oodviewer:__pkg__",
],
- importpath = "code.hackerspace.pl/hscloud/hswaw/oodviewer/templates",
)
diff --git a/hswaw/proto/BUILD.bazel b/hswaw/proto/BUILD.bazel
index 5e98007..81df6e8 100644
--- a/hswaw/proto/BUILD.bazel
+++ b/hswaw/proto/BUILD.bazel
@@ -1,3 +1,4 @@
+load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
@@ -16,7 +17,7 @@
)
go_library(
- name = "go_default_library",
+ name = "proto",
embed = [":proto_go_proto"],
importpath = "code.hackerspace.pl/hscloud/hswaw/proto",
visibility = ["//visibility:public"],
diff --git a/hswaw/site/BUILD.bazel b/hswaw/site/BUILD.bazel
index 5bc499f..d9b7cdd 100644
--- a/hswaw/site/BUILD.bazel
+++ b/hswaw/site/BUILD.bazel
@@ -2,7 +2,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "site_lib",
srcs = [
"at.go",
"events.go",
@@ -14,32 +14,32 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/site",
visibility = ["//visibility:private"],
deps = [
- "//go/mirko:go_default_library",
- "//hswaw/site/calendar:go_default_library",
+ "//go/mirko",
+ "//hswaw/site/calendar",
"//hswaw/site/static:static_go",
"//hswaw/site/templates:templates_go",
- "@com_github_golang_glog//:go_default_library",
+ "@com_github_golang_glog//:glog",
],
)
go_binary(
name = "site",
- embed = [":go_default_library"],
+ embed = [":site_lib"],
visibility = ["//visibility:public"],
)
container_image(
name = "latest",
base = "@prodimage-focal//image",
- files = [":site"],
directory = "/hswaw/site/",
entrypoint = ["/hswaw/site/site"],
+ files = [":site"],
)
container_push(
name = "push",
- image = ":latest",
format = "Docker",
+ image = ":latest",
registry = "registry.k0.hswaw.net",
repository = "ar/hswaw-site",
tag = "1690197486-{STABLE_GIT_COMMIT}",
diff --git a/hswaw/site/calendar/BUILD.bazel b/hswaw/site/calendar/BUILD.bazel
index fcdac53..aae6731 100644
--- a/hswaw/site/calendar/BUILD.bazel
+++ b/hswaw/site/calendar/BUILD.bazel
@@ -1,7 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
- name = "go_default_library",
+ name = "calendar",
srcs = [
"event.go",
"load.go",
@@ -10,13 +10,13 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/site/calendar",
visibility = ["//hswaw/site:__subpackages__"],
deps = [
- "@com_github_arran4_golang_ical//:go_default_library",
- "@com_github_golang_glog//:go_default_library",
+ "@com_github_arran4_golang_ical//:golang-ical",
+ "@com_github_golang_glog//:glog",
],
)
go_test(
- name = "go_default_test",
+ name = "calendar_test",
srcs = [
"event_test.go",
"load_test.go",
@@ -24,6 +24,6 @@
data = [
":test.ical",
],
- embed = [":go_default_library"],
- deps = ["@com_github_google_go_cmp//cmp:go_default_library"],
+ embed = [":calendar"],
+ deps = ["@com_github_google_go_cmp//cmp"],
)
diff --git a/hswaw/site/static/BUILD.bazel b/hswaw/site/static/BUILD.bazel
index 810d1a9..4da9c9e 100644
--- a/hswaw/site/static/BUILD.bazel
+++ b/hswaw/site/static/BUILD.bazel
@@ -4,21 +4,17 @@
go_embed_data(
name = "static",
srcs = [
- "fonts.css",
- "landing.css",
-
"animations.js",
- "led.js",
-
+ "fonts.css",
"frezarka.jpg",
"kuka.jpg",
+ "landing.css",
+ "led.js",
"neon-syrenka.svg",
"serwerownia.jpg",
"space.jpg",
+ "statut_warszawski_hackerspace-v1.3.pdf",
"tokarka.jpg",
-
- "statut_warszawski_hackerspace-v1.3.pdf",
-
"@com_gstatic_fonts_comfortaa_400//file:font.ttf",
"@com_gstatic_fonts_inconsolata_400//file:font.ttf",
"@com_gstatic_fonts_inconsolata_700//file:font.ttf",
diff --git a/hswaw/smsgw/BUILD.bazel b/hswaw/smsgw/BUILD.bazel
index 0e91141..000f20c 100644
--- a/hswaw/smsgw/BUILD.bazel
+++ b/hswaw/smsgw/BUILD.bazel
@@ -2,7 +2,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
go_library(
- name = "go_default_library",
+ name = "smsgw_lib",
srcs = [
"dispatcher.go",
"main.go",
@@ -11,32 +11,32 @@
importpath = "code.hackerspace.pl/hscloud/hswaw/smsgw",
visibility = ["//visibility:private"],
deps = [
- "//go/mirko:go_default_library",
- "//hswaw/smsgw/proto:go_default_library",
- "@com_github_golang_glog//:go_default_library",
- "@org_golang_google_grpc//codes:go_default_library",
- "@org_golang_google_grpc//status:go_default_library",
+ "//go/mirko",
+ "//hswaw/smsgw/proto",
+ "@com_github_golang_glog//:glog",
+ "@org_golang_google_grpc//codes",
+ "@org_golang_google_grpc//status",
],
)
go_binary(
name = "smsgw",
- embed = [":go_default_library"],
+ embed = [":smsgw_lib"],
visibility = ["//visibility:public"],
)
go_test(
- name = "go_default_test",
+ name = "smsgw_test",
srcs = ["dispatcher_test.go"],
- embed = [":go_default_library"],
+ embed = [":smsgw_lib"],
)
container_layer(
name = "layer_bin",
+ directory = "/smsgw/",
files = [
":smsgw",
],
- directory = "/smsgw/",
)
container_image(
@@ -49,8 +49,8 @@
container_push(
name = "push",
- image = ":runtime",
format = "Docker",
+ image = ":runtime",
registry = "registry.k0.hswaw.net",
repository = "q3k/smsgs",
tag = "{BUILD_TIMESTAMP}-{STABLE_GIT_COMMIT}",
diff --git a/hswaw/smsgw/proto/BUILD.bazel b/hswaw/smsgw/proto/BUILD.bazel
index be3451f..0aca681 100644
--- a/hswaw/smsgw/proto/BUILD.bazel
+++ b/hswaw/smsgw/proto/BUILD.bazel
@@ -1,3 +1,4 @@
+load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
@@ -16,7 +17,7 @@
)
go_library(
- name = "go_default_library",
+ name = "proto",
embed = [":proto_go_proto"],
importpath = "code.hackerspace.pl/hscloud/hswaw/smsgw/proto",
visibility = ["//visibility:public"],
diff --git a/hswaw/voucherchecker/BUILD.bazel b/hswaw/voucherchecker/BUILD.bazel
index 17bd5da..f9e8406 100644
--- a/hswaw/voucherchecker/BUILD.bazel
+++ b/hswaw/voucherchecker/BUILD.bazel
@@ -2,25 +2,25 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
- name = "go_default_library",
+ name = "voucherchecker_lib",
srcs = ["main.go"],
importpath = "code.hackerspace.pl/hscloud/hswaw/voucherchecker",
visibility = ["//visibility:private"],
- deps = ["@com_github_golang_glog//:go_default_library"],
+ deps = ["@com_github_golang_glog//:glog"],
)
go_binary(
name = "voucherchecker",
- embed = [":go_default_library"],
+ embed = [":voucherchecker_lib"],
visibility = ["//visibility:public"],
)
container_layer(
name = "layer_bin",
+ directory = "/voucherchecker/",
files = [
":voucherchecker",
],
- directory = "/voucherchecker/",
)
container_image(
@@ -33,8 +33,8 @@
container_push(
name = "push",
- image = ":runtime",
format = "Docker",
+ image = ":runtime",
registry = "registry.k0.hswaw.net",
repository = "q3k/voucherchecker",
tag = "{BUILD_TIMESTAMP}-{STABLE_GIT_COMMIT}",