Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/docker/alpine-3.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
komer3 authored Sep 20, 2024
2 parents 1f2946d + d610d40 commit f0722bd
Show file tree
Hide file tree
Showing 34 changed files with 1,913 additions and 1,793 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Install cryptsetup
run: |
sudo apt install libcryptsetup12 libcryptsetup-dev
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -25,7 +28,6 @@ jobs:
version: latest
- run: make build
- run: go test -cover ./... -coverprofile ./coverage.out
- run: make elevated-test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
Expand All @@ -46,6 +48,9 @@ jobs:
WORKER_NODES: ${{ github.ref == 'refs/heads/main' && '3' || '0' }}
E2E_SELECTOR: ${{ github.ref == 'refs/heads/main' && 'all' || 'quick' }}
steps:
- name: Install cryptsetup
run: |
sudo apt install libcryptsetup12 libcryptsetup-dev
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v3

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
check-latest: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _cgo_export.*
_output
_testmain.go
linode-blockstorage-csi-driver
test-cluster-kubeconfig.yaml

*.exe
*.test
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as builder
FROM golang:1.22.5-alpine AS builder
# from makefile
ARG REV

Expand All @@ -10,17 +10,18 @@ COPY go.sum .
COPY main.go .
COPY pkg ./pkg
COPY internal ./internal
RUN apk add cryptsetup cryptsetup-libs cryptsetup-dev gcc musl-dev pkgconfig

RUN go mod download

RUN go build -a -ldflags '-X main.vendorVersion='${REV}' -extldflags "-static"' -o /bin/linode-blockstorage-csi-driver /linode
RUN CGO_ENABLED=1 go build -a -ldflags '-X main.vendorVersion='${REV}'' -o /bin/linode-blockstorage-csi-driver /linode

FROM alpine:3.20.3
LABEL maintainers="Linode"
LABEL description="Linode CSI Driver"

COPY --from=builder /bin/linode-blockstorage-csi-driver /linode

RUN apk add --no-cache e2fsprogs findmnt blkid cryptsetup xfsprogs

RUN apk add --no-cache e2fsprogs findmnt blkid cryptsetup xfsprogs lsblk
COPY --from=builder /bin/linode-blockstorage-csi-driver /linode
ENTRYPOINT ["/linode"]
29 changes: 29 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM golang:1.22.5-alpine AS builder
# from makefile
ARG REV

RUN mkdir -p /linode
WORKDIR /linode

RUN apk add \
blkid \
cryptsetup \
cryptsetup-libs \
cryptsetup-dev \
e2fsprogs \
findmnt \
gcc \
lsblk \
make \
musl-dev \
pkgconfig \
xfsprogs

COPY go.mod go.sum ./
RUN go mod tidy

COPY . .

RUN CGO_ENABLED=1 go build -a -ldflags '-X main.vendorVersion='${REV}'' -o /bin/linode-blockstorage-csi-driver /linode
RUN CGO_ENABLED=1 go install go.uber.org/mock/mockgen@latest
CMD ["sh"]
40 changes: 21 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
PLATFORM ?= linux/amd64
REGISTRY_NAME ?= index.docker.io
IMAGE_NAME ?= linode/linode-blockstorage-csi-driver
DOCKER_USER ?= linode
IMAGE_NAME ?= linode-blockstorage-csi-driver
REV := $(shell git branch --show-current 2> /dev/null || echo "dev")
ifdef DEV_TAG_EXTENSION
IMAGE_VERSION ?= $(REV)-$(DEV_TAG_EXTENSION)
else
IMAGE_VERSION ?= $(REV)
IMAGE_TAG ?= $(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)
endif
IMAGE_TAG ?= $(REGISTRY_NAME)/$(DOCKER_USER)/$(IMAGE_NAME):$(IMAGE_VERSION)
GOLANGCI_LINT_IMG := golangci/golangci-lint:v1.59-alpine
RELEASE_DIR ?= release
DOCKERFILE ?= Dockerfile

#####################################################################
# OS / ARCH
Expand All @@ -24,19 +30,19 @@ endif
#####################################################################
.PHONY: fmt
fmt:
go fmt ./...
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) go fmt ./...

