Skip to content

Commit

Permalink
Merge pull request #181 from kanisterio/sync
Browse files Browse the repository at this point in the history
IBM Block; EFS file; Resource Filtering; Build w/ gomod
  • Loading branch information
SupriyaKasten committed Jul 16, 2019
2 parents 94e6429 + 0c8028b commit 17b5e03
Show file tree
Hide file tree
Showing 58 changed files with 1,564 additions and 906 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@ services:
language: go

go:
- "1.10.x"
- "1.12.x"

branches:
only:
- master

# This moves Kubernetes specific config files.
env:
- CHANGE_MINIKUBE_NONE_USER=true
- CHANGE_MINIKUBE_NONE_USER=true GO111MODULE=on

before_install:
- sudo bash build/local_kubernetes.sh get_minikube
- wget --progress=dot:mega https://storage.googleapis.com/kubernetes-release/release/v1.8.4/bin/linux/amd64/kubectl
- sudo chmod +x kubectl
- sudo mv kubectl /usr/local/bin/kubectl
- wget --progress=dot:mega https://github.com/Masterminds/glide/releases/download/v0.13.1/glide-v0.13.1-linux-amd64.tar.gz -O glide.tar.gz
- tar zxfp glide.tar.gz linux-amd64/glide --strip=1
- sudo mv glide /usr/local/bin/glide

script:
- go mod download
- make build DOCKER_BUILD=false
- make docs
- sudo bash build/local_kubernetes.sh start_minikube
Expand Down
38 changes: 10 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ IMAGE_NAME := $(BIN)

IMAGE := $(REGISTRY)/$(IMAGE_NAME)

BUILD_IMAGE ?= kanisterio/build:0.13.2-go1.11
BUILD_IMAGE ?= kanisterio/build:v0.0.1
DOCS_BUILD_IMAGE ?= kanisterio/docker-sphinx

DEFAULT_PATH := /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

DOCS_RELEASE_BUCKET ?= s3://docs.kanister.io

GITHUB_TOKEN ?= ""
Expand All @@ -92,10 +90,10 @@ all-push: $(addprefix push-, $(ALL_ARCH))

build: bin/$(ARCH)/$(BIN)

bin/$(ARCH)/$(BIN): .vendor
bin/$(ARCH)/$(BIN):
@echo "building: $@"
@$(MAKE) run CMD='-c " \
ARCH=$(ARCH) \
GOARCH=$(ARCH) \
VERSION=$(VERSION) \
PKG=$(PKG) \
./build/build.sh \
Expand All @@ -107,24 +105,14 @@ shell: build-dirs
-ti \
--rm \
--privileged \
-e GOPATH=/go \
-e GOROOT=/usr/local/go \
-v "$(PWD)/.go:/go" \
-v "$(PWD)/.go/pkg:/go/pkg" \
-v "$(PWD):/go/src/$(PKG)" \
-v "$(PWD)/bin/$(ARCH):/go/bin" \
-v "$(PWD)/bin/$(ARCH):/go/bin/$$(go env GOOS)_$(ARCH)" \
-v "$(PWD)/.go/std/$(ARCH):/usr/local/go/pkg/linux_$(ARCH)_static" \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
/bin/bash -l

.vendor:
@$(MAKE) run CMD='-c " \
PATH=$$GOPATH/bin:$$GOROOT/bin::$${PATH} \
glide install --strip-vendor \
"'
@touch $@
/bin/sh

DOTFILE_IMAGE = $(subst :,_,$(subst /,_,$(IMAGE))-$(VERSION))

Expand Down Expand Up @@ -168,7 +156,7 @@ deploy: release-controller .deploy-$(DOTFILE_IMAGE)
bundle.yaml.in > .deploy-$(DOTFILE_IMAGE)
@kubectl apply -f .deploy-$(DOTFILE_IMAGE)

test: .vendor build-dirs
test: build-dirs
@$(MAKE) run CMD='-c "./build/test.sh $(SRC_DIRS)"'

