github.com/flanksource/konfigadm@v0.12.0/resources/static.go (about) 1 // Code generated by "esc --prefix resources/ --ignore static.go -o resources/static.go --pkg resources resources"; DO NOT EDIT. 2 3 package resources 4 5 import ( 6 "bytes" 7 "compress/gzip" 8 "encoding/base64" 9 "fmt" 10 "io" 11 "io/ioutil" 12 "net/http" 13 "os" 14 "path" 15 "sync" 16 "time" 17 ) 18 19 type _escLocalFS struct{} 20 21 var _escLocal _escLocalFS 22 23 type _escStaticFS struct{} 24 25 var _escStatic _escStaticFS 26 27 type _escDirectory struct { 28 fs http.FileSystem 29 name string 30 } 31 32 type _escFile struct { 33 compressed string 34 size int64 35 modtime int64 36 local string 37 isDir bool 38 39 once sync.Once 40 data []byte 41 name string 42 } 43 44 func (_escLocalFS) Open(name string) (http.File, error) { 45 f, present := _escData[path.Clean(name)] 46 if !present { 47 return nil, os.ErrNotExist 48 } 49 return os.Open(f.local) 50 } 51 52 func (_escStaticFS) prepare(name string) (*_escFile, error) { 53 f, present := _escData[path.Clean(name)] 54 if !present { 55 return nil, os.ErrNotExist 56 } 57 var err error 58 f.once.Do(func() { 59 f.name = path.Base(name) 60 if f.size == 0 { 61 return 62 } 63 var gr *gzip.Reader 64 b64 := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(f.compressed)) 65 gr, err = gzip.NewReader(b64) 66 if err != nil { 67 return 68 } 69 f.data, err = ioutil.ReadAll(gr) 70 }) 71 if err != nil { 72 return nil, err 73 } 74 return f, nil 75 } 76 77 func (fs _escStaticFS) Open(name string) (http.File, error) { 78 f, err := fs.prepare(name) 79 if err != nil { 80 return nil, err 81 } 82 return f.File() 83 } 84 85 func (dir _escDirectory) Open(name string) (http.File, error) { 86 return dir.fs.Open(dir.name + name) 87 } 88 89 func (f *_escFile) File() (http.File, error) { 90 type httpFile struct { 91 *bytes.Reader 92 *_escFile 93 } 94 return &httpFile{ 95 Reader: bytes.NewReader(f.data), 96 _escFile: f, 97 }, nil 98 } 99 100 func (f *_escFile) Close() error { 101 return nil 102 } 103 104 func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) { 105 if !f.isDir { 106 return nil, fmt.Errorf(" escFile.Readdir: '%s' is not directory", f.name) 107 } 108 109 fis, ok := _escDirs[f.local] 110 if !ok { 111 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) 112 } 113 limit := count 114 if count <= 0 || limit > len(fis) { 115 limit = len(fis) 116 } 117 118 if len(fis) == 0 && count > 0 { 119 return nil, io.EOF 120 } 121 122 return fis[0:limit], nil 123 } 124 125 func (f *_escFile) Stat() (os.FileInfo, error) { 126 return f, nil 127 } 128 129 func (f *_escFile) Name() string { 130 return f.name 131 } 132 133 func (f *_escFile) Size() int64 { 134 return f.size 135 } 136 137 func (f *_escFile) Mode() os.FileMode { 138 return 0 139 } 140 141 func (f *_escFile) ModTime() time.Time { 142 return time.Unix(f.modtime, 0) 143 } 144 145 func (f *_escFile) IsDir() bool { 146 return f.isDir 147 } 148 149 func (f *_escFile) Sys() interface{} { 150 return f 151 } 152 153 // FS returns a http.Filesystem for the embedded assets. If useLocal is true, 154 // the filesystem's contents are instead used. 155 func FS(useLocal bool) http.FileSystem { 156 if useLocal { 157 return _escLocal 158 } 159 return _escStatic 160 } 161 162 // Dir returns a http.Filesystem for the embedded assets on a given prefix dir. 163 // If useLocal is true, the filesystem's contents are instead used. 164 func Dir(useLocal bool, name string) http.FileSystem { 165 if useLocal { 166 return _escDirectory{fs: _escLocal, name: name} 167 } 168 return _escDirectory{fs: _escStatic, name: name} 169 } 170 171 // FSByte returns the named file from the embedded assets. If useLocal is 172 // true, the filesystem's contents are instead used. 173 func FSByte(useLocal bool, name string) ([]byte, error) { 174 if useLocal { 175 f, err := _escLocal.Open(name) 176 if err != nil { 177 return nil, err 178 } 179 b, err := ioutil.ReadAll(f) 180 _ = f.Close() 181 return b, err 182 } 183 f, err := _escStatic.prepare(name) 184 if err != nil { 185 return nil, err 186 } 187 return f.data, nil 188 } 189 190 // FSMustByte is the same as FSByte, but panics if name is not present. 191 func FSMustByte(useLocal bool, name string) []byte { 192 b, err := FSByte(useLocal, name) 193 if err != nil { 194 panic(err) 195 } 196 return b 197 } 198 199 // FSString is the string version of FSByte. 200 func FSString(useLocal bool, name string) (string, error) { 201 b, err := FSByte(useLocal, name) 202 return string(b), err 203 } 204 205 // FSMustString is the string version of FSMustByte. 206 func FSMustString(useLocal bool, name string) string { 207 return string(FSMustByte(useLocal, name)) 208 } 209 210 var _escData = map[string]*_escFile{ 211 212 "/const.go": { 213 name: "const.go", 214 local: "resources/const.go", 215 size: 203, 216 modtime: 1609832440, 217 compressed: ` 218 H4sIAAAAAAAC/3TMsQrCMBCH8b1PETpZkPoEThUXcQq4X9N/Q2x7J3dJnl9QcBC6f7/vRWGhCKcwKRpg 219 TVNJ3SCcKTF08tCaAtzZXf29WPZZE8fDTKvh6NpT+JW9fdO2+yxuZcSKPAjPu3gpI2ja/uRjNp9FKeKi 220 qUJ3+UTYhPunCbdd8w4AAP//P7XeAcsAAAA= 221 `, 222 }, 223 224 "/containerd.service": { 225 name: "containerd.service", 226 local: "resources/containerd.service", 227 size: 1421, 228 modtime: 1609832440, 229 compressed: ` 230 H4sIAAAAAAAC/7xUwW7cNhC98ysG0aFA0ZVaoGnrADoksYsGjbuGnSIHwweKHK2mpjgCZ2h7+/UFufau 231 UPhY9CSJmnnz5r0Hmts/I+mdaeBGbVJwHNVSxOTBCgSrWJ4Li9AQEB5JJ0goCzoFZXCBs99QJP1GTAMD 232 s4Ko3aG08GUiAYySEwroZHVVDTP7HFBAspvAlt7HRIqbkcrpbPcwIGRBX6dwHGmXE67pLYk4lb+kpilD 233 k1LctaYxDVwFtIIgiKATwsgh8CPFHQSK9zBygpkTAsWR02yVOIIdOGupNs2a52kjmG20O/Qw7CvooehA 234 rRVMD+TwnWlgUl3kXdfV/wWjTWi9TujZSUvcYeyKrqKd8kJOujKjnXQOzQHNmAYuqm7rfUkOSxYGOBb6 235 Jxb/omqag974hC5rVR8h5ehm/yz8szuHjwJdPOVYTTZNVSjlGItkb+7zgNbPUIa8+Q5s9KBTljW3OYvC 236 gC8+rClSKZzn0kUCS2KHIuj/b59Gijb8VzZVMPN+VEz9icMLuvlQd+9fC4j5aqPKa03nKC7RUnbsV8oe 237 X4sfSjOac3Z5xqhVjv64xrGlJTbm9lMUtSHc1YHoP+xfp2Nubw5vd6a5eEJXL4GrhH0nA8VuZr8kHhD4 238 AVOwe3Os6bssqQvsbOhK5Wm+ucYagt6GR7uXl88bdP1bc44Bd1ax36OY3ymES/bYP6fCbLeXN44Tvvd/ 239 ZdF+c3Z2Zj7TTPrH9tdPny/6H77/8Ze3P/9kGvjNPpSYRI6bvzEx1KpvBZzNggILppqY6LBEbgg4C/iM 240 5bqwznGRMu7qVhNabxqgWMNyjyliaOErQsKSW4wespRit0ucFykQnk++bKoGK9T2mfLV9fZjT3EsLu8P 241 Zx+31xenoy9W7uXSPp1O/gkAAP//LPoJ6o0FAAA= 242 `, 243 }, 244 245 "/daemon.json": { 246 name: "daemon.json", 247 local: "resources/daemon.json", 248 size: 29, 249 modtime: 1609832440, 250 compressed: ` 251 H4sIAAAAAAAC/6rmUlBQKi7JL0pMT9VNKcosSy1SslJQKksrVuKqBQQAAP//uMYVpR0AAAA= 252 `, 253 }, 254 255 "/kubeadm.service": { 256 name: "kubeadm.service", 257 local: "resources/kubeadm.service", 258 size: 900, 259 modtime: 1609832440, 260 compressed: ` 261 H4sIAAAAAAAC/3xSUW+bQAx+51dYtG8roLxOykO20Wrqlk1JJk2apsqAIW6Pu8hnaPn300FpEzXdE8b3 262 +fPnz76AtVP6CLs9e6jEHdiCs2aARycPHh5Z9/DQFYRVC2irMTak0C/SxeJD9GdL0nNJf6Pc9izOtmR1 263 Gd/++pR/y3d34fv5x/r6683danOzXSZJ4Zx6FTwkgal0tuZmmZGWWfgXS0o+OwUZ0jQAIflfzTEyPq/m 264 VMnM06NkhouZIJvy6YCtiaOLyRj2gFCzIdA9KsSzI2xZ49GXl9S9YxtDQ5YElTyggnRWuaUrOLhDZ1DZ 265 NqB7gmOXVl++j8KgR2EsDEE1WGy5RGOG43Gu2dAyeaP6uX1SG2x8SrZ/R3ro23kSKNGGAGon4HoS4Yo8 266 uHpEzFtGaTxgYDDoFYS8E03hp1BNgoUZrl4J/d51pgpxdDFm07WraEMNh1UqO5veTrT5kwquArUr7qlU 267 YDsWTM53E3jU7IGtV8IqfTEr/73brCarnjsWBN51UlIFtbgWNIwdqtMzvoWr8YOfWs3uRfkTlVtF0eVR 268 mHVesoLtjILLd8769eFs8mS9l2/niP4FAAD//8ugzaeEAwAA 269 `, 270 }, 271 272 "/resources": { 273 name: "resources", 274 local: `resources`, 275 isDir: true, 276 }, 277 } 278 279 var _escDirs = map[string][]os.FileInfo{ 280 281 "resources": { 282 _escData["/const.go"], 283 _escData["/containerd.service"], 284 _escData["/daemon.json"], 285 _escData["/kubeadm.service"], 286 }, 287 }