Skip to content
Permalink
Browse files

Initial CI integration

Signed-off-by: Andrew Block <andy.block@gmail.com>
  • Loading branch information...
sabre1041 authored and tsandall committed Feb 25, 2019
1 parent 3a4212e commit 347e42c06babd406e0a42e145f4cea4536262e7c
Showing with 78 additions and 3 deletions.
  1. +20 −0 .travis.yml
  2. +4 −0 Dockerfile_ci
  3. +39 −3 Makefile
  4. +9 −0 build/get-build-commit.sh
  5. +3 −0 build/get-build-hostname.sh
  6. +3 −0 build/get-build-timestamp.sh
@@ -0,0 +1,20 @@
sudo: required
language: go
go_import_path: github.com/open-policy-agent/gatekeeper
go:
- "1.11"
env:
- DEP_VERSION=0.5.0

before_install:
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep
- dep ensure

deploy:
- provider: script
skip_cleanup: true
script: make travis-dev-deploy
on:
repo: open-policy-agent/gatekeeper
branch: master
@@ -0,0 +1,4 @@
FROM ubuntu:latest
WORKDIR /root/
COPY bin/manager .
ENTRYPOINT ["./manager"]
@@ -1,6 +1,20 @@

# Image URL to use all building/pushing image targets
IMG ?= docker.io/nikhilbh/gatekeeper:latest
REGISTRY ?= quay.io
REPOSITORY ?= $(REGISTRY)/open-policy-agent/gatekeeper

IMG := $(REPOSITORY):latest

VERSION := v2.0.1

BUILD_COMMIT := $(shell ./build/get-build-commit.sh)
BUILD_TIMESTAMP := $(shell ./build/get-build-timestamp.sh)
BUILD_HOSTNAME := $(shell ./build/get-build-hostname.sh)

LDFLAGS := "-X github.com/open-policy-agent/gatekeeper/version.Version=$(VERSION) \
-X github.com/open-policy-agent/gatekeeper/version.Vcs=$(BUILD_COMMIT) \
-X github.com/open-policy-agent/gatekeeper/version.Timestamp=$(BUILD_TIMESTAMP) \
-X github.com/open-policy-agent/gatekeeper/version.Hostname=$(BUILD_HOSTNAME)"

all: test manager

@@ -10,7 +24,11 @@ test: generate fmt vet manifests

# Build manager binary
manager: generate fmt vet
go build -o bin/manager github.com/open-policy-agent/gatekeeper/cmd/manager
go build -o bin/manager -ldflags $(LDFLAGS) github.com/open-policy-agent/gatekeeper/cmd/manager

# Build manager binary
manager-osx: generate fmt vet
go build -o bin/manager GOOS=darwin -ldflags $(LDFLAGS) github.com/open-policy-agent/gatekeeper/cmd/manager

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
@@ -42,12 +60,30 @@ vet:
generate:
go generate ./pkg/... ./cmd/...

# Docker Login
docker-login:
@docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD) $(REGISTRY)

# Tag for Dev
docker-tag-dev:
@docker tag $(IMG) $(REPOSITORY):dev

# Tag for Dev
docker-push-dev: docker-tag-dev
@docker push $(REPOSITORY):dev

# Build the docker image
docker-build: test
docker-build:
docker build . -t ${IMG}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

docker-build-ci:
docker build . -t $(IMG) -f Dockerfile_ci

# Push the docker image
docker-push:
docker push ${IMG}

# Travis Dev Deployment
travis-dev-deploy: docker-login docker-build-ci docker-push-dev
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

GIT_SHA=$(git rev-parse --short HEAD)

if [ -z "$(git status --porcelain 2>/dev/null)" ]; then
echo $GIT_SHA
else
echo "$GIT_SHA-dirty"
fi
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

hostname -f
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

date -u +"%Y-%m-%dT%H:%M:%SZ"

0 comments on commit 347e42c

Please sign in to comment.
You can’t perform that action at this time.