diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8495b58..5735bdc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,18 +10,23 @@ on: pull_request: types: [opened, reopened] +env: + GO_VERSION: "^1.15.2" + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '^1.14.1' - - uses: actions/cache@v1 + go-version: ${{ env.GO_VERSION }} + - uses: actions/cache@v2 with: - path: /home/runner/go/pkg/mod - key: go-mod - - uses: goreleaser/goreleaser-action@v1 + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - uses: goreleaser/goreleaser-action@v2 with: args: release --snapshot --skip-sign diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ecaffbc..fb001de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,17 +10,22 @@ on: pull_request: types: [opened, reopened] +env: + GO_VERSION: "^1.15.2" + jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 with: - go-version: '^1.14.1' - - uses: actions/cache@v1 + go-version: ${{ env.GO_VERSION }} + - uses: actions/cache@v2 with: - path: /home/runner/go/pkg/mod - key: go-mod + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Run linters run: make lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3b0027..24ef264 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,23 +6,33 @@ on: tags: - "*" +env: + GO_VERSION: "^1.15.2" + jobs: goreleaser: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-go@v2 with: - go-version: '^1.14.1' - - uses: actions/cache@v1 + go-version: ${{ env.GO_VERSION }} + - uses: actions/cache@v2 with: - path: /home/runner/go/pkg/mod - key: go-mod + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Import GPG signing key + uses: crazy-max/ghaction-import-gpg@v1 + env: + GPG_PRIVATE_KEY: ${{ secrets.SIGNING_KEY }} - name: Login to Docker hub run: docker login -u ${{ secrets.DOCKER_HUB_USER }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} - - uses: goreleaser/goreleaser-action@v1 + - uses: goreleaser/goreleaser-action@v2 with: args: release - key: ${{ secrets.SIGNING_KEY }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d92a48d..f1b9924 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,17 +10,24 @@ on: pull_request: types: [opened, reopened] +env: + GO_VERSION: "^1.15.2" + jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-go@v2-beta + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # some unit tests test the Git integration with our own git history + - uses: actions/setup-go@v2 with: - go-version: '^1.14.1' - - uses: actions/cache@v1 + go-version: ${{ env.GO_VERSION }} + - uses: actions/cache@v2 with: - path: /home/runner/go/pkg/mod - key: go-mod + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Run test suite run: make test diff --git a/.goreleaser.yml b/.goreleaser.yml index dbfe5a8..4b5b6d2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -51,6 +51,7 @@ changelog: - '^Docs:' - '^Test:' - '^Refactor:' + - '^Merge pull request' release: github: diff --git a/README.md b/README.md index 9800b79..ffc618c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # Seiso -[![dockeri.co](https://dockeri.co/image/appuio/seiso)](https://hub.docker.com/r/appuio/seiso) - [![](https://img.shields.io/github/workflow/status/appuio/seiso/Build)](https://github.com/appuio/seiso/actions) -[![](https://img.shields.io/github/v/release/appuio/seiso?include_prereleases)](https://github.com/appuio/seiso/releases) -[![](https://img.shields.io/github/issues-raw/appuio/seiso)](https://github.com/appuio/seiso/issues) -[![](https://img.shields.io/github/issues-pr-raw/appuio/seiso)](https://github.com/appuio/seiso/pulls) +[![](https://img.shields.io/github/v/release/appuio/seiso)](https://github.com/appuio/seiso/releases) +![](https://img.shields.io/github/go-mod/go-version/appuio/seiso) +[![](https://img.shields.io/github/downloads/appuio/seiso/total)](https://github.com/appuio/seiso/releases) +[![](https://img.shields.io/docker/pulls/appuio/seiso)](https://img.shields.io/docker/pulls/appuio/seiso) [![](https://img.shields.io/github/license/appuio/seiso)](https://github.com/appuio/seiso/blob/master/LICENSE) Inspired by Robert C. Martin's book, [Clean Code](https://www.investigatii.md/uploads/resurse/Clean_Code.pdf), foreword, page xx: diff --git a/go.mod b/go.mod index e2a28c2..88ed518 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/appuio/seiso -go 1.14 +go 1.15 require ( github.com/etdub/goparsetime v0.0.0-20160315173935-ea17b0ac3318 // indirect diff --git a/pkg/configmap/configmap.go b/pkg/configmap/configmap.go index 9f28c39..c486bb0 100644 --- a/pkg/configmap/configmap.go +++ b/pkg/configmap/configmap.go @@ -8,6 +8,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/thoas/go-funk" v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" core "k8s.io/client-go/kubernetes/typed/core/v1" @@ -94,7 +95,7 @@ func (cms ConfigMapsService) GetUnused(namespace string, configMaps []v1.ConfigM func (cms ConfigMapsService) Delete(configMaps []v1.ConfigMap) error { for _, resource := range configMaps { err := cms.client.Delete(resource.Name, &metav1.DeleteOptions{}) - if err != nil { + if err != nil && !apierrors.IsNotFound(err) { return err } if cms.configuration.Batch { diff --git a/pkg/secret/secret.go b/pkg/secret/secret.go index 2390beb..b41e061 100644 --- a/pkg/secret/secret.go +++ b/pkg/secret/secret.go @@ -8,6 +8,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/thoas/go-funk" v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" core "k8s.io/client-go/kubernetes/typed/core/v1" @@ -95,7 +96,7 @@ func (ss SecretsService) GetUnused(namespace string, resources []v1.Secret) (unu func (ss SecretsService) Delete(secrets []v1.Secret) error { for _, resource := range secrets { err := ss.client.Delete(resource.Name, &metav1.DeleteOptions{}) - if err != nil { + if err != nil && !apierrors.IsNotFound(err) { return err } if ss.configuration.Batch {