Skip to content

Commit 1521925

Browse files
authored
Bump package (#25)
1 parent 3e13c44 commit 1521925

File tree

22 files changed

+832
-183
lines changed

22 files changed

+832
-183
lines changed

.github/workflows/ci.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2019 Iguazio
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
115
name: CI
216

317
on:
@@ -16,11 +30,12 @@ jobs:
1630
name: Lint
1731
runs-on: ubuntu-latest
1832
steps:
19-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v3
2034

21-
- uses: actions/setup-go@v2
35+
- uses: actions/setup-go@v3
2236
with:
23-
go-version: "1.13"
37+
cache: true
38+
go-version-file: "go.mod"
2439

2540
- name: Run lint
2641
run: make lint
@@ -29,10 +44,7 @@ jobs:
2944
name: Build
3045
runs-on: ubuntu-latest
3146
steps:
32-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v3
3348

34-
- uses: actions/setup-go@v2
35-
with:
36-
go-version: "1.13"
3749
- name: Run build
3850
run: make build

.github/workflows/release.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2019 Iguazio
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
name: Release
16+
17+
on:
18+
release:
19+
types:
20+
- created
21+
22+
# Run Release on push to development for unstable
23+
push:
24+
branches:
25+
- development
26+
27+
jobs:
28+
release:
29+
name: Release Docker Images
30+
runs-on: ubuntu-latest
31+
steps:
32+
33+
- name: Set unstable
34+
if: github.event_name == 'push'
35+
run: |
36+
echo "LABEL=unstable" >> $GITHUB_ENV
37+
38+
- name: Set release
39+
if: github.event_name == 'release'
40+
run: |
41+
echo "LABEL=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
42+
cat $GITHUB_ENV
43+
44+
- uses: actions/checkout@v3
45+
46+
- name: Login to GCR
47+
run: |
48+
echo "$GCR_JSON_KEY" | docker login -u _json_key --password-stdin https://gcr.io
49+
env:
50+
GCR_JSON_KEY: ${{ secrets.GCR_IGUAZIO_JSON_KEY }}
51+
52+
- name: Build image
53+
run: make build
54+
55+
- name: Push image
56+
run: make push

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
# Output of the go coverage tool, specifically when used with LiteIDE
1515
*.out
1616

17+
.github/.act
18+
1719
# ignore all logs
1820
log/

.golangci.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,53 @@ linters:
22
disable-all: true
33
enable:
44
- deadcode
5+
- goconst
56
- gofmt
6-
- golint
7+
- revive
78
- gosimple
89
- ineffassign
9-
- interfacer
1010
- misspell
1111
- staticcheck
1212
- unconvert
1313
- varcheck
1414
- vet
1515
- vetshadow
1616
- errcheck
17+
- govet
18+
- structcheck
19+
- typecheck
20+
- gocritic
1721

1822
run:
1923

2024
# timeout for analysis
21-
timeout: 10m
22-
23-
# include test files or not, default is true
24-
tests: false
25+
timeout: 5m
2526

2627
skip-dirs:
2728
- hack
28-
- docs
29+
30+
linters-settings:
31+
revive:
32+
rules:
33+
34+
# avoid errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) messages
35+
- name: errorf
36+
disabled: true
37+
38+
gocritic:
39+
disabled-checks:
40+
- commentFormatting # we dont want to enforce space before the comment text
2941

3042
issues:
3143

3244
# List of regexps of issue texts to exclude
3345
exclude:
3446
- "comment on"
3547
- "error should be the last"
36-
- "should have comment"
48+
49+
exclude-rules:
50+
51+
# list of excluded linters applied on test files
52+
- path: _test\.go
53+
linters:
54+
- goconst

Jenkinsfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

Makefile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
PROXY_PATH ?= src/github.com/v3io/proxy
2-
PROXY_TAG ?= latest
3-
PROXY_REPOSITORY ?= v3io/
4-
PROXY_BUILD_COMMAND ?= GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-s -w" -o $(GOPATH)/bin/proxy_server $(GOPATH)/$(PROXY_PATH)/main.go
5-
6-
.PHONY: all
7-
all: lint build
8-
@echo Done.
1+
LABEL ?= unstable
2+
REPOSITORY ?= gcr.io/iguazio
3+
IMAGE = $(REPOSITORY)/sidecar-proxy:$(LABEL)
94

105
.PHONY: build
116
build:
12-
docker build -f cmd/sidecarproxy/Dockerfile --tag=$(PROXY_REPOSITORY)sidecar-proxy:$(PROXY_TAG) .
7+
@docker build \
8+
--file cmd/sidecarproxy/Dockerfile \
9+
--tag=$(IMAGE) \
10+
.
1311

14-
.PHONY: bin
15-
bin:
16-
$(PROXY_BUILD_COMMAND)
12+
.PHONY: push
13+
push:
14+
docker push $(IMAGE)
1715

1816
.PHONY: lint
1917
lint:
2018
./hack/lint/install.sh
2119
./hack/lint/run.sh
2220

23-
.PHONY: vet
24-
vet:
25-
go vet ./app/...
21+
.PHONY: fmt
22+
fmt:
23+
@go fmt $(shell go list ./... | grep -v /vendor/)
2624

2725
.PHONY: test
2826
test:
29-
go test -v ./app/...
27+
go test -p1 -v ./pkg/...

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Sidecar proxy
1+
# Sidecar Proxy
2+
23
A containerized proxy meant to run alongside a service (in the same pod) in order to serve Prometheus metrics, and
34
facilitate scale-to-zero flows.
45

@@ -14,12 +15,11 @@ The container includes a server that serves Prometheus metrics through the `/met
1415

1516
All metrics contain these labels: `namespace`, `service_name`, `instance_name`.
1617

17-
The code was built so it will be easy to extend it and add new metrics. This is performed by creating a new metric
18+
The code was built, so it will be easy to extend it and add new metrics. This is performed by creating a new metric
1819
handlers that implement the `MetricsHandler` interface.
1920

2021
When starting the container the `--metric-name` flag (can be defined multiple times) is used to set which metrics
2122
handlers to run (`num_of_requests` is mandatory).
2223

2324
An example helm chart that adds this container alongside a Jupyter service can be found
2425
[here](https://github.com/v3io/helm-charts/tree/development/stable/jupyter)
25-

cmd/sidecarproxy/Dockerfile

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
1-
FROM golang:1.13 as builder
1+
# Copyright 2019 Iguazio
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
FROM gcr.io/iguazio/golang:1.19 as builder
216

317
# copy source tree
4-
WORKDIR /go/src/github.com/v3io/sidecar-proxy
18+
WORKDIR /sidecar-proxy
19+
20+
COPY go.mod go.sum ./
21+
22+
RUN go mod download
23+
524
COPY . .
625

726
# build the app
8-
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-s -w" -o proxy_server cmd/sidecarproxy/main.go
27+
RUN GOOS=linux \
28+
GOARCH=amd64 \
29+
CGO_ENABLED=0 \
30+
go build -a -installsuffix cgo -ldflags="-s -w" -o proxy_server cmd/sidecarproxy/main.go
931

1032
#
1133
# Output stage: Copies binary to an alpine based image
1234
#
1335

14-
FROM alpine:3.7
36+
FROM gcr.io/iguazio/alpine:3.17
1537

1638
# copy app binary from build stage
17-
COPY --from=builder go/src/github.com/v3io/sidecar-proxy/proxy_server /usr/local/bin
39+
COPY --from=builder /sidecar-proxy/proxy_server /usr/local/bin
1840

1941
CMD [ "proxy_server" ]

cmd/sidecarproxy/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
// Copyright 2019 Iguazio
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
114
package main
215

316
import (

go.mod

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
module github.com/v3io/sidecar-proxy
22

3-
go 1.13
3+
go 1.19
44

55
require (
6-
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
7-
github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf // indirect
8-
github.com/nuclio/errors v0.0.1
6+
github.com/nuclio/errors v0.0.4
97
github.com/nuclio/logger v0.0.1
10-
github.com/nuclio/loggerus v0.0.1
11-
github.com/prometheus/client_golang v1.2.1
12-
github.com/sirupsen/logrus v1.4.2
13-
gopkg.in/alecthomas/gometalinter.v2 v2.0.12 // indirect
14-
gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c // indirect
8+
github.com/nuclio/loggerus v0.0.6
9+
github.com/prometheus/client_golang v1.14.0
10+
github.com/sirupsen/logrus v1.9.0
11+
)
12+
13+
require (
14+
github.com/beorn7/perks v1.0.1 // indirect
15+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
16+
github.com/golang/protobuf v1.5.2 // indirect
17+
github.com/logrusorgru/aurora/v3 v3.0.0 // indirect
18+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
19+
github.com/prometheus/client_model v0.3.0 // indirect
20+
github.com/prometheus/common v0.37.0 // indirect
21+
github.com/prometheus/procfs v0.8.0 // indirect
22+
golang.org/x/sys v0.4.0 // indirect
23+
google.golang.org/protobuf v1.28.1 // indirect
1524
)

0 commit comments

Comments
 (0)