Skip to content

Commit

Permalink
fix #190 #163
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed committed Jul 20, 2021
1 parent af55ce2 commit 84bbec9
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 117 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/krew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"

jobs:
krew:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

# - name: Setup Go
# uses: actions/setup-go@v1
# with:
# go-version: 1.16.3

# - name: GoReleaser
# uses: goreleaser/goreleaser-action@v1
# with:
# version: latest
# args: release --rm-dist
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@v0.0.40
26 changes: 0 additions & 26 deletions .github/workflows/release.yml

This file was deleted.

34 changes: 17 additions & 17 deletions .krew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,36 @@ spec:
Popeye is a readonly tool, it does not alter any of your Kubernetes
resources in any way!
platforms:
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Darwin_x86_64.tar.gz" .TagName | indent 6 }}
- bin: kubectl-popeye
{{ addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Darwin_x86_64.tar.gz" .TagName }}
files:
- from: popeye
to: kubectl-popeye
- from: LICENSE
to: "."
bin: kubectl-popeye
- selector:
to: .
selector:
matchLabels:
os: linux
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Linux_x86_64.tar.gz" .TagName | indent 6 }}
- bin: kubectl-popeye
{{ addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Linux_x86_64.tar.gz" .TagName }}
files:
- from: popeye
to: kubectl-popeye
- from: LICENSE
to: "."
bin: kubectl-popeye
- selector:
to: .
selector:
matchLabels:
os: windows
os: linux
arch: amd64
{{addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Windows_x86_64.tar.gz" .TagName | indent 6 }}
- bin: kubectl-popeye.exe
{{ addURIAndSha "https://github.com/derailed/popeye/releases/download/{{ .TagName }}/popeye_Windows_x86_64.tar.gz" .TagName }}
files:
- from: popeye.exe
to: kubectl-popeye.exe
- from: LICENSE
to: "."
bin: kubectl-popeye.exe
to: .
selector:
matchLabels:
os: windows
arch: amd64
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Popeye is a readonly tool, it does not alter any of your Kubernetes resources in
[![codebeat badge](https://codebeat.co/badges/827e5642-3ccc-4ecc-b22b-5707dbc34cf1)](https://codebeat.co/projects/github-com-derailed-popeye-master)
[![Build Status](https://travis-ci.com/derailed/popeye.svg?branch=master)](https://travis-ci.com/derailed/popeye)
[![release](https://img.shields.io/github/release-pre/derailed/popeye.svg)](https://github.com/derailed/popeye/releases)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/derailed/popeye/blob/master/LICENSE)
[![Docker Repository on Quay](https://quay.io/repository/derailed/popeye/status "Docker Repository on Quay")](https://quay.io/repository/derailed/popeye)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/derailed/popeye/blob/master/LICENSE)
[![docker](https://img.shields.io/docker/cloud/build/derailed/popeye?label=Docker&style=flat)](https://hub.docker.com/r/derailed/popeye/builds)
![GitHub stars](https://img.shields.io/github/stars/derailed/popeye.svg?label=github%20stars)
[![Releases](https://img.shields.io/github/downloads/derailed/popeye/total.svg)]()

Expand Down Expand Up @@ -188,15 +188,15 @@ popeye --s3-bucket=NAME-OF-YOUR-S3-BUCKET/OPTIONAL/SUBDIRECTORY --out=json
### Run public docker image locally
You don't have to build and/or install the binary to run popeye: you can just
run it directly from the official docker repo on quay.io. The default command
run it directly from the official docker repo on DockerHub. The default command
when you run the docker container is `popeye`, so you just need to pass
whatever cli args are normally passed to popeye. To access your clusters, map
your local kube config directory into the container with `-v` :

```shell
docker run --rm -it \
-v $HOME/.kube:/root/.kube \
quay.io/derailed/popeye --context foo -n bar
derailed/popeye --context foo -n bar
```

Running the above docker command with `--rm` means that the container gets
Expand All @@ -210,7 +210,7 @@ NOTE: You can override the default output directory location by setting `POPEYE_
-v $HOME/.kube:/root/.kube \
-e POPEYE_REPORT_DIR=/tmp/popeye \
-v /tmp:/tmp \
quay.io/derailed/popeye --context foo -n bar --save --output-file my_report.txt
derailed/popeye --context foo -n bar --save --output-file my_report.txt
# Docker has exited, and the container has been deleted, but the file
# is in your /tmp directory because you mapped it into the container
Expand Down Expand Up @@ -362,7 +362,7 @@ spec:
restartPolicy: Never
containers:
- name: popeye
image: quay.io/derailed/popeye
image: derailed/popeye
imagePullPolicy: IfNotPresent
args:
- -o
Expand Down
26 changes: 26 additions & 0 deletions change_logs/release_v0.9.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/popeye_logo.png" align="right" width="200" height="auto"/>

# Release v0.9.7

## Notes

Thank you to all that contributed with flushing out issues and enhancements for Popeye! I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev and see if we're happier with some of the fixes! If you've filed an issue please help me verify and close. Your support, kindness and awesome suggestions to make Popeye better is as ever very much noticed and appreciated!

This project offers a GitHub Sponsor button (over here 👆). As you well know this is not pimped out by big corps with deep pockets. If you feel `Popeye` is saving you cycles diagnosing potential cluster issues please consider sponsoring this project!! It does go a long way in keeping our servers lights on and beers in our fridge.

Also if you dig this tool, please make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)

---

## Maintenance Release!

---

## Resolved Bugs/PRs

* [Issue #190](https://github.com/derailed/popeye/issues/190) Popeye docker image tag 0.9.6 not available on quay.io
* [Issue #163](https://github.com/derailed/popeye/issues/163) popeye 0.9.0 with K8S 1.21.0 bug on PodDisruptionBudget - Wrong default API. With Feelings!

---

<img src="https://raw.githubusercontent.com/derailed/popeye/master/assets/imhotep_logo.png" width="32" height="auto"/>&nbsp; © 2020 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)
4 changes: 4 additions & 0 deletions internal/client/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import (
"github.com/derailed/popeye/types"
)

// Schema tracks resource schema.
type Schema struct {
GVR GVR
Preferred bool
}

// Meta tracks a collection of resources.
type Meta map[string][]Schema

func newMeta() Meta {
return make(map[string][]Schema)
}

// Resources tracks dictionary of resources.
var Resources = newMeta()

// Load loads resource meta from server.
func Load(f types.Factory) error {
dial, err := f.Client().CachedDiscovery()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/client/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"k8s.io/apimachinery/pkg/version"
)

// Revision tracks server version.
type Revision struct {
Info *version.Info
Major, Minor int
}

var minorRX = regexp.MustCompile(`(\d+)\+?`)

// NewRevision returns a new instance.
func NewRevision(info *version.Info) (*Revision, error) {
major, err := strconv.Atoi(info.Major)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/dag/ing.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

// IngressGVR tracks ingress specification
var IngressGVR = client.NewGVR("networking.k8s.io/v1/ingresses")

// ListIngresses list all included Ingresses.
Expand Down
1 change: 1 addition & 0 deletions internal/issues/codes.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package issues

import (
// Pull in asset codes.
_ "embed"

"github.com/derailed/popeye/pkg/config"
Expand Down
7 changes: 1 addition & 6 deletions internal/sanitize/pdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package sanitize

import (
"context"
"fmt"

"github.com/derailed/popeye/internal"
"github.com/derailed/popeye/internal/issues"
"github.com/rs/zerolog/log"
polv1beta1 "k8s.io/api/policy/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/endpoints/deprecation"
)

type (
Expand Down Expand Up @@ -52,10 +50,7 @@ func (p *PodDisruptionBudget) Sanitize(ctx context.Context) error {
}

func (p *PodDisruptionBudget) checkDeprecation(ctx context.Context, pdb *polv1beta1.PodDisruptionBudget) {
const current = "policy/v1beta1"

fmt.Println("VERSION", pdb.GetObjectKind().GroupVersionKind())
fmt.Printf("WARNING %q", deprecation.WarningMessage(pdb))
const current = "policy/v1"

fqn := internal.MustExtractFQN(ctx)
rev, err := resourceRev(fqn, "PodDisruptionBudget", pdb.Annotations)
Expand Down
1 change: 1 addition & 0 deletions internal/stringset.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type StringSet map[string]Empty
// AllKeys indicates all keys are present.
var AllKeys = StringSet{All: Blank}

// AddAll merges two sets.
func (ss StringSet) AddAll(s StringSet) {
for k := range s {
ss[k] = Blank
Expand Down
59 changes: 0 additions & 59 deletions krew/popeye.yaml

This file was deleted.

1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/derailed/popeye/cmd"
"github.com/derailed/popeye/pkg"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
)

// BasicAuth tracks basic authentication.
type BasicAuth struct {
User *string
Password *string
}

// PushGateway tracks gateway representations.
type PushGateway struct {
Address *string
BasicAuth BasicAuth
Expand Down
6 changes: 4 additions & 2 deletions pkg/popeye.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ func (p *Popeye) sanitizers(rev *client.Revision) map[string]scrubFn {
"apps/v1/replicasets": scrub.NewReplicaSet,
"apps/v1/statefulsets": scrub.NewStatefulSet,
"autoscaling/v1/horizontalpodautoscalers": scrub.NewHorizontalPodAutoscaler,
"networking.k8s.io/v1/ingresses": scrub.NewIngress,
"networking.k8s.io/v1/networkpolicies": scrub.NewNetworkPolicy,
"policy/v1beta1/poddisruptionbudgets": scrub.NewPodDisruptionBudget,
"policy/v1beta1/podsecuritypolicies": scrub.NewPodSecurityPolicy,
"rbac.authorization.k8s.io/v1/clusterroles": scrub.NewClusterRole,
"rbac.authorization.k8s.io/v1/clusterrolebindings": scrub.NewClusterRoleBinding,
Expand All @@ -228,9 +226,13 @@ func (p *Popeye) sanitizers(rev *client.Revision) map[string]scrubFn {

if rev.Minor <= 18 {
mm["networking.k8s.io/v1beta1/ingresses"] = scrub.NewIngress
} else {
mm["networking.k8s.io/v1/ingresses"] = scrub.NewIngress
}
if rev.Minor >= 21 {
mm["policy/v1/poddisruptionbudgets"] = scrub.NewPodDisruptionBudget
} else {
mm["policy/v1beta1/poddisruptionbudgets"] = scrub.NewPodDisruptionBudget
}

return mm
Expand Down

0 comments on commit 84bbec9

Please sign in to comment.