Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
asad-awadia committed Aug 16, 2021
2 parents 36d4bfc + 675de88 commit 8c03449
Show file tree
Hide file tree
Showing 16 changed files with 508 additions and 391 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

jobs:
pre-commit:
runs-on: ubuntu-latest

# don't run this on the master branch
if: github.ref != 'refs/heads/master'

steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: actions/[email protected]
- uses: pre-commit/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:

- name: Setup Node.js for use with actions
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v2.4.0

- name: Checkout
uses: actions/checkout@v2
Expand All @@ -27,18 +27,18 @@ jobs:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ^1.15.0
go-version: ^1.16.5
id: go

- name: Login to github registry
uses: docker/login-action@v1.9.0
uses: docker/login-action@v1.10.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.6.1
uses: goreleaser/goreleaser-action@v2.7.0
with:
version: latest
args: release --rm-dist
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: ^1.15.0
go-version: ^1.16.5
id: go

- name: Checkout
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Setup Go
uses: actions/[email protected]
with:
go-version: ^1.15.0
go-version: ^1.16.5
id: go

- name: Checkout
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Setup Go
uses: actions/[email protected]
with:
go-version: ^1.15.0
go-version: ^1.16.5
id: go

- uses: actions/cache@v2
Expand All @@ -100,7 +100,7 @@ jobs:
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.6.1
uses: goreleaser/goreleaser-action@v2.7.0
with:
version: latest
args: release --rm-dist --skip-validate --skip-publish
Expand Down
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ changelog:
filters:
exclude:
- '^docs:'
- '^chore:'

archives:
- format: binary
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: 38b88246ccc552bffaaf54259d064beeee434539 # v4.0.1
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand All @@ -22,6 +22,12 @@ repos:
# - id: doctoc
# args: ['--title', '## Table of Contents']
- repo: https://github.com/golangci/golangci-lint
rev: v1.41.1
rev: a20748098fb3cb4b69f6b6ebb7809e7741122ef8 # v1.41.1
hooks:
- id: golangci-lint
- repo: https://github.com/dnephin/pre-commit-golang
rev: ac0f6582d2484b3aa90b05d568e70f9f3c1374c7 # v0.0.17
hooks:
- id: go-mod-tidy
- id: go-fmt
- id: go-imports
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ By participating to this project, you agree to abide our
Prerequisites:

- `make`
- [Go 1.15+](https://golang.org/doc/install)
- [Go 1.16+](https://golang.org/doc/install)
- [golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
- [Docker](https://www.docker.com/) (or [Podman](https://podman.io/))
- [kind](https://kind.sigs.k8s.io/)
- [pre-commit](https://pre-commit.com/) (optional)
- [ngrok](https://ngrok.com/) (optional)

Clone `k8s-image-swapper` anywhere:

Expand All @@ -37,13 +40,13 @@ make test
You can create a branch for your changes and try to build from the source as you go:

```sh
make build
make test
```

When you are satisfied with the changes, we suggest you run:

```sh
make ci
make fmt lint test
```

Which runs all the linters and tests.
Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SOURCE_FILES?=./...
TEST_PATTERN?=.
TEST_OPTIONS?=

.PHONY: help $(MAKECMDGOALS)
.DEFAULT_GOAL := help

export GO111MODULE := on
export GOPROXY = https://proxy.golang.org,direct

help: ## List targets & descriptions
@cat Makefile* | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

setup: ## Install dependencies
go mod download
go mod tidy

test: ## Run tests
LC_ALL=C go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=5m

cover: test ## Run tests and open coverage report
go tool cover -html=coverage.txt

fmt: ## gofmt and goimports all go files
gofmt -l -w .
goimports -l -w .

lint: ## Run linters
golangci-lint run
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
whhttp "github.com/slok/kubewebhook/pkg/http"
kwhhttp "github.com/slok/kubewebhook/v2/pkg/http"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -84,7 +84,7 @@ A mutating webhook for Kubernetes, pointing the images to a new location.`,
}

// Get the handler for our webhook.
whHandler, err := whhttp.HandlerFor(wh)
whHandler, err := kwhhttp.HandlerFor(kwhhttp.HandlerConfig{Webhook: wh})
if err != nil {
log.Err(err).Msg("error creating webhook handler")
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The option `logLevel` & `logFormat` allow to adjust the verbosity and format (e.

The option `imageSwapPolicy` (default: `exists`) defines the mutation strategy used.

* `always`: Will always swap the image regardless of the image existence in the target registry.
* `always`: Will always swap the image regardless of the image existence in the target registry.
This can result in pods ending in state ImagePullBack if images fail to be copied to the target registry.
* `exists`: Only swaps the image if it exits in the target registry.
This can result in pods pulling images from the source registry, e.g. the first pod pulls
Expand Down
42 changes: 29 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
module github.com/estahn/k8s-image-swapper

go 1.12
go 1.16

require (
github.com/alitto/pond v1.4.0
github.com/aws/aws-sdk-go v1.38.47
github.com/containers/image/v5 v5.11.0
github.com/alitto/pond v1.5.0
github.com/aws/aws-sdk-go v1.38.65
github.com/containerd/containerd v1.5.2 // indirect
github.com/containers/image/v5 v5.13.2
github.com/containers/libtrust v0.0.0-20200511145503-9c3a6c22cd9a // indirect
github.com/containers/storage v1.32.4 // indirect
github.com/dgraph-io/ristretto v0.1.0
github.com/go-co-op/gocron v0.4.0
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e // indirect
github.com/docker/docker v20.10.7+incompatible // indirect
github.com/go-co-op/gocron v1.6.2
github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0
github.com/mitchellh/go-homedir v1.1.0
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/prometheus/client_golang v1.9.0
github.com/ostreedev/ostree-go v0.0.0-20210511152353-2ca91aaf921c // indirect
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.29.0 // indirect
github.com/rs/zerolog v1.23.0
github.com/slok/kubewebhook v0.11.0
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.1
github.com/slok/kubewebhook/v2 v2.1.0
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.8.0
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
google.golang.org/genproto v0.0.0-20210617175327-b9e0b3197ced // indirect
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.20.1
k8s.io/apimachinery v0.21.1
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.1 // indirect
)
Loading

0 comments on commit 8c03449

Please sign in to comment.