Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

place binaries in cmd/ and packages in pkg/ #815

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ endif

# Default to build the Linux binary
build-linux:
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o aws-k8s-agent -ldflags "-s -w $(LDFLAGS)"
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o aws-cni -ldflags " -s -w $(LDFLAGS)" ./plugins/routed-eni/
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o grpc_health_probe -ldflags "-s -w $(LDFLAGS)" ./client/health-check/
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o aws-k8s-agent -ldflags "-s -w $(LDFLAGS)" ./cmd/aws-k8s-agent/
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o aws-cni -ldflags " -s -w $(LDFLAGS)" ./cmd/routed-eni-cni-plugin/
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -o grpc-health-probe -ldflags "-s -w $(LDFLAGS)" ./cmd/grpc-health-probe/

# Download portmap plugin
download-portmap:
Expand All @@ -59,13 +59,13 @@ unit-test:

# unit-test-race
unit-test-race:
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./cmd/*/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 150s ./pkg/awsutils/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./plugins/routed-eni/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/k8sapi/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/networkutils/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/utils/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/eniconfig/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./ipamd/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/ipamd/...

build-docker-test:
@docker build -f scripts/dockerfiles/Dockerfile.test -t amazon-k8s-cni-test:latest .
Expand All @@ -76,15 +76,15 @@ docker-unit-test: build-docker-test

# Build metrics
build-metrics:
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags="-s -w" -o cni-metrics-helper/cni-metrics-helper cni-metrics-helper/cni-metrics-helper.go
GOOS=linux GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags="-s -w" -o cni-metrics-helper ./cmd/cni-metrics-helper/

# Build metrics Docker image
docker-metrics:
@docker build --build-arg arch="$(ARCH)" -f scripts/dockerfiles/Dockerfile.metrics -t "amazon/cni-metrics-helper:$(VERSION)" .
@echo "Built Docker image \"amazon/cni-metrics-helper:$(VERSION)\""

metrics-unit-test:
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./cni-metrics-helper/metrics/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./cmd/cni-metrics-helper/metrics/...

docker-metrics-test:
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
Expand All @@ -102,16 +102,16 @@ generate-limits:
# To install: go get -u golang.org/x/lint/golint
lint:
golint pkg/awsutils/*.go
golint plugins/routed-eni/*.go
golint plugins/routed-eni/driver/*.go
golint cmd/routed-eni-cni-plugin/*.go
golint cmd/routed-eni-cni-plugin/driver/*.go
golint pkg/k8sapi/*.go
golint pkg/networkutils/*.go
golint ipamd/*.go
golint ipamd/*/*.go
golint pkg/ipamd/*.go
golint pkg/ipamd/*/*.go

# go vet
vet:
GOOS=linux go vet
GOOS=linux go vet ./...

docker-vet: build-docker-test
docker run -e GO111MODULE=on \
Expand All @@ -120,7 +120,8 @@ docker-vet: build-docker-test
clean:
rm -f aws-k8s-agent
rm -f aws-cni
rm -f cni-metrics-helper/cni-metrics-helper
rm -f grpc-health-probe
rm -f cni-metrics-helper
rm -f portmap

files := $(shell find . -not -name 'mock_publisher.go' -not -name 'rpc.pb.go' -not -name 'integration_test.go' -name '*.go' -print)
Expand Down
5 changes: 2 additions & 3 deletions main.go → cmd/aws-k8s-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ package main
import (
"os"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"

"github.com/aws/amazon-vpc-cni-k8s/ipamd"
log "github.com/cihub/seelog"

"github.com/aws/amazon-vpc-cni-k8s/pkg/eniconfig"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd"
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
)

