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

*: add fips build support #201

Merged
merged 2 commits into from
Nov 27, 2023
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
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,33 @@ PACKAGES_TESTS ?= $$($(PACKAGE_LIST_TESTS))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/ng-monitoring/||'
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'

LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMBuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"

GO := GO111MODULE=on go
BUILD_TS := $(shell date -u '+%Y-%m-%d %H:%M:%S')
GIT_HASH := $(shell git rev-parse HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

BUILD_GOEXPERIMENT ?=
BUILD_CGO_ENABLED ?=
BUILD_TAGS ?=
ifeq ("${ENABLE_FIPS}", "1")
GIT_HASH := $(GIT_HASH) (with fips)
GIT_BRANCH := $(GIT_BRANCH) (with fips)
BUILD_TAGS += boringcrypto
BUILD_GOEXPERIMENT = GOEXPERIMENT=boringcrypto
BUILD_CGO_ENABLED = CGO_ENABLED=1
endif

LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMBuildTS=$(BUILD_TS)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitHash=$(GIT_HASH)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitBranch=$(GIT_BRANCH)"

GO := $(BUILD_GOEXPERIMENT) $(BUILD_CGO_ENABLED) GO111MODULE=on go
GOBUILD := $(GO) build
GOTEST := $(GO) test -p 8



default:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/ng-monitoring-server ./main.go
$(GOBUILD) -ldflags '$(LDFLAGS)' -tags '${BUILD_TAGS}' -o bin/ng-monitoring-server ./main.go
@echo Build successfully!

fmt:
Expand Down
3 changes: 3 additions & 0 deletions component/conprof/http/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func TestAPI(t *testing.T) {
mockServer := testutil.CreateMockProfileServer(t)
defer mockServer.Stop(t)

// wait for http server ready
time.Sleep(time.Second)

topoSubScribe := make(topology.Subscriber)
err := conprof.Init(ts.db, topoSubScribe)
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions utils/printer/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build boringcrypto
// +build boringcrypto

package printer

import _ "crypto/tls/fipsonly"