codegen:
Expand Down Expand Up @@ -205,33 +193,27 @@ ifeq ($(DOCKER_BUILD),"true")
@echo "running CMD in the containerized build environment"
@docker run \
--rm \
-e GOPATH=/go \
-e GOROOT=/usr/local/go \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v "${HOME}/.kube:/root/.kube" \
-v "$(PWD)/.go:/go" \
-v "$(PWD)/.go/pkg:/go/pkg" \
-v "$(PWD):/go/src/$(PKG)" \
-v "$(PWD)/bin/$(ARCH):/go/bin" \
-v "$(PWD)/bin/$(ARCH):/go/bin/$$(go env GOOS)_$(ARCH)" \
-v "$(PWD)/bin/$(ARCH)/$$(go env GOOS)_$(ARCH):/go/bin" \
-v "$(PWD)/.go/std/$(ARCH):/usr/local/go/pkg/linux_$(ARCH)_static" \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
/bin/bash $(CMD)
/bin/sh $(CMD)
else
@/bin/bash $(CMD)
endif

clean: dotfile-clean bin-clean vendor-clean
clean: dotfile-clean bin-clean

dotfile-clean:
rm -rf .container-* .dockerfile-* .push-* .vendor .deploy-*

bin-clean:
rm -rf .go bin

vendor-clean:
rm -rf vendor

release-docs: docs
@if [ -z ${AWS_ACCESS_KEY_ID} ] || [ -z ${AWS_SECRET_ACCESS_KEY} ]; then\
echo "Please set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Exiting.";\
Expand Down
10 changes: 1 addition & 9 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ if [ -z "${PKG}" ]; then
echo "PKG must be set"
exit 1
fi
if [ -z "${ARCH}" ]; then
echo "ARCH must be set"
exit 1
fi
if [ -z "${VERSION}" ]; then
echo "VERSION must be set"
exit 1
fi

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

export CGO_ENABLED=0
export GOARCH="${ARCH}"

go install -v \
-installsuffix "static" \
-ldflags "-X ${PKG}/pkg/version.VERSION=${VERSION}" \
./...
./cmd/...
1 change: 1 addition & 0 deletions build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

set -o errexit
set -o nounset
set -o xtrace

if [ -z "${BIN:-""}" ]; then
echo "BIN must be set"
Expand Down
1 change: 1 addition & 0 deletions build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set -o nounset
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

export CGO_ENABLED=0
export GO111MODULE=on

TARGETS=$(for d in "$@"; do echo ./$d/...; done)

Expand Down
16 changes: 16 additions & 0 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.12.4-alpine3.9
MAINTAINER Tom Manville <tom@kasten.io>

RUN apk add --update --no-cache ca-certificates bash git \
&& update-ca-certificates \
&& rm -rf /var/cache/apk/*

COPY --from=bitnami/kubectl:1.13.4 /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/

COPY --from=goreleaser/goreleaser:v0.112.2 /bin/goreleaser /usr/local/bin/

ENV CGO_ENABLED=0 \
GO111MODULE="on" \
GOROOT="/usr/local/go" \
GO_EXTLINK_ENABLED=0 \
PATH="/usr/local/go/bin:${PATH}"
4 changes: 3 additions & 1 deletion docker/tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ FROM busybox:glibc as restbox

# Get restic executable
ENV RESTIC_VERSION=0.9.5
ENV RESTIC_SHA=08cd75e56a67161e9b16885816f04b2bf1fb5b03bc0677b0ccf3812781c1a2ec
ADD https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_linux_amd64.bz2 /
RUN bzip2 -d restic_${RESTIC_VERSION}_linux_amd64.bz2 && mv restic_${RESTIC_VERSION}_linux_amd64 /bin/restic && chmod +x /bin/restic
RUN echo "${RESTIC_SHA} restic_${RESTIC_VERSION}_linux_amd64.bz2" | sha256sum -c \
&& bzip2 -d restic_${RESTIC_VERSION}_linux_amd64.bz2 && mv restic_${RESTIC_VERSION}_linux_amd64 /bin/restic && chmod +x /bin/restic

FROM alpine:3.7
MAINTAINER Tom Manville <tom@kasten.io>
Expand Down
3 changes: 1 addition & 2 deletions examples/time-log/blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actions:
path: '{{ .Profile.Location.Bucket }}/time-log'
backupIdentifier:
keyValue:
id: '{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02" }}'
id: "{{ .Phases.backupToS3.Output.backupID }}"
phases:
- func: BackupData
name: backupToS3
Expand All @@ -22,7 +22,6 @@ actions:
container: test-container
includePath: /var/log
backupArtifactPrefix: "{{ .Profile.Location.Bucket }}/time-log"
backupIdentifier: '{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02" }}'
restore:
type: Deployment
inputArtifactNames:
Expand Down
Loading

0 comments on commit 17b5e03

Please sign in to comment.