full diff: https://github.com/mjibson/esc/compare/v0.1.0...v0.2.0

includes:

- mjibson/esc#51 Readdir Implementation - and covering with tests
- mjibson/esc#53 update go versions and golint import location
- mjibson/esc#58 Avoid unnecessary conversion and so pass with unconvert linter

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-01-20 16:22:37 +01:00
Родитель 7904c23df8
Коммит 97010520d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 76698F39D527CE8C
2 изменённых файлов: 50 добавлений и 8 удалений

Просмотреть файл

@ -6,6 +6,8 @@ import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
@ -100,7 +102,24 @@ func (f *_escFile) Close() error {
}
func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) {
return nil, nil
if !f.isDir {
return nil, fmt.Errorf(" escFile.Readdir: '%s' is not directory", f.name)
}
fis, ok := _escDirs[f.local]
if !ok {
return nil, fmt.Errorf(" escFile.Readdir: '%s' is directory, but we have no info about content of this dir, local=%s", f.name, f.local)
}
limit := count
if count <= 0 || limit > len(fis) {
limit = len(fis)
}
if len(fis) == 0 && count > 0 {
return nil, io.EOF
}
return fis[0:limit], nil
}
func (f *_escFile) Stat() (os.FileInfo, error) {
@ -191,6 +210,7 @@ func _escFSMustString(useLocal bool, name string) string {
var _escData = map[string]*_escFile{
"/data/config_schema_v3.0.json": {
name: "config_schema_v3.0.json",
local: "data/config_schema_v3.0.json",
size: 11063,
modtime: 1518458244,
@ -226,6 +246,7 @@ xHv6XdkMqA34L74ys3aKw8XE5Pt4DNh+IZaN/DMhad9yDyAlGzbxc2F0fns2HUJ234BlbrgaD1QS+++Y
},
"/data/config_schema_v3.1.json": {
name: "config_schema_v3.1.json",
local: "data/config_schema_v3.1.json",
size: 12209,
modtime: 1518458244,
@ -262,6 +283,7 @@ f55aMuPsI9DxPLh9jLlw/TGcbUX23yn6OwAA//8cyfJJsS8AAA==
},
"/data/config_schema_v3.2.json": {
name: "config_schema_v3.2.json",
local: "data/config_schema_v3.2.json",
size: 13755,
modtime: 1518458244,
@ -300,6 +322,7 @@ ZbmZv+QaLHpS4rzkKyabuw8zkGHuhdMrnbUrtIOnbTqoMzZd83f41N8R/735o4f/lZziOLoU+2E3AJpH
},
"/data/config_schema_v3.3.json": {
name: "config_schema_v3.3.json",
local: "data/config_schema_v3.3.json",
size: 15491,
modtime: 1518458244,
@ -340,6 +363,7 @@ b/Iu7P/nxf8DAAD//7pHo+CDPAAA
},
"/data/config_schema_v3.4.json": {
name: "config_schema_v3.4.json",
local: "data/config_schema_v3.4.json",
size: 15874,
modtime: 1518458244,
@ -381,6 +405,7 @@ PS1sPmQbucDQbzovyv9fFv8LAAD//+uCPa4CPgAA
},
"/data/config_schema_v3.5.json": {
name: "config_schema_v3.5.json",
local: "data/config_schema_v3.5.json",
size: 16802,
modtime: 1518458244,
@ -423,6 +448,7 @@ Pum2n6FuR/KZkNgb9IOAvY0qfF0fuE7P2bsPTT1Xf8bV4ab+/7z5fwAAAP//yoGbgKJBAAA=
},
"/data/config_schema_v3.6.json": {
name: "config_schema_v3.6.json",
local: "data/config_schema_v3.6.json",
size: 17084,
modtime: 1518458244,
@ -466,6 +492,7 @@ oqbZ4ab+/7z5fwAAAP//nm8U9rxCAAA=
},
"/data/config_schema_v3.7.json": {
name: "config_schema_v3.7.json",
local: "data/config_schema_v3.7.json",
size: 17854,
modtime: 1518458244,
@ -509,6 +536,7 @@ bnBpPlHfjORjkTRf1wyAwiYqMXd9/G6313QfoXs6/sbZ66r6e179PwAA//8ZL3SpvkUAAA==
},
"/data/config_schema_v3.8.json": {
name: "config_schema_v3.8.json",
local: "data/config_schema_v3.8.json",
size: 18246,
modtime: 1518458244,
@ -553,6 +581,7 @@ ean7MQBPP+U4w19V/z+t/hsAAP//Fd/bF0ZHAAA=
},
"/data/config_schema_v3.9.json": {
name: "config_schema_v3.9.json",
local: "data/config_schema_v3.9.json",
size: 18246,
modtime: 1518458244,
@ -596,13 +625,25 @@ vNT9GICnn3Kc4a+q/59W/w0AAP//CCwovkZHAAA=
`,
},
"/": {
isDir: true,
local: "",
},
"/data": {
name: "data",
local: `data`,
isDir: true,
local: "data",
},
}
var _escDirs = map[string][]os.FileInfo{
"data": {
_escData["/data/config_schema_v3.0.json"],
_escData["/data/config_schema_v3.1.json"],
_escData["/data/config_schema_v3.2.json"],
_escData["/data/config_schema_v3.3.json"],
_escData["/data/config_schema_v3.4.json"],
_escData["/data/config_schema_v3.5.json"],
_escData["/data/config_schema_v3.6.json"],
_escData["/data/config_schema_v3.7.json"],
_escData["/data/config_schema_v3.8.json"],
_escData["/data/config_schema_v3.9.json"],
},
}

Просмотреть файл

@ -12,7 +12,8 @@ RUN go get -d github.com/LK4D4/vndr && \
go build -v -o /usr/bin/vndr . && \
rm -rf /go/src/* /go/pkg/* /go/bin/*
ARG ESC_SHA=58d9cde84f237ecdd89bd7f61c2de2853f4c5c6e
# v0.2.0
ARG ESC_SHA=0ea7db170df78dcddf3e223365f444163147fe89
RUN go get -d github.com/mjibson/esc && \
cd /go/src/github.com/mjibson/esc && \
git checkout -q "$ESC_SHA" && \