ea1e4aa52d
Replace bindata packages with stdlib go:embed. Modernize some uiserver code with newer interfaces introduced in go 1.16 (mainly working with fs.File instead of http.File. Remove steps that are no longer used from our build files. Add Github Action to detect differences in agent/uiserver/dist and verify that the files are correct (by compiling UI assets and comparing contents).
34 lines
616 B
Go
34 lines
616 B
Go
package uiserver
|
|
|
|
import (
|
|
"io"
|
|
"io/fs"
|
|
)
|
|
|
|
// bufferedFile implements fs.File and allows us to modify a file from disk by
|
|
// writing out the new version into a buffer and then serving file reads from
|
|
// that.
|
|
type bufferedFile struct {
|
|
buf io.Reader
|
|
info fs.FileInfo
|
|
}
|
|
|
|
func (b *bufferedFile) Stat() (fs.FileInfo, error) {
|
|
return b.info, nil
|
|
}
|
|
|
|
func (b *bufferedFile) Read(bytes []byte) (int, error) {
|
|
return b.buf.Read(bytes)
|
|
}
|
|
|
|
func (b *bufferedFile) Close() error {
|
|
return nil
|
|
}
|
|
|
|
func newBufferedFile(buf io.Reader, info fs.FileInfo) *bufferedFile {
|
|
return &bufferedFile{
|
|
buf: buf,
|
|
info: info,
|
|
}
|
|
}
|