From 94a7a9507f09715c096da441cc61bd3dd163b1a9 Mon Sep 17 00:00:00 2001 From: Pranav Singh Date: Wed, 3 Aug 2022 21:47:46 +0530 Subject: [PATCH 1/2] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 05a9092f..72cbb71a 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ GOPATH = $(shell go env GOPATH) ## Run Meshery Adapter. run: - go mod tidy; \ + go mod tidy -compat=1.17; \ DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go run-force-dynamic-reg: From 80eadc7b27c9561edcd9f240a99c60c905341aa9 Mon Sep 17 00:00:00 2001 From: Pranav Singh Date: Wed, 3 Aug 2022 22:08:02 +0530 Subject: [PATCH 2/2] normalised Makefile Signed-off-by: Pranav Singh --- Makefile | 103 ++++++++++++++++++++++------------------- build/Makefile.core.mk | 50 ++++++++++++++++++++ 2 files changed, 106 insertions(+), 47 deletions(-) create mode 100644 build/Makefile.core.mk diff --git a/Makefile b/Makefile index 05a9092f..df96a782 100644 --- a/Makefile +++ b/Makefile @@ -1,70 +1,79 @@ +# Copyright Meshery Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include build/Makefile.core.mk include build/Makefile.show-help.mk -GOPATH = $(shell go env GOPATH) +#----------------------------------------------------------------------------- +# Environment Setup +#----------------------------------------------------------------------------- +BUILDER=buildx-multi-arch +ADAPTER=osm -## Run Meshery Adapter. -run: - go mod tidy; \ - DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go +v ?= 1.17.8 # Default go version to be used -run-force-dynamic-reg: - FORCE_DYNAMIC_REG=true DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go -protoc-setup: - cd meshes - wget https://raw.githubusercontent.com/layer5io/meshery/master/meshes/meshops.proto +#----------------------------------------------------------------------------- +# Docker-based Builds +#----------------------------------------------------------------------------- +.PHONY: docker docker-run lint proto-setup proto error test run run-force-dynamic-reg + -check: error +## Lint check Golang +lint: golangci-lint run -check-clean-cache: - golangci-lint cache clean +## Retrieve protos +proto-setup: + cd meshes + wget https://raw.githubusercontent.com/layer5io/meshery/master/meshes/meshops.proto +## Generate protos proto: protoc -I meshes/ meshes/meshops.proto --go_out=plugins=grpc:./meshes/ -## Build Docker Image for Meshery Adapter. +## Build Adapter container image with "edge-latest" tag docker: - docker build -t layer5/meshery-osm . + DOCKER_BUILDKIT=1 docker build -t layer5/meshery-$(ADAPTER):$(RELEASE_CHANNEL)-latest . -## Build and Run Docker Image for Meshery Adapter. +## Run Adapter container with "edge-latest" tag docker-run: - (docker rm -f meshery-osm) || true - docker run --name meshery-osm -d \ + (docker rm -f meshery-$(ADAPTER)) || true + docker run --name meshery-$(ADAPTER) -d \ -p 10009:10009 \ -e DEBUG=true \ - layer5/meshery-osm - -# setup-adapter sets up a new adapter with the given name & port -setup-adapter: - mv "osm" ${ADAPTER} - find . -type f -exec sed -i '' -e 's/osm/${ADAPTER}/g' {} + - find . -type f -exec sed -i '' -e 's//${PORT}/g' {} + - find . -type f -exec sed -i '' -e 's//${GO_VERSION}/g' {} + + layer5/meshery-$(ADAPTER):$(RELEASE_CHANNEL)-latest -## Run all Go checks. -go-all: go-tidy go-fmt go-vet golangci-lint - -go-fmt: - go fmt ./... - -go-vet: - go vet ./... - -go-tidy: - @echo "Executing go mod tidy" - go mod tidy +## Build and run Adapter locally +run: + go$(v) mod tidy -compat=1.17; \ + DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go -golangci-lint: $(GOLANGCILINT) - @echo - $(GOPATH)/bin/golangci-lint run +## Build and run Adapter locally; force component registration +run-force-dynamic-reg: + FORCE_DYNAMIC_REG=true DEBUG=true GOPROXY=direct GOSUMDB=off go run main.go +## Run Meshery Error utility error: - go run github.com/layer5io/meshkit/cmd/errorutil -d . update -i ./helpers -o ./helpers - -$(GOLANGCILINT): - (cd /; GO111MODULE=on GOPROXY="direct" GOSUMDB=off go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0) - -.PHONY: error golangci-lint tidy go-vet go-fmt go-all + go run github.com/layer5io/meshkit/cmd/errorutil -d . analyze -i ./helpers -o ./helpers + +## Run Golang tests +test: + export CURRENTCONTEXT="$(kubectl config current-context)" + echo "current-context:" ${CURRENTCONTEXT} + export KUBECONFIG="${HOME}/.kube/config" + echo "environment-kubeconfig:" ${KUBECONFIG} + GOPROXY=direct GOSUMDB=off GO111MODULE=on go test -v ./... diff --git a/build/Makefile.core.mk b/build/Makefile.core.mk new file mode 100644 index 00000000..8cf440b2 --- /dev/null +++ b/build/Makefile.core.mk @@ -0,0 +1,50 @@ +# Copyright Meshery Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------------- +# Global Variables +#----------------------------------------------------------------------------- +GIT_VERSION = $(shell git describe --tags `git rev-list --tags --max-count=1`) +GIT_COMMITSHA = $(shell git rev-list -1 HEAD) +GIT_STRIPPED_VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1` | cut -c 2-) + +GOVERSION = 1.17.8 +GOPATH = $(shell go env GOPATH) +GOBIN = $(GOPATH)/bin + +SHELL :=/bin/bash -o pipefail + +#----------------------------------------------------------------------------- +# Components +#----------------------------------------------------------------------------- +ADAPTER_URLS := "localhost:10000 localhost:10001 localhost:10002 localhost:10004 localhost:10005 localhost:10006 localhost:10007 localhost:10009 localhost:10010 localhost:10012" + +#----------------------------------------------------------------------------- +# Providers +#----------------------------------------------------------------------------- +REMOTE_PROVIDER_LOCAL="http://localhost:9876" +MESHERY_CLOUD_DEV="http://localhost:9876" +MESHERY_CLOUD_PROD="https://meshery.layer5.io" +MESHERY_CLOUD_STAGING="https://staging-meshery.layer5.io" + +#----------------------------------------------------------------------------- +# Server +#----------------------------------------------------------------------------- +MESHERY_K8S_SKIP_COMP_GEN ?= TRUE +APPLICATIONCONFIGPATH="../install/apps.json" + +#----------------------------------------------------------------------------- +# Build +#----------------------------------------------------------------------------- +RELEASE_CHANNEL=edge