Skip to content

Commit

Permalink
bump version, add docs, fix up dashboard (#595)
Browse files Browse the repository at this point in the history
* bump version\, add docs\, fix up dashboard

* fix pretty output

* Update config.yaml

* fix extra kinds appearing
  • Loading branch information
rbren authored Aug 18, 2021
1 parent 6c14d96 commit 9ae4f77
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<br>
<h3>Best Practices for Kubernetes Workload Configuration</h3>
<a href="https://github.com/FairwindsOps/polaris">
<img src="https://img.shields.io/static/v1.svg?label=Version&message=4.0.7&color=239922">
<img src="https://img.shields.io/static/v1.svg?label=Version&message=4.0.8&color=239922">
</a>
<a href="https://goreportcard.com/report/github.com/FairwindsOps/polaris">
<img src="https://goreportcard.com/badge/github.com/FairwindsOps/polaris">
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ meta:
content: "Fairwinds Polaris | Changelog"

---
## 4.0.8
* Fix support for namespace checks

## 4.0.7
* Fix goreleaser format

Expand Down
13 changes: 13 additions & 0 deletions docs/customization/custom-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ customChecks:
resourceMaximum: "2"
```

## Resource Presence
You can test for the presence of a resource in each Namespace. For example, to
ensure an AlertmanagerConfig is in every Namespace:
```yaml
successMessage: Namespace has monitoring configuration
failureMessage: Namespace should have monitoring configuration
category: Security
target: Namespace
schema: {}
additionalSchemas:
monitoring.coreos.com/AlertmanagerConfig: {}
```

## Templating
You can also utilize go templating in your JSON schema in order to match one field against another.
E.g. here is the built-in check to ensure that the `name` annotation matches the object's name:
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

const (
// Version represents the current release version of Polaris
Version = "4.0.7"
Version = "4.0.8"
)

func main() {
Expand Down
4 changes: 4 additions & 0 deletions pkg/dashboard/templates/dashboard.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@

{{ range $namespace, $results := .FilteredAuditData.GetResultsByNamespace }}
<div id="{{ $namespace }}" class="card namespace">
{{ if eq $namespace "" }}
<h3>Cluster Resources</h3>
{{ else }}
<h3>Namespace: <strong>{{ $namespace }}</strong></h3>
{{ end }}
<div class="expandable-table">
{{ range $index, $result := $results }}
<div class="resource-info">
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interfac
neededKinds = append(neededKinds, conf.TargetKind(key))
}
for _, kind := range neededKinds {
if !funk.Contains(conf.HandledTargets, kind) {
if !funk.Contains(conf.HandledTargets, kind) && !funk.Contains(additionalKinds, kind) {
additionalKinds = append(additionalKinds, kind)
}
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/validator/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ func (res AuditData) GetPrettyOutput(useColor bool) string {

// GetPrettyOutput returns a human-readable string
func (res Result) GetPrettyOutput() string {
str := titleColor.Sprint(fmt.Sprintf("%s %s in namespace %s\n", res.Kind, res.Name, res.Namespace))
str := titleColor.Sprint(fmt.Sprintf("%s %s", res.Kind, res.Name))
if res.Namespace != "" {
str += titleColor.Sprint(fmt.Sprintf("in namespace %s", res.Namespace))
}
str += "\n"
str += res.Results.GetPrettyOutput()
if res.PodResult != nil {
str += res.PodResult.GetPrettyOutput()
Expand Down

0 comments on commit 9ae4f77

Please sign in to comment.