Skip to content

Commit

Permalink
Merge pull request #250 from aws/main
Browse files Browse the repository at this point in the history
Merge main into release-1.1
  • Loading branch information
jchen6585 authored Apr 16, 2024
2 parents 8449a8a + 3b117c2 commit 7fdfc7a
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 170 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go Version
run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: '1.21.5'
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Install `govulncheck`
run: go install golang.org/x/vuln/cmd/govulncheck@latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ config/
vendor/
scripts/results.log
amazon-network-policy-controller-k8s

# Test build files
test/build/
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.21.9
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @aws/eks-networking
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Build the manager binary
FROM public.ecr.aws/eks-distro-build-tooling/golang:1.21.7-8-gcc-al2 as builder
ARG golang_image

FROM $golang_image as builder

ARG TARGETOS
ARG TARGETARCH

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM public.ecr.aws/eks-distro-build-tooling/golang:1.21.7-8-gcc-al2
ARG golang_image

FROM $golang_image

WORKDIR /go/src/github.com/aws/aws-network-policy-agent

# Force the go compiler to use modules.
Expand Down
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
IMAGE ?= amazon/aws-network-policy-agent
VERSION ?= $(shell git describe --tags --always --dirty || echo "unknown")
IMAGE_NAME = $(IMAGE)$(IMAGE_ARCH_SUFFIX):$(VERSION)
GOLANG_VERSION ?= $(shell cat .go-version)
GOLANG_IMAGE ?= public.ecr.aws/eks-distro-build-tooling/golang:$(GOLANG_VERSION)-gcc-al2
# TEST_IMAGE is the testing environment container image.
TEST_IMAGE = aws-network-policy-agent-test
TEST_IMAGE_NAME = $(TEST_IMAGE)$(IMAGE_ARCH_SUFFIX):$(VERSION)
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))

export GOPROXY = direct
export GOSUMDB = sum.golang.org
export GOTOOLCHAIN = go$(GOLANG_VERSION)

# aws-ebpf-sdk-go override in case we need to build against a custom version
EBPF_SDK_OVERRIDE ?= "n"
Expand Down Expand Up @@ -155,26 +160,27 @@ build-bpf: ## Build BPF.
#docker-build: test ## Build docker image with the manager.
# docker build -t ${IMAGE_NAME} .
docker-build: setup-ebpf-sdk-override## Build docker image with the manager.
docker build -t ${IMAGE_NAME} .
docker build -t ${IMAGE_NAME} --build-arg golang_image="$(GOLANG_IMAGE)" .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMAGE_NAME}

##@ Build and Run Unit Tests
##@ Build and Run Unit Tests
# Build the unit test driver container image.
build-docker-test: ## Build the unit test driver container image.
docker build $(DOCKER_BUILD_FLAGS_NP_AGENT) \
-f Dockerfile.test \
-t $(TEST_IMAGE_NAME) \
--build-arg golang_image="$(GOLANG_IMAGE)" \
.

# Run unit tests inside of the testing container image.
docker-unit-tests: build-docker-test ## Run unit tests inside of the testing container image.
docker run $(DOCKER_RUN_ARGS) \
$(TEST_IMAGE_NAME) \
make test


# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
Expand All @@ -194,6 +200,7 @@ docker-buildx: setup-ebpf-sdk-override ## Build and push docker image for the ma
--platform "$(PLATFORMS)"\
--cache-from=type=gha \
--cache-to=type=gha,mode=max \
--build-arg golang_image="$(GOLANG_IMAGE)" \
.
- docker buildx rm project-v3-builder
rm Dockerfile.cross
Expand All @@ -208,6 +215,7 @@ multi-arch-build-and-push: setup-ebpf-sdk-override ## Build and push docker imag
--cache-from=type=gha \
--cache-to=type=gha,mode=max \
-t $(IMAGE):$(VERSION) \
--build-arg golang_image="$(GOLANG_IMAGE)" \
--push \
.

Expand Down Expand Up @@ -269,7 +277,7 @@ $(CONTROLLER_GEN): $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20230216140739-c98506dc3b8e

# Check formatting of source code files without modification.
check-format: FORMAT_FLAGS = -l
Expand Down Expand Up @@ -305,7 +313,7 @@ update-node-agent-image: ## Updates node agent image on an existing cluster. Opt
./scripts/update-node-agent-image.sh AWS_EKS_NODEAGENT=$(AWS_EKS_NODEAGENT) IP_FAMILY=$(IP_FAMILY)

./PHONY: update-image-and-test
update-image-and-test: ## Updates node agent image on existing cluster and runs cyclonus tests. Call with CLUSTER_NAME=<name of the cluster> and AWS_EKS_NODEAGENT=<Image URI>
update-image-and-test: ## Updates node agent image on existing cluster and runs cyclonus tests. Call with CLUSTER_NAME=<name of the cluster> and AWS_EKS_NODEAGENT=<Image URI>
$(MAKE) update-node-agent-image AWS_EKS_NODEAGENT=$(AWS_EKS_NODEAGENT)
$(MAKE) run-cyclonus-test CLUSTER_NAME=$(CLUSTER_NAME) SKIP_ADDON_INSTALLATION=true

Expand All @@ -320,3 +328,8 @@ clean: # Clean temporary files and build artifacts from the project
@rm -f -- aws-eks-na-cli
@rm -f -- aws-eks-na-cli-v6
@rm -f -- coverage.txt

build-test-binaries: # Builds the test suite binaries
mkdir -p ${MAKEFILE_PATH}test/build
find ${MAKEFILE_PATH}test -name '*suite_test.go' -type f | xargs dirname | xargs ginkgo build
find ${MAKEFILE_PATH}test -name "*.test" -print0 | xargs -0 -I {} mv {} ${MAKEFILE_PATH}test/build
39 changes: 20 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ module github.com/aws/aws-network-policy-agent
go 1.21

require (
github.com/aws/amazon-vpc-cni-k8s v1.12.1-0.20240206190757-c7ed274bef5f
github.com/aws/amazon-vpc-cni-k8s v1.18.0
github.com/aws/aws-ebpf-sdk-go v1.0.7
github.com/aws/aws-sdk-go v1.50.9
github.com/aws/aws-sdk-go v1.50.30
github.com/go-logr/logr v1.4.1
github.com/go-logr/zapr v1.3.0
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.4.0
github.com/google/uuid v1.6.0
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.31.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/client_golang v1.19.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/vishvananda/netlink v1.2.1-beta.2
go.uber.org/zap v1.26.0
golang.org/x/sys v0.16.0
google.golang.org/grpc v1.61.0
go.uber.org/zap v1.27.0
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.62.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.1
sigs.k8s.io/controller-runtime v0.17.0
sigs.k8s.io/controller-runtime v0.17.2
)

require (
Expand All @@ -42,7 +42,7 @@ require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
Expand All @@ -52,27 +52,26 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.16.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -85,3 +84,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace golang.org/x/net => golang.org/x/net v0.23.0
Loading

0 comments on commit 7fdfc7a

Please sign in to comment.