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

Krew automation #199

Merged
merged 7 commits into from
Nov 7, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ jobs:
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update krew-index
uses: rajatjindal/[email protected]
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ dockers:
- "ghcr.io/google/{{ .ProjectName }}:{{ .ShortCommit }}"
archives:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name_template: "{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}"
builds:
- gke-policy
files:
- LICENSE*
- README*
- CHANGELOG*
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
name_template: "{{ .ProjectName }}_{{ .Tag }}_SHA256SUMS"
algorithm: sha256
signs:
- artifacts: checksum
Expand Down
58 changes: 58 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: gke-policy
spec:
shortDescription: Validates GKE clusters configuration
homepage: https://github.com/google/gke-policy-automation
description: |
Tool and policy library for validating Google Kubernetes Engine clusters
against the configuration best practices and scalability limits.
caveats: |
The plugin requires Google Cloud credentials to work.
Use "gcloud auth application-default login" command to authenticate or
specify credentials file as an argument.
version: {{ .TagName }}
platforms:
- bin: gke-policy
selector:
matchLabels:
os: linux
arch: arm
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_linux_arm.zip" .TagName }}
- bin: gke-policy
selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_linux_amd64.zip" .TagName }}
- bin: gke-policy
selector:
matchLabels:
os: linux
arch: arm64
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_linux_arm64.zip" .TagName }}
- bin: gke-policy.exe
selector:
matchLabels:
os: windows
arch: 386
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_windows_386.zip" .TagName }}
- bin: gke-policy.exe
selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_windows_amd64.zip" .TagName }}
- bin: gke-policy
selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_darwin_amd64.zip" .TagName }}
- bin: gke-policy
selector:
matchLabels:
os: darwin
arch: arm64
{{addURIAndSha "https://github.com/google/gke-policy-automation/releases/download/{{ .TagName }}/gke-policy-automation_{{ .TagName }}_darwin_arm64.zip" .TagName }}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ docker run --rm ghcr.io/google/gke-policy-automation check \
-project my-project -location europe-west2 -name my-cluster
```

### Krew

The GKE Policy Automation is available as a [Krew](https://krew.sigs.k8s.io) plugin.

```sh
kubectl krew install gke-policy
kubectl gke-policy check --discovery -p my-project
```

### Binary

Binaries for Linux, Windows and Mac are available as tarballs in the
Expand Down
5 changes: 4 additions & 1 deletion scripts/license_header_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

_EXCLUDE_DIRS = ('.git', '.terraform')
_EXCLUDE_RE = re.compile(r'# skip boilerplate check')
_EXCLUDE_FILES = {".krew.yaml"}
_MATCH_FILES = ('Dockerfile', '.py', '.sh', '.tf', '.yaml', '.yml', '.go', '.rego')
_MATCH_STRING = (r'^\s*([#\*]|[/]{2})\sCopyright [0-9]{4} Google LLC$\s+([#\*]|[/]{2})\s+'
r'([#\*]|[/]{2})\sLicensed under the Apache License, Version 2.0 '
r'\(the "License"\);\s+')
_MATCH_RE = re.compile(_MATCH_STRING, re.M)


def main(base_dirs):
"Cycle through files in base_dirs and check for the Apache 2.0 boilerplate."
errors, warnings = [], []
Expand All @@ -45,6 +45,9 @@ def main(base_dirs):
if fname in _MATCH_FILES or os.path.splitext(fname)[1] in _MATCH_FILES:
fpath = os.path.abspath(os.path.join(root, fname))
content = open(fpath).read()
relPath = os.path.relpath(fpath, dir)
if relPath in _EXCLUDE_FILES:
continue
if _EXCLUDE_RE.search(content):
continue
try:
Expand Down