Skip to content

Commit

Permalink
Adding goreleaser support
Browse files Browse the repository at this point in the history
  • Loading branch information
robscott committed May 16, 2019
1 parent ffe7f02 commit 0f81f5a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 18 deletions.
44 changes: 26 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
version: 2

references:
install_goreleaser: &install_goreleaser
run:
name: Install GoReleaser
command: |
curl -fsSLo goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v0.94.0/goreleaser_amd64.deb
echo "8dbad6683d6fc9367e637e6eed8e01a0d63c9660 goreleaser.deb" | sha1sum -c
sudo dpkg -i goreleaser.deb
rm goreleaser.deb
set_environment_variables: &set_environment_variables
run:
name: Set Environment Variables
command: |
echo 'export CI_SHA1=$CIRCLE_SHA1' >> ${BASH_ENV}
echo 'export CI_BRANCH=$CIRCLE_BRANCH' >> ${BASH_ENV}
echo 'export CI_BUILD_NUM=$CIRCLE_BUILD_NUM' >> ${BASH_ENV}
echo 'export CI_TAG=$CIRCLE_TAG' >> ${BASH_ENV}
echo 'export EXTERNAL_REGISTRY_BASE_DOMAIN=quay.io' >> ${BASH_ENV}
echo 'export DOCKERFILE=Dockerfile' >> ${BASH_ENV}
echo 'export REPOSITORY_NAME=reactiveops/polaris' >> ${BASH_ENV}
echo 'export REGISTRY_EMAIL=none' >> ${BASH_ENV}
echo 'export DOCKERTAG=${EXTERNAL_REGISTRY_BASE_DOMAIN}/${REPOSITORY_NAME}' >> ${BASH_ENV}
echo 'export REPO=quay.io/reactiveops/polaris' >> ${BASH_ENV}
docker_build_and_push: &docker_build_and_push
run:
name: Docker login, build, and push
command: |
touch empty.config
docker login quay.io -u="reactiveops+circleci" -p="${quay_token}"
docker-pull -f empty.config
docker-build -f empty.config
docker-push -f empty.config
docker build -t $REPO:dev-$CIRCLE_SHA1 .
docker push $REPO:dev-$CIRCLE_SHA1
docker_tag_release: &docker_tag_release
run:
name: Docker tag release
command: |
docker login quay.io -u="reactiveops+circleci" -p="${quay_token}"
docker pull $REPO:dev-$CIRCLE_SHA1
docker tag $REPO:dev-$CIRCLE_SHA1 $REPO:$CIRCLE_TAG
docker push $REPO:$CIRCLE_TAG
jobs:
build:
Expand All @@ -37,12 +43,11 @@ jobs:
test:
working_directory: /go/src/github.com/reactiveops/polaris/
docker:
- image: circleci/golang:1.11
- image: circleci/golang:1.12

steps:
- checkout
- run: dep ensure
- run: go get -u github.com/golang/lint/golint
- run: go get -u golang.org/x/lint/golint
- run: go list ./... | grep -v vendor | xargs golint -set_exit_status
- run: go list ./... | grep -v vendor | xargs go vet

Expand Down Expand Up @@ -70,13 +75,16 @@ jobs:
exit 1)
release:
working_directory: /go/src/github.com/reactiveops/polaris/
docker:
- image: circleci/buildpack-deps:stretch
- image: circleci/golang:1.12
steps:
- checkout
- setup_remote_docker
- *set_environment_variables
- *docker_build_and_push #TODO don't rebuild for release
- *docker_tag_release
- *install_goreleaser
- run: goreleaser

workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ main
.DS_Store

*-packr.go
dist
28 changes: 28 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
builds:
- env:
- CGO_ENABLED=0
archive:
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
brew:
github:
owner: reactiveops
name: homebrew-tap
folder: Formula
description: Open Source Best Practices for Kubernetes
test: |
system "#{bin}/polaris --version"
52 changes: 52 additions & 0 deletions examples/passing-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: polaris-passing-deployment
labels:
app: polaris-passing-deployment
spec:
replicas: 1
selector:
matchLabels:
app: polaris-passing-deployment
template:
metadata:
labels:
app: polaris-passing-deployment
spec:
containers:
- command:
- polaris
- --dashboard
image: 'quay.io/reactiveops/polaris:0.1.0'
imagePullPolicy: 'Always'
name: dashboard
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 20
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 20
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- ALL
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

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

func main() {
dashboard := flag.Bool("dashboard", false, "Runs the webserver for Polaris dashboard.")
webhook := flag.Bool("webhook", false, "Runs the webhook webserver.")
Expand All @@ -53,11 +58,17 @@ func main() {
auditOutputFile := flag.String("output-file", "", "Destination file for audit results")
configPath := flag.String("config", "config.yaml", "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,
"disable the installer in the webhook server, so it won't install webhook configuration resources during bootstrapping")

flag.Parse()

if *version {
fmt.Printf("Polaris version %s\n", Version)
os.Exit(0)
}

parsedLevel, err := logrus.ParseLevel(*logLevel)
if err != nil {
logrus.Errorf("log-level flag has invalid value %s", *logLevel)
Expand Down

0 comments on commit 0f81f5a

Please sign in to comment.