From 097e5eba9fc7d69958c197db1f9b346cbc88f7d2 Mon Sep 17 00:00:00 2001
From: Max Xu
Date: Tue, 9 Mar 2021 03:26:43 +0800
Subject: [PATCH] feat: remove go-bindata-assetfs in favor of embed by
upgrading to go1.16 (#11733)
---
CREDITS | 74 +---
browser/.gitignore | 1 -
browser/README.md | 13 +-
browser/assets.go | 11 +
browser/build.js | 76 ----
browser/production/chrome.png | Bin 0 -> 3726 bytes
browser/production/favicon-16x16.png | Bin 0 -> 14906 bytes
browser/production/favicon-32x32.png | Bin 0 -> 16066 bytes
browser/production/favicon-96x96.png | Bin 0 -> 17029 bytes
browser/production/firefox.png | Bin 0 -> 4795 bytes
browser/production/index.html | 59 +++
browser/production/index_bundle.js | 67 +++
browser/production/loader.css | 98 ++++
browser/production/logo.svg | 12 +
browser/production/safari.png | Bin 0 -> 4971 bytes
browser/ui-assets.go | 640 ---------------------------
cmd/web-handlers.go | 36 +-
cmd/web-router.go | 18 +-
go.mod | 3 -
go.sum | 17 +-
20 files changed, 297 insertions(+), 828 deletions(-)
create mode 100644 browser/assets.go
create mode 100644 browser/production/chrome.png
create mode 100644 browser/production/favicon-16x16.png
create mode 100644 browser/production/favicon-32x32.png
create mode 100644 browser/production/favicon-96x96.png
create mode 100644 browser/production/firefox.png
create mode 100644 browser/production/index.html
create mode 100644 browser/production/index_bundle.js
create mode 100644 browser/production/loader.css
create mode 100644 browser/production/logo.svg
create mode 100644 browser/production/safari.png
delete mode 100644 browser/ui-assets.go
diff --git a/CREDITS b/CREDITS
index b9e449e64..bc340b1e3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3696,36 +3696,6 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-================================================================
-
-github.com/elazarl/go-bindata-assetfs
-https://github.com/elazarl/go-bindata-assetfs
-----------------------------------------------------------------
-Copyright (c) 2014, Elazar Leibovich
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
================================================================
github.com/fatih/color
@@ -12501,28 +12471,28 @@ SOFTWARE.
github.com/klauspost/readahead
https://github.com/klauspost/readahead
----------------------------------------------------------------
-The MIT License (MIT)
-
-Copyright (c) 2015 Klaus Post
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
+The MIT License (MIT)
+
+Copyright (c) 2015 Klaus Post
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
================================================================
diff --git a/browser/.gitignore b/browser/.gitignore
index 6e4ed66d7..06f49e312 100644
--- a/browser/.gitignore
+++ b/browser/.gitignore
@@ -17,4 +17,3 @@ release
*.syso
coverage.txt
node_modules
-production
diff --git a/browser/README.md b/browser/README.md
index 8b1c94529..d65211b76 100644
--- a/browser/README.md
+++ b/browser/README.md
@@ -17,24 +17,13 @@ nvm install stable
npm install
```
-### Install `go-bindata` and `go-bindata-assetfs`
-
-If you do not have a working Golang environment, please follow [Install Golang](https://golang.org/doc/install)
-
-```sh
-go get github.com/go-bindata/go-bindata/go-bindata
-go get github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs
-```
-
## Generating Assets
-### Generate ui-assets.go
-
```sh
npm run release
```
-This generates ui-assets.go in the current directory. Now do `make` in the parent directory to build the minio binary with the newly generated ``ui-assets.go``
+This generates `production` in the current directory.
## Run MinIO Browser with live reload
diff --git a/browser/assets.go b/browser/assets.go
new file mode 100644
index 000000000..d0a32829d
--- /dev/null
+++ b/browser/assets.go
@@ -0,0 +1,11 @@
+package browser
+
+import "embed"
+
+//go:embed production/*
+var fs embed.FS
+
+// GetStaticAssets returns assets
+func GetStaticAssets() embed.FS {
+ return fs
+}
diff --git a/browser/build.js b/browser/build.js
index 469c0c22f..a1be7e8e9 100644
--- a/browser/build.js
+++ b/browser/build.js
@@ -14,19 +14,11 @@
* limitations under the License.
*/
-var moment = require('moment')
var async = require('async')
var exec = require('child_process').exec
var fs = require('fs')
var isProduction = process.env.NODE_ENV == 'production' ? true : false
-var assetsFileName = ''
-var commitId = ''
-var date = moment.utc()
-var version = date.format('YYYY-MM-DDTHH:mm:ss') + 'Z'
-var releaseTag = date.format('YYYY-MM-DDTHH-mm-ss') + 'Z'
-var buildType = 'DEVELOPMENT'
-if (process.env.MINIO_UI_BUILD) buildType = process.env.MINIO_UI_BUILD
rmDir = function(dirPath) {
try { var files = fs.readdirSync(dirPath); }
@@ -53,74 +45,6 @@ async.waterfall([
console.log('Running', cmd)
exec(cmd, cb)
},
- function(stdout, stderr, cb) {
- if (isProduction) {
- fs.renameSync('production/index_bundle.js',
- 'production/index_bundle-' + releaseTag + '.js')
- } else {
- fs.renameSync('dev/index_bundle.js',
- 'dev/index_bundle-' + releaseTag + '.js')
- }
- var cmd = 'git log --format="%H" -n1'
- console.log('Running', cmd)
- exec(cmd, cb)
- },
- function(stdout, stderr, cb) {
- if (!stdout) throw new Error('commitId is empty')
- commitId = stdout.replace('\n', '')
- if (commitId.length !== 40) throw new Error('commitId invalid : ' + commitId)
- assetsFileName = 'ui-assets.go';
- var cmd = 'go-bindata-assetfs -o bindata_assetfs.go -pkg browser -nocompress=true production/...'
- if (!isProduction) {
- cmd = 'go-bindata-assetfs -o bindata_assetfs.go -pkg browser -nocompress=true dev/...'
- }
- console.log('Running', cmd)
- exec(cmd, cb)
- },
- function(stdout, stderr, cb) {
- var cmd = 'gofmt -s -w -l bindata_assetfs.go'
- console.log('Running', cmd)
- exec(cmd, cb)
- },
- function(stdout, stderr, cb) {
- fs.renameSync('bindata_assetfs.go', assetsFileName)
- fs.appendFileSync(assetsFileName, '\n')
- fs.appendFileSync(assetsFileName, 'var UIReleaseTag = "' + buildType + '.' +
- releaseTag + '"\n')
- fs.appendFileSync(assetsFileName, 'var UICommitID = "' + commitId + '"\n')
- fs.appendFileSync(assetsFileName, 'var UIVersion = "' + version + '"')
- fs.appendFileSync(assetsFileName, '\n')
- var contents;
- if (isProduction) {
- contents = fs.readFileSync(assetsFileName, 'utf8')
- .replace(/_productionIndexHtml/g, '_productionIndexHTML')
- .replace(/productionIndexHtmlBytes/g, 'productionIndexHTMLBytes')
- .replace(/productionIndexHtml/g, 'productionIndexHTML')
- .replace(/_productionIndex_bundleJs/g, '_productionIndexBundleJs')
- .replace(/productionIndex_bundleJsBytes/g, 'productionIndexBundleJsBytes')
- .replace(/productionIndex_bundleJs/g, 'productionIndexBundleJs')
- .replace(/_productionJqueryUiMinJs/g, '_productionJqueryUIMinJs')
- .replace(/productionJqueryUiMinJsBytes/g, 'productionJqueryUIMinJsBytes')
- .replace(/productionJqueryUiMinJs/g, 'productionJqueryUIMinJs');
- } else {
- contents = fs.readFileSync(assetsFileName, 'utf8')
- .replace(/_devIndexHtml/g, '_devIndexHTML')
- .replace(/devIndexHtmlBytes/g, 'devIndexHTMLBytes')
- .replace(/devIndexHtml/g, 'devIndexHTML')
- .replace(/_devIndex_bundleJs/g, '_devIndexBundleJs')
- .replace(/devIndex_bundleJsBytes/g, 'devIndexBundleJsBytes')
- .replace(/devIndex_bundleJs/g, 'devIndexBundleJs')
- .replace(/_devJqueryUiMinJs/g, '_devJqueryUIMinJs')
- .replace(/devJqueryUiMinJsBytes/g, 'devJqueryUIMinJsBytes')
- .replace(/devJqueryUiMinJs/g, 'devJqueryUIMinJs');
- }
- contents = contents.replace(/MINIO_UI_VERSION/g, version)
- contents = contents.replace(/index_bundle.js/g, 'index_bundle-' + releaseTag + '.js')
-
- fs.writeFileSync(assetsFileName, contents, 'utf8')
- console.log('UI assets file :', assetsFileName)
- cb()
- }
], function(err) {
if (err) return console.log(err)
})
diff --git a/browser/production/chrome.png b/browser/production/chrome.png
new file mode 100644
index 0000000000000000000000000000000000000000..278ef4d15ecf2d715b900a25064ecb2fe8728f1b
GIT binary patch
literal 3726
zcmV;94sr2`P)Oxc$W0hQ82|tPL@foWdm1%?Gqfuumvj&n7YBx94TwB3hb19UuSG9>H!O29
z7e5@ACL-rnP1-6c$EXR$OF!{6GdPAcBxEnlof#rtDIR1b&y*&pcpl=q4&-4`LZCoq
zND)sr4ljExbyX1j(g{ttNlds&OtnehAt(CL3res^;VdoTC@bJ4Dg4n2OS4GjKR8LQ
zNJphcH-N+AF)-vgG~+ZeN{Y$<|Nr~W4d+EY@xl~Gs7LwC4n&5>=0ZE-FD~p^Oh~Io
z##!OhHATMeVvBR+7y_nnW~y!0As!YNFQb
zRY-BD+97GB>QY9~9w9Axy6$6CWuDYwn$j_RzW&n){?GvFwjL;TwIp$|T9wb-qbKCA
zBlZ6O@oHEgZmd6*Lp+c|-VQ0?swG{Q(e7VS|Ni;^_5J?&@8+@~>|IXZ6BhhzTTr=9
zC!J10v_9~#EZqkTCUw42#ZWY}G5^~Hd8^t0NRHYdCCeEe=LQ_-O&A<+{t+4rZ?gT%!e2lvBP^|6ftl9wGGJ4C=W8in-#Ty3XgZv-0Jr
zKcGtC7cA$fD*Uo0{J$jp#Tfn254_Xnp2Fk)QAdGxIx?X&>?tg!wkYF%A=nch&)MPQ
z$;oq^zL(0D=8TP6)>b#BOY>1i_18fci#`7{Gq5@Wsy9NCXSVVj2~vu&|PV;0tVL
zBR;^^7Ps^Pd