Skip to content

Commit

Permalink
Merge pull request #53 from almaslennikov/housekeeping
Browse files Browse the repository at this point in the history
Housekeeping
  • Loading branch information
ykulazhenkov committed Jul 20, 2023
2 parents c2985bf + 1f0c705 commit 1bdd521
Show file tree
Hide file tree
Showing 31 changed files with 391 additions and 738 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.18.x]
go-version: [1.20.x]
goarch: [amd64]
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
file: ./Dockerfile

create-push-manifest:
needs: [build-push-amd64]
needs: [ build-push-amd64 ]
runs-on: ubuntu-latest
steps:
- name: Set repository as lower-case output variable
Expand Down Expand Up @@ -77,6 +77,6 @@ jobs:
- name: Create manifest for multi-arch images
env:
REPOSITORY: ghcr.io/${{ steps.repo_name.outputs.repository }}
run: |
docker buildx imagetools create -t ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64
docker buildx imagetools create -t ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64
run: docker buildx imagetools create \
-t ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64 \
-t ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64
26 changes: 26 additions & 0 deletions .github/workflows/static-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: go-static-analysis
on: [push, pull_request]
jobs:
golangci:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: checkout PR
uses: actions/checkout@v2
- name: run make lint
run: make lint
hadolint:
runs-on: ubuntu-22.04
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: checkout PR
uses: actions/checkout@v2
- name: run make hadolint
run: make hadolint
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.18.x]
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.20.x

- name: Checkout code
uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ linters:
- contextcheck
#- cyclop
- decorder
- depguard
- dogsled
- durationcheck
- errcheck
Expand Down
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
# Build go project
FROM golang:1.18 as go-build
FROM golang:1.20 as go-build

# Add everything
ADD . /usr/src/multi-networkpolicy-tc
COPY . /usr/src/multi-networkpolicy-tc

RUN cd /usr/src/multi-networkpolicy-tc && \
go build ./cmd/multi-networkpolicy-tc/
WORKDIR /usr/src/multi-networkpolicy-tc
RUN go build ./cmd/multi-networkpolicy-tc/

# Build iproute2
FROM quay.io/centos/centos:stream8 as iproute-build

ARG IPROUTE2_TAG=v5.17.0

RUN dnf -q -y groupinstall "Development Tools"
RUN dnf -q -y install git libmnl-devel
RUN dnf -q -y groupinstall "Development Tools" && dnf -q -y install libmnl-devel-1.0.4-6.el8 && dnf clean all

RUN git clone --branch ${IPROUTE2_TAG} https://github.com/shemminger/iproute2.git

WORKDIR /iproute2
RUN make && make install

RUN git clone --branch ${IPROUTE2_TAG} https://github.com/shemminger/iproute2.git && \
cd /iproute2 && make && make install

# collect everything into target container
# TODO(adrianc): once we switch to native netlink to drive TC we can switch back to distroless
#FROM gcr.io/distroless/base
FROM quay.io/centos/centos:stream8
LABEL io.k8s.display-name="Multus NetworkPolicy TC" \
io.k8s.description="This is a component provides NetworkPolicy objects for secondary interfaces created with Multus CNI"
RUN dnf -q -y install git libmnl
RUN dnf -q -y install libmnl-1.0.4-6.el8 && dnf clean all
COPY --from=go-build /usr/src/multi-networkpolicy-tc/multi-networkpolicy-tc /usr/bin
COPY --from=iproute-build /sbin/tc /sbin
WORKDIR /usr/bin
Expand Down
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ unit-test: envtest ## Run unit tests.
.PHONY: test
test: lint unit-test ## Run all tests (lint, unit-test).

HADOLINT_TOOL = $(BIN_DIR)/hadolint
$(HADOLINT_TOOL): | $(BASE) ; $(info installing hadolint...)
$(call wget-install-tool,$(HADOLINT_TOOL),"https://github.com/hadolint/hadolint/releases/download/v2.12.1-beta/hadolint-Linux-x86_64")

GOVERALLS = $(BIN_DIR)/goveralls
$(GOVERALLS): | $(BASE) ; $(info installing goveralls...)
$(call go-install-tool,$(GOVERALLS),github.com/mattn/goveralls@latest)

.PHONY: test-coverage
test-coverage: | envtest gocovmerge gcov2lcov ## Run coverage tests
mkdir -p $(PROJECT_DIR)/build/coverage/pkgs
Expand Down Expand Up @@ -129,7 +137,7 @@ kustomize: ## Download kustomize locally if necessary.

