Remove go-bindata
This commit is contained in:
parent
ee7a63d050
commit
692ab5e53c
7 changed files with 62 additions and 649 deletions
|
@ -45,7 +45,6 @@ jobs:
|
|||
&& git clone --depth=1 https://go.googlesource.com/lint $GOPATH/src/golang.org/x/lint
|
||||
&& go get golang.org/x/lint/golint
|
||||
- go get github.com/vbatts/git-validation
|
||||
- go get -u github.com/jteeuwen/go-bindata/...
|
||||
- make verify-all
|
||||
- stage: Lua Unit Test
|
||||
before_script:
|
||||
|
@ -57,11 +56,9 @@ jobs:
|
|||
# start minikube
|
||||
- test/e2e/up.sh
|
||||
script:
|
||||
- go get github.com/jteeuwen/go-bindata/...
|
||||
- make cover
|
||||
- stage: e2e
|
||||
before_script:
|
||||
- go get github.com/jteeuwen/go-bindata/...
|
||||
- go get github.com/onsi/ginkgo/ginkgo
|
||||
- test/e2e/up.sh
|
||||
- make dev-env
|
||||
|
|
5
Makefile
5
Makefile
|
@ -135,11 +135,6 @@ endif
|
|||
clean:
|
||||
$(DOCKER) rmi -f $(MULTI_ARCH_IMG):$(TAG) || true
|
||||
|
||||
.PHONE: code-generator
|
||||
code-generator:
|
||||
@go-bindata -version || go get -u github.com/jteeuwen/go-bindata/...
|
||||
go-bindata -nometadata -o internal/file/bindata.go -prefix="rootfs" -pkg=file -ignore=Dockerfile -ignore=".DS_Store" rootfs/...
|
||||
|
||||
.PHONY: build
|
||||
build: clean
|
||||
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -a -installsuffix cgo \
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2018 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
TMP_DIR="_tmp"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "${TMP_DIR}"
|
||||
}
|
||||
trap "cleanup" EXIT SIGINT
|
||||
|
||||
cleanup
|
||||
|
||||
go-bindata -nometadata -o ${TMP_DIR}/bindata.go -prefix="rootfs" -pkg=file -ignore=Dockerfile -ignore=".DS_Store" rootfs/...
|
||||
|
||||
ret=0
|
||||
diff -Naupr "${TMP_DIR}/bindata.go" "internal/file/bindata.go" || ret=$?
|
||||
if [[ ${ret} -eq 0 ]]
|
||||
then
|
||||
echo "bindata.go up to date."
|
||||
else
|
||||
echo "bindata.go is out of date. Please run make code-generator and NOT gofmt internal/file/bindata.go"
|
||||
exit 1
|
||||
fi
|
File diff suppressed because one or more lines are too long
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||
package file
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"strings"
|
||||
|
||||
"k8s.io/kubernetes/pkg/util/filesystem"
|
||||
)
|
||||
|
@ -34,10 +34,12 @@ type Filesystem interface {
|
|||
func NewLocalFS() (Filesystem, error) {
|
||||
fs := filesystem.DefaultFs{}
|
||||
|
||||
err := initialize(false, fs)
|
||||
for _, directory := range directories {
|
||||
err := fs.MkdirAll(directory, 0655)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return fs, nil
|
||||
}
|
||||
|
@ -46,94 +48,61 @@ func NewLocalFS() (Filesystem, error) {
|
|||
// paths used by the ingress controller.
|
||||
// This allows running test without polluting the local machine.
|
||||
func NewFakeFS() (Filesystem, error) {
|
||||
fs := filesystem.NewFakeFs()
|
||||
osFs := filesystem.DefaultFs{}
|
||||
fakeFs := filesystem.NewFakeFs()
|
||||
|
||||
//TODO: find another way to do this
|
||||
rootFS := filepath.Clean(fmt.Sprintf("%v/%v", os.Getenv("GOPATH"), "src/k8s.io/ingress-nginx/rootfs"))
|
||||
|
||||
var fileList []string
|
||||
err := filepath.Walk(rootFS, func(path string, f os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
file := strings.TrimPrefix(path, rootFS)
|
||||
if file == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
fileList = append(fileList, file)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
err := initialize(true, fs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return fs, nil
|
||||
}
|
||||
for _, file := range fileList {
|
||||
realPath := fmt.Sprintf("%v%v", rootFS, file)
|
||||
|
||||
// initialize creates the required directory structure and when
|
||||
// runs as virtual filesystem it copies the local files to it
|
||||
func initialize(isVirtual bool, fs Filesystem) error {
|
||||
for _, directory := range directories {
|
||||
err := fs.MkdirAll(directory, 0655)
|
||||
data, err := osFs.ReadFile(realPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !isVirtual {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
f, err := fs.Create(file)
|
||||
fakeFile, err := fakeFs.Create(file)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = f.Write([]byte(""))
|
||||
_, err = fakeFile.Write(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
err := fs.MkdirAll("/proc", 0655)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fakeFs.MkdirAll("/run", 0655)
|
||||
fakeFs.MkdirAll("/proc", 0655)
|
||||
fakeFs.MkdirAll("/etc/nginx/template", 0655)
|
||||
|
||||
glog.Info("Restoring generated (go-bindata) assets in virtual filesystem...")
|
||||
for _, assetName := range AssetNames() {
|
||||
err := restoreAsset("/", assetName, fs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fakeFs.MkdirAll(DefaultSSLDirectory, 0655)
|
||||
fakeFs.MkdirAll(AuthDirectory, 0655)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// restoreAsset restores an asset under the given directory
|
||||
func restoreAsset(dir, name string, fs Filesystem) error {
|
||||
data, err := Asset(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err := AssetInfo(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = fs.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f, err := fs.Create(_filePath(dir, name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = f.Write(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//Missing info.Mode()
|
||||
|
||||
return fs.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
||||
return fakeFs, nil
|
||||
}
|
||||
|
|
|
@ -25,18 +25,12 @@ const (
|
|||
// This directory contains all the SSL certificates that are specified in Ingress rules.
|
||||
// The name of each file is <namespace>-<secret name>.pem. The content is the concatenated
|
||||
// certificate and key.
|
||||
DefaultSSLDirectory = "/ingress-controller/ssl"
|
||||
DefaultSSLDirectory = "/etc/ingress-controller/ssl"
|
||||
)
|
||||
|
||||
var (
|
||||
directories = []string{
|
||||
"/etc/nginx/template",
|
||||
"/run",
|
||||
DefaultSSLDirectory,
|
||||
AuthDirectory,
|
||||
}
|
||||
|
||||
files = []string{
|
||||
"/run/nginx.pid",
|
||||
}
|
||||
)
|
||||
|
|
|
@ -16,6 +16,8 @@ FROM BASEIMAGE
|
|||
|
||||
CROSS_BUILD_COPY qemu-QEMUARCH-static /usr/bin/
|
||||
|
||||
WORKDIR /etc/nginx
|
||||
|
||||
RUN clean-install \
|
||||
diffutils \
|
||||
dumb-init
|
||||
|
|
Loading…
Reference in a new issue