initial makefile (#7)
* adds initial makefile Signed-off-by: Mike Brown <brownwm@us.ibm.com> * clean up lint Signed-off-by: Mike Brown <brownwm@us.ibm.com> * presume path is set to contain gomealinter Signed-off-by: Mike Brown <brownwm@us.ibm.com> * addresses requested improvements Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
b5734373c4
commit
11ba1cb54d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
_output/*
|
81
Makefile
Normal file
81
Makefile
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
GO ?= go
|
||||||
|
EPOCH_TEST_COMMIT ?= f2925f58acc259c4b894353f5fc404bdeb40028e
|
||||||
|
PROJECT := github.com/kubernetes-incubator/cri-containerd
|
||||||
|
BINDIR ?= ${DESTDIR}/usr/local/bin
|
||||||
|
BUILD_DIR ?= _output
|
||||||
|
|
||||||
|
all: binaries
|
||||||
|
|
||||||
|
default: help
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Usage: make <target>"
|
||||||
|
@echo
|
||||||
|
@echo " * 'install' - Install binaries to system locations"
|
||||||
|
@echo " * 'binaries' - Build cri-containerd"
|
||||||
|
@echo " * 'clean' - Clean artifacts"
|
||||||
|
@echo " * 'verify' - Execute the source code verification tools"
|
||||||
|
@echo " * 'install.tools' - Installs tools used by verify"
|
||||||
|
@echo " * 'uninstall' - Remove installed binaries from system locations"
|
||||||
|
|
||||||
|
.PHONY: check-gopath
|
||||||
|
|
||||||
|
check-gopath:
|
||||||
|
ifndef GOPATH
|
||||||
|
$(error GOPATH is not set)
|
||||||
|
endif
|
||||||
|
|
||||||
|
verify: lint gofmt
|
||||||
|
|
||||||
|
lint: check-gopath
|
||||||
|
@echo "checking lint"
|
||||||
|
@./hack/lint.sh
|
||||||
|
|
||||||
|
gofmt:
|
||||||
|
@echo "checking gofmt"
|
||||||
|
@./hack/verify-gofmt.sh
|
||||||
|
|
||||||
|
cri-containerd: check-gopath
|
||||||
|
$(GO) build -o $(BUILD_DIR)/$@ \
|
||||||
|
$(PROJECT)/cmd/cri-containerd
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(BUILD_DIR)/cri-containerd
|
||||||
|
|
||||||
|
binaries: cri-containerd
|
||||||
|
|
||||||
|
install: check-gopath
|
||||||
|
install -D -m 755 $(BUILD_DIR)/cri-containerd $(BINDIR)/cri-containerd
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(BINDIR)/cri-containerd
|
||||||
|
|
||||||
|
.PHONY: .gitvalidation
|
||||||
|
# When this is running in travis, it will only check the travis commit range
|
||||||
|
.gitvalidation: check-gopath
|
||||||
|
ifeq ($(TRAVIS),true)
|
||||||
|
git-validation -q -run DCO,short-subject
|
||||||
|
else
|
||||||
|
git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: install.tools .install.gitvalidation .install.gometalinter
|
||||||
|
|
||||||
|
install.tools: .install.gitvalidation .install.gometalinter
|
||||||
|
|
||||||
|
.install.gitvalidation:
|
||||||
|
go get -u github.com/vbatts/git-validation
|
||||||
|
|
||||||
|
.install.gometalinter:
|
||||||
|
go get -u github.com/alecthomas/gometalinter
|
||||||
|
gometalinter --install
|
||||||
|
|
||||||
|
.PHONY: \
|
||||||
|
binaries \
|
||||||
|
clean \
|
||||||
|
default \
|
||||||
|
gofmt \
|
||||||
|
help \
|
||||||
|
install \
|
||||||
|
lint \
|
||||||
|
uninstall
|
@ -33,6 +33,7 @@ type CRIContainerdOptions struct {
|
|||||||
ContainerdConnectionTimeout time.Duration
|
ContainerdConnectionTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCRIContainerdOptions returns a reference to CRIContainerdOptions
|
||||||
func NewCRIContainerdOptions() *CRIContainerdOptions {
|
func NewCRIContainerdOptions() *CRIContainerdOptions {
|
||||||
return &CRIContainerdOptions{}
|
return &CRIContainerdOptions{}
|
||||||
}
|
}
|
||||||
@ -47,6 +48,10 @@ func (c *CRIContainerdOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
2*time.Minute, "Connection timeout for containerd client.")
|
2*time.Minute, "Connection timeout for containerd client.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitFlags must be called after adding all cli options flags are defined and
|
||||||
|
// before flags are accessed by the program. Ths fuction adds flag.CommandLine
|
||||||
|
// (the default set of command-line flags, parsed from os.Args) and then calls
|
||||||
|
// pflag.Parse().
|
||||||
func InitFlags() {
|
func InitFlags() {
|
||||||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
|
33
hack/lint.sh
Executable file
33
hack/lint.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright 2017 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.#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
for d in $(find . -type d -a \( -iwholename './pkg*' -o -iwholename './cmd*' \)); do
|
||||||
|
echo for directory ${d} ...
|
||||||
|
gometalinter \
|
||||||
|
--exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \
|
||||||
|
--exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
|
||||||
|
--exclude='duplicate of.*_test.go.*\(dupl\)$' \
|
||||||
|
--disable=aligncheck \
|
||||||
|
--disable=gotype \
|
||||||
|
--disable=gas \
|
||||||
|
--cyclo-over=60 \
|
||||||
|
--dupl-threshold=100 \
|
||||||
|
--tests \
|
||||||
|
--deadline=30s "${d}"
|
||||||
|
done
|
34
hack/verify-gofmt.sh
Executable file
34
hack/verify-gofmt.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Copyright 2017 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
|
||||||
|
|
||||||
|
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
|
@ -21,6 +21,9 @@ import (
|
|||||||
|
|
||||||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
||||||
|
// TODO remove the underscores from the following imports as the services are
|
||||||
|
// implemented. "_" is being used to hold the reference to keep autocomplete
|
||||||
|
// from deleting them until referenced below.
|
||||||
_ "github.com/containerd/containerd/api/services/content"
|
_ "github.com/containerd/containerd/api/services/content"
|
||||||
_ "github.com/containerd/containerd/api/services/execution"
|
_ "github.com/containerd/containerd/api/services/execution"
|
||||||
_ "github.com/containerd/containerd/api/services/images"
|
_ "github.com/containerd/containerd/api/services/images"
|
||||||
@ -41,6 +44,7 @@ type CRIContainerdService interface {
|
|||||||
// criContainerdService implements CRIContainerdService.
|
// criContainerdService implements CRIContainerdService.
|
||||||
type criContainerdService struct{}
|
type criContainerdService struct{}
|
||||||
|
|
||||||
|
// NewCRIContainerdService returns a new instance of CRIContainerdService
|
||||||
func NewCRIContainerdService(conn *grpc.ClientConn) CRIContainerdService {
|
func NewCRIContainerdService(conn *grpc.ClientConn) CRIContainerdService {
|
||||||
// TODO: Initialize different containerd clients.
|
// TODO: Initialize different containerd clients.
|
||||||
return &criContainerdService{}
|
return &criContainerdService{}
|
||||||
|
Loading…
Reference in New Issue
Block a user