Skip to content

Commit

Permalink
use packr for config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed May 17, 2019
1 parent 1194c8b commit 79f3d2c
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ jobs:
- *set_environment_variables
- *docker_tag_release
- *install_goreleaser
- run: go get -u github.com/gobuffalo/packr/v2/packr2
- run: packr2
- run: goreleaser

workflows:
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
builds:
- env:
- CGO_ENABLED=0
binary: polaris
archive:
replacements:
darwin: Darwin
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ COPY --from=build-env /go/src/github.com/reactiveops/polaris/polaris .

WORKDIR /opt/app

COPY --from=build-env /go/src/github.com/reactiveops/polaris/config.yaml ./config.yaml

CMD ["polaris"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ helm upgrade --install polaris deploy/helm/polaris/ --namespace polaris --set we

## Configuration

Polaris supports a wide range of validations covering a number of Kubernetes best practices. Here's a sample configuration file that includes all currently supported checks. The [default configuration](https://github.com/reactiveops/polaris/blob/master/config.yaml) contains a number of those checks. This repository also includes a sample [full configuration file](https://github.com/reactiveops/polaris/blob/master/config-full.yaml) that enables all available checks.
Polaris supports a wide range of validations covering a number of Kubernetes best practices. Here's a sample configuration file that includes all currently supported checks. The [default configuration](https://github.com/reactiveops/polaris/blob/master/examples/config.yaml) contains a number of those checks. This repository also includes a sample [full configuration file](https://github.com/reactiveops/polaris/blob/master/examples/config-full.yaml) that enables all available checks.

Each check can be assigned a `severity`. Only checks with a severity of `error` or `warning` will be validated. The results of these validations are visible on the dashboard. In the case of the validating webhook, only failures with a severity of `error` will result in a change being rejected.

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
webhookPort := flag.Int("webhook-port", 9876, "Port for the webhook webserver")
auditOutputURL := flag.String("output-url", "", "Destination URL to send audit results")
auditOutputFile := flag.String("output-file", "", "Destination file for audit results")
configPath := flag.String("config", "config.yaml", "Location of Polaris configuration file")
configPath := flag.String("config", "", "Location of Polaris configuration file")
logLevel := flag.String("log-level", logrus.InfoLevel.String(), "Logrus log level")
version := flag.Bool("version", false, "Prints the version of Polaris")
disableWebhookConfigInstaller := flag.Bool("disable-webhook-config-installer", false,
Expand Down
10 changes: 9 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io"
"io/ioutil"

packr "github.com/gobuffalo/packr/v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/yaml"
Expand Down Expand Up @@ -110,7 +111,14 @@ type SecurityCapabilityLists struct {

// ParseFile parses config from a file.
func ParseFile(path string) (Configuration, error) {
rawBytes, err := ioutil.ReadFile(path)
configBox := packr.New("Config", "../../examples")
var rawBytes []byte
var err error
if path == "" {
rawBytes, err = configBox.Find("config.yaml")
} else {
rawBytes, err = ioutil.ReadFile(path)
}
if err != nil {
return Configuration{}, err
}
Expand Down

0 comments on commit 79f3d2c

Please sign in to comment.