.PHONY: vet
vet: fmt
go vet ./...
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) go vet ./...

.PHONY: lint
lint: vet
docker run --rm -v $(PWD):/app -w /app ${GOLANGCI_LINT_IMG} golangci-lint run -v
docker run --rm --platform=$(PLATFORM) --rm -v $(PWD):/app -w /app ${GOLANGCI_LINT_IMG} golangci-lint run -v

.PHONY: verify
verify:
go mod verify
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) go mod verify

.PHONY: clean
clean:
Expand All @@ -59,22 +65,21 @@ WORKER_NODES ?= 0

.PHONY: build
build:
go build -o linode-blockstorage-csi-driver -a -ldflags '-X main.vendorVersion='${IMAGE_VERSION}' -extldflags "-static"' ./main.go
CGO_ENABLED=1 go build -o linode-blockstorage-csi-driver -a -ldflags '-X main.vendorVersion='${IMAGE_VERSION}'' ./main.go

.PHONY: docker-build
docker-build:
DOCKER_BUILDKIT=1 docker build --platform=$(PLATFORM) --progress=plain -t $(IMAGE_TAG) --build-arg REV=$(IMAGE_VERSION) -f ./Dockerfile .
DOCKER_BUILDKIT=1 docker build --platform=$(PLATFORM) --progress=plain -t $(IMAGE_TAG) --build-arg REV=$(IMAGE_VERSION) -f ./$(DOCKERFILE) .

.PHONY: docker-push
docker-push:
echo "[reminder] Did you run `make docker-build`?"
docker push $(IMAGE_TAG)

.PHONY: local-docker-setup
local-docker-setup: build docker-build docker-push
.PHONY: docker-setup
docker-setup: docker-build docker-push

.PHONY: mgmt-and-capl-cluster
mgmt-and-capl-cluster: local-docker-setup mgmt-cluster capl-cluster
mgmt-and-capl-cluster: docker-setup mgmt-cluster capl-cluster

.PHONY: capl-cluster
capl-cluster:
Expand All @@ -91,7 +96,7 @@ capl-cluster:

# Install CSI driver and wait for it to be ready
cat tests/e2e/setup/linode-secret.yaml | envsubst | KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f -
hack/generate-yaml.sh $(IMAGE_VERSION) $(IMAGE_NAME) |KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f -
hack/generate-yaml.sh $(IMAGE_VERSION) $(DOCKER_USER)/$(IMAGE_NAME) |KUBECONFIG=test-cluster-kubeconfig.yaml kubectl apply -f -
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl rollout status -n kube-system daemonset/csi-linode-node --timeout=600s
KUBECONFIG=test-cluster-kubeconfig.yaml kubectl rollout status -n kube-system statefulset/csi-linode-controller --timeout=600s

Expand Down Expand Up @@ -121,14 +126,11 @@ generate-mock:
mockgen -source=internal/driver/nodeserver_helpers.go -destination=mocks/mock_nodeserver.go -package=mocks
mockgen -source=pkg/mount-manager/device-utils.go -destination=mocks/mock_deviceutils.go -package=mocks
mockgen -source=pkg/mount-manager/fs-utils.go -destination=mocks/mock_fsutils.go -package=mocks
mockgen -source=pkg/cryptsetup-client/cryptsetup-client.go -destination=mocks/mock_cryptsetupclient.go -package=mocks

.PHONY: test
test: vet verify generate-mock
go test `go list ./... | grep -v ./mocks$$` -cover $(TEST_ARGS)

.PHONY: elevated-test
elevated-test:
sudo go test `go list ./... | grep -v ./mocks$$` -cover -tags=elevated $(TEST_ARGS)
test:
docker run --rm --platform=$(PLATFORM) --privileged -it $(IMAGE_TAG) go test `go list ./... | grep -v ./mocks$$` -cover $(TEST_ARGS)

.PHONY: e2e-test
e2e-test:
Expand Down
Loading

0 comments on commit f0722bd

Please sign in to comment.