Merge pull request #274 from Crazykev/gofmt-check
Enable Gofmt check in CI
This commit is contained in:
commit
5a769f72ca
6 changed files with 37 additions and 10 deletions
|
@ -17,6 +17,7 @@ before_script:
|
|||
|
||||
script:
|
||||
- make .gitvalidation
|
||||
- make gofmt
|
||||
- make lint
|
||||
- make integration
|
||||
- make docs
|
||||
|
|
5
Makefile
5
Makefile
|
@ -30,6 +30,7 @@ help:
|
|||
@echo " * 'integration' - Execute integration tests"
|
||||
@echo " * 'clean' - Clean artifacts"
|
||||
@echo " * 'lint' - Execute the source code linter"
|
||||
@echo " * 'gofmt' - Verify the source code gofmt"
|
||||
|
||||
lint: ${OCID_LINK}
|
||||
@which gometalinter > /dev/null 2>/dev/null || (echo "ERROR: gometalinter not found. Consider 'make install.tools' target" && false)
|
||||
|
@ -40,6 +41,9 @@ ${OCID_LINK}:
|
|||
mkdir -p ${OCID_LINK_DIR}
|
||||
ln -sfn ${CURDIR} ${OCID_LINK}
|
||||
|
||||
gofmt:
|
||||
@./hack/verify-gofmt.sh
|
||||
|
||||
conmon:
|
||||
make -C $@
|
||||
|
||||
|
@ -164,6 +168,7 @@ install.tools: .install.gitvalidation .install.gometalinter .install.md2man
|
|||
conmon \
|
||||
default \
|
||||
docs \
|
||||
gofmt \
|
||||
help \
|
||||
install \
|
||||
lint \
|
||||
|
|
21
hack/verify-gofmt.sh
Executable file
21
hack/verify-gofmt.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
find_files() {
|
||||
find . -not \( \
|
||||
\( \
|
||||
-wholename '*/vendor/*' \
|
||||
\) -prune \
|
||||
\) -name '*.go'
|
||||
}
|
||||
|
||||
GOFMT="gofmt -s"
|
||||
bad_files=$(find_files | xargs $GOFMT -l)
|
||||
if [[ -n "${bad_files}" ]]; then
|
||||
echo "!!! '$GOFMT' needs to be run on the following files: "
|
||||
echo "${bad_files}"
|
||||
exit 1
|
||||
fi
|
|
@ -25,11 +25,11 @@ func (s *Server) Status(ctx context.Context, req *pb.StatusRequest) (*pb.StatusR
|
|||
resp := &pb.StatusResponse{
|
||||
Status: &pb.RuntimeStatus{
|
||||
Conditions: []*pb.RuntimeCondition{
|
||||
&pb.RuntimeCondition{
|
||||
{
|
||||
Type: &runtimeReadyConditionString,
|
||||
Status: &runtimeReady,
|
||||
},
|
||||
&pb.RuntimeCondition{
|
||||
{
|
||||
Type: &networkReadyConditionString,
|
||||
Status: &networkReady,
|
||||
},
|
||||
|
|
|
@ -9,20 +9,20 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/containernetworking/cni/pkg/ns"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/kubernetes-incubator/cri-o/oci"
|
||||
"github.com/containernetworking/cni/pkg/ns"
|
||||
"golang.org/x/sys/unix"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type sandboxNetNs struct {
|
||||
sync.Mutex
|
||||
ns ns.NetNS
|
||||
symlink *os.File
|
||||
closed bool
|
||||
restored bool
|
||||
ns ns.NetNS
|
||||
symlink *os.File
|
||||
closed bool
|
||||
restored bool
|
||||
}
|
||||
|
||||
func (ns *sandboxNetNs) symlinkCreate(name string) error {
|
||||
|
@ -190,7 +190,7 @@ func (s *sandbox) netNsCreate() error {
|
|||
}
|
||||
|
||||
s.netns = &sandboxNetNs{
|
||||
ns: netNS,
|
||||
ns: netNS,
|
||||
closed: false,
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
|||
if netnsErr := sb.netNsRemove(); netnsErr != nil {
|
||||
logrus.Warnf("Failed to remove networking namespace: %v", netnsErr)
|
||||
}
|
||||
} ()
|
||||
}()
|
||||
|
||||
// Pass the created namespace path to the runtime
|
||||
err = g.AddOrReplaceLinuxNamespace("network", sb.netNsPath())
|
||||
|
|
Loading…
Reference in a new issue