-
Notifications
You must be signed in to change notification settings - Fork 3
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 #1 from flanksource/kubernetes-search-api
feat: add kubernetes search api
- Loading branch information
Showing
26 changed files
with
2,037 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Create Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
semantic-release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release-version: ${{ steps.semantic.outputs.release-version }} | ||
new-release-published: ${{ steps.semantic.outputs.new-release-published }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: codfish/semantic-release-action@v1 | ||
id: semantic | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
binary: | ||
runs-on: ubuntu-latest | ||
needs: semantic-release | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: v1.17.x | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
.bin | ||
key: cache-${{ hashFiles('**/go.sum') }}-${{ hashFiles('.bin/*') }} | ||
restore-keys: | | ||
cache- | ||
- run: make release | ||
env: | ||
VERSION: v${{ needs.semantic-release.outputs.release-version }} | ||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ./.release/* | ||
tag: v${{ needs.semantic-release.outputs.release-version }} | ||
overwrite: true | ||
file_glob: true | ||
docker: | ||
needs: semantic-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Publish to Registry | ||
uses: elgohr/Publish-Docker-Github-Action@master | ||
with: | ||
name: flanksource/apm-hub | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
snapshot: true | ||
tags: "latest,v${{ needs.semantic-release.outputs.release-version }}" |
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,7 @@ | ||
##IDEs | ||
.idea | ||
.vscode | ||
|
||
#Build | ||
.bin/ | ||
.release |
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,28 @@ | ||
branches: | ||
- name: main | ||
plugins: | ||
- - "@semantic-release/commit-analyzer" | ||
- releaseRules: | ||
- { type: doc, scope: README, release: patch } | ||
- { type: fix, release: patch } | ||
- { type: chore, release: patch } | ||
- { type: refactor, release: patch } | ||
- { type: feat, release: patch } | ||
- { type: ci, release: false } | ||
- { type: style, release: false } | ||
parserOpts: | ||
noteKeywords: | ||
- MAJOR RELEASE | ||
- "@semantic-release/release-notes-generator" | ||
- - "@semantic-release/github" | ||
- assets: | ||
- path: ./.bin/apm-hub_linux_amd64 | ||
name: apm-hub-amd64 | ||
- path: ./.bin/apm-hub_linux_arm64 | ||
name: apm-hub-amd64 | ||
- path: ./.bin/apm-hub.exe | ||
name: apm-hub.exe | ||
- path: ./.bin/apm-hub_darwin_amd64 | ||
name: apm-hub_osx-amd64 | ||
- path: ./.bin/apm-hub_darwin_arm64 | ||
name: apm-hub_osx-arm64 |
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,24 @@ | ||
FROM golang:1.17 as builder | ||
WORKDIR /app | ||
ARG VERSION | ||
COPY go.mod /app/go.mod | ||
COPY go.sum /app/go.sum | ||
RUN go mod download | ||
COPY ./ ./ | ||
WORKDIR /app | ||
RUN go version | ||
RUN make build | ||
|
||
FROM ubuntu:bionic | ||
WORKDIR /app | ||
|
||
# install CA certificates | ||
RUN apt-get update && \ | ||
apt-get install -y ca-certificates && \ | ||
rm -Rf /var/lib/apt/lists/* && \ | ||
rm -Rf /usr/share/doc && rm -Rf /usr/share/man && \ | ||
apt-get clean | ||
|
||
COPY --from=builder /app/.bin/apm-hub /app | ||
|
||
ENTRYPOINT ["/app/apm-hub"] |
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,44 @@ | ||
NAME=apm-hub | ||
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
ARCH = $(shell uname -m | sed 's/x86_64/amd64/') | ||
|
||
ifeq ($(VERSION),) | ||
VERSION_TAG=$(shell git describe --abbrev=0 --tags --exact-match 2>/dev/null || echo latest) | ||
else | ||
VERSION_TAG=$(VERSION) | ||
endif | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= docker.io/flanksource/apm-hub:${VERSION_TAG} | ||
|
||
.PHONY: build | ||
build: | ||
go build -o ./.bin/$(NAME) -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
|
||
.PHONY: linux | ||
linux: | ||
GOOS=linux GOARCH=amd64 go build -o ./.bin/$(NAME)_linux_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
GOOS=linux GOARCH=arm64 go build -o ./.bin/$(NAME)_linux_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
|
||
.PHONY: darwin | ||
darwin: | ||
GOOS=darwin GOARCH=amd64 go build -o ./.bin/$(NAME)_darwin_amd64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
GOOS=darwin GOARCH=arm64 go build -o ./.bin/$(NAME)_darwin_arm64 -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
|
||
.PHONY: windows | ||
windows: | ||
GOOS=windows GOARCH=amd64 go build -o ./.bin/$(NAME).exe -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go | ||
|
||
.PHONY: compress | ||
compress: | ||
# upx 3.95 has issues compressing darwin binaries - https://github.com/upx/upx/issues/301 | ||
which upx 2>&1 > /dev/null || (sudo apt-get update && sudo apt-get install -y xz-utils && wget -nv -O upx.tar.xz https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz; tar xf upx.tar.xz; mv upx-3.96-amd64_linux/upx /usr/bin ) | ||
upx -5 ./.bin/$(NAME)_linux_amd64 ./.bin/$(NAME)_linux_arm64 ./.bin/$(NAME)_darwin_amd64 ./.bin/$(NAME)_darwin_arm64 ./.bin/$(NAME).exe | ||
|
||
.PHONY: binaries | ||
binaries: linux darwin windows compress | ||
|
||
.PHONY: release | ||
release: binaries | ||
mkdir -p .release | ||
cp .bin/$(NAME)* .release/ |
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,11 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/flanksource/kommons" | ||
"github.com/labstack/echo/v4" | ||
) | ||
|
||
type Context struct { | ||
echo.Context | ||
Kommons *kommons.Client | ||
} |
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
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,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/flanksource/commons/logger" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
var Root = &cobra.Command{ | ||
Use: "apm-hub", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
logger.UseZap(cmd.Flags()) | ||
}, | ||
} | ||
|
||
var httpPort int | ||
|
||
func ServerFlags(flags *pflag.FlagSet) { | ||
flags.IntVar(&httpPort, "httpPort", 8080, "Port to expose a health dashboard ") | ||
} | ||
|
||
func init() { | ||
logger.BindFlags(Root.PersistentFlags()) | ||
Root.AddCommand(Serve) | ||
} |
Oops, something went wrong.