Skip to content

Commit

Permalink
Go 1.19 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Jan 29, 2023
1 parent 0961c9d commit 2daf8c1
Show file tree
Hide file tree
Showing 22 changed files with 850 additions and 710 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!go.mod
!go.sum
!cmd
!pkg
24 changes: 4 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: "1.17"

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
cache: true
go-version-file: "go.mod"

- name: Lint
run: make lint
Expand All @@ -47,16 +39,8 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: "1.17"

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
cache: true
go-version-file: "go.mod"

- name: Build docker images
run: make build
77 changes: 77 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2019 Iguazio
#
# 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.
#
name: Release

on:
release:
types:
- created

# Run Release on push to development for unstable
push:
branches:
- development

env:
RELEASE_REGISTRY: gcr.io
RELEASE_REPO: iguazio
ARTIFACTORY_REGISTRY: artifactory.iguazeng.com:6555

jobs:
release:
name: Release Docker Images
runs-on: [ self-hosted, Linux ]
steps:

- name: Set unstable
if: github.event_name == 'push'
run: |
echo "SCALER_TAG=unstable" >> $GITHUB_ENV
- name: Set release
if: github.event_name == 'release'
run: |
echo "SCALER_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
- uses: actions/checkout@v3

- name: Login to artifactory
run: docker login -u ${{ secrets.ARTIFACTORY_DOCKER_USERNAME }} -p ${{ secrets.ARTIFACTORY_DOCKER_PASSWORD }} ${{ env.ARTIFACTORY_REGISTRY }}

- name: Login to GCR
run: |
echo "$GCR_JSON_KEY" | docker login -u _json_key --password-stdin https://gcr.io
env:
GCR_JSON_KEY: ${{ secrets.GCR_IGUAZIO_JSON_KEY }}

- name: Build image [GCR]
run: make build
env:
SCALER_REPOSITORY: ${{ env.RELEASE_REGISTRY }}/${{ env.RELEASE_REPO }}

- name: Push image [GCR]
run: make push
env:
SCALER_REPOSITORY: ${{ env.RELEASE_REGISTRY }}/${{ env.RELEASE_REPO }}

- name: Build image [Artifactory]
run: make build
env:
SCALER_REPOSITORY: ${{ env.ARTIFACTORY_REGISTRY }}/${{ env.RELEASE_REPO }}

- name: Push image [Artifactory]
run: make push
env:
SCALER_REPOSITORY: ${{ env.ARTIFACTORY_REGISTRY }}/${{ env.RELEASE_REPO }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

.bin
.github/.act
24 changes: 15 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ linters:
- deadcode
- goconst
- gofmt
- golint
- revive
- gosimple
- ineffassign
- interfacer
- misspell
- staticcheck
- unconvert
Expand All @@ -32,30 +31,37 @@ linters:
- govet
- structcheck
- typecheck
- gocritic

run:

# timeout for analysis
timeout: 5m

skip-dirs:
- docs
- hack

linters-settings:
revive:
rules:

# avoid errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) messages
- name: errorf
disabled: true

gocritic:
disabled-checks:
- commentFormatting # we dont want to enforce space before the comment text

issues:

# List of regexps of issue texts to exclude
exclude:
- "comment on"
- "error should be the last"
- "should have comment"

exclude-rules:

# Auto generated files for kubernetes
- path: pkg/platform/kube/client
linters:
- errcheck

# list of excluded linters applied on test files
- path: _test\.go
linters:
Expand Down
39 changes: 0 additions & 39 deletions Jenkinsfile

This file was deleted.

53 changes: 19 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

SCALER_TAG ?= unstable
SCALER_REPOSITORY ?= iguazio/
V3IO_SCALER_TAG ?= v0.4.5
SCALER_REPOSITORY ?= iguazio
GOPATH ?= $(shell go env GOPATH)
OS_NAME = $(shell uname)

Expand All @@ -27,50 +27,35 @@ endif
build: dlx autoscaler
@echo Done.

.PHONY: push
push:
docker push $(SCALER_REPOSITORY)/dlx:$(SCALER_TAG)
docker push $(SCALER_REPOSITORY)/autoscaler:$(SCALER_TAG)

.PHONY: dlx
dlx:
docker build \
-f dlx/Dockerfile \
--build-arg V3IO_SCALER_TAG=$(V3IO_SCALER_TAG) \
--tag=$(SCALER_REPOSITORY)dlx:$(SCALER_TAG) .
--file cmd/dlx/Dockerfile \
--tag $(SCALER_REPOSITORY)/dlx:$(SCALER_TAG) \
.

.PHONY: autoscaler
autoscaler:
docker build \
-f autoscaler/Dockerfile \
--build-arg V3IO_SCALER_TAG=$(V3IO_SCALER_TAG) \
--tag=$(SCALER_REPOSITORY)autoscaler:$(SCALER_TAG) .

.PHONY: modules
modules: ensure-gopath
@echo Getting go modules
@go mod download
--file cmd/autoscaler/Dockerfile \
--tag $(SCALER_REPOSITORY)/autoscaler:$(SCALER_TAG) \
.

.PHONY: fmt
fmt:
gofmt -s -w .

.PHONY: lint
lint: modules
@echo Installing linters...
@test -e $(GOPATH)/bin/impi || \
(mkdir -p $(GOPATH)/bin && \
curl -s https://api.github.com/repos/pavius/impi/releases/latest \
| grep -i "browser_download_url.*impi.*$(OS_NAME)" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O $(GOPATH)/bin/impi -qi - \
&& chmod +x $(GOPATH)/bin/impi)
./hack/lint/install.sh
./hack/lint/run.sh

@test -e $(GOPATH)/bin/golangci-lint || \
(curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.41.1)

@echo Verifying imports...
$(GOPATH)/bin/impi \
--local github.com/v3io/app-resource-scaler/ \
--scheme stdLocalThirdParty \
./...

@echo Linting...
$(GOPATH)/bin/golangci-lint run -v
@echo Done.
.PHONY: modules
modules: ensure-gopath
@echo Getting go modules
@go mod download
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# app-resource-scaler

This project serves as a plugin for the generic kubernetes resources
[scale to zero infrastructure](https://github.com/v3io/scaler). </br>
This project uses the generic kubernetes resources [scale to zero infrastructure](https://github.com/v3io/scaler).
It implements scaling of Iguazio's app services, by modifying the appropriate CRDs.

## Building the project

There are 2 separate docker images for `dlx` and `scaler`, each in their corresponding directories.
To build, just run the commands (from the root dir of this project): </br>
To build, just run the commands (from the root dir of this project):

`docker build -f dlx/Dockerfile -t [repo]/dlx:[version] .` </br>
`docker build -f dlx/Dockerfile -t [repo]/dlx:[version] .`
`docker build -f autoscaler/Dockerfile -t [repo]/scaler:[version] .`

or run

`SCALER_TAG=[version] SCALER_REPOSITORY=iguazio/ make build`

This will build an image of the [scaler](https://github.com/v3io/scaler) components with `resourcescaler.go` as their
plugin. </br>
To publish the image just `docker push` the resulting images to your favorite repo.

## Notes

Modifying `vendor` dir may result in incompatability with the `vendor` dir in [scaler](https://github.com/v3io/scaler).
Please run `docker build` as described above to verify nothing was broken.
51 changes: 0 additions & 51 deletions autoscaler/Dockerfile

This file was deleted.

Loading

0 comments on commit 2daf8c1

Please sign in to comment.