const (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/golang/glog"
"github.com/spf13/pflag"

"github.com/aws/amazon-vpc-cni-k8s/cni-metrics-helper/metrics"
"github.com/aws/amazon-vpc-cni-k8s/cmd/cni-metrics-helper/metrics"
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
"github.com/aws/amazon-vpc-cni-k8s/pkg/publisher"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func init() {
log.SetFlags(0)
flag.StringVar(&remoteURL, "addr", "", "(required) tcp host:port to connect")
flag.StringVar(&serviceName, "service", "", "service name to check (default: \"\")")
flag.StringVar(&userAgent, "user-agent", "grpc_health_probe", "user-agent header value of health check requests")
flag.StringVar(&userAgent, "user-agent", "grpc-health-probe", "user-agent header value of health check requests")
// timeouts
flag.DurationVar(&connTimeoutDur, "connect-timeout", connTimeoutDur, "timeout for establishing connection")
flag.DurationVar(&rpcTimeoutDur, "rpc-timeout", rpcTimeoutDur, "timeout for health check rpc")
Expand Down
20 changes: 7 additions & 13 deletions plugins/routed-eni/cni.go → cmd/routed-eni-cni-plugin/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,22 @@ import (
"runtime"
"strings"

"github.com/aws/amazon-vpc-cni-k8s/ipamd/datastore"

"github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils"

"golang.org/x/net/context"
"google.golang.org/grpc"

log "github.com/cihub/seelog"

"github.com/pkg/errors"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"

"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
cniSpecVersion "github.com/containernetworking/cni/pkg/version"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"

"github.com/aws/amazon-vpc-cni-k8s/cmd/routed-eni-cni-plugin/driver"
"github.com/aws/amazon-vpc-cni-k8s/pkg/grpcwrapper"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils"
"github.com/aws/amazon-vpc-cni-k8s/pkg/rpcwrapper"
"github.com/aws/amazon-vpc-cni-k8s/pkg/typeswrapper"
"github.com/aws/amazon-vpc-cni-k8s/plugins/routed-eni/driver"
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
pb "github.com/aws/amazon-vpc-cni-k8s/rpc"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
"github.com/containernetworking/cni/pkg/skel"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"

mock_driver "github.com/aws/amazon-vpc-cni-k8s/cmd/routed-eni-cni-plugin/driver/mocks"
mock_grpcwrapper "github.com/aws/amazon-vpc-cni-k8s/pkg/grpcwrapper/mocks"
mock_rpcwrapper "github.com/aws/amazon-vpc-cni-k8s/pkg/rpcwrapper/mocks"
mock_typeswrapper "github.com/aws/amazon-vpc-cni-k8s/pkg/typeswrapper/mocks"
mock_driver "github.com/aws/amazon-vpc-cni-k8s/plugins/routed-eni/driver/mocks"
"github.com/aws/amazon-vpc-cni-k8s/rpc"
mock_rpc "github.com/aws/amazon-vpc-cni-k8s/rpc/mocks"
"google.golang.org/grpc"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions config/v1.5/aws-k8s-cni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ spec:
name: aws-node
#readinessProbe:
# exec:
# command: ["/app/grpc_health_probe", "-addr=:50051"]
# command: ["/app/grpc-health-probe", "-addr=:50051"]
# initialDelaySeconds: 25
#livenessProbe:
# exec:
# command: ["/app/grpc_health_probe", "-addr=:50051"]
# command: ["/app/grpc-health-probe", "-addr=:50051"]
# initialDelaySeconds: 25
env:
- name: AWS_VPC_K8S_CNI_LOGLEVEL
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions ipamd/ipamd.go → pkg/ipamd/ipamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ import (
"sync/atomic"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
log "github.com/cihub/seelog"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/util/sets"

"github.com/aws/aws-sdk-go/aws"

"github.com/aws/aws-sdk-go/service/ec2"

"github.com/aws/amazon-vpc-cni-k8s/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/awsutils"
"github.com/aws/amazon-vpc-cni-k8s/pkg/cri"
"github.com/aws/amazon-vpc-cni-k8s/pkg/eniconfig"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
"github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils"
)
Expand Down
10 changes: 4 additions & 6 deletions ipamd/ipamd_test.go → pkg/ipamd/ipamd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@ import (
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/vishvananda/netlink"

"github.com/aws/amazon-vpc-cni-k8s/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/apis/crd/v1alpha1"
"github.com/aws/amazon-vpc-cni-k8s/pkg/awsutils"
mock_awsutils "github.com/aws/amazon-vpc-cni-k8s/pkg/awsutils/mocks"
"github.com/aws/amazon-vpc-cni-k8s/pkg/cri"
mock_cri "github.com/aws/amazon-vpc-cni-k8s/pkg/cri/mocks"
mock_eniconfig "github.com/aws/amazon-vpc-cni-k8s/pkg/eniconfig/mocks"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
mock_k8sapi "github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi/mocks"
mock_networkutils "github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils/mocks"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/aws/aws-sdk-go/service/ec2"
)

const (
Expand Down
File renamed without changes.
8 changes: 3 additions & 5 deletions ipamd/rpc_handler.go → pkg/ipamd/rpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ import (
"os/signal"
"syscall"

log "github.com/cihub/seelog"
"github.com/pkg/errors"

pb "github.com/aws/amazon-vpc-cni-k8s/rpc"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/reflection"

log "github.com/cihub/seelog"

"github.com/aws/amazon-vpc-cni-k8s/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
pb "github.com/aws/amazon-vpc-cni-k8s/rpc"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"context"
"testing"

"github.com/aws/amazon-vpc-cni-k8s/ipamd/datastore"
"github.com/aws/amazon-vpc-cni-k8s/pkg/ipamd/datastore"
"github.com/aws/aws-sdk-go/aws"

pb "github.com/aws/amazon-vpc-cni-k8s/rpc"
Expand Down
2 changes: 1 addition & 1 deletion scripts/dockerfiles/Dockerfile.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN yum update -y && \

WORKDIR /app

COPY --from=builder /go/src/github.com/aws/amazon-vpc-cni-k8s/cni-metrics-helper/cni-metrics-helper /app
COPY --from=builder /go/src/github.com/aws/amazon-vpc-cni-k8s/cni-metrics-helper /app

# Copy our bundled certs to the first place go will check: see
# https://golang.org/src/pkg/crypto/x509/root_unix.go
Expand Down
2 changes: 1 addition & 1 deletion scripts/dockerfiles/Dockerfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY --from=builder /go/src/github.com/aws/amazon-vpc-cni-k8s/aws-cni \
/go/src/github.com/aws/amazon-vpc-cni-k8s/misc/10-aws.conflist \
/go/src/github.com/aws/amazon-vpc-cni-k8s/portmap \
/go/src/github.com/aws/amazon-vpc-cni-k8s/aws-k8s-agent \
/go/src/github.com/aws/amazon-vpc-cni-k8s/grpc_health_probe \
/go/src/github.com/aws/amazon-vpc-cni-k8s/grpc-health-probe \
/go/src/github.com/aws/amazon-vpc-cni-k8s/scripts/aws-cni-support.sh \
/go/src/github.com/aws/amazon-vpc-cni-k8s/scripts/entrypoint.sh /app/

Expand Down
6 changes: 3 additions & 3 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ if [ ! -f aws-k8s-agent ]; then
echo "Required aws-k8s-agent executable not found."
exit 1
fi
if [ ! -f grpc_health_probe ]; then
echo "Required grpc_health_probe executable not found."
if [ ! -f grpc-health-probe ]; then
echo "Required grpc-health-probe executable not found."
exit 1
fi

Expand All @@ -45,7 +45,7 @@ wait_for_ipam() {

until [ $__sleep_time -eq 8 ]; do
sleep $(( __sleep_time++ ))
if $(./grpc_health_probe -addr 127.0.0.1:50051 >/dev/null 2>&1); then
if $(./grpc-health-probe -addr 127.0.0.1:50051 >/dev/null 2>&1); then
return 0
fi
done
Expand Down