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

refactor: remove root module #54

Merged
merged 17 commits into from
Jan 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.2
go-version: 1.21.3
- run: |
make build-client-all

13 changes: 8 additions & 5 deletions .github/workflows/check-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Test coverage"
name: "Test Client Module Coverage"
on:
push:
branches: ["main"]
Expand All @@ -17,15 +17,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Run unit tests with coverage
run: make test-coverage
run: make test-coverage-client
- name: Remove mocks.go lines from coverage_raw.out
run: |
pushd client
sed '/mocks.go/d' coverage_raw.out > coverage.out
popd
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1
with:
working-directory: client
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
path-to-lcov: coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}

path-to-lcov: client/coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}
13 changes: 10 additions & 3 deletions .github/workflows/golangci-lint-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'
- uses: actions/checkout@v3
- name: golangci-lint
- name: golangci-lint-client
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
version: v1.54
working-directory: client
only-new-issues: true
- name: golangci-lint-service
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
working-directory: service
only-new-issues: true
12 changes: 9 additions & 3 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'
- uses: actions/checkout@v3
- name: golangci-lint
- name: golangci-lint-client
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
version: v1.54
working-directory: client
- name: golangci-lint-service
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
working-directory: service
71 changes: 37 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ else
GOBIN=$(shell go env GOBIN)
endif

# Default arch is amd64.
ARCH=amd64

# Setting SHELL to bash allows bash commands to be executed by recipes.
Expand All @@ -16,9 +17,6 @@ ARCH=amd64
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: build

##@ General

# The help target prints out all targets with their descriptions organized
Expand All @@ -39,68 +37,73 @@ help: ## Display this help.
##@ Development

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
fmt: fmt-client

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
vet: vet-client

.PHONY: fmt-client
fmt-client:
pushd $(PROJECT_DIR)/client && go fmt ./... && popd

.PHONY: fmt-vet
fmt-vet:
@$(MAKE) fmt
@$(MAKE) vet
.PHONY: vet-client
vet-client:
pushd $(PROJECT_DIR)/client && go vet ./... && popd

.PHONY: test
test: ## Test all applicable go packages.
go test $(shell go list ./pkg... | grep -v proto | grep -v vendor | grep -v mock)
test: test-client

.PHONY: test-coverage
test-coverage:
go test $(shell go list ./pkg... | grep -v proto | grep -v vendor | grep -v mock) -coverprofile coverage_raw.out -covermode count
.PHONY: coverage
coverage: test-coverage-client

##@ Build
.PHONY: test-client
test-client: ## Test all applicable go packages within the client module.
pushd $(PROJECT_DIR)/client && go test $(shell go list ./... | grep -v proto | grep -v vendor | grep -v mock) && popd

.PHONY: test-coverage-client
test-coverage-client: ## Test all applicable go packages within the client module and calculate coverage.
pushd $(PROJECT_DIR)/client && go test $(shell go list ./... | grep -v proto | grep -v vendor | grep -v mock) -coverprofile coverage_raw.out -covermode count && popd

.PHONY: protobuf
protobuf: # Generates protobuf implementation files within the service module.
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/protos/bootstrap.proto

.PHONY: generate
generate: mockgen ## Generate gomocks.
generate: mockgen ## Generates gomocks in both the service and client modules.
bin/mockgen \
-copyright_file=hack/copyright_header.txt \
-source=service/protos/bootstrap_grpc.pb.go \
-destination=service/protos/mocks/mock_client.go \
-package=mocks github.com/Azure/aks-secure-tls-bootstrap/service/protos \
SecureTLSBootstrapServiceClient
go generate ./...
pushd $(PROJECT_DIR)/client && go generate ./... && popd

.PHONY: protobuf
protobuf:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/protos/bootstrap.proto
mockgen:
$(call go-install-tool,$(PROJECT_DIR)/bin/mockgen,go.uber.org/mock/mockgen@v0.2.0)

##@ Build

.PHONY: build-client-all
build-client-all: fmt vet ## Builds the client binary for all platforms
build-client-all: fmt vet ## Builds the client binary for all platforms/architectures.
@$(MAKE) build-client-linux ARCH=amd64
@$(MAKE) build-client-linux ARCH=arm64
@$(MAKE) build-client-windows ARCH=amd64
@$(MAKE) build-client-windows ARCH=arm64

.PHONY: build-client-linux
build-client-linux: ## Builds a linux binary for the specified architecture
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -o bin/tls-bootstrap-client-$(ARCH) cmd/client/main.go
build-client-linux: ## Builds the client binary for the specified linux architecture.
pushd $(PROJECT_DIR)/client && CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -o bin/tls-bootstrap-client-$(ARCH) cmd/main.go && popd

.PHONY: build-client-windows
build-client-windows: ## Builds a windows binary for the specified architecture
CGO_ENABLED=0 GOOS=windows GOARCH=$(ARCH) go build -o bin/tls-bootstrap-client-$(ARCH).exe cmd/client/main.go

.PHONY: build
build: fmt vet # Build client binary
go build -o bin/tls-bootstrap-client cmd/client/main.go

mockgen:
$(call go-install-tool,$(PROJECT_DIR)/bin/mockgen,go.uber.org/mock/mockgen@v0.2.0)
build-client-windows: ## Builds the client binary for the specified windows architecture.
pushd $(PROJECT_DIR)/client && CGO_ENABLED=0 GOOS=windows GOARCH=$(ARCH) go build -o bin/tls-bootstrap-client-$(ARCH).exe cmd/main.go && popd

ifndef ignore-not-found
ignore-not-found = false
endif

##@ Util

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
Expand Down
3 changes: 3 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Client

This module supports the implementation of the AKS secure TLS bootstrap client.
2 changes: 1 addition & 1 deletion client/aad.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package client

//go:generate ../../bin/mockgen -copyright_file=../../hack/copyright_header.txt -destination=./mocks/mock_aad.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client AadClient
//go:generate ../bin/mockgen -copyright_file=../hack/copyright_header.txt -destination=./pkg/mocks/mock_aad.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client AadClient

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion client/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package client

//go:generate ../../bin/mockgen -source=file.go -copyright_file=../../hack/copyright_header.txt -destination=./mocks/mock_file.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client FileReader
//go:generate ../bin/mockgen -source=file.go -copyright_file=../hack/copyright_header.txt -destination=./pkg/mocks/mock_file.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client FileReader

import "os"

Expand Down
2 changes: 1 addition & 1 deletion client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Azure/aks-secure-tls-bootstrap/client

go 1.21.3
go 1.21

require (
github.com/Azure/aks-secure-tls-bootstrap/service v0.1.0-alpha.0
Expand Down
2 changes: 1 addition & 1 deletion client/imds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package client

//go:generate ../../bin/mockgen -copyright_file=../../hack/copyright_header.txt -destination=./mocks/mock_imds.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client ImdsClient
//go:generate ../bin/mockgen -copyright_file=../hack/copyright_header.txt -destination=./pkg/mocks/mock_imds.go -package=mocks github.com/Azure/aks-secure-tls-bootstrap/client ImdsClient

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion client/pkg/mocks/mock_aad.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/pkg/mocks/mock_imds.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 0 additions & 78 deletions cmd/client/main.go

This file was deleted.

Loading
Loading