.PHONY: golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-install-tool,$(GOLANGCILINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0)
$(call go-install-tool,$(GOLANGCILINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3)

.PHONY: mockery
mockery: ## Download mockery if necessary.
Expand All @@ -147,6 +155,10 @@ gocovmerge: ## Download gocovmerge if necessary
gcov2lcov: ## Download gcov2lcov if necessary
$(call go-install-tool,$(GCOV2LCOV),github.com/jandelgado/gcov2lcov@v1.0.5)

.PHONY: hadolint
hadolint: $(BASE) $(HADOLINT_TOOL); $(info running hadolint...) @ ## Run hadolint
$Q $(HADOLINT_TOOL) Dockerfile

.PHONY: clean
clean:
@rm -rf build
Expand All @@ -161,3 +173,12 @@ echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
}
endef

define wget-install-tool
@[ -f $(1) ] || { \
mkdir -p $(BIN_DIR);\
echo "Downloading $(2)" ;\
wget -O $(1) $(2);\
chmod +x $(1) ;\
}
endef
141 changes: 73 additions & 68 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,99 +1,104 @@
module github.com/k8snetworkplumbingwg/multi-networkpolicy-tc

go 1.18
go 1.20

require (
github.com/Mellanox/sriovnet v1.1.0
github.com/containernetworking/cni v1.1.1
github.com/google/uuid v1.1.2
github.com/k8snetworkplumbingwg/multi-networkpolicy v0.0.0-20220419111628-220baf5d60c1
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.3.0
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/containernetworking/cni v1.1.2
github.com/google/uuid v1.3.0
github.com/k8snetworkplumbingwg/multi-networkpolicy v0.0.0-20230301165931-f1873dc329c6
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.9.1
github.com/onsi/gomega v1.27.4
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.5.0
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.4
github.com/vishvananda/netlink v1.2.1-beta.2.0.20230206183746-70ca0345eede
golang.org/x/sys v0.0.0-20220804214406-8e32c043e418
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
k8s.io/klog/v2 v2.70.1
k8s.io/kubernetes v1.24.3
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
golang.org/x/sys v0.10.0
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/client-go v0.27.3
k8s.io/klog/v2 v2.100.1
k8s.io/kubernetes v1.27.3
k8s.io/utils v0.0.0-20230505201702-9f6742963106
sigs.k8s.io/controller-runtime v0.12.3
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.10.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // 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.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // 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/nxadm/tail v1.4.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.2 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace (
k8s.io/api => k8s.io/api v0.24.2
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2
k8s.io/apimachinery => k8s.io/apimachinery v0.24.2
k8s.io/apiserver => k8s.io/apiserver v0.24.2
k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2
k8s.io/client-go => k8s.io/client-go v0.24.2
k8s.io/cloud-provider => k8s.io/cloud-provider v0.24.2
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.24.2
k8s.io/code-generator => k8s.io/code-generator v0.24.2
k8s.io/component-base => k8s.io/component-base v0.24.2
k8s.io/component-helpers => k8s.io/component-helpers v0.24.2
k8s.io/controller-manager => k8s.io/controller-manager v0.24.2
k8s.io/cri-api => k8s.io/cri-api v0.24.2
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.24.2
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.24.2
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.24.2
k8s.io/kube-proxy => k8s.io/kube-proxy v0.24.2
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.24.2
k8s.io/kubectl => k8s.io/kubectl v0.24.2
k8s.io/kubelet => k8s.io/kubelet v0.24.2
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.24.2
k8s.io/metrics => k8s.io/metrics v0.24.2
k8s.io/mount-utils => k8s.io/mount-utils v0.24.2
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.2
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.2
k8s.io/api => k8s.io/api v0.27.3
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.27.3
k8s.io/apimachinery => k8s.io/apimachinery v0.27.3
k8s.io/apiserver => k8s.io/apiserver v0.27.3
k8s.io/cli-runtime => k8s.io/cli-runtime v0.27.3
k8s.io/client-go => k8s.io/client-go v0.27.3
k8s.io/cloud-provider => k8s.io/cloud-provider v0.27.3
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.27.3
k8s.io/code-generator => k8s.io/code-generator v0.27.3
k8s.io/component-base => k8s.io/component-base v0.27.3
k8s.io/component-helpers => k8s.io/component-helpers v0.27.3
k8s.io/controller-manager => k8s.io/controller-manager v0.27.3
k8s.io/cri-api => k8s.io/cri-api v0.27.3
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.27.3
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.27.3
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.27.3
k8s.io/kube-proxy => k8s.io/kube-proxy v0.27.3
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.27.3
k8s.io/kubectl => k8s.io/kubectl v0.27.3
k8s.io/kubelet => k8s.io/kubelet v0.27.3
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.27.3
k8s.io/metrics => k8s.io/metrics v0.27.3
k8s.io/mount-utils => k8s.io/mount-utils v0.27.3
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.27.3
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.27.3
)

0 comments on commit 1bdd521

Please sign in to comment.