Skip to content

Commit

Permalink
move proto stuff to aks-node-controller folder
Browse files Browse the repository at this point in the history
  • Loading branch information
r2k1 committed Nov 20, 2024
1 parent addae8b commit fdb1bd7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 47 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ on:
push:
paths:
- "aks-node-controller/proto/**"
- "buf.yaml"
- "buf.gen.yaml"
- "aks-node-controller/buf.yaml"
- "aks-node-controller/buf.gen.yaml"
- ".github/workflows/buf.yaml"
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
paths:
- "aks-node-controller/proto/**"
- "buf.yaml"
- "buf.gen.yaml"
- "aks-node-controller/buf.yaml"
- "aks-node-controller/buf.gen.yaml"
- ".github/workflows/buf.yaml"
permissions:
contents: read
Expand Down
19 changes: 0 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,6 @@ validate-image-version:
generate-kubelet-flags:
@./e2e/kubelet/generate-kubelet-flags.sh

BUF = docker run --volume "$(CURDIR):$(CURDIR)" --workdir $(CURDIR) bufbuild/buf:1.47.2

.PHONY: lint-proto-files
lint-proto-files:
@($(BUF) lint)
@($(BUF) breaking --against '.git#branch=dev') # TODO: change to master

.PHONY: compile-proto-files
compile-proto-files:
@($(BUF) format -w)
protoc -I
$(MAKE) lint-proto-files

.PHONY: proto-generate
proto-generate:
protoc --go_opt=module=github.com/Azure/agentbaker/aks-node-controller --go_out=./ --proto_path=proto $(find proto/aksnodeconfig/v1 -name '*.proto')



.PHONY: generate-manifest
generate-manifest:
./hack/tools/bin/cue export ./schemas/manifest.cue > ./parts/linux/cloud-init/artifacts/manifest.json
Expand Down
14 changes: 11 additions & 3 deletions aks-node-controller/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
.PHONY: proto-generate
.PHONY: proto-generate lint-proto-files
proto-generate:
docker build -t protoc-docker - < protoc.Dockerfile
docker run --rm -v $(shell pwd):/$(shell pwd) --workdir=$(shell pwd) protoc-docker protoc --go_opt=module=github.com/Azure/agentbaker/aks-node-controller --go_out=./ --proto_path=proto $(shell find proto/aksnodeconfig/v1 -name '*.proto')
docker build --platform $(shell uname -m) -t protoc-docker - < protoc.Dockerfile
docker run --rm -v $(shell pwd):/$(shell pwd) --workdir=$(shell pwd) protoc-docker protoc --go_opt=module=github.com/Azure/agentbaker/aks-node-controller --go_out=./ --proto_path=proto $(shell find proto/aksnodeconfig/v1 -name '*.proto')
$(MAKE) proto-lint


BUF = docker run --volume "$(CURDIR)/../:$(CURDIR)/../" --workdir $(CURDIR) bufbuild/buf:1.47.2

proto-lint:
@($(BUF) lint)
@($(BUF) breaking --against '../.git#branch=dev,subdir=aks-node-controller') # TODO: change to master
2 changes: 1 addition & 1 deletion buf.yaml → aks-node-controller/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: v2
modules:
- path: aks-node-controller/proto
- path: proto
lint:
use:
- STANDARD
Expand Down
36 changes: 27 additions & 9 deletions aks-node-controller/protoc.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
# Use a multi-stage build to handle different architectures
FROM golang:1.23.3-alpine3.20

ARG TARGETARCH
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip; \
# Define build-time arguments for the protobuf and gRPC versions
ARG PROTOC_VERSION=28.3
ARG PROTOC_GEN_GO_VERSION=1.35.2

# Determine architecture and set appropriate URLs
RUN set -e; \
ARCH=`uname -m`; \
apk add --no-cache wget unzip; \
if [ "$ARCH" = "x86_64" ]; then \
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"; \
PROTOC_GEN_GO_URL="https://github.com/protocolbuffers/protobuf-go/releases/download/v${PROTOC_GEN_GO_VERSION}/protoc-gen-go.v${PROTOC_GEN_GO_VERSION}.linux.amd64.tar.gz"; \
elif [ "$ARCH" = "aarch64" ]; then \
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-aarch_64.zip"; \
PROTOC_GEN_GO_URL="https://github.com/protocolbuffers/protobuf-go/releases/download/v${PROTOC_GEN_GO_VERSION}/protoc-gen-go.v${PROTOC_GEN_GO_VERSION}.linux.arm64.tar.gz"; \
else \
wget -O protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-aarch_64.zip; \
fi && \
unzip protoc.zip -d /usr/local && \
rm protoc.zip
RUN go install google.golang.org/protobuf/cmd/[email protected]
echo "Unsupported architecture: $ARCH" && exit 1; \
fi; \
\
# Download and install protobuf compiler
wget -O protoc.zip $PROTOC_URL; \
unzip protoc.zip -d /usr/local; \
rm protoc.zip; \
\
# Download and install protobuf Go plugin
wget -O protoc-gen-go.tar.gz $PROTOC_GEN_GO_URL; \
tar -xzf protoc-gen-go.tar.gz -C /usr/local/bin; \
rm protoc-gen-go.tar.gz

# Default command
CMD ["protoc"]
11 changes: 0 additions & 11 deletions buf.gen.yaml

This file was deleted.

0 comments on commit fdb1bd7

Please sign in to comment.