This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
generated from meshery/meshery-adapter-template
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from theBeginner86/theBeginner86-patch-1
[chore] Normalised Makefile
- Loading branch information
Showing
2 changed files
with
106 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>/${PORT}/g' {} + | ||
find . -type f -exec sed -i '' -e 's/<go_version>/${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/[email protected]) | ||
|
||
.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 ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |