Skip to content

Commit

Permalink
Merge pull request #19 from layer5io/kumarabd/feature/init
Browse files Browse the repository at this point in the history
v2 nginx adapter
  • Loading branch information
leecalcote authored Jan 2, 2021
2 parents 77a0dc4 + 95cdcb0 commit d6dc0a4
Show file tree
Hide file tree
Showing 19 changed files with 500 additions and 264 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Meshery-NGINX Build and Releaser
name: Meshery-nginx Build and Releaser
on:
push:
branches:
Expand All @@ -7,6 +7,20 @@ on:
- 'v*'

jobs:
build:
name: Build check
runs-on: ubuntu-latest
# needs: [lint, error_check, static_check, vet, sec_check, tests]
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go build .
docker:
name: Docker build and push
runs-on: ubuntu-latest
Expand Down
126 changes: 89 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,102 @@
name: Meshery NGINX SM
name: Meshery Nginx SM
on:
push:
branches:
- 'master'
- "*"
tags:
- 'v*'
- "v*"
pull_request:
branches:
- 'master'

- master
jobs:
golangci:
name: golangci-lint
lint:
name: Check & Review code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.32

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true


build:
name: Build check
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- run: GOPROXY=direct GOSUMDB=off go get -u golang.org/x/lint/golint; go list ./nginx/... | grep -v /vendor/ | xargs -L1 /home/runner/go/bin/golint -set_exit_status
error_check:
name: Error check
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go get -u github.com/kisielk/errcheck; /home/runner/go/bin/errcheck -tags draft ./...
static_check:
name: Static check
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go get -u honnef.co/go/tools/cmd/staticcheck; /home/runner/go/bin/staticcheck -tags draft -checks all ./nginx/... # https://staticcheck.io/docs/checks
vet:
name: Vet
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go vet -tags draft ./...
sec_check:
name: Security check
runs-on: ubuntu-latest
# needs: [lint, error_check, static_check, vet, sec_check, tests]
env:
GO111MODULE: on
steps:
- name: Check out code
uses: actions/checkout@master
with:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./... -exclude=G301,G304,G107,G101,G110
tests:
# needs: [lint, error_check, static_check, vet, sec_check]
name: Tests
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Check out code
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v1
with:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ secrets.GO_VERSION }}
# TODO(kushthedude): remove the cache clear sub-step once the mod checksum error is solved
- run: |
go clean -modcache
GO111MODULE=on go build .
- name: Create cluster using KinD
uses: engineerd/[email protected]
with:
version: "v0.7.0"
- run: |
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 ./...
43 changes: 24 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
FROM golang:1.14-stretch as bd
ARG CONFIG_PROVIDER="viper"
RUN apt update && apt install git libc-dev gcc pkgconf -y
COPY ${PWD} /go/src/github.com/layer5io/meshery-nginx/
WORKDIR /go/src/github.com/layer5io/meshery-nginx/
RUN go build -ldflags="-w -s -X main.configProvider=$CONFIG_PROVIDER" -a -o meshery-nginx
FROM golang:1.13 as builder

FROM golang:1.14-stretch
RUN apt update && apt install ca-certificates curl -y
# Install kubectl
RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl" && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl
WORKDIR /build
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY main.go main.go
COPY internal/ internal/
COPY nginx/ nginx/
# Build
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o meshery-nginx main.go

RUN mkdir /home/scripts/ && \
mkdir -p ${HOME}/.kube/

COPY --from=bd /go/src/github.com/layer5io/meshery-nginx/meshery-nginx /home/
COPY ${PWD}/scripts /home/scripts
WORKDIR /home
CMD ./meshery-nginx
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/base
ENV DISTRO="debian"
ENV GOARCH="amd64"
WORKDIR /.meshery
COPY bin/nginx-meshctl .
WORKDIR /
COPY --from=builder /build/meshery-nginx .
ENTRYPOINT ["/meshery-nginx"]
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ replace (
)

require (
github.com/layer5io/meshery-adapter-library v0.1.6
github.com/layer5io/meshkit v0.1.28
github.com/layer5io/meshery-adapter-library v0.1.9
github.com/layer5io/meshkit v0.1.30
google.golang.org/grpc v1.33.1 // indirect
helm.sh/helm/v3 v3.3.4 // indirect
k8s.io/apimachinery v0.18.12
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,16 @@ github.com/layer5io/meshery-adapter-library v0.1.5 h1:ZrYG15THG1D/Mr4sTdMI/ex2hc
github.com/layer5io/meshery-adapter-library v0.1.5/go.mod h1:R5K6nE7PAtLj9S/Qg2cFUPYM/8Qs32jeTw/D1MIh4zE=
github.com/layer5io/meshery-adapter-library v0.1.6 h1:9U9y4CT7sH3EhAlSqVoWpChdeqDHpHG5XnIzglKNKi4=
github.com/layer5io/meshery-adapter-library v0.1.6/go.mod h1:ph6YYsiZn7raWuyvK/c3R4ujWl4FUZBkU0wXiKhZ1Uw=
github.com/layer5io/meshery-adapter-library v0.1.9 h1:1faPSuaUDIRNMyECElWm/C5fedQDDXRHPAfi1M58T4Y=
github.com/layer5io/meshery-adapter-library v0.1.9/go.mod h1:dxrUzS10o5qDwfJE5qvAAH/s8PzLcRHFu3L4afgSBNc=
github.com/layer5io/meshkit v0.1.25 h1:+beK1qrqroP1Ce8UW8iRabWqSLVHSaLL2Ks38a/6uME=
github.com/layer5io/meshkit v0.1.25/go.mod h1:4x8Azv5a/T7HI8z2amRKxR9rWfeJQlXDOQbohb81GjY=
github.com/layer5io/meshkit v0.1.26 h1:yqcjffNeT9yD2PgDfOHB/gzP78biv6DjqqJn2cZ+llw=
github.com/layer5io/meshkit v0.1.26/go.mod h1:4x8Azv5a/T7HI8z2amRKxR9rWfeJQlXDOQbohb81GjY=
github.com/layer5io/meshkit v0.1.28 h1:F7DWcm3Txqb0QIqoEcBlp/qIO4s6+5Hp/CExMQM7Gjw=
github.com/layer5io/meshkit v0.1.28/go.mod h1:AznOL6xqpUZGyExSZJ3Bdx6EZ22UnAT9V620pm7R484=
github.com/layer5io/meshkit v0.1.30 h1:d9emBQAf+YnURkA5wZ6VbbqDfnx9G8G3xqOv6dG4n/k=
github.com/layer5io/meshkit v0.1.30/go.mod h1:AznOL6xqpUZGyExSZJ3Bdx6EZ22UnAT9V620pm7R484=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY=
Expand Down
Loading

0 comments on commit d6dc0a4

Please sign in to comment.