Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore inexisting resources #43

Merged
merged 6 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 11 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 18 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
19 changes: 13 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ changelog:
- '^Docs:'
- '^Test:'
- '^Refactor:'
- '^Merge pull request'

release:
github:
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down