From 5bf8e7c570508e585bbd2abb6c437f4e907fd6f6 Mon Sep 17 00:00:00 2001 From: Julio Lopez Date: Tue, 21 Dec 2021 20:19:27 -0800 Subject: [PATCH] Allow building without UI (#1614) --- Makefile | 1 + internal/server/htmlui_embed.go | 3 +++ internal/server/htmlui_fallback.go | 17 +++++++++++++++++ internal/server/index.html | 11 +++++++++++ 4 files changed, 32 insertions(+) create mode 100644 internal/server/htmlui_fallback.go create mode 100644 internal/server/index.html diff --git a/Makefile b/Makefile index 8f0ff43a1..ccf59196e 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,7 @@ endif install: go install $(KOPIA_BUILD_FLAGS) -tags "$(KOPIA_BUILD_TAGS)" +install-noui: KOPIA_BUILD_TAGS=nohtmlui install-noui: install install-race: diff --git a/internal/server/htmlui_embed.go b/internal/server/htmlui_embed.go index ff032f33e..fbd6eb11d 100644 --- a/internal/server/htmlui_embed.go +++ b/internal/server/htmlui_embed.go @@ -1,3 +1,6 @@ +//go:build !nohtmlui +// +build !nohtmlui + package server import ( diff --git a/internal/server/htmlui_fallback.go b/internal/server/htmlui_fallback.go new file mode 100644 index 000000000..102ade083 --- /dev/null +++ b/internal/server/htmlui_fallback.go @@ -0,0 +1,17 @@ +//go:build nohtmlui +// +build nohtmlui + +package server + +import ( + "embed" + "net/http" +) + +//go:embed index.html +var data embed.FS + +// AssetFile return a http.FileSystem instance that data backend by asset. +func AssetFile() http.FileSystem { + return http.FS(data) +} diff --git a/internal/server/index.html b/internal/server/index.html new file mode 100644 index 000000000..7a89e56ff --- /dev/null +++ b/internal/server/index.html @@ -0,0 +1,11 @@ + + + + Kopia UI not supported. + + +

Kopia UI not supported, use an official build.

+

When compiling from source use:

+
make html-ui && go install -tags embedhtml
+ +